babylon.module.d.ts 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384157385157386157387157388157389157390157391157392157393157394157395157396157397157398157399157400157401157402157403157404157405157406157407157408157409157410157411157412157413157414157415157416157417157418157419157420157421157422157423157424157425157426157427157428157429157430157431157432157433157434157435157436157437157438157439157440157441157442157443157444157445157446157447157448157449157450157451157452157453157454157455157456157457157458157459157460157461157462157463157464157465157466157467157468157469157470157471157472157473157474157475157476157477157478157479157480157481157482157483157484157485157486157487157488157489157490157491157492157493157494157495157496157497157498157499157500157501157502157503157504157505157506157507157508157509157510157511157512157513157514157515157516157517157518157519157520157521157522157523157524157525157526157527157528157529157530157531157532157533157534157535157536157537157538157539157540157541157542157543157544157545157546157547157548157549157550157551157552157553157554157555157556157557157558157559157560157561157562157563157564157565157566157567157568157569157570157571157572157573157574157575157576157577157578157579157580157581157582157583157584157585157586157587157588157589157590157591157592157593157594157595157596157597157598157599157600157601157602157603157604157605157606157607157608157609157610157611157612157613157614157615157616157617157618157619157620157621157622157623157624157625157626157627157628157629157630157631157632157633157634157635157636157637157638157639157640157641157642157643157644157645157646157647157648157649157650157651157652157653157654157655157656157657157658157659157660157661157662157663157664157665157666157667157668157669157670157671157672157673157674157675157676157677157678157679157680157681157682157683157684157685157686157687157688157689157690157691157692157693157694157695157696157697157698157699157700157701157702157703157704157705157706157707157708157709157710157711157712157713157714157715157716157717157718157719157720157721157722157723157724157725157726157727157728157729157730157731157732157733157734157735157736157737157738157739157740157741157742157743157744157745157746157747157748157749157750157751157752157753157754157755157756157757157758157759157760157761157762157763157764157765157766157767157768157769157770157771157772157773157774157775157776157777157778157779157780157781157782157783157784157785157786157787157788157789157790157791157792157793157794157795157796157797157798157799157800157801157802157803157804157805157806157807157808157809157810157811157812157813157814157815157816157817157818157819157820157821157822157823157824157825157826157827157828157829157830157831157832157833157834157835157836157837157838157839157840157841157842157843157844157845157846157847157848157849157850157851157852157853157854157855157856157857157858157859157860157861157862157863157864157865157866157867157868157869157870157871157872157873157874157875157876157877157878157879157880157881157882157883157884157885157886157887157888157889157890157891157892157893157894157895157896157897157898157899157900157901157902157903157904157905157906157907157908157909157910157911157912157913157914157915157916157917157918157919157920157921157922157923157924157925157926157927157928157929157930157931157932157933157934157935157936157937157938157939157940157941157942157943157944157945157946157947157948157949157950157951157952157953157954157955157956157957157958157959157960157961157962157963157964157965157966157967157968157969157970157971157972157973157974157975157976157977157978157979157980157981157982157983157984157985157986157987157988157989157990157991157992157993157994157995157996157997157998157999158000158001158002158003158004158005158006158007158008158009158010158011158012158013158014158015158016158017158018158019158020158021158022158023158024158025158026158027158028158029158030158031158032158033158034158035158036158037158038158039158040158041158042158043158044158045158046158047158048158049158050158051158052158053158054158055158056158057158058158059158060158061158062158063158064158065158066158067158068158069158070158071158072158073158074158075158076158077158078158079158080158081158082158083158084158085158086158087158088158089158090158091158092158093158094158095158096158097158098158099158100158101158102158103158104158105158106158107158108158109158110158111158112158113158114158115158116158117158118158119158120158121158122158123158124158125158126158127158128158129158130158131158132158133158134158135158136158137158138158139158140158141158142158143158144158145158146158147158148158149158150158151158152158153158154158155158156158157158158158159158160158161158162158163158164158165158166158167158168158169158170158171158172158173158174158175158176158177158178158179158180158181158182158183158184158185158186158187158188158189158190158191158192158193158194158195158196158197158198158199158200158201158202158203158204158205158206158207158208158209158210158211158212158213158214158215158216158217158218158219158220158221158222158223158224158225158226158227158228158229158230158231158232158233158234158235158236158237158238158239158240158241158242158243158244158245158246158247158248158249158250158251158252158253158254158255158256158257158258158259158260158261158262158263158264158265158266158267158268158269158270158271158272158273158274158275158276158277158278158279158280158281158282158283158284158285158286158287158288158289158290158291158292158293158294158295158296158297158298158299158300158301158302158303158304158305158306158307158308158309158310158311158312158313158314158315158316158317158318158319158320158321158322158323158324158325158326158327158328158329158330158331158332158333158334158335158336158337158338158339158340158341158342158343158344158345158346158347158348158349158350158351158352158353158354158355158356158357158358158359158360158361158362158363158364158365158366158367158368158369158370158371158372158373158374158375158376158377158378158379158380158381158382158383158384158385158386158387158388158389158390158391158392158393158394158395158396158397158398158399158400158401158402158403158404158405158406158407158408158409158410158411158412158413158414158415158416158417158418158419158420158421158422158423158424158425158426158427158428158429158430158431158432158433158434158435158436158437158438158439158440158441158442158443158444158445158446158447158448158449158450158451158452158453158454158455158456158457158458158459158460158461158462158463158464158465158466158467158468158469158470158471158472158473158474158475158476158477158478158479158480158481158482158483158484158485158486158487158488158489158490158491158492158493158494158495158496158497158498158499158500158501158502158503158504158505158506158507158508158509158510158511158512158513158514158515158516158517158518158519158520158521158522158523158524158525158526158527158528158529158530158531158532158533158534158535158536158537158538158539158540158541158542158543158544158545158546158547158548158549158550158551158552158553158554158555158556158557158558158559158560158561158562158563158564158565158566158567158568158569158570158571158572158573158574158575158576158577158578158579158580158581158582158583158584158585158586158587158588158589158590158591158592158593158594158595158596158597158598158599158600158601158602158603158604158605158606158607158608158609158610158611158612158613158614158615158616158617158618158619158620158621158622158623158624158625158626158627158628158629158630158631158632158633158634158635158636158637158638158639158640158641158642158643158644158645158646158647158648158649158650158651158652158653158654158655158656158657158658158659158660158661158662158663158664158665158666158667158668158669158670158671158672158673158674158675158676
  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. private static _LogCache;
  334. /**
  335. * Gets a value indicating the number of loading errors
  336. * @ignorenaming
  337. */
  338. static errorsCount: number;
  339. /**
  340. * Callback called when a new log is added
  341. */
  342. static OnNewCacheEntry: (entry: string) => void;
  343. private static _AddLogEntry;
  344. private static _FormatMessage;
  345. private static _LogDisabled;
  346. private static _LogEnabled;
  347. private static _WarnDisabled;
  348. private static _WarnEnabled;
  349. private static _ErrorDisabled;
  350. private static _ErrorEnabled;
  351. /**
  352. * Log a message to the console
  353. */
  354. static Log: (message: string) => void;
  355. /**
  356. * Write a warning message to the console
  357. */
  358. static Warn: (message: string) => void;
  359. /**
  360. * Write an error message to the console
  361. */
  362. static Error: (message: string) => void;
  363. /**
  364. * Gets current log cache (list of logs)
  365. */
  366. static get LogCache(): string;
  367. /**
  368. * Clears the log cache
  369. */
  370. static ClearLogCache(): void;
  371. /**
  372. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  373. */
  374. static set LogLevels(level: number);
  375. }
  376. }
  377. declare module "babylonjs/Misc/typeStore" {
  378. /** @hidden */
  379. export class _TypeStore {
  380. /** @hidden */
  381. static RegisteredTypes: {
  382. [key: string]: Object;
  383. };
  384. /** @hidden */
  385. static GetClass(fqdn: string): any;
  386. }
  387. }
  388. declare module "babylonjs/Misc/stringTools" {
  389. /**
  390. * Helper to manipulate strings
  391. */
  392. export class StringTools {
  393. /**
  394. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  395. * @param str Source string
  396. * @param suffix Suffix to search for in the source string
  397. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  398. */
  399. static EndsWith(str: string, suffix: string): boolean;
  400. /**
  401. * Checks for a matching suffix at the beginning 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 StartsWith(str: string, suffix: string): boolean;
  407. /**
  408. * Decodes a buffer into a string
  409. * @param buffer The buffer to decode
  410. * @returns The decoded string
  411. */
  412. static Decode(buffer: Uint8Array | Uint16Array): string;
  413. /**
  414. * Encode a buffer to a base64 string
  415. * @param buffer defines the buffer to encode
  416. * @returns the encoded string
  417. */
  418. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  419. /**
  420. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  421. * @param num the number to convert and pad
  422. * @param length the expected length of the string
  423. * @returns the padded string
  424. */
  425. static PadNumber(num: number, length: number): string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/deepCopier" {
  429. /**
  430. * Class containing a set of static utilities functions for deep copy.
  431. */
  432. export class DeepCopier {
  433. /**
  434. * Tries to copy an object by duplicating every property
  435. * @param source defines the source object
  436. * @param destination defines the target object
  437. * @param doNotCopyList defines a list of properties to avoid
  438. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  439. */
  440. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  441. }
  442. }
  443. declare module "babylonjs/Misc/precisionDate" {
  444. /**
  445. * Class containing a set of static utilities functions for precision date
  446. */
  447. export class PrecisionDate {
  448. /**
  449. * Gets either window.performance.now() if supported or Date.now() else
  450. */
  451. static get Now(): number;
  452. }
  453. }
  454. declare module "babylonjs/Misc/devTools" {
  455. /** @hidden */
  456. export class _DevTools {
  457. static WarnImport(name: string): string;
  458. }
  459. }
  460. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  461. /**
  462. * Interface used to define the mechanism to get data from the network
  463. */
  464. export interface IWebRequest {
  465. /**
  466. * Returns client's response url
  467. */
  468. responseURL: string;
  469. /**
  470. * Returns client's status
  471. */
  472. status: number;
  473. /**
  474. * Returns client's status as a text
  475. */
  476. statusText: string;
  477. }
  478. }
  479. declare module "babylonjs/Misc/webRequest" {
  480. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  481. import { Nullable } from "babylonjs/types";
  482. /**
  483. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  484. */
  485. export class WebRequest implements IWebRequest {
  486. private _xhr;
  487. /**
  488. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  489. * i.e. when loading files, where the server/service expects an Authorization header
  490. */
  491. static CustomRequestHeaders: {
  492. [key: string]: string;
  493. };
  494. /**
  495. * Add callback functions in this array to update all the requests before they get sent to the network
  496. */
  497. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  498. private _injectCustomRequestHeaders;
  499. /**
  500. * Gets or sets a function to be called when loading progress changes
  501. */
  502. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  503. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  504. /**
  505. * Returns client's state
  506. */
  507. get readyState(): number;
  508. /**
  509. * Returns client's status
  510. */
  511. get status(): number;
  512. /**
  513. * Returns client's status as a text
  514. */
  515. get statusText(): string;
  516. /**
  517. * Returns client's response
  518. */
  519. get response(): any;
  520. /**
  521. * Returns client's response url
  522. */
  523. get responseURL(): string;
  524. /**
  525. * Returns client's response as text
  526. */
  527. get responseText(): string;
  528. /**
  529. * Gets or sets the expected response type
  530. */
  531. get responseType(): XMLHttpRequestResponseType;
  532. set responseType(value: XMLHttpRequestResponseType);
  533. /** @hidden */
  534. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  535. /** @hidden */
  536. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  537. /**
  538. * Cancels any network activity
  539. */
  540. abort(): void;
  541. /**
  542. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  543. * @param body defines an optional request body
  544. */
  545. send(body?: Document | BodyInit | null): void;
  546. /**
  547. * Sets the request method, request URL
  548. * @param method defines the method to use (GET, POST, etc..)
  549. * @param url defines the url to connect with
  550. */
  551. open(method: string, url: string): void;
  552. /**
  553. * Sets the value of a request header.
  554. * @param name The name of the header whose value is to be set
  555. * @param value The value to set as the body of the header
  556. */
  557. setRequestHeader(name: string, value: string): void;
  558. /**
  559. * Get the string containing the text of a particular header's value.
  560. * @param name The name of the header
  561. * @returns The string containing the text of the given header name
  562. */
  563. getResponseHeader(name: string): Nullable<string>;
  564. }
  565. }
  566. declare module "babylonjs/Misc/fileRequest" {
  567. import { Observable } from "babylonjs/Misc/observable";
  568. /**
  569. * File request interface
  570. */
  571. export interface IFileRequest {
  572. /**
  573. * Raised when the request is complete (success or error).
  574. */
  575. onCompleteObservable: Observable<IFileRequest>;
  576. /**
  577. * Aborts the request for a file.
  578. */
  579. abort: () => void;
  580. }
  581. }
  582. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  583. /**
  584. * Define options used to create a render target texture
  585. */
  586. export class RenderTargetCreationOptions {
  587. /**
  588. * Specifies is mipmaps must be generated
  589. */
  590. generateMipMaps?: boolean;
  591. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  592. generateDepthBuffer?: boolean;
  593. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  594. generateStencilBuffer?: boolean;
  595. /** Defines texture type (int by default) */
  596. type?: number;
  597. /** Defines sampling mode (trilinear by default) */
  598. samplingMode?: number;
  599. /** Defines format (RGBA by default) */
  600. format?: number;
  601. }
  602. }
  603. declare module "babylonjs/Engines/constants" {
  604. /** Defines the cross module used constants to avoid circular dependncies */
  605. export class Constants {
  606. /** Defines that alpha blending is disabled */
  607. static readonly ALPHA_DISABLE: number;
  608. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  609. static readonly ALPHA_ADD: number;
  610. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  611. static readonly ALPHA_COMBINE: number;
  612. /** Defines that alpha blending is DEST - SRC * DEST */
  613. static readonly ALPHA_SUBTRACT: number;
  614. /** Defines that alpha blending is SRC * DEST */
  615. static readonly ALPHA_MULTIPLY: number;
  616. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  617. static readonly ALPHA_MAXIMIZED: number;
  618. /** Defines that alpha blending is SRC + DEST */
  619. static readonly ALPHA_ONEONE: number;
  620. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  621. static readonly ALPHA_PREMULTIPLIED: number;
  622. /**
  623. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  624. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  625. */
  626. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  627. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  628. static readonly ALPHA_INTERPOLATE: number;
  629. /**
  630. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  631. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  632. */
  633. static readonly ALPHA_SCREENMODE: number;
  634. /**
  635. * Defines that alpha blending is SRC + DST
  636. * Alpha will be set to SRC ALPHA + DST ALPHA
  637. */
  638. static readonly ALPHA_ONEONE_ONEONE: number;
  639. /**
  640. * Defines that alpha blending is SRC * DST ALPHA + DST
  641. * Alpha will be set to 0
  642. */
  643. static readonly ALPHA_ALPHATOCOLOR: number;
  644. /**
  645. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  646. */
  647. static readonly ALPHA_REVERSEONEMINUS: number;
  648. /**
  649. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  650. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  651. */
  652. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  653. /**
  654. * Defines that alpha blending is SRC + DST
  655. * Alpha will be set to SRC ALPHA
  656. */
  657. static readonly ALPHA_ONEONE_ONEZERO: number;
  658. /**
  659. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  660. * Alpha will be set to DST ALPHA
  661. */
  662. static readonly ALPHA_EXCLUSION: number;
  663. /** Defines that alpha blending equation a SUM */
  664. static readonly ALPHA_EQUATION_ADD: number;
  665. /** Defines that alpha blending equation a SUBSTRACTION */
  666. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  667. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  668. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  669. /** Defines that alpha blending equation a MAX operation */
  670. static readonly ALPHA_EQUATION_MAX: number;
  671. /** Defines that alpha blending equation a MIN operation */
  672. static readonly ALPHA_EQUATION_MIN: number;
  673. /**
  674. * Defines that alpha blending equation a DARKEN operation:
  675. * It takes the min of the src and sums the alpha channels.
  676. */
  677. static readonly ALPHA_EQUATION_DARKEN: number;
  678. /** Defines that the ressource is not delayed*/
  679. static readonly DELAYLOADSTATE_NONE: number;
  680. /** Defines that the ressource was successfully delay loaded */
  681. static readonly DELAYLOADSTATE_LOADED: number;
  682. /** Defines that the ressource is currently delay loading */
  683. static readonly DELAYLOADSTATE_LOADING: number;
  684. /** Defines that the ressource is delayed and has not started loading */
  685. static readonly DELAYLOADSTATE_NOTLOADED: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  687. static readonly NEVER: number;
  688. /** 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 */
  689. static readonly ALWAYS: number;
  690. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  691. static readonly LESS: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  693. static readonly EQUAL: number;
  694. /** 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 */
  695. static readonly LEQUAL: number;
  696. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  697. static readonly GREATER: number;
  698. /** 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 */
  699. static readonly GEQUAL: number;
  700. /** 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 */
  701. static readonly NOTEQUAL: number;
  702. /** Passed to stencilOperation to specify that stencil value must be kept */
  703. static readonly KEEP: number;
  704. /** Passed to stencilOperation to specify that stencil value must be replaced */
  705. static readonly REPLACE: number;
  706. /** Passed to stencilOperation to specify that stencil value must be incremented */
  707. static readonly INCR: number;
  708. /** Passed to stencilOperation to specify that stencil value must be decremented */
  709. static readonly DECR: number;
  710. /** Passed to stencilOperation to specify that stencil value must be inverted */
  711. static readonly INVERT: number;
  712. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  713. static readonly INCR_WRAP: number;
  714. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  715. static readonly DECR_WRAP: number;
  716. /** Texture is not repeating outside of 0..1 UVs */
  717. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  718. /** Texture is repeating outside of 0..1 UVs */
  719. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  720. /** Texture is repeating and mirrored */
  721. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  722. /** ALPHA */
  723. static readonly TEXTUREFORMAT_ALPHA: number;
  724. /** LUMINANCE */
  725. static readonly TEXTUREFORMAT_LUMINANCE: number;
  726. /** LUMINANCE_ALPHA */
  727. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  728. /** RGB */
  729. static readonly TEXTUREFORMAT_RGB: number;
  730. /** RGBA */
  731. static readonly TEXTUREFORMAT_RGBA: number;
  732. /** RED */
  733. static readonly TEXTUREFORMAT_RED: number;
  734. /** RED (2nd reference) */
  735. static readonly TEXTUREFORMAT_R: number;
  736. /** RG */
  737. static readonly TEXTUREFORMAT_RG: number;
  738. /** RED_INTEGER */
  739. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  740. /** RED_INTEGER (2nd reference) */
  741. static readonly TEXTUREFORMAT_R_INTEGER: number;
  742. /** RG_INTEGER */
  743. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  744. /** RGB_INTEGER */
  745. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  746. /** RGBA_INTEGER */
  747. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  748. /** UNSIGNED_BYTE */
  749. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  750. /** UNSIGNED_BYTE (2nd reference) */
  751. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  752. /** FLOAT */
  753. static readonly TEXTURETYPE_FLOAT: number;
  754. /** HALF_FLOAT */
  755. static readonly TEXTURETYPE_HALF_FLOAT: number;
  756. /** BYTE */
  757. static readonly TEXTURETYPE_BYTE: number;
  758. /** SHORT */
  759. static readonly TEXTURETYPE_SHORT: number;
  760. /** UNSIGNED_SHORT */
  761. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  762. /** INT */
  763. static readonly TEXTURETYPE_INT: number;
  764. /** UNSIGNED_INT */
  765. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  766. /** UNSIGNED_SHORT_4_4_4_4 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  768. /** UNSIGNED_SHORT_5_5_5_1 */
  769. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  770. /** UNSIGNED_SHORT_5_6_5 */
  771. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  772. /** UNSIGNED_INT_2_10_10_10_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  774. /** UNSIGNED_INT_24_8 */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  776. /** UNSIGNED_INT_10F_11F_11F_REV */
  777. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  778. /** UNSIGNED_INT_5_9_9_9_REV */
  779. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  780. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  781. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  782. /** nearest is mag = nearest and min = nearest and no mip */
  783. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  784. /** mag = nearest and min = nearest and mip = none */
  785. static readonly TEXTURE_NEAREST_NEAREST: number;
  786. /** Bilinear is mag = linear and min = linear and no mip */
  787. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  788. /** mag = linear and min = linear and mip = none */
  789. static readonly TEXTURE_LINEAR_LINEAR: number;
  790. /** Trilinear is mag = linear and min = linear and mip = linear */
  791. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  792. /** Trilinear is mag = linear and min = linear and mip = linear */
  793. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  794. /** mag = nearest and min = nearest and mip = nearest */
  795. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  796. /** mag = nearest and min = linear and mip = nearest */
  797. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  798. /** mag = nearest and min = linear and mip = linear */
  799. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  800. /** mag = nearest and min = linear and mip = none */
  801. static readonly TEXTURE_NEAREST_LINEAR: number;
  802. /** nearest is mag = nearest and min = nearest and mip = linear */
  803. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  804. /** mag = linear and min = nearest and mip = nearest */
  805. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = linear */
  807. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  808. /** Bilinear is mag = linear and min = linear and mip = nearest */
  809. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  810. /** mag = linear and min = nearest and mip = none */
  811. static readonly TEXTURE_LINEAR_NEAREST: number;
  812. /** Explicit coordinates mode */
  813. static readonly TEXTURE_EXPLICIT_MODE: number;
  814. /** Spherical coordinates mode */
  815. static readonly TEXTURE_SPHERICAL_MODE: number;
  816. /** Planar coordinates mode */
  817. static readonly TEXTURE_PLANAR_MODE: number;
  818. /** Cubic coordinates mode */
  819. static readonly TEXTURE_CUBIC_MODE: number;
  820. /** Projection coordinates mode */
  821. static readonly TEXTURE_PROJECTION_MODE: number;
  822. /** Skybox coordinates mode */
  823. static readonly TEXTURE_SKYBOX_MODE: number;
  824. /** Inverse Cubic coordinates mode */
  825. static readonly TEXTURE_INVCUBIC_MODE: number;
  826. /** Equirectangular coordinates mode */
  827. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  828. /** Equirectangular Fixed coordinates mode */
  829. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  830. /** Equirectangular Fixed Mirrored coordinates mode */
  831. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  832. /** Offline (baking) quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  834. /** High quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  836. /** Medium quality for texture filtering */
  837. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  838. /** Low quality for texture filtering */
  839. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  840. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  841. static readonly SCALEMODE_FLOOR: number;
  842. /** Defines that texture rescaling will look for the nearest power of 2 size */
  843. static readonly SCALEMODE_NEAREST: number;
  844. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  845. static readonly SCALEMODE_CEILING: number;
  846. /**
  847. * The dirty texture flag value
  848. */
  849. static readonly MATERIAL_TextureDirtyFlag: number;
  850. /**
  851. * The dirty light flag value
  852. */
  853. static readonly MATERIAL_LightDirtyFlag: number;
  854. /**
  855. * The dirty fresnel flag value
  856. */
  857. static readonly MATERIAL_FresnelDirtyFlag: number;
  858. /**
  859. * The dirty attribute flag value
  860. */
  861. static readonly MATERIAL_AttributesDirtyFlag: number;
  862. /**
  863. * The dirty misc flag value
  864. */
  865. static readonly MATERIAL_MiscDirtyFlag: number;
  866. /**
  867. * The dirty prepass flag value
  868. */
  869. static readonly MATERIAL_PrePassDirtyFlag: number;
  870. /**
  871. * The all dirty flag value
  872. */
  873. static readonly MATERIAL_AllDirtyFlag: number;
  874. /**
  875. * Returns the triangle fill mode
  876. */
  877. static readonly MATERIAL_TriangleFillMode: number;
  878. /**
  879. * Returns the wireframe mode
  880. */
  881. static readonly MATERIAL_WireFrameFillMode: number;
  882. /**
  883. * Returns the point fill mode
  884. */
  885. static readonly MATERIAL_PointFillMode: number;
  886. /**
  887. * Returns the point list draw mode
  888. */
  889. static readonly MATERIAL_PointListDrawMode: number;
  890. /**
  891. * Returns the line list draw mode
  892. */
  893. static readonly MATERIAL_LineListDrawMode: number;
  894. /**
  895. * Returns the line loop draw mode
  896. */
  897. static readonly MATERIAL_LineLoopDrawMode: number;
  898. /**
  899. * Returns the line strip draw mode
  900. */
  901. static readonly MATERIAL_LineStripDrawMode: number;
  902. /**
  903. * Returns the triangle strip draw mode
  904. */
  905. static readonly MATERIAL_TriangleStripDrawMode: number;
  906. /**
  907. * Returns the triangle fan draw mode
  908. */
  909. static readonly MATERIAL_TriangleFanDrawMode: number;
  910. /**
  911. * Stores the clock-wise side orientation
  912. */
  913. static readonly MATERIAL_ClockWiseSideOrientation: number;
  914. /**
  915. * Stores the counter clock-wise side orientation
  916. */
  917. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  918. /**
  919. * Nothing
  920. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_NothingTrigger: number;
  923. /**
  924. * On pick
  925. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickTrigger: number;
  928. /**
  929. * On left pick
  930. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnLeftPickTrigger: number;
  933. /**
  934. * On right pick
  935. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  936. */
  937. static readonly ACTION_OnRightPickTrigger: number;
  938. /**
  939. * On center pick
  940. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  941. */
  942. static readonly ACTION_OnCenterPickTrigger: number;
  943. /**
  944. * On pick down
  945. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  946. */
  947. static readonly ACTION_OnPickDownTrigger: number;
  948. /**
  949. * On double pick
  950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  951. */
  952. static readonly ACTION_OnDoublePickTrigger: number;
  953. /**
  954. * On pick up
  955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  956. */
  957. static readonly ACTION_OnPickUpTrigger: number;
  958. /**
  959. * On pick out.
  960. * This trigger will only be raised if you also declared a OnPickDown
  961. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnPickOutTrigger: number;
  964. /**
  965. * On long press
  966. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnLongPressTrigger: number;
  969. /**
  970. * On pointer over
  971. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnPointerOverTrigger: number;
  974. /**
  975. * On pointer out
  976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  977. */
  978. static readonly ACTION_OnPointerOutTrigger: number;
  979. /**
  980. * On every frame
  981. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  982. */
  983. static readonly ACTION_OnEveryFrameTrigger: number;
  984. /**
  985. * On intersection enter
  986. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  987. */
  988. static readonly ACTION_OnIntersectionEnterTrigger: number;
  989. /**
  990. * On intersection exit
  991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  992. */
  993. static readonly ACTION_OnIntersectionExitTrigger: number;
  994. /**
  995. * On key down
  996. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  997. */
  998. static readonly ACTION_OnKeyDownTrigger: number;
  999. /**
  1000. * On key up
  1001. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1002. */
  1003. static readonly ACTION_OnKeyUpTrigger: number;
  1004. /**
  1005. * Billboard mode will only apply to Y axis
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1008. /**
  1009. * Billboard mode will apply to all axes
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1012. /**
  1013. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1014. */
  1015. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1016. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1017. * Test order :
  1018. * Is the bounding sphere outside the frustum ?
  1019. * If not, are the bounding box vertices outside the frustum ?
  1020. * It not, then the cullable object is in the frustum.
  1021. */
  1022. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1023. /** Culling strategy : Bounding Sphere Only.
  1024. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1025. * It's also less accurate than the standard because some not visible objects can still be selected.
  1026. * Test : is the bounding sphere outside the frustum ?
  1027. * If not, then the cullable object is in the frustum.
  1028. */
  1029. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1030. /** Culling strategy : Optimistic Inclusion.
  1031. * This in an inclusion test first, then the standard exclusion test.
  1032. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1033. * 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.
  1034. * Anyway, it's as accurate as the standard strategy.
  1035. * Test :
  1036. * Is the cullable object bounding sphere center in the frustum ?
  1037. * If not, apply the default culling strategy.
  1038. */
  1039. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1040. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1041. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1042. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1043. * 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.
  1044. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1045. * Test :
  1046. * Is the cullable object bounding sphere center in the frustum ?
  1047. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1048. */
  1049. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1050. /**
  1051. * No logging while loading
  1052. */
  1053. static readonly SCENELOADER_NO_LOGGING: number;
  1054. /**
  1055. * Minimal logging while loading
  1056. */
  1057. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1058. /**
  1059. * Summary logging while loading
  1060. */
  1061. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1062. /**
  1063. * Detailled logging while loading
  1064. */
  1065. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1066. /**
  1067. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1069. */
  1070. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the position texture index in the textures array in the prepass
  1073. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1074. */
  1075. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1078. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1079. */
  1080. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1091. /**
  1092. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1093. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1094. */
  1095. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1096. /**
  1097. * Constant used to retrieve albedo index in the textures array in the prepass
  1098. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1099. */
  1100. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1101. }
  1102. }
  1103. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1104. import { Nullable } from "babylonjs/types";
  1105. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1106. /**
  1107. * This represents the required contract to create a new type of texture loader.
  1108. */
  1109. export interface IInternalTextureLoader {
  1110. /**
  1111. * Defines wether the loader supports cascade loading the different faces.
  1112. */
  1113. supportCascades: boolean;
  1114. /**
  1115. * This returns if the loader support the current file information.
  1116. * @param extension defines the file extension of the file being loaded
  1117. * @param mimeType defines the optional mime type of the file being loaded
  1118. * @returns true if the loader can load the specified file
  1119. */
  1120. canLoad(extension: string, mimeType?: string): boolean;
  1121. /**
  1122. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1123. * @param data contains the texture data
  1124. * @param texture defines the BabylonJS internal texture
  1125. * @param createPolynomials will be true if polynomials have been requested
  1126. * @param onLoad defines the callback to trigger once the texture is ready
  1127. * @param onError defines the callback to trigger in case of error
  1128. * @param options options to be passed to the loader
  1129. */
  1130. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  1131. /**
  1132. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1133. * @param data contains the texture data
  1134. * @param texture defines the BabylonJS internal texture
  1135. * @param callback defines the method to call once ready to upload
  1136. * @param options options to be passed to the loader
  1137. */
  1138. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  1139. }
  1140. }
  1141. declare module "babylonjs/Engines/IPipelineContext" {
  1142. /**
  1143. * Class used to store and describe the pipeline context associated with an effect
  1144. */
  1145. export interface IPipelineContext {
  1146. /**
  1147. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1148. */
  1149. isAsync: boolean;
  1150. /**
  1151. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1152. */
  1153. isReady: boolean;
  1154. /** @hidden */
  1155. _getVertexShaderCode(): string | null;
  1156. /** @hidden */
  1157. _getFragmentShaderCode(): string | null;
  1158. /** @hidden */
  1159. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1160. }
  1161. }
  1162. declare module "babylonjs/Meshes/dataBuffer" {
  1163. /**
  1164. * Class used to store gfx data (like WebGLBuffer)
  1165. */
  1166. export class DataBuffer {
  1167. /**
  1168. * Gets or sets the number of objects referencing this buffer
  1169. */
  1170. references: number;
  1171. /** Gets or sets the size of the underlying buffer */
  1172. capacity: number;
  1173. /**
  1174. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1175. */
  1176. is32Bits: boolean;
  1177. /**
  1178. * Gets the underlying buffer
  1179. */
  1180. get underlyingResource(): any;
  1181. }
  1182. }
  1183. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1184. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1185. /** @hidden */
  1186. export interface IShaderProcessor {
  1187. attributeProcessor?: (attribute: string) => string;
  1188. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1189. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1190. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1191. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1192. lineProcessor?: (line: string, isFragment: boolean) => string;
  1193. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1194. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  1195. }
  1196. }
  1197. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1198. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1199. /** @hidden */
  1200. export interface ProcessingOptions {
  1201. defines: string[];
  1202. indexParameters: any;
  1203. isFragment: boolean;
  1204. shouldUseHighPrecisionShader: boolean;
  1205. supportsUniformBuffers: boolean;
  1206. shadersRepository: string;
  1207. includesShadersStore: {
  1208. [key: string]: string;
  1209. };
  1210. processor?: IShaderProcessor;
  1211. version: string;
  1212. platformName: string;
  1213. lookForClosingBracketForUniformBuffer?: boolean;
  1214. }
  1215. }
  1216. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1217. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1218. /** @hidden */
  1219. export class ShaderCodeNode {
  1220. line: string;
  1221. children: ShaderCodeNode[];
  1222. additionalDefineKey?: string;
  1223. additionalDefineValue?: string;
  1224. isValid(preprocessors: {
  1225. [key: string]: string;
  1226. }): boolean;
  1227. process(preprocessors: {
  1228. [key: string]: string;
  1229. }, options: ProcessingOptions): string;
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1233. /** @hidden */
  1234. export class ShaderCodeCursor {
  1235. private _lines;
  1236. lineIndex: number;
  1237. get currentLine(): string;
  1238. get canRead(): boolean;
  1239. set lines(value: string[]);
  1240. }
  1241. }
  1242. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1243. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1244. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1245. /** @hidden */
  1246. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1247. process(preprocessors: {
  1248. [key: string]: string;
  1249. }, options: ProcessingOptions): string;
  1250. }
  1251. }
  1252. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1253. /** @hidden */
  1254. export class ShaderDefineExpression {
  1255. isTrue(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. private static _OperatorPriority;
  1259. private static _Stack;
  1260. static postfixToInfix(postfix: string[]): string;
  1261. static infixToPostfix(infix: string): string[];
  1262. }
  1263. }
  1264. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1265. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1266. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1267. /** @hidden */
  1268. export class ShaderCodeTestNode extends ShaderCodeNode {
  1269. testExpression: ShaderDefineExpression;
  1270. isValid(preprocessors: {
  1271. [key: string]: string;
  1272. }): boolean;
  1273. }
  1274. }
  1275. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1276. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1277. /** @hidden */
  1278. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1279. define: string;
  1280. not: boolean;
  1281. constructor(define: string, not?: boolean);
  1282. isTrue(preprocessors: {
  1283. [key: string]: string;
  1284. }): boolean;
  1285. }
  1286. }
  1287. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1288. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1289. /** @hidden */
  1290. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1291. leftOperand: ShaderDefineExpression;
  1292. rightOperand: ShaderDefineExpression;
  1293. isTrue(preprocessors: {
  1294. [key: string]: string;
  1295. }): boolean;
  1296. }
  1297. }
  1298. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1299. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1300. /** @hidden */
  1301. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1302. leftOperand: ShaderDefineExpression;
  1303. rightOperand: ShaderDefineExpression;
  1304. isTrue(preprocessors: {
  1305. [key: string]: string;
  1306. }): boolean;
  1307. }
  1308. }
  1309. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1310. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1311. /** @hidden */
  1312. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1313. define: string;
  1314. operand: string;
  1315. testValue: string;
  1316. constructor(define: string, operand: string, testValue: string);
  1317. isTrue(preprocessors: {
  1318. [key: string]: string;
  1319. }): boolean;
  1320. }
  1321. }
  1322. declare module "babylonjs/Offline/IOfflineProvider" {
  1323. /**
  1324. * Class used to enable access to offline support
  1325. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1326. */
  1327. export interface IOfflineProvider {
  1328. /**
  1329. * Gets a boolean indicating if scene must be saved in the database
  1330. */
  1331. enableSceneOffline: boolean;
  1332. /**
  1333. * Gets a boolean indicating if textures must be saved in the database
  1334. */
  1335. enableTexturesOffline: boolean;
  1336. /**
  1337. * Open the offline support and make it available
  1338. * @param successCallback defines the callback to call on success
  1339. * @param errorCallback defines the callback to call on error
  1340. */
  1341. open(successCallback: () => void, errorCallback: () => void): void;
  1342. /**
  1343. * Loads an image from the offline support
  1344. * @param url defines the url to load from
  1345. * @param image defines the target DOM image
  1346. */
  1347. loadImage(url: string, image: HTMLImageElement): void;
  1348. /**
  1349. * Loads a file from offline support
  1350. * @param url defines the URL to load from
  1351. * @param sceneLoaded defines a callback to call on success
  1352. * @param progressCallBack defines a callback to call when progress changed
  1353. * @param errorCallback defines a callback to call on error
  1354. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1355. */
  1356. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1357. }
  1358. }
  1359. declare module "babylonjs/Misc/filesInputStore" {
  1360. /**
  1361. * Class used to help managing file picking and drag'n'drop
  1362. * File Storage
  1363. */
  1364. export class FilesInputStore {
  1365. /**
  1366. * List of files ready to be loaded
  1367. */
  1368. static FilesToLoad: {
  1369. [key: string]: File;
  1370. };
  1371. }
  1372. }
  1373. declare module "babylonjs/Misc/retryStrategy" {
  1374. import { WebRequest } from "babylonjs/Misc/webRequest";
  1375. /**
  1376. * Class used to define a retry strategy when error happens while loading assets
  1377. */
  1378. export class RetryStrategy {
  1379. /**
  1380. * Function used to defines an exponential back off strategy
  1381. * @param maxRetries defines the maximum number of retries (3 by default)
  1382. * @param baseInterval defines the interval between retries
  1383. * @returns the strategy function to use
  1384. */
  1385. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1386. }
  1387. }
  1388. declare module "babylonjs/Misc/baseError" {
  1389. /**
  1390. * @ignore
  1391. * Application error to support additional information when loading a file
  1392. */
  1393. export abstract class BaseError extends Error {
  1394. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1395. }
  1396. }
  1397. declare module "babylonjs/Misc/fileTools" {
  1398. import { WebRequest } from "babylonjs/Misc/webRequest";
  1399. import { Nullable } from "babylonjs/types";
  1400. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1401. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1402. import { BaseError } from "babylonjs/Misc/baseError";
  1403. /** @ignore */
  1404. export class LoadFileError extends BaseError {
  1405. request?: WebRequest;
  1406. file?: File;
  1407. /**
  1408. * Creates a new LoadFileError
  1409. * @param message defines the message of the error
  1410. * @param request defines the optional web request
  1411. * @param file defines the optional file
  1412. */
  1413. constructor(message: string, object?: WebRequest | File);
  1414. }
  1415. /** @ignore */
  1416. export class RequestFileError extends BaseError {
  1417. request: WebRequest;
  1418. /**
  1419. * Creates a new LoadFileError
  1420. * @param message defines the message of the error
  1421. * @param request defines the optional web request
  1422. */
  1423. constructor(message: string, request: WebRequest);
  1424. }
  1425. /** @ignore */
  1426. export class ReadFileError extends BaseError {
  1427. file: File;
  1428. /**
  1429. * Creates a new ReadFileError
  1430. * @param message defines the message of the error
  1431. * @param file defines the optional file
  1432. */
  1433. constructor(message: string, file: File);
  1434. }
  1435. /**
  1436. * @hidden
  1437. */
  1438. export class FileTools {
  1439. /**
  1440. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1441. */
  1442. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1443. /**
  1444. * Gets or sets the base URL to use to load assets
  1445. */
  1446. static BaseUrl: string;
  1447. /**
  1448. * Default behaviour for cors in the application.
  1449. * It can be a string if the expected behavior is identical in the entire app.
  1450. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1451. */
  1452. static CorsBehavior: string | ((url: string | string[]) => string);
  1453. /**
  1454. * Gets or sets a function used to pre-process url before using them to load assets
  1455. */
  1456. static PreprocessUrl: (url: string) => string;
  1457. /**
  1458. * Removes unwanted characters from an url
  1459. * @param url defines the url to clean
  1460. * @returns the cleaned url
  1461. */
  1462. private static _CleanUrl;
  1463. /**
  1464. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1465. * @param url define the url we are trying
  1466. * @param element define the dom element where to configure the cors policy
  1467. */
  1468. static SetCorsBehavior(url: string | string[], element: {
  1469. crossOrigin: string | null;
  1470. }): void;
  1471. /**
  1472. * Loads an image as an HTMLImageElement.
  1473. * @param input url string, ArrayBuffer, or Blob to load
  1474. * @param onLoad callback called when the image successfully loads
  1475. * @param onError callback called when the image fails to load
  1476. * @param offlineProvider offline provider for caching
  1477. * @param mimeType optional mime type
  1478. * @returns the HTMLImageElement of the loaded image
  1479. */
  1480. 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>;
  1481. /**
  1482. * Reads a file from a File object
  1483. * @param file defines the file to load
  1484. * @param onSuccess defines the callback to call when data is loaded
  1485. * @param onProgress defines the callback to call during loading process
  1486. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1487. * @param onError defines the callback to call when an error occurs
  1488. * @returns a file request object
  1489. */
  1490. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1491. /**
  1492. * Loads a file from a url
  1493. * @param url url to load
  1494. * @param onSuccess callback called when the file successfully loads
  1495. * @param onProgress callback called while file is loading (if the server supports this mode)
  1496. * @param offlineProvider defines the offline provider for caching
  1497. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1498. * @param onError callback called when the file fails to load
  1499. * @returns a file request object
  1500. */
  1501. 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;
  1502. /**
  1503. * Loads a file
  1504. * @param url url to load
  1505. * @param onSuccess callback called when the file successfully loads
  1506. * @param onProgress callback called while file is loading (if the server supports this mode)
  1507. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1508. * @param onError callback called when the file fails to load
  1509. * @param onOpened callback called when the web request is opened
  1510. * @returns a file request object
  1511. */
  1512. 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;
  1513. /**
  1514. * Checks if the loaded document was accessed via `file:`-Protocol.
  1515. * @returns boolean
  1516. */
  1517. static IsFileURL(): boolean;
  1518. }
  1519. }
  1520. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1521. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1522. import { WebRequest } from "babylonjs/Misc/webRequest";
  1523. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1524. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1525. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1526. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  1527. /** @hidden */
  1528. export class ShaderProcessor {
  1529. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  1530. private static _ProcessPrecision;
  1531. private static _ExtractOperation;
  1532. private static _BuildSubExpression;
  1533. private static _BuildExpression;
  1534. private static _MoveCursorWithinIf;
  1535. private static _MoveCursor;
  1536. private static _EvaluatePreProcessors;
  1537. private static _PreparePreProcessors;
  1538. private static _ProcessShaderConversion;
  1539. private static _ProcessIncludes;
  1540. /**
  1541. * Loads a file from a url
  1542. * @param url url to load
  1543. * @param onSuccess callback called when the file successfully loads
  1544. * @param onProgress callback called while file is loading (if the server supports this mode)
  1545. * @param offlineProvider defines the offline provider for caching
  1546. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1547. * @param onError callback called when the file fails to load
  1548. * @returns a file request object
  1549. * @hidden
  1550. */
  1551. 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;
  1552. }
  1553. }
  1554. declare module "babylonjs/Maths/math.like" {
  1555. import { float, int, DeepImmutable } from "babylonjs/types";
  1556. /**
  1557. * @hidden
  1558. */
  1559. export interface IColor4Like {
  1560. r: float;
  1561. g: float;
  1562. b: float;
  1563. a: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IColor3Like {
  1569. r: float;
  1570. g: float;
  1571. b: float;
  1572. }
  1573. /**
  1574. * @hidden
  1575. */
  1576. export interface IVector4Like {
  1577. x: float;
  1578. y: float;
  1579. z: float;
  1580. w: float;
  1581. }
  1582. /**
  1583. * @hidden
  1584. */
  1585. export interface IVector3Like {
  1586. x: float;
  1587. y: float;
  1588. z: float;
  1589. }
  1590. /**
  1591. * @hidden
  1592. */
  1593. export interface IVector2Like {
  1594. x: float;
  1595. y: float;
  1596. }
  1597. /**
  1598. * @hidden
  1599. */
  1600. export interface IMatrixLike {
  1601. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1602. updateFlag: int;
  1603. }
  1604. /**
  1605. * @hidden
  1606. */
  1607. export interface IViewportLike {
  1608. x: float;
  1609. y: float;
  1610. width: float;
  1611. height: float;
  1612. }
  1613. /**
  1614. * @hidden
  1615. */
  1616. export interface IPlaneLike {
  1617. normal: IVector3Like;
  1618. d: float;
  1619. normalize(): void;
  1620. }
  1621. }
  1622. declare module "babylonjs/Materials/iEffectFallbacks" {
  1623. import { Effect } from "babylonjs/Materials/effect";
  1624. /**
  1625. * Interface used to define common properties for effect fallbacks
  1626. */
  1627. export interface IEffectFallbacks {
  1628. /**
  1629. * Removes the defines that should be removed when falling back.
  1630. * @param currentDefines defines the current define statements for the shader.
  1631. * @param effect defines the current effect we try to compile
  1632. * @returns The resulting defines with defines of the current rank removed.
  1633. */
  1634. reduce(currentDefines: string, effect: Effect): string;
  1635. /**
  1636. * Removes the fallback from the bound mesh.
  1637. */
  1638. unBindMesh(): void;
  1639. /**
  1640. * Checks to see if more fallbacks are still availible.
  1641. */
  1642. hasMoreFallbacks: boolean;
  1643. }
  1644. }
  1645. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1646. /**
  1647. * Class used to evalaute queries containing `and` and `or` operators
  1648. */
  1649. export class AndOrNotEvaluator {
  1650. /**
  1651. * Evaluate a query
  1652. * @param query defines the query to evaluate
  1653. * @param evaluateCallback defines the callback used to filter result
  1654. * @returns true if the query matches
  1655. */
  1656. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1657. private static _HandleParenthesisContent;
  1658. private static _SimplifyNegation;
  1659. }
  1660. }
  1661. declare module "babylonjs/Misc/tags" {
  1662. /**
  1663. * Class used to store custom tags
  1664. */
  1665. export class Tags {
  1666. /**
  1667. * Adds support for tags on the given object
  1668. * @param obj defines the object to use
  1669. */
  1670. static EnableFor(obj: any): void;
  1671. /**
  1672. * Removes tags support
  1673. * @param obj defines the object to use
  1674. */
  1675. static DisableFor(obj: any): void;
  1676. /**
  1677. * Gets a boolean indicating if the given object has tags
  1678. * @param obj defines the object to use
  1679. * @returns a boolean
  1680. */
  1681. static HasTags(obj: any): boolean;
  1682. /**
  1683. * Gets the tags available on a given object
  1684. * @param obj defines the object to use
  1685. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1686. * @returns the tags
  1687. */
  1688. static GetTags(obj: any, asString?: boolean): any;
  1689. /**
  1690. * Adds tags to an object
  1691. * @param obj defines the object to use
  1692. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1693. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1694. */
  1695. static AddTagsTo(obj: any, tagsString: string): void;
  1696. /**
  1697. * @hidden
  1698. */
  1699. static _AddTagTo(obj: any, tag: string): void;
  1700. /**
  1701. * Removes specific tags from a specific object
  1702. * @param obj defines the object to use
  1703. * @param tagsString defines the tags to remove
  1704. */
  1705. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1706. /**
  1707. * @hidden
  1708. */
  1709. static _RemoveTagFrom(obj: any, tag: string): void;
  1710. /**
  1711. * Defines if tags hosted on an object match a given query
  1712. * @param obj defines the object to use
  1713. * @param tagsQuery defines the tag query
  1714. * @returns a boolean
  1715. */
  1716. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1717. }
  1718. }
  1719. declare module "babylonjs/Maths/math.scalar" {
  1720. /**
  1721. * Scalar computation library
  1722. */
  1723. export class Scalar {
  1724. /**
  1725. * Two pi constants convenient for computation.
  1726. */
  1727. static TwoPi: number;
  1728. /**
  1729. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1730. * @param a number
  1731. * @param b number
  1732. * @param epsilon (default = 1.401298E-45)
  1733. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1734. */
  1735. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1736. /**
  1737. * Returns a string : the upper case translation of the number i to hexadecimal.
  1738. * @param i number
  1739. * @returns the upper case translation of the number i to hexadecimal.
  1740. */
  1741. static ToHex(i: number): string;
  1742. /**
  1743. * Returns -1 if value is negative and +1 is value is positive.
  1744. * @param value the value
  1745. * @returns the value itself if it's equal to zero.
  1746. */
  1747. static Sign(value: number): number;
  1748. /**
  1749. * Returns the value itself if it's between min and max.
  1750. * Returns min if the value is lower than min.
  1751. * Returns max if the value is greater than max.
  1752. * @param value the value to clmap
  1753. * @param min the min value to clamp to (default: 0)
  1754. * @param max the max value to clamp to (default: 1)
  1755. * @returns the clamped value
  1756. */
  1757. static Clamp(value: number, min?: number, max?: number): number;
  1758. /**
  1759. * the log2 of value.
  1760. * @param value the value to compute log2 of
  1761. * @returns the log2 of value.
  1762. */
  1763. static Log2(value: number): number;
  1764. /**
  1765. * Loops the value, so that it is never larger than length and never smaller than 0.
  1766. *
  1767. * This is similar to the modulo operator but it works with floating point numbers.
  1768. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1769. * With t = 5 and length = 2.5, the result would be 0.0.
  1770. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1771. * @param value the value
  1772. * @param length the length
  1773. * @returns the looped value
  1774. */
  1775. static Repeat(value: number, length: number): number;
  1776. /**
  1777. * Normalize the value between 0.0 and 1.0 using min and max values
  1778. * @param value value to normalize
  1779. * @param min max to normalize between
  1780. * @param max min to normalize between
  1781. * @returns the normalized value
  1782. */
  1783. static Normalize(value: number, min: number, max: number): number;
  1784. /**
  1785. * Denormalize the value from 0.0 and 1.0 using min and max values
  1786. * @param normalized value to denormalize
  1787. * @param min max to denormalize between
  1788. * @param max min to denormalize between
  1789. * @returns the denormalized value
  1790. */
  1791. static Denormalize(normalized: number, min: number, max: number): number;
  1792. /**
  1793. * Calculates the shortest difference between two given angles given in degrees.
  1794. * @param current current angle in degrees
  1795. * @param target target angle in degrees
  1796. * @returns the delta
  1797. */
  1798. static DeltaAngle(current: number, target: number): number;
  1799. /**
  1800. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1801. * @param tx value
  1802. * @param length length
  1803. * @returns The returned value will move back and forth between 0 and length
  1804. */
  1805. static PingPong(tx: number, length: number): number;
  1806. /**
  1807. * Interpolates between min and max with smoothing at the limits.
  1808. *
  1809. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1810. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1811. * @param from from
  1812. * @param to to
  1813. * @param tx value
  1814. * @returns the smooth stepped value
  1815. */
  1816. static SmoothStep(from: number, to: number, tx: number): number;
  1817. /**
  1818. * Moves a value current towards target.
  1819. *
  1820. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1821. * Negative values of maxDelta pushes the value away from target.
  1822. * @param current current value
  1823. * @param target target value
  1824. * @param maxDelta max distance to move
  1825. * @returns resulting value
  1826. */
  1827. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1828. /**
  1829. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1830. *
  1831. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1832. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1833. * @param current current value
  1834. * @param target target value
  1835. * @param maxDelta max distance to move
  1836. * @returns resulting angle
  1837. */
  1838. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1839. /**
  1840. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1841. * @param start start value
  1842. * @param end target value
  1843. * @param amount amount to lerp between
  1844. * @returns the lerped value
  1845. */
  1846. static Lerp(start: number, end: number, amount: number): number;
  1847. /**
  1848. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1849. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1850. * @param start start value
  1851. * @param end target value
  1852. * @param amount amount to lerp between
  1853. * @returns the lerped value
  1854. */
  1855. static LerpAngle(start: number, end: number, amount: number): number;
  1856. /**
  1857. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1858. * @param a start value
  1859. * @param b target value
  1860. * @param value value between a and b
  1861. * @returns the inverseLerp value
  1862. */
  1863. static InverseLerp(a: number, b: number, value: number): number;
  1864. /**
  1865. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1866. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1867. * @param value1 spline value
  1868. * @param tangent1 spline value
  1869. * @param value2 spline value
  1870. * @param tangent2 spline value
  1871. * @param amount input value
  1872. * @returns hermite result
  1873. */
  1874. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1875. /**
  1876. * Returns a random float number between and min and max values
  1877. * @param min min value of random
  1878. * @param max max value of random
  1879. * @returns random value
  1880. */
  1881. static RandomRange(min: number, max: number): number;
  1882. /**
  1883. * This function returns percentage of a number in a given range.
  1884. *
  1885. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1886. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1887. * @param number to convert to percentage
  1888. * @param min min range
  1889. * @param max max range
  1890. * @returns the percentage
  1891. */
  1892. static RangeToPercent(number: number, min: number, max: number): number;
  1893. /**
  1894. * This function returns number that corresponds to the percentage in a given range.
  1895. *
  1896. * PercentToRange(0.34,0,100) will return 34.
  1897. * @param percent to convert to number
  1898. * @param min min range
  1899. * @param max max range
  1900. * @returns the number
  1901. */
  1902. static PercentToRange(percent: number, min: number, max: number): number;
  1903. /**
  1904. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1905. * @param angle The angle to normalize in radian.
  1906. * @return The converted angle.
  1907. */
  1908. static NormalizeRadians(angle: number): number;
  1909. }
  1910. }
  1911. declare module "babylonjs/Maths/math.constants" {
  1912. /**
  1913. * Constant used to convert a value to gamma space
  1914. * @ignorenaming
  1915. */
  1916. export const ToGammaSpace: number;
  1917. /**
  1918. * Constant used to convert a value to linear space
  1919. * @ignorenaming
  1920. */
  1921. export const ToLinearSpace = 2.2;
  1922. /**
  1923. * Constant used to define the minimal number value in Babylon.js
  1924. * @ignorenaming
  1925. */
  1926. let Epsilon: number;
  1927. export { Epsilon };
  1928. }
  1929. declare module "babylonjs/Maths/math.viewport" {
  1930. /**
  1931. * Class used to represent a viewport on screen
  1932. */
  1933. export class Viewport {
  1934. /** viewport left coordinate */
  1935. x: number;
  1936. /** viewport top coordinate */
  1937. y: number;
  1938. /**viewport width */
  1939. width: number;
  1940. /** viewport height */
  1941. height: number;
  1942. /**
  1943. * Creates a Viewport object located at (x, y) and sized (width, height)
  1944. * @param x defines viewport left coordinate
  1945. * @param y defines viewport top coordinate
  1946. * @param width defines the viewport width
  1947. * @param height defines the viewport height
  1948. */
  1949. constructor(
  1950. /** viewport left coordinate */
  1951. x: number,
  1952. /** viewport top coordinate */
  1953. y: number,
  1954. /**viewport width */
  1955. width: number,
  1956. /** viewport height */
  1957. height: number);
  1958. /**
  1959. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1960. * @param renderWidth defines the rendering width
  1961. * @param renderHeight defines the rendering height
  1962. * @returns a new Viewport
  1963. */
  1964. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1965. /**
  1966. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1967. * @param renderWidth defines the rendering width
  1968. * @param renderHeight defines the rendering height
  1969. * @param ref defines the target viewport
  1970. * @returns the current viewport
  1971. */
  1972. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1973. /**
  1974. * Returns a new Viewport copied from the current one
  1975. * @returns a new Viewport
  1976. */
  1977. clone(): Viewport;
  1978. }
  1979. }
  1980. declare module "babylonjs/Misc/arrayTools" {
  1981. /**
  1982. * Class containing a set of static utilities functions for arrays.
  1983. */
  1984. export class ArrayTools {
  1985. /**
  1986. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1987. * @param size the number of element to construct and put in the array
  1988. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1989. * @returns a new array filled with new objects
  1990. */
  1991. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1992. }
  1993. }
  1994. declare module "babylonjs/Maths/math.plane" {
  1995. import { DeepImmutable } from "babylonjs/types";
  1996. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1997. /**
  1998. * Represents a plane by the equation ax + by + cz + d = 0
  1999. */
  2000. export class Plane {
  2001. private static _TmpMatrix;
  2002. /**
  2003. * Normal of the plane (a,b,c)
  2004. */
  2005. normal: Vector3;
  2006. /**
  2007. * d component of the plane
  2008. */
  2009. d: number;
  2010. /**
  2011. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2012. * @param a a component of the plane
  2013. * @param b b component of the plane
  2014. * @param c c component of the plane
  2015. * @param d d component of the plane
  2016. */
  2017. constructor(a: number, b: number, c: number, d: number);
  2018. /**
  2019. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2020. */
  2021. asArray(): number[];
  2022. /**
  2023. * @returns a new plane copied from the current Plane.
  2024. */
  2025. clone(): Plane;
  2026. /**
  2027. * @returns the string "Plane".
  2028. */
  2029. getClassName(): string;
  2030. /**
  2031. * @returns the Plane hash code.
  2032. */
  2033. getHashCode(): number;
  2034. /**
  2035. * Normalize the current Plane in place.
  2036. * @returns the updated Plane.
  2037. */
  2038. normalize(): Plane;
  2039. /**
  2040. * Applies a transformation the plane and returns the result
  2041. * @param transformation the transformation matrix to be applied to the plane
  2042. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2043. */
  2044. transform(transformation: DeepImmutable<Matrix>): Plane;
  2045. /**
  2046. * Compute the dot product between the point and the plane normal
  2047. * @param point point to calculate the dot product with
  2048. * @returns the dot product (float) of the point coordinates and the plane normal.
  2049. */
  2050. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2051. /**
  2052. * Updates the current Plane from the plane defined by the three given points.
  2053. * @param point1 one of the points used to contruct the plane
  2054. * @param point2 one of the points used to contruct the plane
  2055. * @param point3 one of the points used to contruct the plane
  2056. * @returns the updated Plane.
  2057. */
  2058. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2059. /**
  2060. * Checks if the plane is facing a given direction
  2061. * @param direction the direction to check if the plane is facing
  2062. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2063. * @returns True is the vector "direction" is the same side than the plane normal.
  2064. */
  2065. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2066. /**
  2067. * Calculates the distance to a point
  2068. * @param point point to calculate distance to
  2069. * @returns the signed distance (float) from the given point to the Plane.
  2070. */
  2071. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2072. /**
  2073. * Creates a plane from an array
  2074. * @param array the array to create a plane from
  2075. * @returns a new Plane from the given array.
  2076. */
  2077. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2078. /**
  2079. * Creates a plane from three points
  2080. * @param point1 point used to create the plane
  2081. * @param point2 point used to create the plane
  2082. * @param point3 point used to create the plane
  2083. * @returns a new Plane defined by the three given points.
  2084. */
  2085. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2086. /**
  2087. * Creates a plane from an origin point and a normal
  2088. * @param origin origin of the plane to be constructed
  2089. * @param normal normal of the plane to be constructed
  2090. * @returns a new Plane the normal vector to this plane at the given origin point.
  2091. * Note : the vector "normal" is updated because normalized.
  2092. */
  2093. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2094. /**
  2095. * Calculates the distance from a plane and a point
  2096. * @param origin origin of the plane to be constructed
  2097. * @param normal normal of the plane to be constructed
  2098. * @param point point to calculate distance to
  2099. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2100. */
  2101. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2102. }
  2103. }
  2104. declare module "babylonjs/Engines/performanceConfigurator" {
  2105. /** @hidden */
  2106. export class PerformanceConfigurator {
  2107. /** @hidden */
  2108. static MatrixUse64Bits: boolean;
  2109. /** @hidden */
  2110. static MatrixTrackPrecisionChange: boolean;
  2111. /** @hidden */
  2112. static MatrixCurrentType: any;
  2113. /** @hidden */
  2114. static MatrixTrackedMatrices: Array<any> | null;
  2115. /** @hidden */
  2116. static SetMatrixPrecision(use64bits: boolean): void;
  2117. }
  2118. }
  2119. declare module "babylonjs/Maths/math.vector" {
  2120. import { Viewport } from "babylonjs/Maths/math.viewport";
  2121. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2122. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2123. import { Plane } from "babylonjs/Maths/math.plane";
  2124. /**
  2125. * Class representing a vector containing 2 coordinates
  2126. */
  2127. export class Vector2 {
  2128. /** defines the first coordinate */
  2129. x: number;
  2130. /** defines the second coordinate */
  2131. y: number;
  2132. /**
  2133. * Creates a new Vector2 from the given x and y coordinates
  2134. * @param x defines the first coordinate
  2135. * @param y defines the second coordinate
  2136. */
  2137. constructor(
  2138. /** defines the first coordinate */
  2139. x?: number,
  2140. /** defines the second coordinate */
  2141. y?: number);
  2142. /**
  2143. * Gets a string with the Vector2 coordinates
  2144. * @returns a string with the Vector2 coordinates
  2145. */
  2146. toString(): string;
  2147. /**
  2148. * Gets class name
  2149. * @returns the string "Vector2"
  2150. */
  2151. getClassName(): string;
  2152. /**
  2153. * Gets current vector hash code
  2154. * @returns the Vector2 hash code as a number
  2155. */
  2156. getHashCode(): number;
  2157. /**
  2158. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2159. * @param array defines the source array
  2160. * @param index defines the offset in source array
  2161. * @returns the current Vector2
  2162. */
  2163. toArray(array: FloatArray, index?: number): Vector2;
  2164. /**
  2165. * Update the current vector from an array
  2166. * @param array defines the destination array
  2167. * @param index defines the offset in the destination array
  2168. * @returns the current Vector3
  2169. */
  2170. fromArray(array: FloatArray, index?: number): Vector2;
  2171. /**
  2172. * Copy the current vector to an array
  2173. * @returns a new array with 2 elements: the Vector2 coordinates.
  2174. */
  2175. asArray(): number[];
  2176. /**
  2177. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2178. * @param source defines the source Vector2
  2179. * @returns the current updated Vector2
  2180. */
  2181. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2182. /**
  2183. * Sets the Vector2 coordinates with the given floats
  2184. * @param x defines the first coordinate
  2185. * @param y defines the second coordinate
  2186. * @returns the current updated Vector2
  2187. */
  2188. copyFromFloats(x: number, y: number): Vector2;
  2189. /**
  2190. * Sets the Vector2 coordinates with the given floats
  2191. * @param x defines the first coordinate
  2192. * @param y defines the second coordinate
  2193. * @returns the current updated Vector2
  2194. */
  2195. set(x: number, y: number): Vector2;
  2196. /**
  2197. * Add another vector with the current one
  2198. * @param otherVector defines the other vector
  2199. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2200. */
  2201. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2202. /**
  2203. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2204. * @param otherVector defines the other vector
  2205. * @param result defines the target vector
  2206. * @returns the unmodified current Vector2
  2207. */
  2208. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2209. /**
  2210. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2211. * @param otherVector defines the other vector
  2212. * @returns the current updated Vector2
  2213. */
  2214. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2215. /**
  2216. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2217. * @param otherVector defines the other vector
  2218. * @returns a new Vector2
  2219. */
  2220. addVector3(otherVector: Vector3): Vector2;
  2221. /**
  2222. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2223. * @param otherVector defines the other vector
  2224. * @returns a new Vector2
  2225. */
  2226. subtract(otherVector: Vector2): Vector2;
  2227. /**
  2228. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2229. * @param otherVector defines the other vector
  2230. * @param result defines the target vector
  2231. * @returns the unmodified current Vector2
  2232. */
  2233. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2234. /**
  2235. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2236. * @param otherVector defines the other vector
  2237. * @returns the current updated Vector2
  2238. */
  2239. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2240. /**
  2241. * Multiplies in place the current Vector2 coordinates by the given ones
  2242. * @param otherVector defines the other vector
  2243. * @returns the current updated Vector2
  2244. */
  2245. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2246. /**
  2247. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2248. * @param otherVector defines the other vector
  2249. * @returns a new Vector2
  2250. */
  2251. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2254. * @param otherVector defines the other vector
  2255. * @param result defines the target vector
  2256. * @returns the unmodified current Vector2
  2257. */
  2258. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2259. /**
  2260. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2261. * @param x defines the first coordinate
  2262. * @param y defines the second coordinate
  2263. * @returns a new Vector2
  2264. */
  2265. multiplyByFloats(x: number, y: number): Vector2;
  2266. /**
  2267. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2268. * @param otherVector defines the other vector
  2269. * @returns a new Vector2
  2270. */
  2271. divide(otherVector: Vector2): Vector2;
  2272. /**
  2273. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2274. * @param otherVector defines the other vector
  2275. * @param result defines the target vector
  2276. * @returns the unmodified current Vector2
  2277. */
  2278. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2279. /**
  2280. * Divides the current Vector2 coordinates by the given ones
  2281. * @param otherVector defines the other vector
  2282. * @returns the current updated Vector2
  2283. */
  2284. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2285. /**
  2286. * Gets a new Vector2 with current Vector2 negated coordinates
  2287. * @returns a new Vector2
  2288. */
  2289. negate(): Vector2;
  2290. /**
  2291. * Negate this vector in place
  2292. * @returns this
  2293. */
  2294. negateInPlace(): Vector2;
  2295. /**
  2296. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2297. * @param result defines the Vector3 object where to store the result
  2298. * @returns the current Vector2
  2299. */
  2300. negateToRef(result: Vector2): Vector2;
  2301. /**
  2302. * Multiply the Vector2 coordinates by scale
  2303. * @param scale defines the scaling factor
  2304. * @returns the current updated Vector2
  2305. */
  2306. scaleInPlace(scale: number): Vector2;
  2307. /**
  2308. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2309. * @param scale defines the scaling factor
  2310. * @returns a new Vector2
  2311. */
  2312. scale(scale: number): Vector2;
  2313. /**
  2314. * Scale the current Vector2 values by a factor to a given Vector2
  2315. * @param scale defines the scale factor
  2316. * @param result defines the Vector2 object where to store the result
  2317. * @returns the unmodified current Vector2
  2318. */
  2319. scaleToRef(scale: number, result: Vector2): Vector2;
  2320. /**
  2321. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2322. * @param scale defines the scale factor
  2323. * @param result defines the Vector2 object where to store the result
  2324. * @returns the unmodified current Vector2
  2325. */
  2326. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2327. /**
  2328. * Gets a boolean if two vectors are equals
  2329. * @param otherVector defines the other vector
  2330. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2331. */
  2332. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2333. /**
  2334. * Gets a boolean if two vectors are equals (using an epsilon value)
  2335. * @param otherVector defines the other vector
  2336. * @param epsilon defines the minimal distance to consider equality
  2337. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2338. */
  2339. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2340. /**
  2341. * Gets a new Vector2 from current Vector2 floored values
  2342. * @returns a new Vector2
  2343. */
  2344. floor(): Vector2;
  2345. /**
  2346. * Gets a new Vector2 from current Vector2 floored values
  2347. * @returns a new Vector2
  2348. */
  2349. fract(): Vector2;
  2350. /**
  2351. * Gets the length of the vector
  2352. * @returns the vector length (float)
  2353. */
  2354. length(): number;
  2355. /**
  2356. * Gets the vector squared length
  2357. * @returns the vector squared length (float)
  2358. */
  2359. lengthSquared(): number;
  2360. /**
  2361. * Normalize the vector
  2362. * @returns the current updated Vector2
  2363. */
  2364. normalize(): Vector2;
  2365. /**
  2366. * Gets a new Vector2 copied from the Vector2
  2367. * @returns a new Vector2
  2368. */
  2369. clone(): Vector2;
  2370. /**
  2371. * Gets a new Vector2(0, 0)
  2372. * @returns a new Vector2
  2373. */
  2374. static Zero(): Vector2;
  2375. /**
  2376. * Gets a new Vector2(1, 1)
  2377. * @returns a new Vector2
  2378. */
  2379. static One(): Vector2;
  2380. /**
  2381. * Gets a new Vector2 set from the given index element of the given array
  2382. * @param array defines the data source
  2383. * @param offset defines the offset in the data source
  2384. * @returns a new Vector2
  2385. */
  2386. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2387. /**
  2388. * Sets "result" from the given index element of the given array
  2389. * @param array defines the data source
  2390. * @param offset defines the offset in the data source
  2391. * @param result defines the target vector
  2392. */
  2393. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2394. /**
  2395. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2396. * @param value1 defines 1st point of control
  2397. * @param value2 defines 2nd point of control
  2398. * @param value3 defines 3rd point of control
  2399. * @param value4 defines 4th point of control
  2400. * @param amount defines the interpolation factor
  2401. * @returns a new Vector2
  2402. */
  2403. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2404. /**
  2405. * 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".
  2406. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2407. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2408. * @param value defines the value to clamp
  2409. * @param min defines the lower limit
  2410. * @param max defines the upper limit
  2411. * @returns a new Vector2
  2412. */
  2413. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2414. /**
  2415. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2416. * @param value1 defines the 1st control point
  2417. * @param tangent1 defines the outgoing tangent
  2418. * @param value2 defines the 2nd control point
  2419. * @param tangent2 defines the incoming tangent
  2420. * @param amount defines the interpolation factor
  2421. * @returns a new Vector2
  2422. */
  2423. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2424. /**
  2425. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2426. * @param start defines the start vector
  2427. * @param end defines the end vector
  2428. * @param amount defines the interpolation factor
  2429. * @returns a new Vector2
  2430. */
  2431. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2432. /**
  2433. * Gets the dot product of the vector "left" and the vector "right"
  2434. * @param left defines first vector
  2435. * @param right defines second vector
  2436. * @returns the dot product (float)
  2437. */
  2438. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2439. /**
  2440. * Returns a new Vector2 equal to the normalized given vector
  2441. * @param vector defines the vector to normalize
  2442. * @returns a new Vector2
  2443. */
  2444. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2445. /**
  2446. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2447. * @param left defines 1st vector
  2448. * @param right defines 2nd vector
  2449. * @returns a new Vector2
  2450. */
  2451. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2452. /**
  2453. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2454. * @param left defines 1st vector
  2455. * @param right defines 2nd vector
  2456. * @returns a new Vector2
  2457. */
  2458. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2459. /**
  2460. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2461. * @param vector defines the vector to transform
  2462. * @param transformation defines the matrix to apply
  2463. * @returns a new Vector2
  2464. */
  2465. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2466. /**
  2467. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2468. * @param vector defines the vector to transform
  2469. * @param transformation defines the matrix to apply
  2470. * @param result defines the target vector
  2471. */
  2472. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2473. /**
  2474. * Determines if a given vector is included in a triangle
  2475. * @param p defines the vector to test
  2476. * @param p0 defines 1st triangle point
  2477. * @param p1 defines 2nd triangle point
  2478. * @param p2 defines 3rd triangle point
  2479. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2480. */
  2481. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2482. /**
  2483. * Gets the distance between the vectors "value1" and "value2"
  2484. * @param value1 defines first vector
  2485. * @param value2 defines second vector
  2486. * @returns the distance between vectors
  2487. */
  2488. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2489. /**
  2490. * Returns the squared distance between the vectors "value1" and "value2"
  2491. * @param value1 defines first vector
  2492. * @param value2 defines second vector
  2493. * @returns the squared distance between vectors
  2494. */
  2495. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2496. /**
  2497. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2498. * @param value1 defines first vector
  2499. * @param value2 defines second vector
  2500. * @returns a new Vector2
  2501. */
  2502. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2503. /**
  2504. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2505. * @param p defines the middle point
  2506. * @param segA defines one point of the segment
  2507. * @param segB defines the other point of the segment
  2508. * @returns the shortest distance
  2509. */
  2510. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2511. }
  2512. /**
  2513. * Class used to store (x,y,z) vector representation
  2514. * A Vector3 is the main object used in 3D geometry
  2515. * It can represent etiher the coordinates of a point the space, either a direction
  2516. * Reminder: js uses a left handed forward facing system
  2517. */
  2518. export class Vector3 {
  2519. private static _UpReadOnly;
  2520. private static _ZeroReadOnly;
  2521. /** @hidden */
  2522. _x: number;
  2523. /** @hidden */
  2524. _y: number;
  2525. /** @hidden */
  2526. _z: number;
  2527. /** @hidden */
  2528. _isDirty: boolean;
  2529. /** Gets or sets the x coordinate */
  2530. get x(): number;
  2531. set x(value: number);
  2532. /** Gets or sets the y coordinate */
  2533. get y(): number;
  2534. set y(value: number);
  2535. /** Gets or sets the z coordinate */
  2536. get z(): number;
  2537. set z(value: number);
  2538. /**
  2539. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2540. * @param x defines the first coordinates (on X axis)
  2541. * @param y defines the second coordinates (on Y axis)
  2542. * @param z defines the third coordinates (on Z axis)
  2543. */
  2544. constructor(x?: number, y?: number, z?: number);
  2545. /**
  2546. * Creates a string representation of the Vector3
  2547. * @returns a string with the Vector3 coordinates.
  2548. */
  2549. toString(): string;
  2550. /**
  2551. * Gets the class name
  2552. * @returns the string "Vector3"
  2553. */
  2554. getClassName(): string;
  2555. /**
  2556. * Creates the Vector3 hash code
  2557. * @returns a number which tends to be unique between Vector3 instances
  2558. */
  2559. getHashCode(): number;
  2560. /**
  2561. * Creates an array containing three elements : the coordinates of the Vector3
  2562. * @returns a new array of numbers
  2563. */
  2564. asArray(): number[];
  2565. /**
  2566. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2567. * @param array defines the destination array
  2568. * @param index defines the offset in the destination array
  2569. * @returns the current Vector3
  2570. */
  2571. toArray(array: FloatArray, index?: number): Vector3;
  2572. /**
  2573. * Update the current vector from an array
  2574. * @param array defines the destination array
  2575. * @param index defines the offset in the destination array
  2576. * @returns the current Vector3
  2577. */
  2578. fromArray(array: FloatArray, index?: number): Vector3;
  2579. /**
  2580. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2581. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2582. */
  2583. toQuaternion(): Quaternion;
  2584. /**
  2585. * Adds the given vector to the current Vector3
  2586. * @param otherVector defines the second operand
  2587. * @returns the current updated Vector3
  2588. */
  2589. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Adds the given coordinates to the current Vector3
  2592. * @param x defines the x coordinate of the operand
  2593. * @param y defines the y coordinate of the operand
  2594. * @param z defines the z coordinate of the operand
  2595. * @returns the current updated Vector3
  2596. */
  2597. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2598. /**
  2599. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2600. * @param otherVector defines the second operand
  2601. * @returns the resulting Vector3
  2602. */
  2603. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2604. /**
  2605. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2606. * @param otherVector defines the second operand
  2607. * @param result defines the Vector3 object where to store the result
  2608. * @returns the current Vector3
  2609. */
  2610. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2611. /**
  2612. * Subtract the given vector from the current Vector3
  2613. * @param otherVector defines the second operand
  2614. * @returns the current updated Vector3
  2615. */
  2616. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2617. /**
  2618. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2619. * @param otherVector defines the second operand
  2620. * @returns the resulting Vector3
  2621. */
  2622. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2623. /**
  2624. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2625. * @param otherVector defines the second operand
  2626. * @param result defines the Vector3 object where to store the result
  2627. * @returns the current Vector3
  2628. */
  2629. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2630. /**
  2631. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2632. * @param x defines the x coordinate of the operand
  2633. * @param y defines the y coordinate of the operand
  2634. * @param z defines the z coordinate of the operand
  2635. * @returns the resulting Vector3
  2636. */
  2637. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2638. /**
  2639. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2640. * @param x defines the x coordinate of the operand
  2641. * @param y defines the y coordinate of the operand
  2642. * @param z defines the z coordinate of the operand
  2643. * @param result defines the Vector3 object where to store the result
  2644. * @returns the current Vector3
  2645. */
  2646. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2647. /**
  2648. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2649. * @returns a new Vector3
  2650. */
  2651. negate(): Vector3;
  2652. /**
  2653. * Negate this vector in place
  2654. * @returns this
  2655. */
  2656. negateInPlace(): Vector3;
  2657. /**
  2658. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2659. * @param result defines the Vector3 object where to store the result
  2660. * @returns the current Vector3
  2661. */
  2662. negateToRef(result: Vector3): Vector3;
  2663. /**
  2664. * Multiplies the Vector3 coordinates by the float "scale"
  2665. * @param scale defines the multiplier factor
  2666. * @returns the current updated Vector3
  2667. */
  2668. scaleInPlace(scale: number): Vector3;
  2669. /**
  2670. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2671. * @param scale defines the multiplier factor
  2672. * @returns a new Vector3
  2673. */
  2674. scale(scale: number): Vector3;
  2675. /**
  2676. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2677. * @param scale defines the multiplier factor
  2678. * @param result defines the Vector3 object where to store the result
  2679. * @returns the current Vector3
  2680. */
  2681. scaleToRef(scale: number, result: Vector3): Vector3;
  2682. /**
  2683. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2684. * @param scale defines the scale factor
  2685. * @param result defines the Vector3 object where to store the result
  2686. * @returns the unmodified current Vector3
  2687. */
  2688. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2689. /**
  2690. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2691. * @param origin defines the origin of the projection ray
  2692. * @param plane defines the plane to project to
  2693. * @returns the projected vector3
  2694. */
  2695. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2696. /**
  2697. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2698. * @param origin defines the origin of the projection ray
  2699. * @param plane defines the plane to project to
  2700. * @param result defines the Vector3 where to store the result
  2701. */
  2702. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2703. /**
  2704. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2705. * @param otherVector defines the second operand
  2706. * @returns true if both vectors are equals
  2707. */
  2708. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2709. /**
  2710. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2711. * @param otherVector defines the second operand
  2712. * @param epsilon defines the minimal distance to define values as equals
  2713. * @returns true if both vectors are distant less than epsilon
  2714. */
  2715. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2716. /**
  2717. * Returns true if the current Vector3 coordinates equals the given floats
  2718. * @param x defines the x coordinate of the operand
  2719. * @param y defines the y coordinate of the operand
  2720. * @param z defines the z coordinate of the operand
  2721. * @returns true if both vectors are equals
  2722. */
  2723. equalsToFloats(x: number, y: number, z: number): boolean;
  2724. /**
  2725. * Multiplies the current Vector3 coordinates by the given ones
  2726. * @param otherVector defines the second operand
  2727. * @returns the current updated Vector3
  2728. */
  2729. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2730. /**
  2731. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2732. * @param otherVector defines the second operand
  2733. * @returns the new Vector3
  2734. */
  2735. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2736. /**
  2737. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2738. * @param otherVector defines the second operand
  2739. * @param result defines the Vector3 object where to store the result
  2740. * @returns the current Vector3
  2741. */
  2742. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2743. /**
  2744. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2745. * @param x defines the x coordinate of the operand
  2746. * @param y defines the y coordinate of the operand
  2747. * @param z defines the z coordinate of the operand
  2748. * @returns the new Vector3
  2749. */
  2750. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2751. /**
  2752. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2753. * @param otherVector defines the second operand
  2754. * @returns the new Vector3
  2755. */
  2756. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2757. /**
  2758. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2759. * @param otherVector defines the second operand
  2760. * @param result defines the Vector3 object where to store the result
  2761. * @returns the current Vector3
  2762. */
  2763. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2764. /**
  2765. * Divides the current Vector3 coordinates by the given ones.
  2766. * @param otherVector defines the second operand
  2767. * @returns the current updated Vector3
  2768. */
  2769. divideInPlace(otherVector: Vector3): Vector3;
  2770. /**
  2771. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2772. * @param other defines the second operand
  2773. * @returns the current updated Vector3
  2774. */
  2775. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2776. /**
  2777. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2778. * @param other defines the second operand
  2779. * @returns the current updated Vector3
  2780. */
  2781. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2782. /**
  2783. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2784. * @param x defines the x coordinate of the operand
  2785. * @param y defines the y coordinate of the operand
  2786. * @param z defines the z coordinate of the operand
  2787. * @returns the current updated Vector3
  2788. */
  2789. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2790. /**
  2791. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2792. * @param x defines the x coordinate of the operand
  2793. * @param y defines the y coordinate of the operand
  2794. * @param z defines the z coordinate of the operand
  2795. * @returns the current updated Vector3
  2796. */
  2797. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2798. /**
  2799. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2800. * Check if is non uniform within a certain amount of decimal places to account for this
  2801. * @param epsilon the amount the values can differ
  2802. * @returns if the the vector is non uniform to a certain number of decimal places
  2803. */
  2804. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2805. /**
  2806. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2807. */
  2808. get isNonUniform(): boolean;
  2809. /**
  2810. * Gets a new Vector3 from current Vector3 floored values
  2811. * @returns a new Vector3
  2812. */
  2813. floor(): Vector3;
  2814. /**
  2815. * Gets a new Vector3 from current Vector3 floored values
  2816. * @returns a new Vector3
  2817. */
  2818. fract(): Vector3;
  2819. /**
  2820. * Gets the length of the Vector3
  2821. * @returns the length of the Vector3
  2822. */
  2823. length(): number;
  2824. /**
  2825. * Gets the squared length of the Vector3
  2826. * @returns squared length of the Vector3
  2827. */
  2828. lengthSquared(): number;
  2829. /**
  2830. * Normalize the current Vector3.
  2831. * Please note that this is an in place operation.
  2832. * @returns the current updated Vector3
  2833. */
  2834. normalize(): Vector3;
  2835. /**
  2836. * Reorders the x y z properties of the vector in place
  2837. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2838. * @returns the current updated vector
  2839. */
  2840. reorderInPlace(order: string): this;
  2841. /**
  2842. * Rotates the vector around 0,0,0 by a quaternion
  2843. * @param quaternion the rotation quaternion
  2844. * @param result vector to store the result
  2845. * @returns the resulting vector
  2846. */
  2847. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2848. /**
  2849. * Rotates a vector around a given point
  2850. * @param quaternion the rotation quaternion
  2851. * @param point the point to rotate around
  2852. * @param result vector to store the result
  2853. * @returns the resulting vector
  2854. */
  2855. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2856. /**
  2857. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2858. * The cross product is then orthogonal to both current and "other"
  2859. * @param other defines the right operand
  2860. * @returns the cross product
  2861. */
  2862. cross(other: Vector3): Vector3;
  2863. /**
  2864. * Normalize the current Vector3 with the given input length.
  2865. * Please note that this is an in place operation.
  2866. * @param len the length of the vector
  2867. * @returns the current updated Vector3
  2868. */
  2869. normalizeFromLength(len: number): Vector3;
  2870. /**
  2871. * Normalize the current Vector3 to a new vector
  2872. * @returns the new Vector3
  2873. */
  2874. normalizeToNew(): Vector3;
  2875. /**
  2876. * Normalize the current Vector3 to the reference
  2877. * @param reference define the Vector3 to update
  2878. * @returns the updated Vector3
  2879. */
  2880. normalizeToRef(reference: Vector3): Vector3;
  2881. /**
  2882. * Creates a new Vector3 copied from the current Vector3
  2883. * @returns the new Vector3
  2884. */
  2885. clone(): Vector3;
  2886. /**
  2887. * Copies the given vector coordinates to the current Vector3 ones
  2888. * @param source defines the source Vector3
  2889. * @returns the current updated Vector3
  2890. */
  2891. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2892. /**
  2893. * Copies the given floats to the current Vector3 coordinates
  2894. * @param x defines the x coordinate of the operand
  2895. * @param y defines the y coordinate of the operand
  2896. * @param z defines the z coordinate of the operand
  2897. * @returns the current updated Vector3
  2898. */
  2899. copyFromFloats(x: number, y: number, z: number): Vector3;
  2900. /**
  2901. * Copies the given floats to the current Vector3 coordinates
  2902. * @param x defines the x coordinate of the operand
  2903. * @param y defines the y coordinate of the operand
  2904. * @param z defines the z coordinate of the operand
  2905. * @returns the current updated Vector3
  2906. */
  2907. set(x: number, y: number, z: number): Vector3;
  2908. /**
  2909. * Copies the given float to the current Vector3 coordinates
  2910. * @param v defines the x, y and z coordinates of the operand
  2911. * @returns the current updated Vector3
  2912. */
  2913. setAll(v: number): Vector3;
  2914. /**
  2915. * Get the clip factor between two vectors
  2916. * @param vector0 defines the first operand
  2917. * @param vector1 defines the second operand
  2918. * @param axis defines the axis to use
  2919. * @param size defines the size along the axis
  2920. * @returns the clip factor
  2921. */
  2922. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2923. /**
  2924. * Get angle between two vectors
  2925. * @param vector0 angle between vector0 and vector1
  2926. * @param vector1 angle between vector0 and vector1
  2927. * @param normal direction of the normal
  2928. * @return the angle between vector0 and vector1
  2929. */
  2930. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2931. /**
  2932. * Returns a new Vector3 set from the index "offset" of the given array
  2933. * @param array defines the source array
  2934. * @param offset defines the offset in the source array
  2935. * @returns the new Vector3
  2936. */
  2937. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2938. /**
  2939. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2940. * @param array defines the source array
  2941. * @param offset defines the offset in the source array
  2942. * @returns the new Vector3
  2943. * @deprecated Please use FromArray instead.
  2944. */
  2945. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2946. /**
  2947. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2948. * @param array defines the source array
  2949. * @param offset defines the offset in the source array
  2950. * @param result defines the Vector3 where to store the result
  2951. */
  2952. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2953. /**
  2954. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2955. * @param array defines the source array
  2956. * @param offset defines the offset in the source array
  2957. * @param result defines the Vector3 where to store the result
  2958. * @deprecated Please use FromArrayToRef instead.
  2959. */
  2960. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2961. /**
  2962. * Sets the given vector "result" with the given floats.
  2963. * @param x defines the x coordinate of the source
  2964. * @param y defines the y coordinate of the source
  2965. * @param z defines the z coordinate of the source
  2966. * @param result defines the Vector3 where to store the result
  2967. */
  2968. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2969. /**
  2970. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2971. * @returns a new empty Vector3
  2972. */
  2973. static Zero(): Vector3;
  2974. /**
  2975. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2976. * @returns a new unit Vector3
  2977. */
  2978. static One(): Vector3;
  2979. /**
  2980. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2981. * @returns a new up Vector3
  2982. */
  2983. static Up(): Vector3;
  2984. /**
  2985. * Gets a up Vector3 that must not be updated
  2986. */
  2987. static get UpReadOnly(): DeepImmutable<Vector3>;
  2988. /**
  2989. * Gets a zero Vector3 that must not be updated
  2990. */
  2991. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2992. /**
  2993. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2994. * @returns a new down Vector3
  2995. */
  2996. static Down(): Vector3;
  2997. /**
  2998. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2999. * @param rightHandedSystem is the scene right-handed (negative z)
  3000. * @returns a new forward Vector3
  3001. */
  3002. static Forward(rightHandedSystem?: boolean): Vector3;
  3003. /**
  3004. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  3005. * @param rightHandedSystem is the scene right-handed (negative-z)
  3006. * @returns a new forward Vector3
  3007. */
  3008. static Backward(rightHandedSystem?: boolean): Vector3;
  3009. /**
  3010. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3011. * @returns a new right Vector3
  3012. */
  3013. static Right(): Vector3;
  3014. /**
  3015. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3016. * @returns a new left Vector3
  3017. */
  3018. static Left(): Vector3;
  3019. /**
  3020. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3021. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3022. * @param vector defines the Vector3 to transform
  3023. * @param transformation defines the transformation matrix
  3024. * @returns the transformed Vector3
  3025. */
  3026. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3027. /**
  3028. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3029. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3030. * @param vector defines the Vector3 to transform
  3031. * @param transformation defines the transformation matrix
  3032. * @param result defines the Vector3 where to store the result
  3033. */
  3034. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3035. /**
  3036. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3037. * This method computes tranformed coordinates only, not transformed direction vectors
  3038. * @param x define the x coordinate of the source vector
  3039. * @param y define the y coordinate of the source vector
  3040. * @param z define the z coordinate of the source vector
  3041. * @param transformation defines the transformation matrix
  3042. * @param result defines the Vector3 where to store the result
  3043. */
  3044. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3045. /**
  3046. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3047. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3048. * @param vector defines the Vector3 to transform
  3049. * @param transformation defines the transformation matrix
  3050. * @returns the new Vector3
  3051. */
  3052. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3053. /**
  3054. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3055. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3056. * @param vector defines the Vector3 to transform
  3057. * @param transformation defines the transformation matrix
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3061. /**
  3062. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3063. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3064. * @param x define the x coordinate of the source vector
  3065. * @param y define the y coordinate of the source vector
  3066. * @param z define the z coordinate of the source vector
  3067. * @param transformation defines the transformation matrix
  3068. * @param result defines the Vector3 where to store the result
  3069. */
  3070. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3071. /**
  3072. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3073. * @param value1 defines the first control point
  3074. * @param value2 defines the second control point
  3075. * @param value3 defines the third control point
  3076. * @param value4 defines the fourth control point
  3077. * @param amount defines the amount on the spline to use
  3078. * @returns the new Vector3
  3079. */
  3080. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3081. /**
  3082. * 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"
  3083. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3084. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3085. * @param value defines the current value
  3086. * @param min defines the lower range value
  3087. * @param max defines the upper range value
  3088. * @returns the new Vector3
  3089. */
  3090. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3091. /**
  3092. * 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"
  3093. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3094. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3095. * @param value defines the current value
  3096. * @param min defines the lower range value
  3097. * @param max defines the upper range value
  3098. * @param result defines the Vector3 where to store the result
  3099. */
  3100. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3101. /**
  3102. * Checks if a given vector is inside a specific range
  3103. * @param v defines the vector to test
  3104. * @param min defines the minimum range
  3105. * @param max defines the maximum range
  3106. */
  3107. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3108. /**
  3109. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3110. * @param value1 defines the first control point
  3111. * @param tangent1 defines the first tangent vector
  3112. * @param value2 defines the second control point
  3113. * @param tangent2 defines the second tangent vector
  3114. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3115. * @returns the new Vector3
  3116. */
  3117. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3118. /**
  3119. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3120. * @param start defines the start value
  3121. * @param end defines the end value
  3122. * @param amount max defines amount between both (between 0 and 1)
  3123. * @returns the new Vector3
  3124. */
  3125. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3126. /**
  3127. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3128. * @param start defines the start value
  3129. * @param end defines the end value
  3130. * @param amount max defines amount between both (between 0 and 1)
  3131. * @param result defines the Vector3 where to store the result
  3132. */
  3133. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3134. /**
  3135. * Returns the dot product (float) between the vectors "left" and "right"
  3136. * @param left defines the left operand
  3137. * @param right defines the right operand
  3138. * @returns the dot product
  3139. */
  3140. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3141. /**
  3142. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3143. * The cross product is then orthogonal to both "left" and "right"
  3144. * @param left defines the left operand
  3145. * @param right defines the right operand
  3146. * @returns the cross product
  3147. */
  3148. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3149. /**
  3150. * Sets the given vector "result" with the cross product of "left" and "right"
  3151. * The cross product is then orthogonal to both "left" and "right"
  3152. * @param left defines the left operand
  3153. * @param right defines the right operand
  3154. * @param result defines the Vector3 where to store the result
  3155. */
  3156. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3157. /**
  3158. * Returns a new Vector3 as the normalization of the given vector
  3159. * @param vector defines the Vector3 to normalize
  3160. * @returns the new Vector3
  3161. */
  3162. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3163. /**
  3164. * Sets the given vector "result" with the normalization of the given first vector
  3165. * @param vector defines the Vector3 to normalize
  3166. * @param result defines the Vector3 where to store the result
  3167. */
  3168. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3169. /**
  3170. * Project a Vector3 onto screen space
  3171. * @param vector defines the Vector3 to project
  3172. * @param world defines the world matrix to use
  3173. * @param transform defines the transform (view x projection) matrix to use
  3174. * @param viewport defines the screen viewport to use
  3175. * @returns the new Vector3
  3176. */
  3177. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3178. /**
  3179. * Project a Vector3 onto screen space to reference
  3180. * @param vector defines the Vector3 to project
  3181. * @param world defines the world matrix to use
  3182. * @param transform defines the transform (view x projection) matrix to use
  3183. * @param viewport defines the screen viewport to use
  3184. * @param result the vector in which the screen space will be stored
  3185. * @returns the new Vector3
  3186. */
  3187. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  3188. /** @hidden */
  3189. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3190. /**
  3191. * Unproject from screen space to object space
  3192. * @param source defines the screen space Vector3 to use
  3193. * @param viewportWidth defines the current width of the viewport
  3194. * @param viewportHeight defines the current height of the viewport
  3195. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3196. * @param transform defines the transform (view x projection) matrix to use
  3197. * @returns the new Vector3
  3198. */
  3199. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3200. /**
  3201. * Unproject from screen space to object space
  3202. * @param source defines the screen space Vector3 to use
  3203. * @param viewportWidth defines the current width of the viewport
  3204. * @param viewportHeight defines the current height of the viewport
  3205. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3206. * @param view defines the view matrix to use
  3207. * @param projection defines the projection matrix to use
  3208. * @returns the new Vector3
  3209. */
  3210. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3211. /**
  3212. * Unproject from screen space to object space
  3213. * @param source defines the screen space Vector3 to use
  3214. * @param viewportWidth defines the current width of the viewport
  3215. * @param viewportHeight defines the current height of the viewport
  3216. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3217. * @param view defines the view matrix to use
  3218. * @param projection defines the projection matrix to use
  3219. * @param result defines the Vector3 where to store the result
  3220. */
  3221. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3222. /**
  3223. * Unproject from screen space to object space
  3224. * @param sourceX defines the screen space x coordinate to use
  3225. * @param sourceY defines the screen space y coordinate to use
  3226. * @param sourceZ defines the screen space z coordinate to use
  3227. * @param viewportWidth defines the current width of the viewport
  3228. * @param viewportHeight defines the current height of the viewport
  3229. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3230. * @param view defines the view matrix to use
  3231. * @param projection defines the projection matrix to use
  3232. * @param result defines the Vector3 where to store the result
  3233. */
  3234. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3235. /**
  3236. * Gets the minimal coordinate values between two Vector3
  3237. * @param left defines the first operand
  3238. * @param right defines the second operand
  3239. * @returns the new Vector3
  3240. */
  3241. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3242. /**
  3243. * Gets the maximal coordinate values between two Vector3
  3244. * @param left defines the first operand
  3245. * @param right defines the second operand
  3246. * @returns the new Vector3
  3247. */
  3248. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3249. /**
  3250. * Returns the distance between the vectors "value1" and "value2"
  3251. * @param value1 defines the first operand
  3252. * @param value2 defines the second operand
  3253. * @returns the distance
  3254. */
  3255. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3256. /**
  3257. * Returns the squared distance between the vectors "value1" and "value2"
  3258. * @param value1 defines the first operand
  3259. * @param value2 defines the second operand
  3260. * @returns the squared distance
  3261. */
  3262. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3263. /**
  3264. * Returns a new Vector3 located at the center between "value1" and "value2"
  3265. * @param value1 defines the first operand
  3266. * @param value2 defines the second operand
  3267. * @returns the new Vector3
  3268. */
  3269. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3270. /**
  3271. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3272. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3273. * to something in order to rotate it from its local system to the given target system
  3274. * Note: axis1, axis2 and axis3 are normalized during this operation
  3275. * @param axis1 defines the first axis
  3276. * @param axis2 defines the second axis
  3277. * @param axis3 defines the third axis
  3278. * @returns a new Vector3
  3279. */
  3280. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3281. /**
  3282. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3283. * @param axis1 defines the first axis
  3284. * @param axis2 defines the second axis
  3285. * @param axis3 defines the third axis
  3286. * @param ref defines the Vector3 where to store the result
  3287. */
  3288. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3289. }
  3290. /**
  3291. * Vector4 class created for EulerAngle class conversion to Quaternion
  3292. */
  3293. export class Vector4 {
  3294. /** x value of the vector */
  3295. x: number;
  3296. /** y value of the vector */
  3297. y: number;
  3298. /** z value of the vector */
  3299. z: number;
  3300. /** w value of the vector */
  3301. w: number;
  3302. /**
  3303. * Creates a Vector4 object from the given floats.
  3304. * @param x x value of the vector
  3305. * @param y y value of the vector
  3306. * @param z z value of the vector
  3307. * @param w w value of the vector
  3308. */
  3309. constructor(
  3310. /** x value of the vector */
  3311. x: number,
  3312. /** y value of the vector */
  3313. y: number,
  3314. /** z value of the vector */
  3315. z: number,
  3316. /** w value of the vector */
  3317. w: number);
  3318. /**
  3319. * Returns the string with the Vector4 coordinates.
  3320. * @returns a string containing all the vector values
  3321. */
  3322. toString(): string;
  3323. /**
  3324. * Returns the string "Vector4".
  3325. * @returns "Vector4"
  3326. */
  3327. getClassName(): string;
  3328. /**
  3329. * Returns the Vector4 hash code.
  3330. * @returns a unique hash code
  3331. */
  3332. getHashCode(): number;
  3333. /**
  3334. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3335. * @returns the resulting array
  3336. */
  3337. asArray(): number[];
  3338. /**
  3339. * Populates the given array from the given index with the Vector4 coordinates.
  3340. * @param array array to populate
  3341. * @param index index of the array to start at (default: 0)
  3342. * @returns the Vector4.
  3343. */
  3344. toArray(array: FloatArray, index?: number): Vector4;
  3345. /**
  3346. * Update the current vector from an array
  3347. * @param array defines the destination array
  3348. * @param index defines the offset in the destination array
  3349. * @returns the current Vector3
  3350. */
  3351. fromArray(array: FloatArray, index?: number): Vector4;
  3352. /**
  3353. * Adds the given vector to the current Vector4.
  3354. * @param otherVector the vector to add
  3355. * @returns the updated Vector4.
  3356. */
  3357. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3358. /**
  3359. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3360. * @param otherVector the vector to add
  3361. * @returns the resulting vector
  3362. */
  3363. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3364. /**
  3365. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3366. * @param otherVector the vector to add
  3367. * @param result the vector to store the result
  3368. * @returns the current Vector4.
  3369. */
  3370. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3371. /**
  3372. * Subtract in place the given vector from the current Vector4.
  3373. * @param otherVector the vector to subtract
  3374. * @returns the updated Vector4.
  3375. */
  3376. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3377. /**
  3378. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3379. * @param otherVector the vector to add
  3380. * @returns the new vector with the result
  3381. */
  3382. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3383. /**
  3384. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3385. * @param otherVector the vector to subtract
  3386. * @param result the vector to store the result
  3387. * @returns the current Vector4.
  3388. */
  3389. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3390. /**
  3391. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3392. */
  3393. /**
  3394. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3395. * @param x value to subtract
  3396. * @param y value to subtract
  3397. * @param z value to subtract
  3398. * @param w value to subtract
  3399. * @returns new vector containing the result
  3400. */
  3401. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3402. /**
  3403. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3404. * @param x value to subtract
  3405. * @param y value to subtract
  3406. * @param z value to subtract
  3407. * @param w value to subtract
  3408. * @param result the vector to store the result in
  3409. * @returns the current Vector4.
  3410. */
  3411. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3412. /**
  3413. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3414. * @returns a new vector with the negated values
  3415. */
  3416. negate(): Vector4;
  3417. /**
  3418. * Negate this vector in place
  3419. * @returns this
  3420. */
  3421. negateInPlace(): Vector4;
  3422. /**
  3423. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3424. * @param result defines the Vector3 object where to store the result
  3425. * @returns the current Vector4
  3426. */
  3427. negateToRef(result: Vector4): Vector4;
  3428. /**
  3429. * Multiplies the current Vector4 coordinates by scale (float).
  3430. * @param scale the number to scale with
  3431. * @returns the updated Vector4.
  3432. */
  3433. scaleInPlace(scale: number): Vector4;
  3434. /**
  3435. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3436. * @param scale the number to scale with
  3437. * @returns a new vector with the result
  3438. */
  3439. scale(scale: number): Vector4;
  3440. /**
  3441. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3442. * @param scale the number to scale with
  3443. * @param result a vector to store the result in
  3444. * @returns the current Vector4.
  3445. */
  3446. scaleToRef(scale: number, result: Vector4): Vector4;
  3447. /**
  3448. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3449. * @param scale defines the scale factor
  3450. * @param result defines the Vector4 object where to store the result
  3451. * @returns the unmodified current Vector4
  3452. */
  3453. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3454. /**
  3455. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3456. * @param otherVector the vector to compare against
  3457. * @returns true if they are equal
  3458. */
  3459. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3460. /**
  3461. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3462. * @param otherVector vector to compare against
  3463. * @param epsilon (Default: very small number)
  3464. * @returns true if they are equal
  3465. */
  3466. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3467. /**
  3468. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3469. * @param x x value to compare against
  3470. * @param y y value to compare against
  3471. * @param z z value to compare against
  3472. * @param w w value to compare against
  3473. * @returns true if equal
  3474. */
  3475. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3476. /**
  3477. * Multiplies in place the current Vector4 by the given one.
  3478. * @param otherVector vector to multiple with
  3479. * @returns the updated Vector4.
  3480. */
  3481. multiplyInPlace(otherVector: Vector4): Vector4;
  3482. /**
  3483. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3484. * @param otherVector vector to multiple with
  3485. * @returns resulting new vector
  3486. */
  3487. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3488. /**
  3489. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3490. * @param otherVector vector to multiple with
  3491. * @param result vector to store the result
  3492. * @returns the current Vector4.
  3493. */
  3494. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3495. /**
  3496. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3497. * @param x x value multiply with
  3498. * @param y y value multiply with
  3499. * @param z z value multiply with
  3500. * @param w w value multiply with
  3501. * @returns resulting new vector
  3502. */
  3503. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3504. /**
  3505. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3506. * @param otherVector vector to devide with
  3507. * @returns resulting new vector
  3508. */
  3509. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3510. /**
  3511. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3512. * @param otherVector vector to devide with
  3513. * @param result vector to store the result
  3514. * @returns the current Vector4.
  3515. */
  3516. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3517. /**
  3518. * Divides the current Vector3 coordinates by the given ones.
  3519. * @param otherVector vector to devide with
  3520. * @returns the updated Vector3.
  3521. */
  3522. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3523. /**
  3524. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3525. * @param other defines the second operand
  3526. * @returns the current updated Vector4
  3527. */
  3528. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3529. /**
  3530. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3531. * @param other defines the second operand
  3532. * @returns the current updated Vector4
  3533. */
  3534. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3535. /**
  3536. * Gets a new Vector4 from current Vector4 floored values
  3537. * @returns a new Vector4
  3538. */
  3539. floor(): Vector4;
  3540. /**
  3541. * Gets a new Vector4 from current Vector3 floored values
  3542. * @returns a new Vector4
  3543. */
  3544. fract(): Vector4;
  3545. /**
  3546. * Returns the Vector4 length (float).
  3547. * @returns the length
  3548. */
  3549. length(): number;
  3550. /**
  3551. * Returns the Vector4 squared length (float).
  3552. * @returns the length squared
  3553. */
  3554. lengthSquared(): number;
  3555. /**
  3556. * Normalizes in place the Vector4.
  3557. * @returns the updated Vector4.
  3558. */
  3559. normalize(): Vector4;
  3560. /**
  3561. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3562. * @returns this converted to a new vector3
  3563. */
  3564. toVector3(): Vector3;
  3565. /**
  3566. * Returns a new Vector4 copied from the current one.
  3567. * @returns the new cloned vector
  3568. */
  3569. clone(): Vector4;
  3570. /**
  3571. * Updates the current Vector4 with the given one coordinates.
  3572. * @param source the source vector to copy from
  3573. * @returns the updated Vector4.
  3574. */
  3575. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3576. /**
  3577. * Updates the current Vector4 coordinates with the given floats.
  3578. * @param x float to copy from
  3579. * @param y float to copy from
  3580. * @param z float to copy from
  3581. * @param w float to copy from
  3582. * @returns the updated Vector4.
  3583. */
  3584. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3585. /**
  3586. * Updates the current Vector4 coordinates with the given floats.
  3587. * @param x float to set from
  3588. * @param y float to set from
  3589. * @param z float to set from
  3590. * @param w float to set from
  3591. * @returns the updated Vector4.
  3592. */
  3593. set(x: number, y: number, z: number, w: number): Vector4;
  3594. /**
  3595. * Copies the given float to the current Vector3 coordinates
  3596. * @param v defines the x, y, z and w coordinates of the operand
  3597. * @returns the current updated Vector3
  3598. */
  3599. setAll(v: number): Vector4;
  3600. /**
  3601. * Returns a new Vector4 set from the starting index of the given array.
  3602. * @param array the array to pull values from
  3603. * @param offset the offset into the array to start at
  3604. * @returns the new vector
  3605. */
  3606. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3607. /**
  3608. * Updates the given vector "result" from the starting index of the given array.
  3609. * @param array the array to pull values from
  3610. * @param offset the offset into the array to start at
  3611. * @param result the vector to store the result in
  3612. */
  3613. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3614. /**
  3615. * Updates the given vector "result" from the starting index of the given Float32Array.
  3616. * @param array the array to pull values from
  3617. * @param offset the offset into the array to start at
  3618. * @param result the vector to store the result in
  3619. */
  3620. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3621. /**
  3622. * Updates the given vector "result" coordinates from the given floats.
  3623. * @param x float to set from
  3624. * @param y float to set from
  3625. * @param z float to set from
  3626. * @param w float to set from
  3627. * @param result the vector to the floats in
  3628. */
  3629. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3630. /**
  3631. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3632. * @returns the new vector
  3633. */
  3634. static Zero(): Vector4;
  3635. /**
  3636. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3637. * @returns the new vector
  3638. */
  3639. static One(): Vector4;
  3640. /**
  3641. * Returns a new normalized Vector4 from the given one.
  3642. * @param vector the vector to normalize
  3643. * @returns the vector
  3644. */
  3645. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3646. /**
  3647. * Updates the given vector "result" from the normalization of the given one.
  3648. * @param vector the vector to normalize
  3649. * @param result the vector to store the result in
  3650. */
  3651. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3652. /**
  3653. * Returns a vector with the minimum values from the left and right vectors
  3654. * @param left left vector to minimize
  3655. * @param right right vector to minimize
  3656. * @returns a new vector with the minimum of the left and right vector values
  3657. */
  3658. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3659. /**
  3660. * Returns a vector with the maximum values from the left and right vectors
  3661. * @param left left vector to maximize
  3662. * @param right right vector to maximize
  3663. * @returns a new vector with the maximum of the left and right vector values
  3664. */
  3665. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3666. /**
  3667. * Returns the distance (float) between the vectors "value1" and "value2".
  3668. * @param value1 value to calulate the distance between
  3669. * @param value2 value to calulate the distance between
  3670. * @return the distance between the two vectors
  3671. */
  3672. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3673. /**
  3674. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3675. * @param value1 value to calulate the distance between
  3676. * @param value2 value to calulate the distance between
  3677. * @return the distance between the two vectors squared
  3678. */
  3679. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3680. /**
  3681. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3682. * @param value1 value to calulate the center between
  3683. * @param value2 value to calulate the center between
  3684. * @return the center between the two vectors
  3685. */
  3686. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3687. /**
  3688. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3689. * This methods computes transformed normalized direction vectors only.
  3690. * @param vector the vector to transform
  3691. * @param transformation the transformation matrix to apply
  3692. * @returns the new vector
  3693. */
  3694. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3695. /**
  3696. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3697. * This methods computes transformed normalized direction vectors only.
  3698. * @param vector the vector to transform
  3699. * @param transformation the transformation matrix to apply
  3700. * @param result the vector to store the result in
  3701. */
  3702. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3703. /**
  3704. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3705. * This methods computes transformed normalized direction vectors only.
  3706. * @param x value to transform
  3707. * @param y value to transform
  3708. * @param z value to transform
  3709. * @param w value to transform
  3710. * @param transformation the transformation matrix to apply
  3711. * @param result the vector to store the results in
  3712. */
  3713. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3714. /**
  3715. * Creates a new Vector4 from a Vector3
  3716. * @param source defines the source data
  3717. * @param w defines the 4th component (default is 0)
  3718. * @returns a new Vector4
  3719. */
  3720. static FromVector3(source: Vector3, w?: number): Vector4;
  3721. }
  3722. /**
  3723. * Class used to store quaternion data
  3724. * @see https://en.wikipedia.org/wiki/Quaternion
  3725. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3726. */
  3727. export class Quaternion {
  3728. /** @hidden */
  3729. _x: number;
  3730. /** @hidden */
  3731. _y: number;
  3732. /** @hidden */
  3733. _z: number;
  3734. /** @hidden */
  3735. _w: number;
  3736. /** @hidden */
  3737. _isDirty: boolean;
  3738. /** Gets or sets the x coordinate */
  3739. get x(): number;
  3740. set x(value: number);
  3741. /** Gets or sets the y coordinate */
  3742. get y(): number;
  3743. set y(value: number);
  3744. /** Gets or sets the z coordinate */
  3745. get z(): number;
  3746. set z(value: number);
  3747. /** Gets or sets the w coordinate */
  3748. get w(): number;
  3749. set w(value: number);
  3750. /**
  3751. * Creates a new Quaternion from the given floats
  3752. * @param x defines the first component (0 by default)
  3753. * @param y defines the second component (0 by default)
  3754. * @param z defines the third component (0 by default)
  3755. * @param w defines the fourth component (1.0 by default)
  3756. */
  3757. constructor(x?: number, y?: number, z?: number, w?: number);
  3758. /**
  3759. * Gets a string representation for the current quaternion
  3760. * @returns a string with the Quaternion coordinates
  3761. */
  3762. toString(): string;
  3763. /**
  3764. * Gets the class name of the quaternion
  3765. * @returns the string "Quaternion"
  3766. */
  3767. getClassName(): string;
  3768. /**
  3769. * Gets a hash code for this quaternion
  3770. * @returns the quaternion hash code
  3771. */
  3772. getHashCode(): number;
  3773. /**
  3774. * Copy the quaternion to an array
  3775. * @returns a new array populated with 4 elements from the quaternion coordinates
  3776. */
  3777. asArray(): number[];
  3778. /**
  3779. * Check if two quaternions are equals
  3780. * @param otherQuaternion defines the second operand
  3781. * @return true if the current quaternion and the given one coordinates are strictly equals
  3782. */
  3783. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3784. /**
  3785. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3786. * @param otherQuaternion defines the other quaternion
  3787. * @param epsilon defines the minimal distance to consider equality
  3788. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3789. */
  3790. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3791. /**
  3792. * Clone the current quaternion
  3793. * @returns a new quaternion copied from the current one
  3794. */
  3795. clone(): Quaternion;
  3796. /**
  3797. * Copy a quaternion to the current one
  3798. * @param other defines the other quaternion
  3799. * @returns the updated current quaternion
  3800. */
  3801. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3802. /**
  3803. * Updates the current quaternion with the given float coordinates
  3804. * @param x defines the x coordinate
  3805. * @param y defines the y coordinate
  3806. * @param z defines the z coordinate
  3807. * @param w defines the w coordinate
  3808. * @returns the updated current quaternion
  3809. */
  3810. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3811. /**
  3812. * Updates the current quaternion from the given float coordinates
  3813. * @param x defines the x coordinate
  3814. * @param y defines the y coordinate
  3815. * @param z defines the z coordinate
  3816. * @param w defines the w coordinate
  3817. * @returns the updated current quaternion
  3818. */
  3819. set(x: number, y: number, z: number, w: number): Quaternion;
  3820. /**
  3821. * Adds two quaternions
  3822. * @param other defines the second operand
  3823. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3824. */
  3825. add(other: DeepImmutable<Quaternion>): Quaternion;
  3826. /**
  3827. * Add a quaternion to the current one
  3828. * @param other defines the quaternion to add
  3829. * @returns the current quaternion
  3830. */
  3831. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3832. /**
  3833. * Subtract two quaternions
  3834. * @param other defines the second operand
  3835. * @returns a new quaternion as the subtraction result of the given one from the current one
  3836. */
  3837. subtract(other: Quaternion): Quaternion;
  3838. /**
  3839. * Multiplies the current quaternion by a scale factor
  3840. * @param value defines the scale factor
  3841. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3842. */
  3843. scale(value: number): Quaternion;
  3844. /**
  3845. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3846. * @param scale defines the scale factor
  3847. * @param result defines the Quaternion object where to store the result
  3848. * @returns the unmodified current quaternion
  3849. */
  3850. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3851. /**
  3852. * Multiplies in place the current quaternion by a scale factor
  3853. * @param value defines the scale factor
  3854. * @returns the current modified quaternion
  3855. */
  3856. scaleInPlace(value: number): Quaternion;
  3857. /**
  3858. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3859. * @param scale defines the scale factor
  3860. * @param result defines the Quaternion object where to store the result
  3861. * @returns the unmodified current quaternion
  3862. */
  3863. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3864. /**
  3865. * Multiplies two quaternions
  3866. * @param q1 defines the second operand
  3867. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3868. */
  3869. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3870. /**
  3871. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3872. * @param q1 defines the second operand
  3873. * @param result defines the target quaternion
  3874. * @returns the current quaternion
  3875. */
  3876. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3877. /**
  3878. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3879. * @param q1 defines the second operand
  3880. * @returns the currentupdated quaternion
  3881. */
  3882. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3883. /**
  3884. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3885. * @param ref defines the target quaternion
  3886. * @returns the current quaternion
  3887. */
  3888. conjugateToRef(ref: Quaternion): Quaternion;
  3889. /**
  3890. * Conjugates in place (1-q) the current quaternion
  3891. * @returns the current updated quaternion
  3892. */
  3893. conjugateInPlace(): Quaternion;
  3894. /**
  3895. * Conjugates in place (1-q) the current quaternion
  3896. * @returns a new quaternion
  3897. */
  3898. conjugate(): Quaternion;
  3899. /**
  3900. * Gets length of current quaternion
  3901. * @returns the quaternion length (float)
  3902. */
  3903. length(): number;
  3904. /**
  3905. * Normalize in place the current quaternion
  3906. * @returns the current updated quaternion
  3907. */
  3908. normalize(): Quaternion;
  3909. /**
  3910. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3911. * @param order is a reserved parameter and is ignored for now
  3912. * @returns a new Vector3 containing the Euler angles
  3913. */
  3914. toEulerAngles(order?: string): Vector3;
  3915. /**
  3916. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3917. * @param result defines the vector which will be filled with the Euler angles
  3918. * @returns the current unchanged quaternion
  3919. */
  3920. toEulerAnglesToRef(result: Vector3): Quaternion;
  3921. /**
  3922. * Updates the given rotation matrix with the current quaternion values
  3923. * @param result defines the target matrix
  3924. * @returns the current unchanged quaternion
  3925. */
  3926. toRotationMatrix(result: Matrix): Quaternion;
  3927. /**
  3928. * Updates the current quaternion from the given rotation matrix values
  3929. * @param matrix defines the source matrix
  3930. * @returns the current updated quaternion
  3931. */
  3932. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3933. /**
  3934. * Creates a new quaternion from a rotation matrix
  3935. * @param matrix defines the source matrix
  3936. * @returns a new quaternion created from the given rotation matrix values
  3937. */
  3938. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3939. /**
  3940. * Updates the given quaternion with the given rotation matrix values
  3941. * @param matrix defines the source matrix
  3942. * @param result defines the target quaternion
  3943. */
  3944. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3945. /**
  3946. * Returns the dot product (float) between the quaternions "left" and "right"
  3947. * @param left defines the left operand
  3948. * @param right defines the right operand
  3949. * @returns the dot product
  3950. */
  3951. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3952. /**
  3953. * Checks if the two quaternions are close to each other
  3954. * @param quat0 defines the first quaternion to check
  3955. * @param quat1 defines the second quaternion to check
  3956. * @returns true if the two quaternions are close to each other
  3957. */
  3958. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3959. /**
  3960. * Creates an empty quaternion
  3961. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3962. */
  3963. static Zero(): Quaternion;
  3964. /**
  3965. * Inverse a given quaternion
  3966. * @param q defines the source quaternion
  3967. * @returns a new quaternion as the inverted current quaternion
  3968. */
  3969. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3970. /**
  3971. * Inverse a given quaternion
  3972. * @param q defines the source quaternion
  3973. * @param result the quaternion the result will be stored in
  3974. * @returns the result quaternion
  3975. */
  3976. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3977. /**
  3978. * Creates an identity quaternion
  3979. * @returns the identity quaternion
  3980. */
  3981. static Identity(): Quaternion;
  3982. /**
  3983. * Gets a boolean indicating if the given quaternion is identity
  3984. * @param quaternion defines the quaternion to check
  3985. * @returns true if the quaternion is identity
  3986. */
  3987. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3988. /**
  3989. * Creates a quaternion from a rotation around an axis
  3990. * @param axis defines the axis to use
  3991. * @param angle defines the angle to use
  3992. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3993. */
  3994. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3995. /**
  3996. * Creates a rotation around an axis and stores it into the given quaternion
  3997. * @param axis defines the axis to use
  3998. * @param angle defines the angle to use
  3999. * @param result defines the target quaternion
  4000. * @returns the target quaternion
  4001. */
  4002. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  4003. /**
  4004. * Creates a new quaternion from data stored into an array
  4005. * @param array defines the data source
  4006. * @param offset defines the offset in the source array where the data starts
  4007. * @returns a new quaternion
  4008. */
  4009. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  4010. /**
  4011. * Updates the given quaternion "result" from the starting index of the given array.
  4012. * @param array the array to pull values from
  4013. * @param offset the offset into the array to start at
  4014. * @param result the quaternion to store the result in
  4015. */
  4016. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  4017. /**
  4018. * Create a quaternion from Euler rotation angles
  4019. * @param x Pitch
  4020. * @param y Yaw
  4021. * @param z Roll
  4022. * @returns the new Quaternion
  4023. */
  4024. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4025. /**
  4026. * Updates a quaternion from Euler rotation angles
  4027. * @param x Pitch
  4028. * @param y Yaw
  4029. * @param z Roll
  4030. * @param result the quaternion to store the result
  4031. * @returns the updated quaternion
  4032. */
  4033. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4034. /**
  4035. * Create a quaternion from Euler rotation vector
  4036. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4037. * @returns the new Quaternion
  4038. */
  4039. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4040. /**
  4041. * Updates a quaternion from Euler rotation vector
  4042. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4043. * @param result the quaternion to store the result
  4044. * @returns the updated quaternion
  4045. */
  4046. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4047. /**
  4048. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4049. * @param yaw defines the rotation around Y axis
  4050. * @param pitch defines the rotation around X axis
  4051. * @param roll defines the rotation around Z axis
  4052. * @returns the new quaternion
  4053. */
  4054. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4055. /**
  4056. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4057. * @param yaw defines the rotation around Y axis
  4058. * @param pitch defines the rotation around X axis
  4059. * @param roll defines the rotation around Z axis
  4060. * @param result defines the target quaternion
  4061. */
  4062. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4063. /**
  4064. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4065. * @param alpha defines the rotation around first axis
  4066. * @param beta defines the rotation around second axis
  4067. * @param gamma defines the rotation around third axis
  4068. * @returns the new quaternion
  4069. */
  4070. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4071. /**
  4072. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4073. * @param alpha defines the rotation around first axis
  4074. * @param beta defines the rotation around second axis
  4075. * @param gamma defines the rotation around third axis
  4076. * @param result defines the target quaternion
  4077. */
  4078. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4079. /**
  4080. * 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)
  4081. * @param axis1 defines the first axis
  4082. * @param axis2 defines the second axis
  4083. * @param axis3 defines the third axis
  4084. * @returns the new quaternion
  4085. */
  4086. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4087. /**
  4088. * 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
  4089. * @param axis1 defines the first axis
  4090. * @param axis2 defines the second axis
  4091. * @param axis3 defines the third axis
  4092. * @param ref defines the target quaternion
  4093. */
  4094. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4095. /**
  4096. * Interpolates between two quaternions
  4097. * @param left defines first quaternion
  4098. * @param right defines second quaternion
  4099. * @param amount defines the gradient to use
  4100. * @returns the new interpolated quaternion
  4101. */
  4102. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4103. /**
  4104. * Interpolates between two quaternions and stores it into a target quaternion
  4105. * @param left defines first quaternion
  4106. * @param right defines second quaternion
  4107. * @param amount defines the gradient to use
  4108. * @param result defines the target quaternion
  4109. */
  4110. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4111. /**
  4112. * Interpolate between two quaternions using Hermite interpolation
  4113. * @param value1 defines first quaternion
  4114. * @param tangent1 defines the incoming tangent
  4115. * @param value2 defines second quaternion
  4116. * @param tangent2 defines the outgoing tangent
  4117. * @param amount defines the target quaternion
  4118. * @returns the new interpolated quaternion
  4119. */
  4120. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4121. }
  4122. /**
  4123. * Class used to store matrix data (4x4)
  4124. */
  4125. export class Matrix {
  4126. /**
  4127. * Gets the precision of matrix computations
  4128. */
  4129. static get Use64Bits(): boolean;
  4130. private static _updateFlagSeed;
  4131. private static _identityReadOnly;
  4132. private _isIdentity;
  4133. private _isIdentityDirty;
  4134. private _isIdentity3x2;
  4135. private _isIdentity3x2Dirty;
  4136. /**
  4137. * Gets the update flag of the matrix which is an unique number for the matrix.
  4138. * It will be incremented every time the matrix data change.
  4139. * You can use it to speed the comparison between two versions of the same matrix.
  4140. */
  4141. updateFlag: number;
  4142. private readonly _m;
  4143. /**
  4144. * Gets the internal data of the matrix
  4145. */
  4146. get m(): DeepImmutable<Float32Array | Array<number>>;
  4147. /** @hidden */
  4148. _markAsUpdated(): void;
  4149. /** @hidden */
  4150. private _updateIdentityStatus;
  4151. /**
  4152. * Creates an empty matrix (filled with zeros)
  4153. */
  4154. constructor();
  4155. /**
  4156. * Check if the current matrix is identity
  4157. * @returns true is the matrix is the identity matrix
  4158. */
  4159. isIdentity(): boolean;
  4160. /**
  4161. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4162. * @returns true is the matrix is the identity matrix
  4163. */
  4164. isIdentityAs3x2(): boolean;
  4165. /**
  4166. * Gets the determinant of the matrix
  4167. * @returns the matrix determinant
  4168. */
  4169. determinant(): number;
  4170. /**
  4171. * Returns the matrix as a Float32Array or Array<number>
  4172. * @returns the matrix underlying array
  4173. */
  4174. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4175. /**
  4176. * Returns the matrix as a Float32Array or Array<number>
  4177. * @returns the matrix underlying array.
  4178. */
  4179. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4180. /**
  4181. * Inverts the current matrix in place
  4182. * @returns the current inverted matrix
  4183. */
  4184. invert(): Matrix;
  4185. /**
  4186. * Sets all the matrix elements to zero
  4187. * @returns the current matrix
  4188. */
  4189. reset(): Matrix;
  4190. /**
  4191. * Adds the current matrix with a second one
  4192. * @param other defines the matrix to add
  4193. * @returns a new matrix as the addition of the current matrix and the given one
  4194. */
  4195. add(other: DeepImmutable<Matrix>): Matrix;
  4196. /**
  4197. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4198. * @param other defines the matrix to add
  4199. * @param result defines the target matrix
  4200. * @returns the current matrix
  4201. */
  4202. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4203. /**
  4204. * Adds in place the given matrix to the current matrix
  4205. * @param other defines the second operand
  4206. * @returns the current updated matrix
  4207. */
  4208. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4209. /**
  4210. * Sets the given matrix to the current inverted Matrix
  4211. * @param other defines the target matrix
  4212. * @returns the unmodified current matrix
  4213. */
  4214. invertToRef(other: Matrix): Matrix;
  4215. /**
  4216. * add a value at the specified position in the current Matrix
  4217. * @param index the index of the value within the matrix. between 0 and 15.
  4218. * @param value the value to be added
  4219. * @returns the current updated matrix
  4220. */
  4221. addAtIndex(index: number, value: number): Matrix;
  4222. /**
  4223. * mutiply the specified position in the current Matrix by a value
  4224. * @param index the index of the value within the matrix. between 0 and 15.
  4225. * @param value the value to be added
  4226. * @returns the current updated matrix
  4227. */
  4228. multiplyAtIndex(index: number, value: number): Matrix;
  4229. /**
  4230. * Inserts the translation vector (using 3 floats) in the current matrix
  4231. * @param x defines the 1st component of the translation
  4232. * @param y defines the 2nd component of the translation
  4233. * @param z defines the 3rd component of the translation
  4234. * @returns the current updated matrix
  4235. */
  4236. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4237. /**
  4238. * Adds the translation vector (using 3 floats) in the current matrix
  4239. * @param x defines the 1st component of the translation
  4240. * @param y defines the 2nd component of the translation
  4241. * @param z defines the 3rd component of the translation
  4242. * @returns the current updated matrix
  4243. */
  4244. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4245. /**
  4246. * Inserts the translation vector in the current matrix
  4247. * @param vector3 defines the translation to insert
  4248. * @returns the current updated matrix
  4249. */
  4250. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4251. /**
  4252. * Gets the translation value of the current matrix
  4253. * @returns a new Vector3 as the extracted translation from the matrix
  4254. */
  4255. getTranslation(): Vector3;
  4256. /**
  4257. * Fill a Vector3 with the extracted translation from the matrix
  4258. * @param result defines the Vector3 where to store the translation
  4259. * @returns the current matrix
  4260. */
  4261. getTranslationToRef(result: Vector3): Matrix;
  4262. /**
  4263. * Remove rotation and scaling part from the matrix
  4264. * @returns the updated matrix
  4265. */
  4266. removeRotationAndScaling(): Matrix;
  4267. /**
  4268. * Multiply two matrices
  4269. * @param other defines the second operand
  4270. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4271. */
  4272. multiply(other: DeepImmutable<Matrix>): Matrix;
  4273. /**
  4274. * Copy the current matrix from the given one
  4275. * @param other defines the source matrix
  4276. * @returns the current updated matrix
  4277. */
  4278. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4279. /**
  4280. * Populates the given array from the starting index with the current matrix values
  4281. * @param array defines the target array
  4282. * @param offset defines the offset in the target array where to start storing values
  4283. * @returns the current matrix
  4284. */
  4285. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4286. /**
  4287. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4288. * @param other defines the second operand
  4289. * @param result defines the matrix where to store the multiplication
  4290. * @returns the current matrix
  4291. */
  4292. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4293. /**
  4294. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4295. * @param other defines the second operand
  4296. * @param result defines the array where to store the multiplication
  4297. * @param offset defines the offset in the target array where to start storing values
  4298. * @returns the current matrix
  4299. */
  4300. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4301. /**
  4302. * Check equality between this matrix and a second one
  4303. * @param value defines the second matrix to compare
  4304. * @returns true is the current matrix and the given one values are strictly equal
  4305. */
  4306. equals(value: DeepImmutable<Matrix>): boolean;
  4307. /**
  4308. * Clone the current matrix
  4309. * @returns a new matrix from the current matrix
  4310. */
  4311. clone(): Matrix;
  4312. /**
  4313. * Returns the name of the current matrix class
  4314. * @returns the string "Matrix"
  4315. */
  4316. getClassName(): string;
  4317. /**
  4318. * Gets the hash code of the current matrix
  4319. * @returns the hash code
  4320. */
  4321. getHashCode(): number;
  4322. /**
  4323. * Decomposes the current Matrix into a translation, rotation and scaling components
  4324. * @param scale defines the scale vector3 given as a reference to update
  4325. * @param rotation defines the rotation quaternion given as a reference to update
  4326. * @param translation defines the translation vector3 given as a reference to update
  4327. * @returns true if operation was successful
  4328. */
  4329. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4330. /**
  4331. * Gets specific row of the matrix
  4332. * @param index defines the number of the row to get
  4333. * @returns the index-th row of the current matrix as a new Vector4
  4334. */
  4335. getRow(index: number): Nullable<Vector4>;
  4336. /**
  4337. * Sets the index-th row of the current matrix to the vector4 values
  4338. * @param index defines the number of the row to set
  4339. * @param row defines the target vector4
  4340. * @returns the updated current matrix
  4341. */
  4342. setRow(index: number, row: Vector4): Matrix;
  4343. /**
  4344. * Compute the transpose of the matrix
  4345. * @returns the new transposed matrix
  4346. */
  4347. transpose(): Matrix;
  4348. /**
  4349. * Compute the transpose of the matrix and store it in a given matrix
  4350. * @param result defines the target matrix
  4351. * @returns the current matrix
  4352. */
  4353. transposeToRef(result: Matrix): Matrix;
  4354. /**
  4355. * Sets the index-th row of the current matrix with the given 4 x float values
  4356. * @param index defines the row index
  4357. * @param x defines the x component to set
  4358. * @param y defines the y component to set
  4359. * @param z defines the z component to set
  4360. * @param w defines the w component to set
  4361. * @returns the updated current matrix
  4362. */
  4363. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4364. /**
  4365. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4366. * @param scale defines the scale factor
  4367. * @returns a new matrix
  4368. */
  4369. scale(scale: number): Matrix;
  4370. /**
  4371. * Scale the current matrix values by a factor to a given result matrix
  4372. * @param scale defines the scale factor
  4373. * @param result defines the matrix to store the result
  4374. * @returns the current matrix
  4375. */
  4376. scaleToRef(scale: number, result: Matrix): Matrix;
  4377. /**
  4378. * Scale the current matrix values by a factor and add the result to a given matrix
  4379. * @param scale defines the scale factor
  4380. * @param result defines the Matrix to store the result
  4381. * @returns the current matrix
  4382. */
  4383. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4384. /**
  4385. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4386. * @param ref matrix to store the result
  4387. */
  4388. toNormalMatrix(ref: Matrix): void;
  4389. /**
  4390. * Gets only rotation part of the current matrix
  4391. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4392. */
  4393. getRotationMatrix(): Matrix;
  4394. /**
  4395. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4396. * @param result defines the target matrix to store data to
  4397. * @returns the current matrix
  4398. */
  4399. getRotationMatrixToRef(result: Matrix): Matrix;
  4400. /**
  4401. * Toggles model matrix from being right handed to left handed in place and vice versa
  4402. */
  4403. toggleModelMatrixHandInPlace(): void;
  4404. /**
  4405. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4406. */
  4407. toggleProjectionMatrixHandInPlace(): void;
  4408. /**
  4409. * Creates a matrix from an array
  4410. * @param array defines the source array
  4411. * @param offset defines an offset in the source array
  4412. * @returns a new Matrix set from the starting index of the given array
  4413. */
  4414. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4415. /**
  4416. * Copy the content of an array into a given matrix
  4417. * @param array defines the source array
  4418. * @param offset defines an offset in the source array
  4419. * @param result defines the target matrix
  4420. */
  4421. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4422. /**
  4423. * Stores an array into a matrix after having multiplied each component by a given factor
  4424. * @param array defines the source array
  4425. * @param offset defines the offset in the source array
  4426. * @param scale defines the scaling factor
  4427. * @param result defines the target matrix
  4428. */
  4429. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4430. /**
  4431. * Gets an identity matrix that must not be updated
  4432. */
  4433. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4434. /**
  4435. * Stores a list of values (16) inside a given matrix
  4436. * @param initialM11 defines 1st value of 1st row
  4437. * @param initialM12 defines 2nd value of 1st row
  4438. * @param initialM13 defines 3rd value of 1st row
  4439. * @param initialM14 defines 4th value of 1st row
  4440. * @param initialM21 defines 1st value of 2nd row
  4441. * @param initialM22 defines 2nd value of 2nd row
  4442. * @param initialM23 defines 3rd value of 2nd row
  4443. * @param initialM24 defines 4th value of 2nd row
  4444. * @param initialM31 defines 1st value of 3rd row
  4445. * @param initialM32 defines 2nd value of 3rd row
  4446. * @param initialM33 defines 3rd value of 3rd row
  4447. * @param initialM34 defines 4th value of 3rd row
  4448. * @param initialM41 defines 1st value of 4th row
  4449. * @param initialM42 defines 2nd value of 4th row
  4450. * @param initialM43 defines 3rd value of 4th row
  4451. * @param initialM44 defines 4th value of 4th row
  4452. * @param result defines the target matrix
  4453. */
  4454. 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;
  4455. /**
  4456. * Creates new matrix from a list of values (16)
  4457. * @param initialM11 defines 1st value of 1st row
  4458. * @param initialM12 defines 2nd value of 1st row
  4459. * @param initialM13 defines 3rd value of 1st row
  4460. * @param initialM14 defines 4th value of 1st row
  4461. * @param initialM21 defines 1st value of 2nd row
  4462. * @param initialM22 defines 2nd value of 2nd row
  4463. * @param initialM23 defines 3rd value of 2nd row
  4464. * @param initialM24 defines 4th value of 2nd row
  4465. * @param initialM31 defines 1st value of 3rd row
  4466. * @param initialM32 defines 2nd value of 3rd row
  4467. * @param initialM33 defines 3rd value of 3rd row
  4468. * @param initialM34 defines 4th value of 3rd row
  4469. * @param initialM41 defines 1st value of 4th row
  4470. * @param initialM42 defines 2nd value of 4th row
  4471. * @param initialM43 defines 3rd value of 4th row
  4472. * @param initialM44 defines 4th value of 4th row
  4473. * @returns the new matrix
  4474. */
  4475. 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;
  4476. /**
  4477. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4478. * @param scale defines the scale vector3
  4479. * @param rotation defines the rotation quaternion
  4480. * @param translation defines the translation vector3
  4481. * @returns a new matrix
  4482. */
  4483. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4484. /**
  4485. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4486. * @param scale defines the scale vector3
  4487. * @param rotation defines the rotation quaternion
  4488. * @param translation defines the translation vector3
  4489. * @param result defines the target matrix
  4490. */
  4491. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4492. /**
  4493. * Creates a new identity matrix
  4494. * @returns a new identity matrix
  4495. */
  4496. static Identity(): Matrix;
  4497. /**
  4498. * Creates a new identity matrix and stores the result in a given matrix
  4499. * @param result defines the target matrix
  4500. */
  4501. static IdentityToRef(result: Matrix): void;
  4502. /**
  4503. * Creates a new zero matrix
  4504. * @returns a new zero matrix
  4505. */
  4506. static Zero(): Matrix;
  4507. /**
  4508. * Creates a new rotation matrix for "angle" radians around the X axis
  4509. * @param angle defines the angle (in radians) to use
  4510. * @return the new matrix
  4511. */
  4512. static RotationX(angle: number): Matrix;
  4513. /**
  4514. * Creates a new matrix as the invert of a given matrix
  4515. * @param source defines the source matrix
  4516. * @returns the new matrix
  4517. */
  4518. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4519. /**
  4520. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4521. * @param angle defines the angle (in radians) to use
  4522. * @param result defines the target matrix
  4523. */
  4524. static RotationXToRef(angle: number, result: Matrix): void;
  4525. /**
  4526. * Creates a new rotation matrix for "angle" radians around the Y axis
  4527. * @param angle defines the angle (in radians) to use
  4528. * @return the new matrix
  4529. */
  4530. static RotationY(angle: number): Matrix;
  4531. /**
  4532. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4533. * @param angle defines the angle (in radians) to use
  4534. * @param result defines the target matrix
  4535. */
  4536. static RotationYToRef(angle: number, result: Matrix): void;
  4537. /**
  4538. * Creates a new rotation matrix for "angle" radians around the Z axis
  4539. * @param angle defines the angle (in radians) to use
  4540. * @return the new matrix
  4541. */
  4542. static RotationZ(angle: number): Matrix;
  4543. /**
  4544. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4545. * @param angle defines the angle (in radians) to use
  4546. * @param result defines the target matrix
  4547. */
  4548. static RotationZToRef(angle: number, result: Matrix): void;
  4549. /**
  4550. * Creates a new rotation matrix for "angle" radians around the given axis
  4551. * @param axis defines the axis to use
  4552. * @param angle defines the angle (in radians) to use
  4553. * @return the new matrix
  4554. */
  4555. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4556. /**
  4557. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4558. * @param axis defines the axis to use
  4559. * @param angle defines the angle (in radians) to use
  4560. * @param result defines the target matrix
  4561. */
  4562. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4563. /**
  4564. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4565. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4566. * @param from defines the vector to align
  4567. * @param to defines the vector to align to
  4568. * @param result defines the target matrix
  4569. */
  4570. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4571. /**
  4572. * Creates a rotation matrix
  4573. * @param yaw defines the yaw angle in radians (Y axis)
  4574. * @param pitch defines the pitch angle in radians (X axis)
  4575. * @param roll defines the roll angle in radians (Z axis)
  4576. * @returns the new rotation matrix
  4577. */
  4578. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4579. /**
  4580. * Creates a rotation matrix and stores it in a given matrix
  4581. * @param yaw defines the yaw angle in radians (Y axis)
  4582. * @param pitch defines the pitch angle in radians (X axis)
  4583. * @param roll defines the roll angle in radians (Z axis)
  4584. * @param result defines the target matrix
  4585. */
  4586. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4587. /**
  4588. * Creates a scaling matrix
  4589. * @param x defines the scale factor on X axis
  4590. * @param y defines the scale factor on Y axis
  4591. * @param z defines the scale factor on Z axis
  4592. * @returns the new matrix
  4593. */
  4594. static Scaling(x: number, y: number, z: number): Matrix;
  4595. /**
  4596. * Creates a scaling matrix and stores it in a given matrix
  4597. * @param x defines the scale factor on X axis
  4598. * @param y defines the scale factor on Y axis
  4599. * @param z defines the scale factor on Z axis
  4600. * @param result defines the target matrix
  4601. */
  4602. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4603. /**
  4604. * Creates a translation matrix
  4605. * @param x defines the translation on X axis
  4606. * @param y defines the translation on Y axis
  4607. * @param z defines the translationon Z axis
  4608. * @returns the new matrix
  4609. */
  4610. static Translation(x: number, y: number, z: number): Matrix;
  4611. /**
  4612. * Creates a translation matrix and stores it in a given matrix
  4613. * @param x defines the translation on X axis
  4614. * @param y defines the translation on Y axis
  4615. * @param z defines the translationon Z axis
  4616. * @param result defines the target matrix
  4617. */
  4618. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4619. /**
  4620. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4621. * @param startValue defines the start value
  4622. * @param endValue defines the end value
  4623. * @param gradient defines the gradient factor
  4624. * @returns the new matrix
  4625. */
  4626. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4627. /**
  4628. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4629. * @param startValue defines the start value
  4630. * @param endValue defines the end value
  4631. * @param gradient defines the gradient factor
  4632. * @param result defines the Matrix object where to store data
  4633. */
  4634. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4635. /**
  4636. * Builds a new matrix whose values are computed by:
  4637. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4638. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4639. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4640. * @param startValue defines the first matrix
  4641. * @param endValue defines the second matrix
  4642. * @param gradient defines the gradient between the two matrices
  4643. * @returns the new matrix
  4644. */
  4645. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4646. /**
  4647. * Update a matrix to values which are computed by:
  4648. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4649. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4650. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4651. * @param startValue defines the first matrix
  4652. * @param endValue defines the second matrix
  4653. * @param gradient defines the gradient between the two matrices
  4654. * @param result defines the target matrix
  4655. */
  4656. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4657. /**
  4658. * 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"
  4659. * This function works in left handed mode
  4660. * @param eye defines the final position of the entity
  4661. * @param target defines where the entity should look at
  4662. * @param up defines the up vector for the entity
  4663. * @returns the new matrix
  4664. */
  4665. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4666. /**
  4667. * 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".
  4668. * This function works in left handed mode
  4669. * @param eye defines the final position of the entity
  4670. * @param target defines where the entity should look at
  4671. * @param up defines the up vector for the entity
  4672. * @param result defines the target matrix
  4673. */
  4674. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4675. /**
  4676. * 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"
  4677. * This function works in right handed mode
  4678. * @param eye defines the final position of the entity
  4679. * @param target defines where the entity should look at
  4680. * @param up defines the up vector for the entity
  4681. * @returns the new matrix
  4682. */
  4683. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4684. /**
  4685. * 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".
  4686. * This function works in right handed mode
  4687. * @param eye defines the final position of the entity
  4688. * @param target defines where the entity should look at
  4689. * @param up defines the up vector for the entity
  4690. * @param result defines the target matrix
  4691. */
  4692. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4693. /**
  4694. * Create a left-handed orthographic projection matrix
  4695. * @param width defines the viewport width
  4696. * @param height defines the viewport height
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a left-handed orthographic projection matrix
  4700. */
  4701. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Store a left-handed orthographic projection to a given matrix
  4704. * @param width defines the viewport width
  4705. * @param height defines the viewport height
  4706. * @param znear defines the near clip plane
  4707. * @param zfar defines the far clip plane
  4708. * @param result defines the target matrix
  4709. */
  4710. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4711. /**
  4712. * Create a left-handed orthographic projection matrix
  4713. * @param left defines the viewport left coordinate
  4714. * @param right defines the viewport right coordinate
  4715. * @param bottom defines the viewport bottom coordinate
  4716. * @param top defines the viewport top coordinate
  4717. * @param znear defines the near clip plane
  4718. * @param zfar defines the far clip plane
  4719. * @returns a new matrix as a left-handed orthographic projection matrix
  4720. */
  4721. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4722. /**
  4723. * Stores a left-handed orthographic projection into a given matrix
  4724. * @param left defines the viewport left coordinate
  4725. * @param right defines the viewport right coordinate
  4726. * @param bottom defines the viewport bottom coordinate
  4727. * @param top defines the viewport top coordinate
  4728. * @param znear defines the near clip plane
  4729. * @param zfar defines the far clip plane
  4730. * @param result defines the target matrix
  4731. */
  4732. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4733. /**
  4734. * Creates a right-handed orthographic projection matrix
  4735. * @param left defines the viewport left coordinate
  4736. * @param right defines the viewport right coordinate
  4737. * @param bottom defines the viewport bottom coordinate
  4738. * @param top defines the viewport top coordinate
  4739. * @param znear defines the near clip plane
  4740. * @param zfar defines the far clip plane
  4741. * @returns a new matrix as a right-handed orthographic projection matrix
  4742. */
  4743. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4744. /**
  4745. * Stores a right-handed orthographic projection into a given matrix
  4746. * @param left defines the viewport left coordinate
  4747. * @param right defines the viewport right coordinate
  4748. * @param bottom defines the viewport bottom coordinate
  4749. * @param top defines the viewport top coordinate
  4750. * @param znear defines the near clip plane
  4751. * @param zfar defines the far clip plane
  4752. * @param result defines the target matrix
  4753. */
  4754. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4755. /**
  4756. * Creates a left-handed perspective projection matrix
  4757. * @param width defines the viewport width
  4758. * @param height defines the viewport height
  4759. * @param znear defines the near clip plane
  4760. * @param zfar defines the far clip plane
  4761. * @returns a new matrix as a left-handed perspective projection matrix
  4762. */
  4763. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4764. /**
  4765. * Creates a left-handed perspective projection matrix
  4766. * @param fov defines the horizontal field of view
  4767. * @param aspect defines the aspect ratio
  4768. * @param znear defines the near clip plane
  4769. * @param zfar defines the far clip plane
  4770. * @returns a new matrix as a left-handed perspective projection matrix
  4771. */
  4772. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4773. /**
  4774. * Stores a left-handed perspective projection into a given matrix
  4775. * @param fov defines the horizontal field of view
  4776. * @param aspect defines the aspect ratio
  4777. * @param znear defines the near clip plane
  4778. * @param zfar defines the far clip plane
  4779. * @param result defines the target matrix
  4780. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4781. */
  4782. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4783. /**
  4784. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4785. * @param fov defines the horizontal field of view
  4786. * @param aspect defines the aspect ratio
  4787. * @param znear defines the near clip plane
  4788. * @param zfar not used as infinity is used as far clip
  4789. * @param result defines the target matrix
  4790. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4791. */
  4792. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4793. /**
  4794. * Creates a right-handed perspective projection matrix
  4795. * @param fov defines the horizontal field of view
  4796. * @param aspect defines the aspect ratio
  4797. * @param znear defines the near clip plane
  4798. * @param zfar defines the far clip plane
  4799. * @returns a new matrix as a right-handed perspective projection matrix
  4800. */
  4801. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4802. /**
  4803. * Stores a right-handed perspective projection into a given matrix
  4804. * @param fov defines the horizontal field of view
  4805. * @param aspect defines the aspect ratio
  4806. * @param znear defines the near clip plane
  4807. * @param zfar defines the far clip plane
  4808. * @param result defines the target matrix
  4809. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4810. */
  4811. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4812. /**
  4813. * Stores a right-handed perspective projection into a given matrix
  4814. * @param fov defines the horizontal field of view
  4815. * @param aspect defines the aspect ratio
  4816. * @param znear defines the near clip plane
  4817. * @param zfar not used as infinity is used as far clip
  4818. * @param result defines the target matrix
  4819. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4820. */
  4821. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4822. /**
  4823. * Stores a perspective projection for WebVR info a given matrix
  4824. * @param fov defines the field of view
  4825. * @param znear defines the near clip plane
  4826. * @param zfar defines the far clip plane
  4827. * @param result defines the target matrix
  4828. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4829. */
  4830. static PerspectiveFovWebVRToRef(fov: {
  4831. upDegrees: number;
  4832. downDegrees: number;
  4833. leftDegrees: number;
  4834. rightDegrees: number;
  4835. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4836. /**
  4837. * Computes a complete transformation matrix
  4838. * @param viewport defines the viewport to use
  4839. * @param world defines the world matrix
  4840. * @param view defines the view matrix
  4841. * @param projection defines the projection matrix
  4842. * @param zmin defines the near clip plane
  4843. * @param zmax defines the far clip plane
  4844. * @returns the transformation matrix
  4845. */
  4846. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4847. /**
  4848. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4849. * @param matrix defines the matrix to use
  4850. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4851. */
  4852. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4853. /**
  4854. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4855. * @param matrix defines the matrix to use
  4856. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4857. */
  4858. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4859. /**
  4860. * Compute the transpose of a given matrix
  4861. * @param matrix defines the matrix to transpose
  4862. * @returns the new matrix
  4863. */
  4864. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4865. /**
  4866. * Compute the transpose of a matrix and store it in a target matrix
  4867. * @param matrix defines the matrix to transpose
  4868. * @param result defines the target matrix
  4869. */
  4870. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4871. /**
  4872. * Computes a reflection matrix from a plane
  4873. * @param plane defines the reflection plane
  4874. * @returns a new matrix
  4875. */
  4876. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4877. /**
  4878. * Computes a reflection matrix from a plane
  4879. * @param plane defines the reflection plane
  4880. * @param result defines the target matrix
  4881. */
  4882. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4883. /**
  4884. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4885. * @param xaxis defines the value of the 1st axis
  4886. * @param yaxis defines the value of the 2nd axis
  4887. * @param zaxis defines the value of the 3rd axis
  4888. * @param result defines the target matrix
  4889. */
  4890. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4891. /**
  4892. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4893. * @param quat defines the quaternion to use
  4894. * @param result defines the target matrix
  4895. */
  4896. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4897. }
  4898. /**
  4899. * @hidden
  4900. */
  4901. export class TmpVectors {
  4902. static Vector2: Vector2[];
  4903. static Vector3: Vector3[];
  4904. static Vector4: Vector4[];
  4905. static Quaternion: Quaternion[];
  4906. static Matrix: Matrix[];
  4907. }
  4908. }
  4909. declare module "babylonjs/Maths/math.path" {
  4910. import { DeepImmutable, Nullable } from "babylonjs/types";
  4911. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4912. /**
  4913. * Defines potential orientation for back face culling
  4914. */
  4915. export enum Orientation {
  4916. /**
  4917. * Clockwise
  4918. */
  4919. CW = 0,
  4920. /** Counter clockwise */
  4921. CCW = 1
  4922. }
  4923. /** Class used to represent a Bezier curve */
  4924. export class BezierCurve {
  4925. /**
  4926. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4927. * @param t defines the time
  4928. * @param x1 defines the left coordinate on X axis
  4929. * @param y1 defines the left coordinate on Y axis
  4930. * @param x2 defines the right coordinate on X axis
  4931. * @param y2 defines the right coordinate on Y axis
  4932. * @returns the interpolated value
  4933. */
  4934. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4935. }
  4936. /**
  4937. * Defines angle representation
  4938. */
  4939. export class Angle {
  4940. private _radians;
  4941. /**
  4942. * Creates an Angle object of "radians" radians (float).
  4943. * @param radians the angle in radians
  4944. */
  4945. constructor(radians: number);
  4946. /**
  4947. * Get value in degrees
  4948. * @returns the Angle value in degrees (float)
  4949. */
  4950. degrees(): number;
  4951. /**
  4952. * Get value in radians
  4953. * @returns the Angle value in radians (float)
  4954. */
  4955. radians(): number;
  4956. /**
  4957. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4958. * @param a defines first point as the origin
  4959. * @param b defines point
  4960. * @returns a new Angle
  4961. */
  4962. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4963. /**
  4964. * Gets a new Angle object from the given float in radians
  4965. * @param radians defines the angle value in radians
  4966. * @returns a new Angle
  4967. */
  4968. static FromRadians(radians: number): Angle;
  4969. /**
  4970. * Gets a new Angle object from the given float in degrees
  4971. * @param degrees defines the angle value in degrees
  4972. * @returns a new Angle
  4973. */
  4974. static FromDegrees(degrees: number): Angle;
  4975. }
  4976. /**
  4977. * This represents an arc in a 2d space.
  4978. */
  4979. export class Arc2 {
  4980. /** Defines the start point of the arc */
  4981. startPoint: Vector2;
  4982. /** Defines the mid point of the arc */
  4983. midPoint: Vector2;
  4984. /** Defines the end point of the arc */
  4985. endPoint: Vector2;
  4986. /**
  4987. * Defines the center point of the arc.
  4988. */
  4989. centerPoint: Vector2;
  4990. /**
  4991. * Defines the radius of the arc.
  4992. */
  4993. radius: number;
  4994. /**
  4995. * Defines the angle of the arc (from mid point to end point).
  4996. */
  4997. angle: Angle;
  4998. /**
  4999. * Defines the start angle of the arc (from start point to middle point).
  5000. */
  5001. startAngle: Angle;
  5002. /**
  5003. * Defines the orientation of the arc (clock wise/counter clock wise).
  5004. */
  5005. orientation: Orientation;
  5006. /**
  5007. * Creates an Arc object from the three given points : start, middle and end.
  5008. * @param startPoint Defines the start point of the arc
  5009. * @param midPoint Defines the midlle point of the arc
  5010. * @param endPoint Defines the end point of the arc
  5011. */
  5012. constructor(
  5013. /** Defines the start point of the arc */
  5014. startPoint: Vector2,
  5015. /** Defines the mid point of the arc */
  5016. midPoint: Vector2,
  5017. /** Defines the end point of the arc */
  5018. endPoint: Vector2);
  5019. }
  5020. /**
  5021. * Represents a 2D path made up of multiple 2D points
  5022. */
  5023. export class Path2 {
  5024. private _points;
  5025. private _length;
  5026. /**
  5027. * If the path start and end point are the same
  5028. */
  5029. closed: boolean;
  5030. /**
  5031. * Creates a Path2 object from the starting 2D coordinates x and y.
  5032. * @param x the starting points x value
  5033. * @param y the starting points y value
  5034. */
  5035. constructor(x: number, y: number);
  5036. /**
  5037. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5038. * @param x the added points x value
  5039. * @param y the added points y value
  5040. * @returns the updated Path2.
  5041. */
  5042. addLineTo(x: number, y: number): Path2;
  5043. /**
  5044. * 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.
  5045. * @param midX middle point x value
  5046. * @param midY middle point y value
  5047. * @param endX end point x value
  5048. * @param endY end point y value
  5049. * @param numberOfSegments (default: 36)
  5050. * @returns the updated Path2.
  5051. */
  5052. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5053. /**
  5054. * Closes the Path2.
  5055. * @returns the Path2.
  5056. */
  5057. close(): Path2;
  5058. /**
  5059. * Gets the sum of the distance between each sequential point in the path
  5060. * @returns the Path2 total length (float).
  5061. */
  5062. length(): number;
  5063. /**
  5064. * Gets the points which construct the path
  5065. * @returns the Path2 internal array of points.
  5066. */
  5067. getPoints(): Vector2[];
  5068. /**
  5069. * Retreives the point at the distance aways from the starting point
  5070. * @param normalizedLengthPosition the length along the path to retreive the point from
  5071. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5072. */
  5073. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5074. /**
  5075. * Creates a new path starting from an x and y position
  5076. * @param x starting x value
  5077. * @param y starting y value
  5078. * @returns a new Path2 starting at the coordinates (x, y).
  5079. */
  5080. static StartingAt(x: number, y: number): Path2;
  5081. }
  5082. /**
  5083. * Represents a 3D path made up of multiple 3D points
  5084. */
  5085. export class Path3D {
  5086. /**
  5087. * an array of Vector3, the curve axis of the Path3D
  5088. */
  5089. path: Vector3[];
  5090. private _curve;
  5091. private _distances;
  5092. private _tangents;
  5093. private _normals;
  5094. private _binormals;
  5095. private _raw;
  5096. private _alignTangentsWithPath;
  5097. private readonly _pointAtData;
  5098. /**
  5099. * new Path3D(path, normal, raw)
  5100. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5101. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5102. * @param path an array of Vector3, the curve axis of the Path3D
  5103. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5104. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5105. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5106. */
  5107. constructor(
  5108. /**
  5109. * an array of Vector3, the curve axis of the Path3D
  5110. */
  5111. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5112. /**
  5113. * Returns the Path3D array of successive Vector3 designing its curve.
  5114. * @returns the Path3D array of successive Vector3 designing its curve.
  5115. */
  5116. getCurve(): Vector3[];
  5117. /**
  5118. * Returns the Path3D array of successive Vector3 designing its curve.
  5119. * @returns the Path3D array of successive Vector3 designing its curve.
  5120. */
  5121. getPoints(): Vector3[];
  5122. /**
  5123. * @returns the computed length (float) of the path.
  5124. */
  5125. length(): number;
  5126. /**
  5127. * Returns an array populated with tangent vectors on each Path3D curve point.
  5128. * @returns an array populated with tangent vectors on each Path3D curve point.
  5129. */
  5130. getTangents(): Vector3[];
  5131. /**
  5132. * Returns an array populated with normal vectors on each Path3D curve point.
  5133. * @returns an array populated with normal vectors on each Path3D curve point.
  5134. */
  5135. getNormals(): Vector3[];
  5136. /**
  5137. * Returns an array populated with binormal vectors on each Path3D curve point.
  5138. * @returns an array populated with binormal vectors on each Path3D curve point.
  5139. */
  5140. getBinormals(): Vector3[];
  5141. /**
  5142. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5143. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5144. */
  5145. getDistances(): number[];
  5146. /**
  5147. * Returns an interpolated point along this path
  5148. * @param position the position of the point along this path, from 0.0 to 1.0
  5149. * @returns a new Vector3 as the point
  5150. */
  5151. getPointAt(position: number): Vector3;
  5152. /**
  5153. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5154. * @param position the position of the point along this path, from 0.0 to 1.0
  5155. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5156. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5157. */
  5158. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5159. /**
  5160. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5161. * @param position the position of the point along this path, from 0.0 to 1.0
  5162. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5163. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5164. */
  5165. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5166. /**
  5167. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5168. * @param position the position of the point along this path, from 0.0 to 1.0
  5169. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5170. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5171. */
  5172. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5173. /**
  5174. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5175. * @param position the position of the point along this path, from 0.0 to 1.0
  5176. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5177. */
  5178. getDistanceAt(position: number): number;
  5179. /**
  5180. * Returns the array index of the previous point of an interpolated point along this path
  5181. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5182. * @returns the array index
  5183. */
  5184. getPreviousPointIndexAt(position: number): number;
  5185. /**
  5186. * 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)
  5187. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5188. * @returns the sub position
  5189. */
  5190. getSubPositionAt(position: number): number;
  5191. /**
  5192. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5193. * @param target the vector of which to get the closest position to
  5194. * @returns the position of the closest virtual point on this path to the target vector
  5195. */
  5196. getClosestPositionTo(target: Vector3): number;
  5197. /**
  5198. * Returns a sub path (slice) of this path
  5199. * @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
  5200. * @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
  5201. * @returns a sub path (slice) of this path
  5202. */
  5203. slice(start?: number, end?: number): Path3D;
  5204. /**
  5205. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5206. * @param path path which all values are copied into the curves points
  5207. * @param firstNormal which should be projected onto the curve
  5208. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5209. * @returns the same object updated.
  5210. */
  5211. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5212. private _compute;
  5213. private _getFirstNonNullVector;
  5214. private _getLastNonNullVector;
  5215. private _normalVector;
  5216. /**
  5217. * Updates the point at data for an interpolated point along this curve
  5218. * @param position the position of the point along this curve, from 0.0 to 1.0
  5219. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5220. * @returns the (updated) point at data
  5221. */
  5222. private _updatePointAtData;
  5223. /**
  5224. * Updates the point at data from the specified parameters
  5225. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5226. * @param point the interpolated point
  5227. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5228. */
  5229. private _setPointAtData;
  5230. /**
  5231. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5232. */
  5233. private _updateInterpolationMatrix;
  5234. }
  5235. /**
  5236. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5237. * A Curve3 is designed from a series of successive Vector3.
  5238. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5239. */
  5240. export class Curve3 {
  5241. private _points;
  5242. private _length;
  5243. /**
  5244. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5245. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5246. * @param v1 (Vector3) the control point
  5247. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5248. * @param nbPoints (integer) the wanted number of points in the curve
  5249. * @returns the created Curve3
  5250. */
  5251. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5252. /**
  5253. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5254. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5255. * @param v1 (Vector3) the first control point
  5256. * @param v2 (Vector3) the second control point
  5257. * @param v3 (Vector3) the end point of the Cubic Bezier
  5258. * @param nbPoints (integer) the wanted number of points in the curve
  5259. * @returns the created Curve3
  5260. */
  5261. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5262. /**
  5263. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5264. * @param p1 (Vector3) the origin point of the Hermite Spline
  5265. * @param t1 (Vector3) the tangent vector at the origin point
  5266. * @param p2 (Vector3) the end point of the Hermite Spline
  5267. * @param t2 (Vector3) the tangent vector at the end point
  5268. * @param nbPoints (integer) the wanted number of points in the curve
  5269. * @returns the created Curve3
  5270. */
  5271. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5272. /**
  5273. * Returns a Curve3 object along a CatmullRom Spline curve :
  5274. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5275. * @param nbPoints (integer) the wanted number of points between each curve control points
  5276. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5277. * @returns the created Curve3
  5278. */
  5279. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5280. /**
  5281. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5282. * A Curve3 is designed from a series of successive Vector3.
  5283. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5284. * @param points points which make up the curve
  5285. */
  5286. constructor(points: Vector3[]);
  5287. /**
  5288. * @returns the Curve3 stored array of successive Vector3
  5289. */
  5290. getPoints(): Vector3[];
  5291. /**
  5292. * @returns the computed length (float) of the curve.
  5293. */
  5294. length(): number;
  5295. /**
  5296. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5297. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5298. * curveA and curveB keep unchanged.
  5299. * @param curve the curve to continue from this curve
  5300. * @returns the newly constructed curve
  5301. */
  5302. continue(curve: DeepImmutable<Curve3>): Curve3;
  5303. private _computeLength;
  5304. }
  5305. }
  5306. declare module "babylonjs/Animations/easing" {
  5307. /**
  5308. * This represents the main contract an easing function should follow.
  5309. * Easing functions are used throughout the animation system.
  5310. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5311. */
  5312. export interface IEasingFunction {
  5313. /**
  5314. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5315. * of the easing function.
  5316. * The link below provides some of the most common examples of easing functions.
  5317. * @see https://easings.net/
  5318. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5319. * @returns the corresponding value on the curve defined by the easing function
  5320. */
  5321. ease(gradient: number): number;
  5322. }
  5323. /**
  5324. * Base class used for every default easing function.
  5325. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5326. */
  5327. export class EasingFunction implements IEasingFunction {
  5328. /**
  5329. * Interpolation follows the mathematical formula associated with the easing function.
  5330. */
  5331. static readonly EASINGMODE_EASEIN: number;
  5332. /**
  5333. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5334. */
  5335. static readonly EASINGMODE_EASEOUT: number;
  5336. /**
  5337. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5338. */
  5339. static readonly EASINGMODE_EASEINOUT: number;
  5340. private _easingMode;
  5341. /**
  5342. * Sets the easing mode of the current function.
  5343. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5344. */
  5345. setEasingMode(easingMode: number): void;
  5346. /**
  5347. * Gets the current easing mode.
  5348. * @returns the easing mode
  5349. */
  5350. getEasingMode(): number;
  5351. /**
  5352. * @hidden
  5353. */
  5354. easeInCore(gradient: number): number;
  5355. /**
  5356. * Given an input gradient between 0 and 1, this returns the corresponding value
  5357. * of the easing function.
  5358. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5359. * @returns the corresponding value on the curve defined by the easing function
  5360. */
  5361. ease(gradient: number): number;
  5362. }
  5363. /**
  5364. * Easing function with a circle shape (see link below).
  5365. * @see https://easings.net/#easeInCirc
  5366. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5367. */
  5368. export class CircleEase extends EasingFunction implements IEasingFunction {
  5369. /** @hidden */
  5370. easeInCore(gradient: number): number;
  5371. }
  5372. /**
  5373. * Easing function with a ease back shape (see link below).
  5374. * @see https://easings.net/#easeInBack
  5375. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5376. */
  5377. export class BackEase extends EasingFunction implements IEasingFunction {
  5378. /** Defines the amplitude of the function */
  5379. amplitude: number;
  5380. /**
  5381. * Instantiates a back ease easing
  5382. * @see https://easings.net/#easeInBack
  5383. * @param amplitude Defines the amplitude of the function
  5384. */
  5385. constructor(
  5386. /** Defines the amplitude of the function */
  5387. amplitude?: number);
  5388. /** @hidden */
  5389. easeInCore(gradient: number): number;
  5390. }
  5391. /**
  5392. * Easing function with a bouncing shape (see link below).
  5393. * @see https://easings.net/#easeInBounce
  5394. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5395. */
  5396. export class BounceEase extends EasingFunction implements IEasingFunction {
  5397. /** Defines the number of bounces */
  5398. bounces: number;
  5399. /** Defines the amplitude of the bounce */
  5400. bounciness: number;
  5401. /**
  5402. * Instantiates a bounce easing
  5403. * @see https://easings.net/#easeInBounce
  5404. * @param bounces Defines the number of bounces
  5405. * @param bounciness Defines the amplitude of the bounce
  5406. */
  5407. constructor(
  5408. /** Defines the number of bounces */
  5409. bounces?: number,
  5410. /** Defines the amplitude of the bounce */
  5411. bounciness?: number);
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power of 3 shape (see link below).
  5417. * @see https://easings.net/#easeInCubic
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class CubicEase extends EasingFunction implements IEasingFunction {
  5421. /** @hidden */
  5422. easeInCore(gradient: number): number;
  5423. }
  5424. /**
  5425. * Easing function with an elastic shape (see link below).
  5426. * @see https://easings.net/#easeInElastic
  5427. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5428. */
  5429. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5430. /** Defines the number of oscillations*/
  5431. oscillations: number;
  5432. /** Defines the amplitude of the oscillations*/
  5433. springiness: number;
  5434. /**
  5435. * Instantiates an elastic easing function
  5436. * @see https://easings.net/#easeInElastic
  5437. * @param oscillations Defines the number of oscillations
  5438. * @param springiness Defines the amplitude of the oscillations
  5439. */
  5440. constructor(
  5441. /** Defines the number of oscillations*/
  5442. oscillations?: number,
  5443. /** Defines the amplitude of the oscillations*/
  5444. springiness?: number);
  5445. /** @hidden */
  5446. easeInCore(gradient: number): number;
  5447. }
  5448. /**
  5449. * Easing function with an exponential shape (see link below).
  5450. * @see https://easings.net/#easeInExpo
  5451. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5452. */
  5453. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5454. /** Defines the exponent of the function */
  5455. exponent: number;
  5456. /**
  5457. * Instantiates an exponential easing function
  5458. * @see https://easings.net/#easeInExpo
  5459. * @param exponent Defines the exponent of the function
  5460. */
  5461. constructor(
  5462. /** Defines the exponent of the function */
  5463. exponent?: number);
  5464. /** @hidden */
  5465. easeInCore(gradient: number): number;
  5466. }
  5467. /**
  5468. * Easing function with a power shape (see link below).
  5469. * @see https://easings.net/#easeInQuad
  5470. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5471. */
  5472. export class PowerEase extends EasingFunction implements IEasingFunction {
  5473. /** Defines the power of the function */
  5474. power: number;
  5475. /**
  5476. * Instantiates an power base easing function
  5477. * @see https://easings.net/#easeInQuad
  5478. * @param power Defines the power of the function
  5479. */
  5480. constructor(
  5481. /** Defines the power of the function */
  5482. power?: number);
  5483. /** @hidden */
  5484. easeInCore(gradient: number): number;
  5485. }
  5486. /**
  5487. * Easing function with a power of 2 shape (see link below).
  5488. * @see https://easings.net/#easeInQuad
  5489. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5490. */
  5491. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5492. /** @hidden */
  5493. easeInCore(gradient: number): number;
  5494. }
  5495. /**
  5496. * Easing function with a power of 4 shape (see link below).
  5497. * @see https://easings.net/#easeInQuart
  5498. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5499. */
  5500. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5501. /** @hidden */
  5502. easeInCore(gradient: number): number;
  5503. }
  5504. /**
  5505. * Easing function with a power of 5 shape (see link below).
  5506. * @see https://easings.net/#easeInQuint
  5507. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5508. */
  5509. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5510. /** @hidden */
  5511. easeInCore(gradient: number): number;
  5512. }
  5513. /**
  5514. * Easing function with a sin shape (see link below).
  5515. * @see https://easings.net/#easeInSine
  5516. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5517. */
  5518. export class SineEase extends EasingFunction implements IEasingFunction {
  5519. /** @hidden */
  5520. easeInCore(gradient: number): number;
  5521. }
  5522. /**
  5523. * Easing function with a bezier shape (see link below).
  5524. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5525. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5526. */
  5527. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5528. /** Defines the x component of the start tangent in the bezier curve */
  5529. x1: number;
  5530. /** Defines the y component of the start tangent in the bezier curve */
  5531. y1: number;
  5532. /** Defines the x component of the end tangent in the bezier curve */
  5533. x2: number;
  5534. /** Defines the y component of the end tangent in the bezier curve */
  5535. y2: number;
  5536. /**
  5537. * Instantiates a bezier function
  5538. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5539. * @param x1 Defines the x component of the start tangent in the bezier curve
  5540. * @param y1 Defines the y component of the start tangent in the bezier curve
  5541. * @param x2 Defines the x component of the end tangent in the bezier curve
  5542. * @param y2 Defines the y component of the end tangent in the bezier curve
  5543. */
  5544. constructor(
  5545. /** Defines the x component of the start tangent in the bezier curve */
  5546. x1?: number,
  5547. /** Defines the y component of the start tangent in the bezier curve */
  5548. y1?: number,
  5549. /** Defines the x component of the end tangent in the bezier curve */
  5550. x2?: number,
  5551. /** Defines the y component of the end tangent in the bezier curve */
  5552. y2?: number);
  5553. /** @hidden */
  5554. easeInCore(gradient: number): number;
  5555. }
  5556. }
  5557. declare module "babylonjs/Maths/math.color" {
  5558. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5559. /**
  5560. * Class used to hold a RBG color
  5561. */
  5562. export class Color3 {
  5563. /**
  5564. * Defines the red component (between 0 and 1, default is 0)
  5565. */
  5566. r: number;
  5567. /**
  5568. * Defines the green component (between 0 and 1, default is 0)
  5569. */
  5570. g: number;
  5571. /**
  5572. * Defines the blue component (between 0 and 1, default is 0)
  5573. */
  5574. b: number;
  5575. /**
  5576. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5577. * @param r defines the red component (between 0 and 1, default is 0)
  5578. * @param g defines the green component (between 0 and 1, default is 0)
  5579. * @param b defines the blue component (between 0 and 1, default is 0)
  5580. */
  5581. constructor(
  5582. /**
  5583. * Defines the red component (between 0 and 1, default is 0)
  5584. */
  5585. r?: number,
  5586. /**
  5587. * Defines the green component (between 0 and 1, default is 0)
  5588. */
  5589. g?: number,
  5590. /**
  5591. * Defines the blue component (between 0 and 1, default is 0)
  5592. */
  5593. b?: number);
  5594. /**
  5595. * Creates a string with the Color3 current values
  5596. * @returns the string representation of the Color3 object
  5597. */
  5598. toString(): string;
  5599. /**
  5600. * Returns the string "Color3"
  5601. * @returns "Color3"
  5602. */
  5603. getClassName(): string;
  5604. /**
  5605. * Compute the Color3 hash code
  5606. * @returns an unique number that can be used to hash Color3 objects
  5607. */
  5608. getHashCode(): number;
  5609. /**
  5610. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5611. * @param array defines the array where to store the r,g,b components
  5612. * @param index defines an optional index in the target array to define where to start storing values
  5613. * @returns the current Color3 object
  5614. */
  5615. toArray(array: FloatArray, index?: number): Color3;
  5616. /**
  5617. * Update the current color with values stored in an array from the starting index of the given array
  5618. * @param array defines the source array
  5619. * @param offset defines an offset in the source array
  5620. * @returns the current Color3 object
  5621. */
  5622. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5623. /**
  5624. * Returns a new Color4 object from the current Color3 and the given alpha
  5625. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5626. * @returns a new Color4 object
  5627. */
  5628. toColor4(alpha?: number): Color4;
  5629. /**
  5630. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5631. * @returns the new array
  5632. */
  5633. asArray(): number[];
  5634. /**
  5635. * Returns the luminance value
  5636. * @returns a float value
  5637. */
  5638. toLuminance(): number;
  5639. /**
  5640. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5641. * @param otherColor defines the second operand
  5642. * @returns the new Color3 object
  5643. */
  5644. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5645. /**
  5646. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5647. * @param otherColor defines the second operand
  5648. * @param result defines the Color3 object where to store the result
  5649. * @returns the current Color3
  5650. */
  5651. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5652. /**
  5653. * Determines equality between Color3 objects
  5654. * @param otherColor defines the second operand
  5655. * @returns true if the rgb values are equal to the given ones
  5656. */
  5657. equals(otherColor: DeepImmutable<Color3>): boolean;
  5658. /**
  5659. * Determines equality between the current Color3 object and a set of r,b,g values
  5660. * @param r defines the red component to check
  5661. * @param g defines the green component to check
  5662. * @param b defines the blue component to check
  5663. * @returns true if the rgb values are equal to the given ones
  5664. */
  5665. equalsFloats(r: number, g: number, b: number): boolean;
  5666. /**
  5667. * Multiplies in place each rgb value by scale
  5668. * @param scale defines the scaling factor
  5669. * @returns the updated Color3
  5670. */
  5671. scale(scale: number): Color3;
  5672. /**
  5673. * Multiplies the rgb values by scale and stores the result into "result"
  5674. * @param scale defines the scaling factor
  5675. * @param result defines the Color3 object where to store the result
  5676. * @returns the unmodified current Color3
  5677. */
  5678. scaleToRef(scale: number, result: Color3): Color3;
  5679. /**
  5680. * Scale the current Color3 values by a factor and add the result to a given Color3
  5681. * @param scale defines the scale factor
  5682. * @param result defines color to store the result into
  5683. * @returns the unmodified current Color3
  5684. */
  5685. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5686. /**
  5687. * Clamps the rgb values by the min and max values and stores the result into "result"
  5688. * @param min defines minimum clamping value (default is 0)
  5689. * @param max defines maximum clamping value (default is 1)
  5690. * @param result defines color to store the result into
  5691. * @returns the original Color3
  5692. */
  5693. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5694. /**
  5695. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5696. * @param otherColor defines the second operand
  5697. * @returns the new Color3
  5698. */
  5699. add(otherColor: DeepImmutable<Color3>): Color3;
  5700. /**
  5701. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5702. * @param otherColor defines the second operand
  5703. * @param result defines Color3 object to store the result into
  5704. * @returns the unmodified current Color3
  5705. */
  5706. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5707. /**
  5708. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5709. * @param otherColor defines the second operand
  5710. * @returns the new Color3
  5711. */
  5712. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5713. /**
  5714. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5715. * @param otherColor defines the second operand
  5716. * @param result defines Color3 object to store the result into
  5717. * @returns the unmodified current Color3
  5718. */
  5719. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5720. /**
  5721. * Copy the current object
  5722. * @returns a new Color3 copied the current one
  5723. */
  5724. clone(): Color3;
  5725. /**
  5726. * Copies the rgb values from the source in the current Color3
  5727. * @param source defines the source Color3 object
  5728. * @returns the updated Color3 object
  5729. */
  5730. copyFrom(source: DeepImmutable<Color3>): Color3;
  5731. /**
  5732. * Updates the Color3 rgb values from the given floats
  5733. * @param r defines the red component to read from
  5734. * @param g defines the green component to read from
  5735. * @param b defines the blue component to read from
  5736. * @returns the current Color3 object
  5737. */
  5738. copyFromFloats(r: number, g: number, b: number): Color3;
  5739. /**
  5740. * Updates the Color3 rgb values from the given floats
  5741. * @param r defines the red component to read from
  5742. * @param g defines the green component to read from
  5743. * @param b defines the blue component to read from
  5744. * @returns the current Color3 object
  5745. */
  5746. set(r: number, g: number, b: number): Color3;
  5747. /**
  5748. * Compute the Color3 hexadecimal code as a string
  5749. * @returns a string containing the hexadecimal representation of the Color3 object
  5750. */
  5751. toHexString(): string;
  5752. /**
  5753. * Computes a new Color3 converted from the current one to linear space
  5754. * @returns a new Color3 object
  5755. */
  5756. toLinearSpace(): Color3;
  5757. /**
  5758. * Converts current color in rgb space to HSV values
  5759. * @returns a new color3 representing the HSV values
  5760. */
  5761. toHSV(): Color3;
  5762. /**
  5763. * Converts current color in rgb space to HSV values
  5764. * @param result defines the Color3 where to store the HSV values
  5765. */
  5766. toHSVToRef(result: Color3): void;
  5767. /**
  5768. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5769. * @param convertedColor defines the Color3 object where to store the linear space version
  5770. * @returns the unmodified Color3
  5771. */
  5772. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5773. /**
  5774. * Computes a new Color3 converted from the current one to gamma space
  5775. * @returns a new Color3 object
  5776. */
  5777. toGammaSpace(): Color3;
  5778. /**
  5779. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5780. * @param convertedColor defines the Color3 object where to store the gamma space version
  5781. * @returns the unmodified Color3
  5782. */
  5783. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5784. private static _BlackReadOnly;
  5785. /**
  5786. * Convert Hue, saturation and value to a Color3 (RGB)
  5787. * @param hue defines the hue
  5788. * @param saturation defines the saturation
  5789. * @param value defines the value
  5790. * @param result defines the Color3 where to store the RGB values
  5791. */
  5792. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5793. /**
  5794. * Creates a new Color3 from the string containing valid hexadecimal values
  5795. * @param hex defines a string containing valid hexadecimal values
  5796. * @returns a new Color3 object
  5797. */
  5798. static FromHexString(hex: string): Color3;
  5799. /**
  5800. * Creates a new Color3 from the starting index of the given array
  5801. * @param array defines the source array
  5802. * @param offset defines an offset in the source array
  5803. * @returns a new Color3 object
  5804. */
  5805. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5806. /**
  5807. * Creates a new Color3 from the starting index element of the given array
  5808. * @param array defines the source array to read from
  5809. * @param offset defines the offset in the source array
  5810. * @param result defines the target Color3 object
  5811. */
  5812. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5813. /**
  5814. * Creates a new Color3 from integer values (< 256)
  5815. * @param r defines the red component to read from (value between 0 and 255)
  5816. * @param g defines the green component to read from (value between 0 and 255)
  5817. * @param b defines the blue component to read from (value between 0 and 255)
  5818. * @returns a new Color3 object
  5819. */
  5820. static FromInts(r: number, g: number, b: number): Color3;
  5821. /**
  5822. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5823. * @param start defines the start Color3 value
  5824. * @param end defines the end Color3 value
  5825. * @param amount defines the gradient value between start and end
  5826. * @returns a new Color3 object
  5827. */
  5828. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5829. /**
  5830. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5831. * @param left defines the start value
  5832. * @param right defines the end value
  5833. * @param amount defines the gradient factor
  5834. * @param result defines the Color3 object where to store the result
  5835. */
  5836. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5837. /**
  5838. * Returns a Color3 value containing a red color
  5839. * @returns a new Color3 object
  5840. */
  5841. static Red(): Color3;
  5842. /**
  5843. * Returns a Color3 value containing a green color
  5844. * @returns a new Color3 object
  5845. */
  5846. static Green(): Color3;
  5847. /**
  5848. * Returns a Color3 value containing a blue color
  5849. * @returns a new Color3 object
  5850. */
  5851. static Blue(): Color3;
  5852. /**
  5853. * Returns a Color3 value containing a black color
  5854. * @returns a new Color3 object
  5855. */
  5856. static Black(): Color3;
  5857. /**
  5858. * Gets a Color3 value containing a black color that must not be updated
  5859. */
  5860. static get BlackReadOnly(): DeepImmutable<Color3>;
  5861. /**
  5862. * Returns a Color3 value containing a white color
  5863. * @returns a new Color3 object
  5864. */
  5865. static White(): Color3;
  5866. /**
  5867. * Returns a Color3 value containing a purple color
  5868. * @returns a new Color3 object
  5869. */
  5870. static Purple(): Color3;
  5871. /**
  5872. * Returns a Color3 value containing a magenta color
  5873. * @returns a new Color3 object
  5874. */
  5875. static Magenta(): Color3;
  5876. /**
  5877. * Returns a Color3 value containing a yellow color
  5878. * @returns a new Color3 object
  5879. */
  5880. static Yellow(): Color3;
  5881. /**
  5882. * Returns a Color3 value containing a gray color
  5883. * @returns a new Color3 object
  5884. */
  5885. static Gray(): Color3;
  5886. /**
  5887. * Returns a Color3 value containing a teal color
  5888. * @returns a new Color3 object
  5889. */
  5890. static Teal(): Color3;
  5891. /**
  5892. * Returns a Color3 value containing a random color
  5893. * @returns a new Color3 object
  5894. */
  5895. static Random(): Color3;
  5896. }
  5897. /**
  5898. * Class used to hold a RBGA color
  5899. */
  5900. export class Color4 {
  5901. /**
  5902. * Defines the red component (between 0 and 1, default is 0)
  5903. */
  5904. r: number;
  5905. /**
  5906. * Defines the green component (between 0 and 1, default is 0)
  5907. */
  5908. g: number;
  5909. /**
  5910. * Defines the blue component (between 0 and 1, default is 0)
  5911. */
  5912. b: number;
  5913. /**
  5914. * Defines the alpha component (between 0 and 1, default is 1)
  5915. */
  5916. a: number;
  5917. /**
  5918. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5919. * @param r defines the red component (between 0 and 1, default is 0)
  5920. * @param g defines the green component (between 0 and 1, default is 0)
  5921. * @param b defines the blue component (between 0 and 1, default is 0)
  5922. * @param a defines the alpha component (between 0 and 1, default is 1)
  5923. */
  5924. constructor(
  5925. /**
  5926. * Defines the red component (between 0 and 1, default is 0)
  5927. */
  5928. r?: number,
  5929. /**
  5930. * Defines the green component (between 0 and 1, default is 0)
  5931. */
  5932. g?: number,
  5933. /**
  5934. * Defines the blue component (between 0 and 1, default is 0)
  5935. */
  5936. b?: number,
  5937. /**
  5938. * Defines the alpha component (between 0 and 1, default is 1)
  5939. */
  5940. a?: number);
  5941. /**
  5942. * Adds in place the given Color4 values to the current Color4 object
  5943. * @param right defines the second operand
  5944. * @returns the current updated Color4 object
  5945. */
  5946. addInPlace(right: DeepImmutable<Color4>): Color4;
  5947. /**
  5948. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5949. * @returns the new array
  5950. */
  5951. asArray(): number[];
  5952. /**
  5953. * Stores from the starting index in the given array the Color4 successive values
  5954. * @param array defines the array where to store the r,g,b components
  5955. * @param index defines an optional index in the target array to define where to start storing values
  5956. * @returns the current Color4 object
  5957. */
  5958. toArray(array: number[], index?: number): Color4;
  5959. /**
  5960. * Update the current color with values stored in an array from the starting index of the given array
  5961. * @param array defines the source array
  5962. * @param offset defines an offset in the source array
  5963. * @returns the current Color4 object
  5964. */
  5965. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5966. /**
  5967. * Determines equality between Color4 objects
  5968. * @param otherColor defines the second operand
  5969. * @returns true if the rgba values are equal to the given ones
  5970. */
  5971. equals(otherColor: DeepImmutable<Color4>): boolean;
  5972. /**
  5973. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5974. * @param right defines the second operand
  5975. * @returns a new Color4 object
  5976. */
  5977. add(right: DeepImmutable<Color4>): Color4;
  5978. /**
  5979. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5980. * @param right defines the second operand
  5981. * @returns a new Color4 object
  5982. */
  5983. subtract(right: DeepImmutable<Color4>): Color4;
  5984. /**
  5985. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5986. * @param right defines the second operand
  5987. * @param result defines the Color4 object where to store the result
  5988. * @returns the current Color4 object
  5989. */
  5990. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5991. /**
  5992. * Creates a new Color4 with the current Color4 values multiplied by scale
  5993. * @param scale defines the scaling factor to apply
  5994. * @returns a new Color4 object
  5995. */
  5996. scale(scale: number): Color4;
  5997. /**
  5998. * Multiplies the current Color4 values by scale and stores the result in "result"
  5999. * @param scale defines the scaling factor to apply
  6000. * @param result defines the Color4 object where to store the result
  6001. * @returns the current unmodified Color4
  6002. */
  6003. scaleToRef(scale: number, result: Color4): Color4;
  6004. /**
  6005. * Scale the current Color4 values by a factor and add the result to a given Color4
  6006. * @param scale defines the scale factor
  6007. * @param result defines the Color4 object where to store the result
  6008. * @returns the unmodified current Color4
  6009. */
  6010. scaleAndAddToRef(scale: number, result: Color4): Color4;
  6011. /**
  6012. * Clamps the rgb values by the min and max values and stores the result into "result"
  6013. * @param min defines minimum clamping value (default is 0)
  6014. * @param max defines maximum clamping value (default is 1)
  6015. * @param result defines color to store the result into.
  6016. * @returns the cuurent Color4
  6017. */
  6018. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  6019. /**
  6020. * Multipy an Color4 value by another and return a new Color4 object
  6021. * @param color defines the Color4 value to multiply by
  6022. * @returns a new Color4 object
  6023. */
  6024. multiply(color: Color4): Color4;
  6025. /**
  6026. * Multipy a Color4 value by another and push the result in a reference value
  6027. * @param color defines the Color4 value to multiply by
  6028. * @param result defines the Color4 to fill the result in
  6029. * @returns the result Color4
  6030. */
  6031. multiplyToRef(color: Color4, result: Color4): Color4;
  6032. /**
  6033. * Creates a string with the Color4 current values
  6034. * @returns the string representation of the Color4 object
  6035. */
  6036. toString(): string;
  6037. /**
  6038. * Returns the string "Color4"
  6039. * @returns "Color4"
  6040. */
  6041. getClassName(): string;
  6042. /**
  6043. * Compute the Color4 hash code
  6044. * @returns an unique number that can be used to hash Color4 objects
  6045. */
  6046. getHashCode(): number;
  6047. /**
  6048. * Creates a new Color4 copied from the current one
  6049. * @returns a new Color4 object
  6050. */
  6051. clone(): Color4;
  6052. /**
  6053. * Copies the given Color4 values into the current one
  6054. * @param source defines the source Color4 object
  6055. * @returns the current updated Color4 object
  6056. */
  6057. copyFrom(source: Color4): Color4;
  6058. /**
  6059. * Copies the given float values into the current one
  6060. * @param r defines the red component to read from
  6061. * @param g defines the green component to read from
  6062. * @param b defines the blue component to read from
  6063. * @param a defines the alpha component to read from
  6064. * @returns the current updated Color4 object
  6065. */
  6066. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6067. /**
  6068. * Copies the given float values into the current one
  6069. * @param r defines the red component to read from
  6070. * @param g defines the green component to read from
  6071. * @param b defines the blue component to read from
  6072. * @param a defines the alpha component to read from
  6073. * @returns the current updated Color4 object
  6074. */
  6075. set(r: number, g: number, b: number, a: number): Color4;
  6076. /**
  6077. * Compute the Color4 hexadecimal code as a string
  6078. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6079. * @returns a string containing the hexadecimal representation of the Color4 object
  6080. */
  6081. toHexString(returnAsColor3?: boolean): string;
  6082. /**
  6083. * Computes a new Color4 converted from the current one to linear space
  6084. * @returns a new Color4 object
  6085. */
  6086. toLinearSpace(): Color4;
  6087. /**
  6088. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6089. * @param convertedColor defines the Color4 object where to store the linear space version
  6090. * @returns the unmodified Color4
  6091. */
  6092. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6093. /**
  6094. * Computes a new Color4 converted from the current one to gamma space
  6095. * @returns a new Color4 object
  6096. */
  6097. toGammaSpace(): Color4;
  6098. /**
  6099. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6100. * @param convertedColor defines the Color4 object where to store the gamma space version
  6101. * @returns the unmodified Color4
  6102. */
  6103. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6104. /**
  6105. * Creates a new Color4 from the string containing valid hexadecimal values
  6106. * @param hex defines a string containing valid hexadecimal values
  6107. * @returns a new Color4 object
  6108. */
  6109. static FromHexString(hex: string): Color4;
  6110. /**
  6111. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6112. * @param left defines the start value
  6113. * @param right defines the end value
  6114. * @param amount defines the gradient factor
  6115. * @returns a new Color4 object
  6116. */
  6117. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6118. /**
  6119. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6120. * @param left defines the start value
  6121. * @param right defines the end value
  6122. * @param amount defines the gradient factor
  6123. * @param result defines the Color4 object where to store data
  6124. */
  6125. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6126. /**
  6127. * Creates a new Color4 from a Color3 and an alpha value
  6128. * @param color3 defines the source Color3 to read from
  6129. * @param alpha defines the alpha component (1.0 by default)
  6130. * @returns a new Color4 object
  6131. */
  6132. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6133. /**
  6134. * Creates a new Color4 from the starting index element of the given array
  6135. * @param array defines the source array to read from
  6136. * @param offset defines the offset in the source array
  6137. * @returns a new Color4 object
  6138. */
  6139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6140. /**
  6141. * Creates a new Color4 from the starting index element of the given array
  6142. * @param array defines the source array to read from
  6143. * @param offset defines the offset in the source array
  6144. * @param result defines the target Color4 object
  6145. */
  6146. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6147. /**
  6148. * Creates a new Color3 from integer values (< 256)
  6149. * @param r defines the red component to read from (value between 0 and 255)
  6150. * @param g defines the green component to read from (value between 0 and 255)
  6151. * @param b defines the blue component to read from (value between 0 and 255)
  6152. * @param a defines the alpha component to read from (value between 0 and 255)
  6153. * @returns a new Color3 object
  6154. */
  6155. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6156. /**
  6157. * Check the content of a given array and convert it to an array containing RGBA data
  6158. * If the original array was already containing count * 4 values then it is returned directly
  6159. * @param colors defines the array to check
  6160. * @param count defines the number of RGBA data to expect
  6161. * @returns an array containing count * 4 values (RGBA)
  6162. */
  6163. static CheckColors4(colors: number[], count: number): number[];
  6164. }
  6165. /**
  6166. * @hidden
  6167. */
  6168. export class TmpColors {
  6169. static Color3: Color3[];
  6170. static Color4: Color4[];
  6171. }
  6172. }
  6173. declare module "babylonjs/Animations/animationKey" {
  6174. /**
  6175. * Defines an interface which represents an animation key frame
  6176. */
  6177. export interface IAnimationKey {
  6178. /**
  6179. * Frame of the key frame
  6180. */
  6181. frame: number;
  6182. /**
  6183. * Value at the specifies key frame
  6184. */
  6185. value: any;
  6186. /**
  6187. * The input tangent for the cubic hermite spline
  6188. */
  6189. inTangent?: any;
  6190. /**
  6191. * The output tangent for the cubic hermite spline
  6192. */
  6193. outTangent?: any;
  6194. /**
  6195. * The animation interpolation type
  6196. */
  6197. interpolation?: AnimationKeyInterpolation;
  6198. }
  6199. /**
  6200. * Enum for the animation key frame interpolation type
  6201. */
  6202. export enum AnimationKeyInterpolation {
  6203. /**
  6204. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6205. */
  6206. STEP = 1
  6207. }
  6208. }
  6209. declare module "babylonjs/Animations/animationRange" {
  6210. /**
  6211. * Represents the range of an animation
  6212. */
  6213. export class AnimationRange {
  6214. /**The name of the animation range**/
  6215. name: string;
  6216. /**The starting frame of the animation */
  6217. from: number;
  6218. /**The ending frame of the animation*/
  6219. to: number;
  6220. /**
  6221. * Initializes the range of an animation
  6222. * @param name The name of the animation range
  6223. * @param from The starting frame of the animation
  6224. * @param to The ending frame of the animation
  6225. */
  6226. constructor(
  6227. /**The name of the animation range**/
  6228. name: string,
  6229. /**The starting frame of the animation */
  6230. from: number,
  6231. /**The ending frame of the animation*/
  6232. to: number);
  6233. /**
  6234. * Makes a copy of the animation range
  6235. * @returns A copy of the animation range
  6236. */
  6237. clone(): AnimationRange;
  6238. }
  6239. }
  6240. declare module "babylonjs/Animations/animationEvent" {
  6241. /**
  6242. * Composed of a frame, and an action function
  6243. */
  6244. export class AnimationEvent {
  6245. /** The frame for which the event is triggered **/
  6246. frame: number;
  6247. /** The event to perform when triggered **/
  6248. action: (currentFrame: number) => void;
  6249. /** Specifies if the event should be triggered only once**/
  6250. onlyOnce?: boolean | undefined;
  6251. /**
  6252. * Specifies if the animation event is done
  6253. */
  6254. isDone: boolean;
  6255. /**
  6256. * Initializes the animation event
  6257. * @param frame The frame for which the event is triggered
  6258. * @param action The event to perform when triggered
  6259. * @param onlyOnce Specifies if the event should be triggered only once
  6260. */
  6261. constructor(
  6262. /** The frame for which the event is triggered **/
  6263. frame: number,
  6264. /** The event to perform when triggered **/
  6265. action: (currentFrame: number) => void,
  6266. /** Specifies if the event should be triggered only once**/
  6267. onlyOnce?: boolean | undefined);
  6268. /** @hidden */
  6269. _clone(): AnimationEvent;
  6270. }
  6271. }
  6272. declare module "babylonjs/Behaviors/behavior" {
  6273. import { Nullable } from "babylonjs/types";
  6274. /**
  6275. * Interface used to define a behavior
  6276. */
  6277. export interface Behavior<T> {
  6278. /** gets or sets behavior's name */
  6279. name: string;
  6280. /**
  6281. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6282. */
  6283. init(): void;
  6284. /**
  6285. * Called when the behavior is attached to a target
  6286. * @param target defines the target where the behavior is attached to
  6287. */
  6288. attach(target: T): void;
  6289. /**
  6290. * Called when the behavior is detached from its target
  6291. */
  6292. detach(): void;
  6293. }
  6294. /**
  6295. * Interface implemented by classes supporting behaviors
  6296. */
  6297. export interface IBehaviorAware<T> {
  6298. /**
  6299. * Attach a behavior
  6300. * @param behavior defines the behavior to attach
  6301. * @returns the current host
  6302. */
  6303. addBehavior(behavior: Behavior<T>): T;
  6304. /**
  6305. * Remove a behavior from the current object
  6306. * @param behavior defines the behavior to detach
  6307. * @returns the current host
  6308. */
  6309. removeBehavior(behavior: Behavior<T>): T;
  6310. /**
  6311. * Gets a behavior using its name to search
  6312. * @param name defines the name to search
  6313. * @returns the behavior or null if not found
  6314. */
  6315. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6316. }
  6317. }
  6318. declare module "babylonjs/Misc/smartArray" {
  6319. /**
  6320. * Defines an array and its length.
  6321. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6322. */
  6323. export interface ISmartArrayLike<T> {
  6324. /**
  6325. * The data of the array.
  6326. */
  6327. data: Array<T>;
  6328. /**
  6329. * The active length of the array.
  6330. */
  6331. length: number;
  6332. }
  6333. /**
  6334. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6335. */
  6336. export class SmartArray<T> implements ISmartArrayLike<T> {
  6337. /**
  6338. * The full set of data from the array.
  6339. */
  6340. data: Array<T>;
  6341. /**
  6342. * The active length of the array.
  6343. */
  6344. length: number;
  6345. protected _id: number;
  6346. /**
  6347. * Instantiates a Smart Array.
  6348. * @param capacity defines the default capacity of the array.
  6349. */
  6350. constructor(capacity: number);
  6351. /**
  6352. * Pushes a value at the end of the active data.
  6353. * @param value defines the object to push in the array.
  6354. */
  6355. push(value: T): void;
  6356. /**
  6357. * Iterates over the active data and apply the lambda to them.
  6358. * @param func defines the action to apply on each value.
  6359. */
  6360. forEach(func: (content: T) => void): void;
  6361. /**
  6362. * Sorts the full sets of data.
  6363. * @param compareFn defines the comparison function to apply.
  6364. */
  6365. sort(compareFn: (a: T, b: T) => number): void;
  6366. /**
  6367. * Resets the active data to an empty array.
  6368. */
  6369. reset(): void;
  6370. /**
  6371. * Releases all the data from the array as well as the array.
  6372. */
  6373. dispose(): void;
  6374. /**
  6375. * Concats the active data with a given array.
  6376. * @param array defines the data to concatenate with.
  6377. */
  6378. concat(array: any): void;
  6379. /**
  6380. * Returns the position of a value in the active data.
  6381. * @param value defines the value to find the index for
  6382. * @returns the index if found in the active data otherwise -1
  6383. */
  6384. indexOf(value: T): number;
  6385. /**
  6386. * Returns whether an element is part of the active data.
  6387. * @param value defines the value to look for
  6388. * @returns true if found in the active data otherwise false
  6389. */
  6390. contains(value: T): boolean;
  6391. private static _GlobalId;
  6392. }
  6393. /**
  6394. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6395. * The data in this array can only be present once
  6396. */
  6397. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6398. private _duplicateId;
  6399. /**
  6400. * Pushes a value at the end of the active data.
  6401. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6402. * @param value defines the object to push in the array.
  6403. */
  6404. push(value: T): void;
  6405. /**
  6406. * Pushes a value at the end of the active data.
  6407. * If the data is already present, it won t be added again
  6408. * @param value defines the object to push in the array.
  6409. * @returns true if added false if it was already present
  6410. */
  6411. pushNoDuplicate(value: T): boolean;
  6412. /**
  6413. * Resets the active data to an empty array.
  6414. */
  6415. reset(): void;
  6416. /**
  6417. * Concats the active data with a given array.
  6418. * This ensures no dupplicate will be present in the result.
  6419. * @param array defines the data to concatenate with.
  6420. */
  6421. concatWithNoDuplicate(array: any): void;
  6422. }
  6423. }
  6424. declare module "babylonjs/Cameras/cameraInputsManager" {
  6425. import { Nullable } from "babylonjs/types";
  6426. import { Camera } from "babylonjs/Cameras/camera";
  6427. /**
  6428. * @ignore
  6429. * This is a list of all the different input types that are available in the application.
  6430. * Fo instance: ArcRotateCameraGamepadInput...
  6431. */
  6432. export var CameraInputTypes: {};
  6433. /**
  6434. * This is the contract to implement in order to create a new input class.
  6435. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6436. */
  6437. export interface ICameraInput<TCamera extends Camera> {
  6438. /**
  6439. * Defines the camera the input is attached to.
  6440. */
  6441. camera: Nullable<TCamera>;
  6442. /**
  6443. * Gets the class name of the current intput.
  6444. * @returns the class name
  6445. */
  6446. getClassName(): string;
  6447. /**
  6448. * Get the friendly name associated with the input class.
  6449. * @returns the input friendly name
  6450. */
  6451. getSimpleName(): string;
  6452. /**
  6453. * Attach the input controls to a specific dom element to get the input from.
  6454. * @param element Defines the element the controls should be listened from
  6455. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6456. */
  6457. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6458. /**
  6459. * Detach the current controls from the specified dom element.
  6460. * @param element Defines the element to stop listening the inputs from
  6461. */
  6462. detachControl(element: Nullable<HTMLElement>): void;
  6463. /**
  6464. * Update the current camera state depending on the inputs that have been used this frame.
  6465. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6466. */
  6467. checkInputs?: () => void;
  6468. }
  6469. /**
  6470. * Represents a map of input types to input instance or input index to input instance.
  6471. */
  6472. export interface CameraInputsMap<TCamera extends Camera> {
  6473. /**
  6474. * Accessor to the input by input type.
  6475. */
  6476. [name: string]: ICameraInput<TCamera>;
  6477. /**
  6478. * Accessor to the input by input index.
  6479. */
  6480. [idx: number]: ICameraInput<TCamera>;
  6481. }
  6482. /**
  6483. * This represents the input manager used within a camera.
  6484. * It helps dealing with all the different kind of input attached to a camera.
  6485. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6486. */
  6487. export class CameraInputsManager<TCamera extends Camera> {
  6488. /**
  6489. * Defines the list of inputs attahed to the camera.
  6490. */
  6491. attached: CameraInputsMap<TCamera>;
  6492. /**
  6493. * Defines the dom element the camera is collecting inputs from.
  6494. * This is null if the controls have not been attached.
  6495. */
  6496. attachedElement: Nullable<HTMLElement>;
  6497. /**
  6498. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6499. */
  6500. noPreventDefault: boolean;
  6501. /**
  6502. * Defined the camera the input manager belongs to.
  6503. */
  6504. camera: TCamera;
  6505. /**
  6506. * Update the current camera state depending on the inputs that have been used this frame.
  6507. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6508. */
  6509. checkInputs: () => void;
  6510. /**
  6511. * Instantiate a new Camera Input Manager.
  6512. * @param camera Defines the camera the input manager blongs to
  6513. */
  6514. constructor(camera: TCamera);
  6515. /**
  6516. * Add an input method to a camera
  6517. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6518. * @param input camera input method
  6519. */
  6520. add(input: ICameraInput<TCamera>): void;
  6521. /**
  6522. * Remove a specific input method from a camera
  6523. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6524. * @param inputToRemove camera input method
  6525. */
  6526. remove(inputToRemove: ICameraInput<TCamera>): void;
  6527. /**
  6528. * Remove a specific input type from a camera
  6529. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6530. * @param inputType the type of the input to remove
  6531. */
  6532. removeByType(inputType: string): void;
  6533. private _addCheckInputs;
  6534. /**
  6535. * Attach the input controls to the currently attached dom element to listen the events from.
  6536. * @param input Defines the input to attach
  6537. */
  6538. attachInput(input: ICameraInput<TCamera>): void;
  6539. /**
  6540. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6541. * @param element Defines the dom element to collect the events from
  6542. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6543. */
  6544. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6545. /**
  6546. * Detach the current manager inputs controls from a specific dom element.
  6547. * @param element Defines the dom element to collect the events from
  6548. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6549. */
  6550. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6551. /**
  6552. * Rebuild the dynamic inputCheck function from the current list of
  6553. * defined inputs in the manager.
  6554. */
  6555. rebuildInputCheck(): void;
  6556. /**
  6557. * Remove all attached input methods from a camera
  6558. */
  6559. clear(): void;
  6560. /**
  6561. * Serialize the current input manager attached to a camera.
  6562. * This ensures than once parsed,
  6563. * the input associated to the camera will be identical to the current ones
  6564. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6565. */
  6566. serialize(serializedCamera: any): void;
  6567. /**
  6568. * Parses an input manager serialized JSON to restore the previous list of inputs
  6569. * and states associated to a camera.
  6570. * @param parsedCamera Defines the JSON to parse
  6571. */
  6572. parse(parsedCamera: any): void;
  6573. }
  6574. }
  6575. declare module "babylonjs/Meshes/buffer" {
  6576. import { Nullable, DataArray } from "babylonjs/types";
  6577. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6578. /**
  6579. * Class used to store data that will be store in GPU memory
  6580. */
  6581. export class Buffer {
  6582. private _engine;
  6583. private _buffer;
  6584. /** @hidden */
  6585. _data: Nullable<DataArray>;
  6586. private _updatable;
  6587. private _instanced;
  6588. private _divisor;
  6589. /**
  6590. * Gets the byte stride.
  6591. */
  6592. readonly byteStride: number;
  6593. /**
  6594. * Constructor
  6595. * @param engine the engine
  6596. * @param data the data to use for this buffer
  6597. * @param updatable whether the data is updatable
  6598. * @param stride the stride (optional)
  6599. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6600. * @param instanced whether the buffer is instanced (optional)
  6601. * @param useBytes set to true if the stride in in bytes (optional)
  6602. * @param divisor sets an optional divisor for instances (1 by default)
  6603. */
  6604. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6605. /**
  6606. * Create a new VertexBuffer based on the current buffer
  6607. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6608. * @param offset defines offset in the buffer (0 by default)
  6609. * @param size defines the size in floats of attributes (position is 3 for instance)
  6610. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6611. * @param instanced defines if the vertex buffer contains indexed data
  6612. * @param useBytes defines if the offset and stride are in bytes *
  6613. * @param divisor sets an optional divisor for instances (1 by default)
  6614. * @returns the new vertex buffer
  6615. */
  6616. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6617. /**
  6618. * Gets a boolean indicating if the Buffer is updatable?
  6619. * @returns true if the buffer is updatable
  6620. */
  6621. isUpdatable(): boolean;
  6622. /**
  6623. * Gets current buffer's data
  6624. * @returns a DataArray or null
  6625. */
  6626. getData(): Nullable<DataArray>;
  6627. /**
  6628. * Gets underlying native buffer
  6629. * @returns underlying native buffer
  6630. */
  6631. getBuffer(): Nullable<DataBuffer>;
  6632. /**
  6633. * Gets the stride in float32 units (i.e. byte stride / 4).
  6634. * May not be an integer if the byte stride is not divisible by 4.
  6635. * @returns the stride in float32 units
  6636. * @deprecated Please use byteStride instead.
  6637. */
  6638. getStrideSize(): number;
  6639. /**
  6640. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6641. * @param data defines the data to store
  6642. */
  6643. create(data?: Nullable<DataArray>): void;
  6644. /** @hidden */
  6645. _rebuild(): void;
  6646. /**
  6647. * Update current buffer data
  6648. * @param data defines the data to store
  6649. */
  6650. update(data: DataArray): void;
  6651. /**
  6652. * Updates the data directly.
  6653. * @param data the new data
  6654. * @param offset the new offset
  6655. * @param vertexCount the vertex count (optional)
  6656. * @param useBytes set to true if the offset is in bytes
  6657. */
  6658. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6659. /**
  6660. * Release all resources
  6661. */
  6662. dispose(): void;
  6663. }
  6664. /**
  6665. * Specialized buffer used to store vertex data
  6666. */
  6667. export class VertexBuffer {
  6668. /** @hidden */
  6669. _buffer: Buffer;
  6670. private _kind;
  6671. private _size;
  6672. private _ownsBuffer;
  6673. private _instanced;
  6674. private _instanceDivisor;
  6675. /**
  6676. * The byte type.
  6677. */
  6678. static readonly BYTE: number;
  6679. /**
  6680. * The unsigned byte type.
  6681. */
  6682. static readonly UNSIGNED_BYTE: number;
  6683. /**
  6684. * The short type.
  6685. */
  6686. static readonly SHORT: number;
  6687. /**
  6688. * The unsigned short type.
  6689. */
  6690. static readonly UNSIGNED_SHORT: number;
  6691. /**
  6692. * The integer type.
  6693. */
  6694. static readonly INT: number;
  6695. /**
  6696. * The unsigned integer type.
  6697. */
  6698. static readonly UNSIGNED_INT: number;
  6699. /**
  6700. * The float type.
  6701. */
  6702. static readonly FLOAT: number;
  6703. /**
  6704. * Gets or sets the instance divisor when in instanced mode
  6705. */
  6706. get instanceDivisor(): number;
  6707. set instanceDivisor(value: number);
  6708. /**
  6709. * Gets the byte stride.
  6710. */
  6711. readonly byteStride: number;
  6712. /**
  6713. * Gets the byte offset.
  6714. */
  6715. readonly byteOffset: number;
  6716. /**
  6717. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6718. */
  6719. readonly normalized: boolean;
  6720. /**
  6721. * Gets the data type of each component in the array.
  6722. */
  6723. readonly type: number;
  6724. /**
  6725. * Constructor
  6726. * @param engine the engine
  6727. * @param data the data to use for this vertex buffer
  6728. * @param kind the vertex buffer kind
  6729. * @param updatable whether the data is updatable
  6730. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6731. * @param stride the stride (optional)
  6732. * @param instanced whether the buffer is instanced (optional)
  6733. * @param offset the offset of the data (optional)
  6734. * @param size the number of components (optional)
  6735. * @param type the type of the component (optional)
  6736. * @param normalized whether the data contains normalized data (optional)
  6737. * @param useBytes set to true if stride and offset are in bytes (optional)
  6738. * @param divisor defines the instance divisor to use (1 by default)
  6739. */
  6740. 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);
  6741. /** @hidden */
  6742. _rebuild(): void;
  6743. /**
  6744. * Returns the kind of the VertexBuffer (string)
  6745. * @returns a string
  6746. */
  6747. getKind(): string;
  6748. /**
  6749. * Gets a boolean indicating if the VertexBuffer is updatable?
  6750. * @returns true if the buffer is updatable
  6751. */
  6752. isUpdatable(): boolean;
  6753. /**
  6754. * Gets current buffer's data
  6755. * @returns a DataArray or null
  6756. */
  6757. getData(): Nullable<DataArray>;
  6758. /**
  6759. * Gets underlying native buffer
  6760. * @returns underlying native buffer
  6761. */
  6762. getBuffer(): Nullable<DataBuffer>;
  6763. /**
  6764. * Gets the stride in float32 units (i.e. byte stride / 4).
  6765. * May not be an integer if the byte stride is not divisible by 4.
  6766. * @returns the stride in float32 units
  6767. * @deprecated Please use byteStride instead.
  6768. */
  6769. getStrideSize(): number;
  6770. /**
  6771. * Returns the offset as a multiple of the type byte length.
  6772. * @returns the offset in bytes
  6773. * @deprecated Please use byteOffset instead.
  6774. */
  6775. getOffset(): number;
  6776. /**
  6777. * Returns the number of components per vertex attribute (integer)
  6778. * @returns the size in float
  6779. */
  6780. getSize(): number;
  6781. /**
  6782. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6783. * @returns true if this buffer is instanced
  6784. */
  6785. getIsInstanced(): boolean;
  6786. /**
  6787. * Returns the instancing divisor, zero for non-instanced (integer).
  6788. * @returns a number
  6789. */
  6790. getInstanceDivisor(): number;
  6791. /**
  6792. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6793. * @param data defines the data to store
  6794. */
  6795. create(data?: DataArray): void;
  6796. /**
  6797. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6798. * This function will create a new buffer if the current one is not updatable
  6799. * @param data defines the data to store
  6800. */
  6801. update(data: DataArray): void;
  6802. /**
  6803. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6804. * Returns the directly updated WebGLBuffer.
  6805. * @param data the new data
  6806. * @param offset the new offset
  6807. * @param useBytes set to true if the offset is in bytes
  6808. */
  6809. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6810. /**
  6811. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6812. */
  6813. dispose(): void;
  6814. /**
  6815. * Enumerates each value of this vertex buffer as numbers.
  6816. * @param count the number of values to enumerate
  6817. * @param callback the callback function called for each value
  6818. */
  6819. forEach(count: number, callback: (value: number, index: number) => void): void;
  6820. /**
  6821. * Positions
  6822. */
  6823. static readonly PositionKind: string;
  6824. /**
  6825. * Normals
  6826. */
  6827. static readonly NormalKind: string;
  6828. /**
  6829. * Tangents
  6830. */
  6831. static readonly TangentKind: string;
  6832. /**
  6833. * Texture coordinates
  6834. */
  6835. static readonly UVKind: string;
  6836. /**
  6837. * Texture coordinates 2
  6838. */
  6839. static readonly UV2Kind: string;
  6840. /**
  6841. * Texture coordinates 3
  6842. */
  6843. static readonly UV3Kind: string;
  6844. /**
  6845. * Texture coordinates 4
  6846. */
  6847. static readonly UV4Kind: string;
  6848. /**
  6849. * Texture coordinates 5
  6850. */
  6851. static readonly UV5Kind: string;
  6852. /**
  6853. * Texture coordinates 6
  6854. */
  6855. static readonly UV6Kind: string;
  6856. /**
  6857. * Colors
  6858. */
  6859. static readonly ColorKind: string;
  6860. /**
  6861. * Matrix indices (for bones)
  6862. */
  6863. static readonly MatricesIndicesKind: string;
  6864. /**
  6865. * Matrix weights (for bones)
  6866. */
  6867. static readonly MatricesWeightsKind: string;
  6868. /**
  6869. * Additional matrix indices (for bones)
  6870. */
  6871. static readonly MatricesIndicesExtraKind: string;
  6872. /**
  6873. * Additional matrix weights (for bones)
  6874. */
  6875. static readonly MatricesWeightsExtraKind: string;
  6876. /**
  6877. * Deduces the stride given a kind.
  6878. * @param kind The kind string to deduce
  6879. * @returns The deduced stride
  6880. */
  6881. static DeduceStride(kind: string): number;
  6882. /**
  6883. * Gets the byte length of the given type.
  6884. * @param type the type
  6885. * @returns the number of bytes
  6886. */
  6887. static GetTypeByteLength(type: number): number;
  6888. /**
  6889. * Enumerates each value of the given parameters as numbers.
  6890. * @param data the data to enumerate
  6891. * @param byteOffset the byte offset of the data
  6892. * @param byteStride the byte stride of the data
  6893. * @param componentCount the number of components per element
  6894. * @param componentType the type of the component
  6895. * @param count the number of values to enumerate
  6896. * @param normalized whether the data is normalized
  6897. * @param callback the callback function called for each value
  6898. */
  6899. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6900. private static _GetFloatValue;
  6901. }
  6902. }
  6903. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6904. import { Vector3 } from "babylonjs/Maths/math.vector";
  6905. import { Mesh } from "babylonjs/Meshes/mesh";
  6906. /**
  6907. * The options Interface for creating a Capsule Mesh
  6908. */
  6909. export interface ICreateCapsuleOptions {
  6910. /** The Orientation of the capsule. Default : Vector3.Up() */
  6911. orientation?: Vector3;
  6912. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6913. subdivisions: number;
  6914. /** Number of cylindrical segments on the capsule. */
  6915. tessellation: number;
  6916. /** Height or Length of the capsule. */
  6917. height: number;
  6918. /** Radius of the capsule. */
  6919. radius: number;
  6920. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6921. capSubdivisions: number;
  6922. /** Overwrite for the top radius. */
  6923. radiusTop?: number;
  6924. /** Overwrite for the bottom radius. */
  6925. radiusBottom?: number;
  6926. /** Overwrite for the top capSubdivisions. */
  6927. topCapSubdivisions?: number;
  6928. /** Overwrite for the bottom capSubdivisions. */
  6929. bottomCapSubdivisions?: number;
  6930. }
  6931. /**
  6932. * Class containing static functions to help procedurally build meshes
  6933. */
  6934. export class CapsuleBuilder {
  6935. /**
  6936. * Creates a capsule or a pill mesh
  6937. * @param name defines the name of the mesh
  6938. * @param options The constructors options.
  6939. * @param scene The scene the mesh is scoped to.
  6940. * @returns Capsule Mesh
  6941. */
  6942. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6943. }
  6944. }
  6945. declare module "babylonjs/Collisions/intersectionInfo" {
  6946. import { Nullable } from "babylonjs/types";
  6947. /**
  6948. * @hidden
  6949. */
  6950. export class IntersectionInfo {
  6951. bu: Nullable<number>;
  6952. bv: Nullable<number>;
  6953. distance: number;
  6954. faceId: number;
  6955. subMeshId: number;
  6956. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6957. }
  6958. }
  6959. declare module "babylonjs/Culling/boundingSphere" {
  6960. import { DeepImmutable } from "babylonjs/types";
  6961. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6962. import { Plane } from "babylonjs/Maths/math.plane";
  6963. /**
  6964. * Class used to store bounding sphere information
  6965. */
  6966. export class BoundingSphere {
  6967. /**
  6968. * Gets the center of the bounding sphere in local space
  6969. */
  6970. readonly center: Vector3;
  6971. /**
  6972. * Radius of the bounding sphere in local space
  6973. */
  6974. radius: number;
  6975. /**
  6976. * Gets the center of the bounding sphere in world space
  6977. */
  6978. readonly centerWorld: Vector3;
  6979. /**
  6980. * Radius of the bounding sphere in world space
  6981. */
  6982. radiusWorld: number;
  6983. /**
  6984. * Gets the minimum vector in local space
  6985. */
  6986. readonly minimum: Vector3;
  6987. /**
  6988. * Gets the maximum vector in local space
  6989. */
  6990. readonly maximum: Vector3;
  6991. private _worldMatrix;
  6992. private static readonly TmpVector3;
  6993. /**
  6994. * Creates a new bounding sphere
  6995. * @param min defines the minimum vector (in local space)
  6996. * @param max defines the maximum vector (in local space)
  6997. * @param worldMatrix defines the new world matrix
  6998. */
  6999. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7000. /**
  7001. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  7002. * @param min defines the new minimum vector (in local space)
  7003. * @param max defines the new maximum vector (in local space)
  7004. * @param worldMatrix defines the new world matrix
  7005. */
  7006. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7007. /**
  7008. * Scale the current bounding sphere by applying a scale factor
  7009. * @param factor defines the scale factor to apply
  7010. * @returns the current bounding box
  7011. */
  7012. scale(factor: number): BoundingSphere;
  7013. /**
  7014. * Gets the world matrix of the bounding box
  7015. * @returns a matrix
  7016. */
  7017. getWorldMatrix(): DeepImmutable<Matrix>;
  7018. /** @hidden */
  7019. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7020. /**
  7021. * Tests if the bounding sphere is intersecting the frustum planes
  7022. * @param frustumPlanes defines the frustum planes to test
  7023. * @returns true if there is an intersection
  7024. */
  7025. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7026. /**
  7027. * Tests if the bounding sphere center is in between the frustum planes.
  7028. * Used for optimistic fast inclusion.
  7029. * @param frustumPlanes defines the frustum planes to test
  7030. * @returns true if the sphere center is in between the frustum planes
  7031. */
  7032. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7033. /**
  7034. * Tests if a point is inside the bounding sphere
  7035. * @param point defines the point to test
  7036. * @returns true if the point is inside the bounding sphere
  7037. */
  7038. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7039. /**
  7040. * Checks if two sphere intersct
  7041. * @param sphere0 sphere 0
  7042. * @param sphere1 sphere 1
  7043. * @returns true if the speres intersect
  7044. */
  7045. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7046. }
  7047. }
  7048. declare module "babylonjs/Culling/boundingBox" {
  7049. import { DeepImmutable } from "babylonjs/types";
  7050. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7051. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7052. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7053. import { Plane } from "babylonjs/Maths/math.plane";
  7054. /**
  7055. * Class used to store bounding box information
  7056. */
  7057. export class BoundingBox implements ICullable {
  7058. /**
  7059. * Gets the 8 vectors representing the bounding box in local space
  7060. */
  7061. readonly vectors: Vector3[];
  7062. /**
  7063. * Gets the center of the bounding box in local space
  7064. */
  7065. readonly center: Vector3;
  7066. /**
  7067. * Gets the center of the bounding box in world space
  7068. */
  7069. readonly centerWorld: Vector3;
  7070. /**
  7071. * Gets the extend size in local space
  7072. */
  7073. readonly extendSize: Vector3;
  7074. /**
  7075. * Gets the extend size in world space
  7076. */
  7077. readonly extendSizeWorld: Vector3;
  7078. /**
  7079. * Gets the OBB (object bounding box) directions
  7080. */
  7081. readonly directions: Vector3[];
  7082. /**
  7083. * Gets the 8 vectors representing the bounding box in world space
  7084. */
  7085. readonly vectorsWorld: Vector3[];
  7086. /**
  7087. * Gets the minimum vector in world space
  7088. */
  7089. readonly minimumWorld: Vector3;
  7090. /**
  7091. * Gets the maximum vector in world space
  7092. */
  7093. readonly maximumWorld: Vector3;
  7094. /**
  7095. * Gets the minimum vector in local space
  7096. */
  7097. readonly minimum: Vector3;
  7098. /**
  7099. * Gets the maximum vector in local space
  7100. */
  7101. readonly maximum: Vector3;
  7102. private _worldMatrix;
  7103. private static readonly TmpVector3;
  7104. /**
  7105. * @hidden
  7106. */
  7107. _tag: number;
  7108. /**
  7109. * Creates a new bounding box
  7110. * @param min defines the minimum vector (in local space)
  7111. * @param max defines the maximum vector (in local space)
  7112. * @param worldMatrix defines the new world matrix
  7113. */
  7114. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7115. /**
  7116. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7117. * @param min defines the new minimum vector (in local space)
  7118. * @param max defines the new maximum vector (in local space)
  7119. * @param worldMatrix defines the new world matrix
  7120. */
  7121. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7122. /**
  7123. * Scale the current bounding box by applying a scale factor
  7124. * @param factor defines the scale factor to apply
  7125. * @returns the current bounding box
  7126. */
  7127. scale(factor: number): BoundingBox;
  7128. /**
  7129. * Gets the world matrix of the bounding box
  7130. * @returns a matrix
  7131. */
  7132. getWorldMatrix(): DeepImmutable<Matrix>;
  7133. /** @hidden */
  7134. _update(world: DeepImmutable<Matrix>): void;
  7135. /**
  7136. * Tests if the bounding box is intersecting the frustum planes
  7137. * @param frustumPlanes defines the frustum planes to test
  7138. * @returns true if there is an intersection
  7139. */
  7140. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7141. /**
  7142. * Tests if the bounding box is entirely inside the frustum planes
  7143. * @param frustumPlanes defines the frustum planes to test
  7144. * @returns true if there is an inclusion
  7145. */
  7146. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7147. /**
  7148. * Tests if a point is inside the bounding box
  7149. * @param point defines the point to test
  7150. * @returns true if the point is inside the bounding box
  7151. */
  7152. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7153. /**
  7154. * Tests if the bounding box intersects with a bounding sphere
  7155. * @param sphere defines the sphere to test
  7156. * @returns true if there is an intersection
  7157. */
  7158. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7159. /**
  7160. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7161. * @param min defines the min vector to use
  7162. * @param max defines the max vector to use
  7163. * @returns true if there is an intersection
  7164. */
  7165. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7166. /**
  7167. * Tests if two bounding boxes are intersections
  7168. * @param box0 defines the first box to test
  7169. * @param box1 defines the second box to test
  7170. * @returns true if there is an intersection
  7171. */
  7172. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7173. /**
  7174. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7175. * @param minPoint defines the minimum vector of the bounding box
  7176. * @param maxPoint defines the maximum vector of the bounding box
  7177. * @param sphereCenter defines the sphere center
  7178. * @param sphereRadius defines the sphere radius
  7179. * @returns true if there is an intersection
  7180. */
  7181. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7182. /**
  7183. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7184. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7185. * @param frustumPlanes defines the frustum planes to test
  7186. * @return true if there is an inclusion
  7187. */
  7188. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7189. /**
  7190. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7191. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7192. * @param frustumPlanes defines the frustum planes to test
  7193. * @return true if there is an intersection
  7194. */
  7195. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7196. }
  7197. }
  7198. declare module "babylonjs/Collisions/collider" {
  7199. import { Nullable, IndicesArray } from "babylonjs/types";
  7200. import { Vector3 } from "babylonjs/Maths/math.vector";
  7201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7202. import { Plane } from "babylonjs/Maths/math.plane";
  7203. /** @hidden */
  7204. export class Collider {
  7205. /** Define if a collision was found */
  7206. collisionFound: boolean;
  7207. /**
  7208. * Define last intersection point in local space
  7209. */
  7210. intersectionPoint: Vector3;
  7211. /**
  7212. * Define last collided mesh
  7213. */
  7214. collidedMesh: Nullable<AbstractMesh>;
  7215. private _collisionPoint;
  7216. private _planeIntersectionPoint;
  7217. private _tempVector;
  7218. private _tempVector2;
  7219. private _tempVector3;
  7220. private _tempVector4;
  7221. private _edge;
  7222. private _baseToVertex;
  7223. private _destinationPoint;
  7224. private _slidePlaneNormal;
  7225. private _displacementVector;
  7226. /** @hidden */
  7227. _radius: Vector3;
  7228. /** @hidden */
  7229. _retry: number;
  7230. private _velocity;
  7231. private _basePoint;
  7232. private _epsilon;
  7233. /** @hidden */
  7234. _velocityWorldLength: number;
  7235. /** @hidden */
  7236. _basePointWorld: Vector3;
  7237. private _velocityWorld;
  7238. private _normalizedVelocity;
  7239. /** @hidden */
  7240. _initialVelocity: Vector3;
  7241. /** @hidden */
  7242. _initialPosition: Vector3;
  7243. private _nearestDistance;
  7244. private _collisionMask;
  7245. get collisionMask(): number;
  7246. set collisionMask(mask: number);
  7247. /**
  7248. * Gets the plane normal used to compute the sliding response (in local space)
  7249. */
  7250. get slidePlaneNormal(): Vector3;
  7251. /** @hidden */
  7252. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7253. /** @hidden */
  7254. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7255. /** @hidden */
  7256. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7257. /** @hidden */
  7258. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7259. /** @hidden */
  7260. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7261. /** @hidden */
  7262. _getResponse(pos: Vector3, vel: Vector3): void;
  7263. }
  7264. }
  7265. declare module "babylonjs/Culling/boundingInfo" {
  7266. import { DeepImmutable } from "babylonjs/types";
  7267. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7268. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7269. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7270. import { Plane } from "babylonjs/Maths/math.plane";
  7271. import { Collider } from "babylonjs/Collisions/collider";
  7272. /**
  7273. * Interface for cullable objects
  7274. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7275. */
  7276. export interface ICullable {
  7277. /**
  7278. * Checks if the object or part of the object is in the frustum
  7279. * @param frustumPlanes Camera near/planes
  7280. * @returns true if the object is in frustum otherwise false
  7281. */
  7282. isInFrustum(frustumPlanes: Plane[]): boolean;
  7283. /**
  7284. * Checks if a cullable object (mesh...) is in the camera frustum
  7285. * Unlike isInFrustum this cheks the full bounding box
  7286. * @param frustumPlanes Camera near/planes
  7287. * @returns true if the object is in frustum otherwise false
  7288. */
  7289. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7290. }
  7291. /**
  7292. * Info for a bounding data of a mesh
  7293. */
  7294. export class BoundingInfo implements ICullable {
  7295. /**
  7296. * Bounding box for the mesh
  7297. */
  7298. readonly boundingBox: BoundingBox;
  7299. /**
  7300. * Bounding sphere for the mesh
  7301. */
  7302. readonly boundingSphere: BoundingSphere;
  7303. private _isLocked;
  7304. private static readonly TmpVector3;
  7305. /**
  7306. * Constructs bounding info
  7307. * @param minimum min vector of the bounding box/sphere
  7308. * @param maximum max vector of the bounding box/sphere
  7309. * @param worldMatrix defines the new world matrix
  7310. */
  7311. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7312. /**
  7313. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7314. * @param min defines the new minimum vector (in local space)
  7315. * @param max defines the new maximum vector (in local space)
  7316. * @param worldMatrix defines the new world matrix
  7317. */
  7318. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7319. /**
  7320. * min vector of the bounding box/sphere
  7321. */
  7322. get minimum(): Vector3;
  7323. /**
  7324. * max vector of the bounding box/sphere
  7325. */
  7326. get maximum(): Vector3;
  7327. /**
  7328. * If the info is locked and won't be updated to avoid perf overhead
  7329. */
  7330. get isLocked(): boolean;
  7331. set isLocked(value: boolean);
  7332. /**
  7333. * Updates the bounding sphere and box
  7334. * @param world world matrix to be used to update
  7335. */
  7336. update(world: DeepImmutable<Matrix>): void;
  7337. /**
  7338. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7339. * @param center New center of the bounding info
  7340. * @param extend New extend of the bounding info
  7341. * @returns the current bounding info
  7342. */
  7343. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7344. /**
  7345. * Scale the current bounding info by applying a scale factor
  7346. * @param factor defines the scale factor to apply
  7347. * @returns the current bounding info
  7348. */
  7349. scale(factor: number): BoundingInfo;
  7350. /**
  7351. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7352. * @param frustumPlanes defines the frustum to test
  7353. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7354. * @returns true if the bounding info is in the frustum planes
  7355. */
  7356. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7357. /**
  7358. * Gets the world distance between the min and max points of the bounding box
  7359. */
  7360. get diagonalLength(): number;
  7361. /**
  7362. * Checks if a cullable object (mesh...) is in the camera frustum
  7363. * Unlike isInFrustum this cheks the full bounding box
  7364. * @param frustumPlanes Camera near/planes
  7365. * @returns true if the object is in frustum otherwise false
  7366. */
  7367. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7368. /** @hidden */
  7369. _checkCollision(collider: Collider): boolean;
  7370. /**
  7371. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7372. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7373. * @param point the point to check intersection with
  7374. * @returns if the point intersects
  7375. */
  7376. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7377. /**
  7378. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7379. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7380. * @param boundingInfo the bounding info to check intersection with
  7381. * @param precise if the intersection should be done using OBB
  7382. * @returns if the bounding info intersects
  7383. */
  7384. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7385. }
  7386. }
  7387. declare module "babylonjs/Maths/math.functions" {
  7388. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7389. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7390. /**
  7391. * Extracts minimum and maximum values from a list of indexed positions
  7392. * @param positions defines the positions to use
  7393. * @param indices defines the indices to the positions
  7394. * @param indexStart defines the start index
  7395. * @param indexCount defines the end index
  7396. * @param bias defines bias value to add to the result
  7397. * @return minimum and maximum values
  7398. */
  7399. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7400. minimum: Vector3;
  7401. maximum: Vector3;
  7402. };
  7403. /**
  7404. * Extracts minimum and maximum values from a list of positions
  7405. * @param positions defines the positions to use
  7406. * @param start defines the start index in the positions array
  7407. * @param count defines the number of positions to handle
  7408. * @param bias defines bias value to add to the result
  7409. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7410. * @return minimum and maximum values
  7411. */
  7412. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7413. minimum: Vector3;
  7414. maximum: Vector3;
  7415. };
  7416. }
  7417. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7418. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7419. /** @hidden */
  7420. export class WebGLDataBuffer extends DataBuffer {
  7421. private _buffer;
  7422. constructor(resource: WebGLBuffer);
  7423. get underlyingResource(): any;
  7424. }
  7425. }
  7426. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7427. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7428. import { Nullable } from "babylonjs/types";
  7429. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7430. /** @hidden */
  7431. export class WebGLPipelineContext implements IPipelineContext {
  7432. engine: ThinEngine;
  7433. program: Nullable<WebGLProgram>;
  7434. context?: WebGLRenderingContext;
  7435. vertexShader?: WebGLShader;
  7436. fragmentShader?: WebGLShader;
  7437. isParallelCompiled: boolean;
  7438. onCompiled?: () => void;
  7439. transformFeedback?: WebGLTransformFeedback | null;
  7440. vertexCompilationError: Nullable<string>;
  7441. fragmentCompilationError: Nullable<string>;
  7442. programLinkError: Nullable<string>;
  7443. programValidationError: Nullable<string>;
  7444. get isAsync(): boolean;
  7445. get isReady(): boolean;
  7446. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7447. _getVertexShaderCode(): string | null;
  7448. _getFragmentShaderCode(): string | null;
  7449. }
  7450. }
  7451. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7452. import { FloatArray, Nullable } from "babylonjs/types";
  7453. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7454. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7455. module "babylonjs/Engines/thinEngine" {
  7456. interface ThinEngine {
  7457. /**
  7458. * Create an uniform buffer
  7459. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7460. * @param elements defines the content of the uniform buffer
  7461. * @returns the webGL uniform buffer
  7462. */
  7463. createUniformBuffer(elements: FloatArray): DataBuffer;
  7464. /**
  7465. * Create a dynamic uniform buffer
  7466. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7467. * @param elements defines the content of the uniform buffer
  7468. * @returns the webGL uniform buffer
  7469. */
  7470. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7471. /**
  7472. * Update an existing uniform buffer
  7473. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7474. * @param uniformBuffer defines the target uniform buffer
  7475. * @param elements defines the content to update
  7476. * @param offset defines the offset in the uniform buffer where update should start
  7477. * @param count defines the size of the data to update
  7478. */
  7479. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7480. /**
  7481. * Bind an uniform buffer to the current webGL context
  7482. * @param buffer defines the buffer to bind
  7483. */
  7484. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7485. /**
  7486. * Bind a buffer to the current webGL context at a given location
  7487. * @param buffer defines the buffer to bind
  7488. * @param location defines the index where to bind the buffer
  7489. */
  7490. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7491. /**
  7492. * Bind a specific block at a given index in a specific shader program
  7493. * @param pipelineContext defines the pipeline context to use
  7494. * @param blockName defines the block name
  7495. * @param index defines the index where to bind the block
  7496. */
  7497. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7498. }
  7499. }
  7500. }
  7501. declare module "babylonjs/Materials/uniformBuffer" {
  7502. import { Nullable, FloatArray } from "babylonjs/types";
  7503. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7504. import { Engine } from "babylonjs/Engines/engine";
  7505. import { Effect } from "babylonjs/Materials/effect";
  7506. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7507. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7508. import { Color3 } from "babylonjs/Maths/math.color";
  7509. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7510. /**
  7511. * Uniform buffer objects.
  7512. *
  7513. * Handles blocks of uniform on the GPU.
  7514. *
  7515. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7516. *
  7517. * For more information, please refer to :
  7518. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7519. */
  7520. export class UniformBuffer {
  7521. private _engine;
  7522. private _buffer;
  7523. private _data;
  7524. private _bufferData;
  7525. private _dynamic?;
  7526. private _uniformLocations;
  7527. private _uniformSizes;
  7528. private _uniformLocationPointer;
  7529. private _needSync;
  7530. private _noUBO;
  7531. private _currentEffect;
  7532. /** @hidden */
  7533. _alreadyBound: boolean;
  7534. private static _MAX_UNIFORM_SIZE;
  7535. private static _tempBuffer;
  7536. /**
  7537. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7538. * This is dynamic to allow compat with webgl 1 and 2.
  7539. * You will need to pass the name of the uniform as well as the value.
  7540. */
  7541. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7542. /**
  7543. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7544. * This is dynamic to allow compat with webgl 1 and 2.
  7545. * You will need to pass the name of the uniform as well as the value.
  7546. */
  7547. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7548. /**
  7549. * Lambda to Update a single float in a uniform buffer.
  7550. * This is dynamic to allow compat with webgl 1 and 2.
  7551. * You will need to pass the name of the uniform as well as the value.
  7552. */
  7553. updateFloat: (name: string, x: number) => void;
  7554. /**
  7555. * Lambda to Update a vec2 of float in a uniform buffer.
  7556. * This is dynamic to allow compat with webgl 1 and 2.
  7557. * You will need to pass the name of the uniform as well as the value.
  7558. */
  7559. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7560. /**
  7561. * Lambda to Update a vec3 of float in a uniform buffer.
  7562. * This is dynamic to allow compat with webgl 1 and 2.
  7563. * You will need to pass the name of the uniform as well as the value.
  7564. */
  7565. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7566. /**
  7567. * Lambda to Update a vec4 of float in a uniform buffer.
  7568. * This is dynamic to allow compat with webgl 1 and 2.
  7569. * You will need to pass the name of the uniform as well as the value.
  7570. */
  7571. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7572. /**
  7573. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7574. * This is dynamic to allow compat with webgl 1 and 2.
  7575. * You will need to pass the name of the uniform as well as the value.
  7576. */
  7577. updateMatrix: (name: string, mat: Matrix) => void;
  7578. /**
  7579. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7580. * This is dynamic to allow compat with webgl 1 and 2.
  7581. * You will need to pass the name of the uniform as well as the value.
  7582. */
  7583. updateVector3: (name: string, vector: Vector3) => void;
  7584. /**
  7585. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7586. * This is dynamic to allow compat with webgl 1 and 2.
  7587. * You will need to pass the name of the uniform as well as the value.
  7588. */
  7589. updateVector4: (name: string, vector: Vector4) => void;
  7590. /**
  7591. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7592. * This is dynamic to allow compat with webgl 1 and 2.
  7593. * You will need to pass the name of the uniform as well as the value.
  7594. */
  7595. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7596. /**
  7597. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7598. * This is dynamic to allow compat with webgl 1 and 2.
  7599. * You will need to pass the name of the uniform as well as the value.
  7600. */
  7601. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7602. /**
  7603. * Instantiates a new Uniform buffer objects.
  7604. *
  7605. * Handles blocks of uniform on the GPU.
  7606. *
  7607. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7608. *
  7609. * For more information, please refer to :
  7610. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7611. * @param engine Define the engine the buffer is associated with
  7612. * @param data Define the data contained in the buffer
  7613. * @param dynamic Define if the buffer is updatable
  7614. */
  7615. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7616. /**
  7617. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7618. * or just falling back on setUniformXXX calls.
  7619. */
  7620. get useUbo(): boolean;
  7621. /**
  7622. * Indicates if the WebGL underlying uniform buffer is in sync
  7623. * with the javascript cache data.
  7624. */
  7625. get isSync(): boolean;
  7626. /**
  7627. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7628. * Also, a dynamic UniformBuffer will disable cache verification and always
  7629. * update the underlying WebGL uniform buffer to the GPU.
  7630. * @returns if Dynamic, otherwise false
  7631. */
  7632. isDynamic(): boolean;
  7633. /**
  7634. * The data cache on JS side.
  7635. * @returns the underlying data as a float array
  7636. */
  7637. getData(): Float32Array;
  7638. /**
  7639. * The underlying WebGL Uniform buffer.
  7640. * @returns the webgl buffer
  7641. */
  7642. getBuffer(): Nullable<DataBuffer>;
  7643. /**
  7644. * std140 layout specifies how to align data within an UBO structure.
  7645. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7646. * for specs.
  7647. */
  7648. private _fillAlignment;
  7649. /**
  7650. * Adds an uniform in the buffer.
  7651. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7652. * for the layout to be correct !
  7653. * @param name Name of the uniform, as used in the uniform block in the shader.
  7654. * @param size Data size, or data directly.
  7655. */
  7656. addUniform(name: string, size: number | number[]): void;
  7657. /**
  7658. * Adds a Matrix 4x4 to the uniform buffer.
  7659. * @param name Name of the uniform, as used in the uniform block in the shader.
  7660. * @param mat A 4x4 matrix.
  7661. */
  7662. addMatrix(name: string, mat: Matrix): void;
  7663. /**
  7664. * Adds a vec2 to the uniform buffer.
  7665. * @param name Name of the uniform, as used in the uniform block in the shader.
  7666. * @param x Define the x component value of the vec2
  7667. * @param y Define the y component value of the vec2
  7668. */
  7669. addFloat2(name: string, x: number, y: number): void;
  7670. /**
  7671. * Adds a vec3 to the uniform buffer.
  7672. * @param name Name of the uniform, as used in the uniform block in the shader.
  7673. * @param x Define the x component value of the vec3
  7674. * @param y Define the y component value of the vec3
  7675. * @param z Define the z component value of the vec3
  7676. */
  7677. addFloat3(name: string, x: number, y: number, z: number): void;
  7678. /**
  7679. * Adds a vec3 to the uniform buffer.
  7680. * @param name Name of the uniform, as used in the uniform block in the shader.
  7681. * @param color Define the vec3 from a Color
  7682. */
  7683. addColor3(name: string, color: Color3): void;
  7684. /**
  7685. * Adds a vec4 to the uniform buffer.
  7686. * @param name Name of the uniform, as used in the uniform block in the shader.
  7687. * @param color Define the rgb components from a Color
  7688. * @param alpha Define the a component of the vec4
  7689. */
  7690. addColor4(name: string, color: Color3, alpha: number): void;
  7691. /**
  7692. * Adds a vec3 to the uniform buffer.
  7693. * @param name Name of the uniform, as used in the uniform block in the shader.
  7694. * @param vector Define the vec3 components from a Vector
  7695. */
  7696. addVector3(name: string, vector: Vector3): void;
  7697. /**
  7698. * Adds a Matrix 3x3 to the uniform buffer.
  7699. * @param name Name of the uniform, as used in the uniform block in the shader.
  7700. */
  7701. addMatrix3x3(name: string): void;
  7702. /**
  7703. * Adds a Matrix 2x2 to the uniform buffer.
  7704. * @param name Name of the uniform, as used in the uniform block in the shader.
  7705. */
  7706. addMatrix2x2(name: string): void;
  7707. /**
  7708. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7709. */
  7710. create(): void;
  7711. /** @hidden */
  7712. _rebuild(): void;
  7713. /**
  7714. * Updates the WebGL Uniform Buffer on the GPU.
  7715. * If the `dynamic` flag is set to true, no cache comparison is done.
  7716. * Otherwise, the buffer will be updated only if the cache differs.
  7717. */
  7718. update(): void;
  7719. /**
  7720. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7721. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7722. * @param data Define the flattened data
  7723. * @param size Define the size of the data.
  7724. */
  7725. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7726. private _valueCache;
  7727. private _cacheMatrix;
  7728. private _updateMatrix3x3ForUniform;
  7729. private _updateMatrix3x3ForEffect;
  7730. private _updateMatrix2x2ForEffect;
  7731. private _updateMatrix2x2ForUniform;
  7732. private _updateFloatForEffect;
  7733. private _updateFloatForUniform;
  7734. private _updateFloat2ForEffect;
  7735. private _updateFloat2ForUniform;
  7736. private _updateFloat3ForEffect;
  7737. private _updateFloat3ForUniform;
  7738. private _updateFloat4ForEffect;
  7739. private _updateFloat4ForUniform;
  7740. private _updateMatrixForEffect;
  7741. private _updateMatrixForUniform;
  7742. private _updateVector3ForEffect;
  7743. private _updateVector3ForUniform;
  7744. private _updateVector4ForEffect;
  7745. private _updateVector4ForUniform;
  7746. private _updateColor3ForEffect;
  7747. private _updateColor3ForUniform;
  7748. private _updateColor4ForEffect;
  7749. private _updateColor4ForUniform;
  7750. /**
  7751. * Sets a sampler uniform on the effect.
  7752. * @param name Define the name of the sampler.
  7753. * @param texture Define the texture to set in the sampler
  7754. */
  7755. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7756. /**
  7757. * Directly updates the value of the uniform in the cache AND on the GPU.
  7758. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7759. * @param data Define the flattened data
  7760. */
  7761. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7762. /**
  7763. * Binds this uniform buffer to an effect.
  7764. * @param effect Define the effect to bind the buffer to
  7765. * @param name Name of the uniform block in the shader.
  7766. */
  7767. bindToEffect(effect: Effect, name: string): void;
  7768. /**
  7769. * Disposes the uniform buffer.
  7770. */
  7771. dispose(): void;
  7772. }
  7773. }
  7774. declare module "babylonjs/Misc/iInspectable" {
  7775. /**
  7776. * Enum that determines the text-wrapping mode to use.
  7777. */
  7778. export enum InspectableType {
  7779. /**
  7780. * Checkbox for booleans
  7781. */
  7782. Checkbox = 0,
  7783. /**
  7784. * Sliders for numbers
  7785. */
  7786. Slider = 1,
  7787. /**
  7788. * Vector3
  7789. */
  7790. Vector3 = 2,
  7791. /**
  7792. * Quaternions
  7793. */
  7794. Quaternion = 3,
  7795. /**
  7796. * Color3
  7797. */
  7798. Color3 = 4,
  7799. /**
  7800. * String
  7801. */
  7802. String = 5
  7803. }
  7804. /**
  7805. * Interface used to define custom inspectable properties.
  7806. * This interface is used by the inspector to display custom property grids
  7807. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7808. */
  7809. export interface IInspectable {
  7810. /**
  7811. * Gets the label to display
  7812. */
  7813. label: string;
  7814. /**
  7815. * Gets the name of the property to edit
  7816. */
  7817. propertyName: string;
  7818. /**
  7819. * Gets the type of the editor to use
  7820. */
  7821. type: InspectableType;
  7822. /**
  7823. * Gets the minimum value of the property when using in "slider" mode
  7824. */
  7825. min?: number;
  7826. /**
  7827. * Gets the maximum value of the property when using in "slider" mode
  7828. */
  7829. max?: number;
  7830. /**
  7831. * Gets the setp to use when using in "slider" mode
  7832. */
  7833. step?: number;
  7834. }
  7835. }
  7836. declare module "babylonjs/Misc/timingTools" {
  7837. /**
  7838. * Class used to provide helper for timing
  7839. */
  7840. export class TimingTools {
  7841. /**
  7842. * Polyfill for setImmediate
  7843. * @param action defines the action to execute after the current execution block
  7844. */
  7845. static SetImmediate(action: () => void): void;
  7846. }
  7847. }
  7848. declare module "babylonjs/Misc/instantiationTools" {
  7849. /**
  7850. * Class used to enable instatition of objects by class name
  7851. */
  7852. export class InstantiationTools {
  7853. /**
  7854. * Use this object to register external classes like custom textures or material
  7855. * to allow the laoders to instantiate them
  7856. */
  7857. static RegisteredExternalClasses: {
  7858. [key: string]: Object;
  7859. };
  7860. /**
  7861. * Tries to instantiate a new object from a given class name
  7862. * @param className defines the class name to instantiate
  7863. * @returns the new object or null if the system was not able to do the instantiation
  7864. */
  7865. static Instantiate(className: string): any;
  7866. }
  7867. }
  7868. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7869. /**
  7870. * Define options used to create a depth texture
  7871. */
  7872. export class DepthTextureCreationOptions {
  7873. /** Specifies whether or not a stencil should be allocated in the texture */
  7874. generateStencil?: boolean;
  7875. /** Specifies whether or not bilinear filtering is enable on the texture */
  7876. bilinearFiltering?: boolean;
  7877. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7878. comparisonFunction?: number;
  7879. /** Specifies if the created texture is a cube texture */
  7880. isCube?: boolean;
  7881. }
  7882. }
  7883. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7884. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7885. import { Nullable } from "babylonjs/types";
  7886. import { Scene } from "babylonjs/scene";
  7887. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7888. module "babylonjs/Engines/thinEngine" {
  7889. interface ThinEngine {
  7890. /**
  7891. * Creates a depth stencil cube texture.
  7892. * This is only available in WebGL 2.
  7893. * @param size The size of face edge in the cube texture.
  7894. * @param options The options defining the cube texture.
  7895. * @returns The cube texture
  7896. */
  7897. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7898. /**
  7899. * Creates a cube texture
  7900. * @param rootUrl defines the url where the files to load is located
  7901. * @param scene defines the current scene
  7902. * @param files defines the list of files to load (1 per face)
  7903. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7904. * @param onLoad defines an optional callback raised when the texture is loaded
  7905. * @param onError defines an optional callback raised if there is an issue to load the texture
  7906. * @param format defines the format of the data
  7907. * @param forcedExtension defines the extension to use to pick the right loader
  7908. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7909. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7910. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7911. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7912. * @param loaderOptions options to be passed to the loader
  7913. * @returns the cube texture as an InternalTexture
  7914. */
  7915. 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;
  7916. /**
  7917. * Creates a cube texture
  7918. * @param rootUrl defines the url where the files to load is located
  7919. * @param scene defines the current scene
  7920. * @param files defines the list of files to load (1 per face)
  7921. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7922. * @param onLoad defines an optional callback raised when the texture is loaded
  7923. * @param onError defines an optional callback raised if there is an issue to load the texture
  7924. * @param format defines the format of the data
  7925. * @param forcedExtension defines the extension to use to pick the right loader
  7926. * @returns the cube texture as an InternalTexture
  7927. */
  7928. 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;
  7929. /**
  7930. * Creates a cube texture
  7931. * @param rootUrl defines the url where the files to load is located
  7932. * @param scene defines the current scene
  7933. * @param files defines the list of files to load (1 per face)
  7934. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7935. * @param onLoad defines an optional callback raised when the texture is loaded
  7936. * @param onError defines an optional callback raised if there is an issue to load the texture
  7937. * @param format defines the format of the data
  7938. * @param forcedExtension defines the extension to use to pick the right loader
  7939. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7940. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7941. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7942. * @returns the cube texture as an InternalTexture
  7943. */
  7944. 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;
  7945. /** @hidden */
  7946. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7947. /** @hidden */
  7948. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7949. /** @hidden */
  7950. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7951. /** @hidden */
  7952. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7953. /**
  7954. * @hidden
  7955. */
  7956. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  7957. }
  7958. }
  7959. }
  7960. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7961. import { Nullable } from "babylonjs/types";
  7962. import { Scene } from "babylonjs/scene";
  7963. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7964. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7965. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7966. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7967. import { Observable } from "babylonjs/Misc/observable";
  7968. /**
  7969. * Class for creating a cube texture
  7970. */
  7971. export class CubeTexture extends BaseTexture {
  7972. private _delayedOnLoad;
  7973. /**
  7974. * Observable triggered once the texture has been loaded.
  7975. */
  7976. onLoadObservable: Observable<CubeTexture>;
  7977. /**
  7978. * The url of the texture
  7979. */
  7980. url: string;
  7981. /**
  7982. * Gets or sets the center of the bounding box associated with the cube texture.
  7983. * It must define where the camera used to render the texture was set
  7984. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7985. */
  7986. boundingBoxPosition: Vector3;
  7987. private _boundingBoxSize;
  7988. /**
  7989. * Gets or sets the size of the bounding box associated with the cube texture
  7990. * When defined, the cubemap will switch to local mode
  7991. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7992. * @example https://www.babylonjs-playground.com/#RNASML
  7993. */
  7994. set boundingBoxSize(value: Vector3);
  7995. /**
  7996. * Returns the bounding box size
  7997. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7998. */
  7999. get boundingBoxSize(): Vector3;
  8000. protected _rotationY: number;
  8001. /**
  8002. * Sets texture matrix rotation angle around Y axis in radians.
  8003. */
  8004. set rotationY(value: number);
  8005. /**
  8006. * Gets texture matrix rotation angle around Y axis radians.
  8007. */
  8008. get rotationY(): number;
  8009. /**
  8010. * Are mip maps generated for this texture or not.
  8011. */
  8012. get noMipmap(): boolean;
  8013. private _noMipmap;
  8014. private _files;
  8015. protected _forcedExtension: Nullable<string>;
  8016. private _extensions;
  8017. private _textureMatrix;
  8018. private _format;
  8019. private _createPolynomials;
  8020. private _loaderOptions;
  8021. /**
  8022. * Creates a cube texture from an array of image urls
  8023. * @param files defines an array of image urls
  8024. * @param scene defines the hosting scene
  8025. * @param noMipmap specifies if mip maps are not used
  8026. * @returns a cube texture
  8027. */
  8028. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8029. /**
  8030. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8031. * @param url defines the url of the prefiltered texture
  8032. * @param scene defines the scene the texture is attached to
  8033. * @param forcedExtension defines the extension of the file if different from the url
  8034. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8035. * @return the prefiltered texture
  8036. */
  8037. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8038. /**
  8039. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8040. * as prefiltered data.
  8041. * @param rootUrl defines the url of the texture or the root name of the six images
  8042. * @param null defines the scene or engine the texture is attached to
  8043. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8044. * @param noMipmap defines if mipmaps should be created or not
  8045. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8046. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8047. * @param onError defines a callback triggered in case of error during load
  8048. * @param format defines the internal format to use for the texture once loaded
  8049. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8050. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8051. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8052. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8053. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8054. * @param loaderOptions options to be passed to the loader
  8055. * @return the cube texture
  8056. */
  8057. 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);
  8058. /**
  8059. * Get the current class name of the texture useful for serialization or dynamic coding.
  8060. * @returns "CubeTexture"
  8061. */
  8062. getClassName(): string;
  8063. /**
  8064. * Update the url (and optional buffer) of this texture if url was null during construction.
  8065. * @param url the url of the texture
  8066. * @param forcedExtension defines the extension to use
  8067. * @param onLoad callback called when the texture is loaded (defaults to null)
  8068. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8069. */
  8070. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8071. /**
  8072. * Delays loading of the cube texture
  8073. * @param forcedExtension defines the extension to use
  8074. */
  8075. delayLoad(forcedExtension?: string): void;
  8076. /**
  8077. * Returns the reflection texture matrix
  8078. * @returns the reflection texture matrix
  8079. */
  8080. getReflectionTextureMatrix(): Matrix;
  8081. /**
  8082. * Sets the reflection texture matrix
  8083. * @param value Reflection texture matrix
  8084. */
  8085. setReflectionTextureMatrix(value: Matrix): void;
  8086. /**
  8087. * Parses text to create a cube texture
  8088. * @param parsedTexture define the serialized text to read from
  8089. * @param scene defines the hosting scene
  8090. * @param rootUrl defines the root url of the cube texture
  8091. * @returns a cube texture
  8092. */
  8093. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8094. /**
  8095. * Makes a clone, or deep copy, of the cube texture
  8096. * @returns a new cube texture
  8097. */
  8098. clone(): CubeTexture;
  8099. }
  8100. }
  8101. declare module "babylonjs/Materials/materialDefines" {
  8102. /**
  8103. * Manages the defines for the Material
  8104. */
  8105. export class MaterialDefines {
  8106. /** @hidden */
  8107. protected _keys: string[];
  8108. private _isDirty;
  8109. /** @hidden */
  8110. _renderId: number;
  8111. /** @hidden */
  8112. _areLightsDirty: boolean;
  8113. /** @hidden */
  8114. _areLightsDisposed: boolean;
  8115. /** @hidden */
  8116. _areAttributesDirty: boolean;
  8117. /** @hidden */
  8118. _areTexturesDirty: boolean;
  8119. /** @hidden */
  8120. _areFresnelDirty: boolean;
  8121. /** @hidden */
  8122. _areMiscDirty: boolean;
  8123. /** @hidden */
  8124. _arePrePassDirty: boolean;
  8125. /** @hidden */
  8126. _areImageProcessingDirty: boolean;
  8127. /** @hidden */
  8128. _normals: boolean;
  8129. /** @hidden */
  8130. _uvs: boolean;
  8131. /** @hidden */
  8132. _needNormals: boolean;
  8133. /** @hidden */
  8134. _needUVs: boolean;
  8135. [id: string]: any;
  8136. /**
  8137. * Specifies if the material needs to be re-calculated
  8138. */
  8139. get isDirty(): boolean;
  8140. /**
  8141. * Marks the material to indicate that it has been re-calculated
  8142. */
  8143. markAsProcessed(): void;
  8144. /**
  8145. * Marks the material to indicate that it needs to be re-calculated
  8146. */
  8147. markAsUnprocessed(): void;
  8148. /**
  8149. * Marks the material to indicate all of its defines need to be re-calculated
  8150. */
  8151. markAllAsDirty(): void;
  8152. /**
  8153. * Marks the material to indicate that image processing needs to be re-calculated
  8154. */
  8155. markAsImageProcessingDirty(): void;
  8156. /**
  8157. * Marks the material to indicate the lights need to be re-calculated
  8158. * @param disposed Defines whether the light is dirty due to dispose or not
  8159. */
  8160. markAsLightDirty(disposed?: boolean): void;
  8161. /**
  8162. * Marks the attribute state as changed
  8163. */
  8164. markAsAttributesDirty(): void;
  8165. /**
  8166. * Marks the texture state as changed
  8167. */
  8168. markAsTexturesDirty(): void;
  8169. /**
  8170. * Marks the fresnel state as changed
  8171. */
  8172. markAsFresnelDirty(): void;
  8173. /**
  8174. * Marks the misc state as changed
  8175. */
  8176. markAsMiscDirty(): void;
  8177. /**
  8178. * Marks the prepass state as changed
  8179. */
  8180. markAsPrePassDirty(): void;
  8181. /**
  8182. * Rebuilds the material defines
  8183. */
  8184. rebuild(): void;
  8185. /**
  8186. * Specifies if two material defines are equal
  8187. * @param other - A material define instance to compare to
  8188. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8189. */
  8190. isEqual(other: MaterialDefines): boolean;
  8191. /**
  8192. * Clones this instance's defines to another instance
  8193. * @param other - material defines to clone values to
  8194. */
  8195. cloneTo(other: MaterialDefines): void;
  8196. /**
  8197. * Resets the material define values
  8198. */
  8199. reset(): void;
  8200. /**
  8201. * Converts the material define values to a string
  8202. * @returns - String of material define information
  8203. */
  8204. toString(): string;
  8205. }
  8206. }
  8207. declare module "babylonjs/Materials/colorCurves" {
  8208. import { Effect } from "babylonjs/Materials/effect";
  8209. /**
  8210. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8211. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8212. * 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;
  8213. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8214. */
  8215. export class ColorCurves {
  8216. private _dirty;
  8217. private _tempColor;
  8218. private _globalCurve;
  8219. private _highlightsCurve;
  8220. private _midtonesCurve;
  8221. private _shadowsCurve;
  8222. private _positiveCurve;
  8223. private _negativeCurve;
  8224. private _globalHue;
  8225. private _globalDensity;
  8226. private _globalSaturation;
  8227. private _globalExposure;
  8228. /**
  8229. * Gets the global Hue value.
  8230. * 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).
  8231. */
  8232. get globalHue(): number;
  8233. /**
  8234. * Sets the global Hue value.
  8235. * 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).
  8236. */
  8237. set globalHue(value: number);
  8238. /**
  8239. * Gets the global Density value.
  8240. * 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.
  8241. * Values less than zero provide a filter of opposite hue.
  8242. */
  8243. get globalDensity(): number;
  8244. /**
  8245. * Sets the global Density value.
  8246. * 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.
  8247. * Values less than zero provide a filter of opposite hue.
  8248. */
  8249. set globalDensity(value: number);
  8250. /**
  8251. * Gets the global Saturation value.
  8252. * 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.
  8253. */
  8254. get globalSaturation(): number;
  8255. /**
  8256. * Sets the global Saturation value.
  8257. * 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.
  8258. */
  8259. set globalSaturation(value: number);
  8260. /**
  8261. * Gets the global Exposure value.
  8262. * 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.
  8263. */
  8264. get globalExposure(): number;
  8265. /**
  8266. * Sets the global Exposure value.
  8267. * 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.
  8268. */
  8269. set globalExposure(value: number);
  8270. private _highlightsHue;
  8271. private _highlightsDensity;
  8272. private _highlightsSaturation;
  8273. private _highlightsExposure;
  8274. /**
  8275. * Gets the highlights Hue value.
  8276. * 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).
  8277. */
  8278. get highlightsHue(): number;
  8279. /**
  8280. * Sets the highlights Hue value.
  8281. * 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).
  8282. */
  8283. set highlightsHue(value: number);
  8284. /**
  8285. * Gets the highlights Density value.
  8286. * 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.
  8287. * Values less than zero provide a filter of opposite hue.
  8288. */
  8289. get highlightsDensity(): number;
  8290. /**
  8291. * Sets the highlights Density value.
  8292. * 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.
  8293. * Values less than zero provide a filter of opposite hue.
  8294. */
  8295. set highlightsDensity(value: number);
  8296. /**
  8297. * Gets the highlights Saturation value.
  8298. * 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.
  8299. */
  8300. get highlightsSaturation(): number;
  8301. /**
  8302. * Sets the highlights Saturation value.
  8303. * 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.
  8304. */
  8305. set highlightsSaturation(value: number);
  8306. /**
  8307. * Gets the highlights Exposure value.
  8308. * 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.
  8309. */
  8310. get highlightsExposure(): number;
  8311. /**
  8312. * Sets the highlights Exposure value.
  8313. * 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.
  8314. */
  8315. set highlightsExposure(value: number);
  8316. private _midtonesHue;
  8317. private _midtonesDensity;
  8318. private _midtonesSaturation;
  8319. private _midtonesExposure;
  8320. /**
  8321. * Gets the midtones Hue value.
  8322. * 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).
  8323. */
  8324. get midtonesHue(): number;
  8325. /**
  8326. * Sets the midtones Hue value.
  8327. * 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).
  8328. */
  8329. set midtonesHue(value: number);
  8330. /**
  8331. * Gets the midtones Density value.
  8332. * 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.
  8333. * Values less than zero provide a filter of opposite hue.
  8334. */
  8335. get midtonesDensity(): number;
  8336. /**
  8337. * Sets the midtones Density value.
  8338. * 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.
  8339. * Values less than zero provide a filter of opposite hue.
  8340. */
  8341. set midtonesDensity(value: number);
  8342. /**
  8343. * Gets the midtones Saturation value.
  8344. * 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.
  8345. */
  8346. get midtonesSaturation(): number;
  8347. /**
  8348. * Sets the midtones Saturation value.
  8349. * 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.
  8350. */
  8351. set midtonesSaturation(value: number);
  8352. /**
  8353. * Gets the midtones Exposure value.
  8354. * 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.
  8355. */
  8356. get midtonesExposure(): number;
  8357. /**
  8358. * Sets the midtones Exposure value.
  8359. * 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.
  8360. */
  8361. set midtonesExposure(value: number);
  8362. private _shadowsHue;
  8363. private _shadowsDensity;
  8364. private _shadowsSaturation;
  8365. private _shadowsExposure;
  8366. /**
  8367. * Gets the shadows Hue value.
  8368. * 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).
  8369. */
  8370. get shadowsHue(): number;
  8371. /**
  8372. * Sets the shadows Hue value.
  8373. * 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).
  8374. */
  8375. set shadowsHue(value: number);
  8376. /**
  8377. * Gets the shadows Density value.
  8378. * 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.
  8379. * Values less than zero provide a filter of opposite hue.
  8380. */
  8381. get shadowsDensity(): number;
  8382. /**
  8383. * Sets the shadows Density value.
  8384. * 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.
  8385. * Values less than zero provide a filter of opposite hue.
  8386. */
  8387. set shadowsDensity(value: number);
  8388. /**
  8389. * Gets the shadows Saturation value.
  8390. * 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.
  8391. */
  8392. get shadowsSaturation(): number;
  8393. /**
  8394. * Sets the shadows Saturation value.
  8395. * 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.
  8396. */
  8397. set shadowsSaturation(value: number);
  8398. /**
  8399. * Gets the shadows Exposure value.
  8400. * 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.
  8401. */
  8402. get shadowsExposure(): number;
  8403. /**
  8404. * Sets the shadows Exposure value.
  8405. * 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.
  8406. */
  8407. set shadowsExposure(value: number);
  8408. /**
  8409. * Returns the class name
  8410. * @returns The class name
  8411. */
  8412. getClassName(): string;
  8413. /**
  8414. * Binds the color curves to the shader.
  8415. * @param colorCurves The color curve to bind
  8416. * @param effect The effect to bind to
  8417. * @param positiveUniform The positive uniform shader parameter
  8418. * @param neutralUniform The neutral uniform shader parameter
  8419. * @param negativeUniform The negative uniform shader parameter
  8420. */
  8421. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8422. /**
  8423. * Prepare the list of uniforms associated with the ColorCurves effects.
  8424. * @param uniformsList The list of uniforms used in the effect
  8425. */
  8426. static PrepareUniforms(uniformsList: string[]): void;
  8427. /**
  8428. * Returns color grading data based on a hue, density, saturation and exposure value.
  8429. * @param filterHue The hue of the color filter.
  8430. * @param filterDensity The density of the color filter.
  8431. * @param saturation The saturation.
  8432. * @param exposure The exposure.
  8433. * @param result The result data container.
  8434. */
  8435. private getColorGradingDataToRef;
  8436. /**
  8437. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8438. * @param value The input slider value in range [-100,100].
  8439. * @returns Adjusted value.
  8440. */
  8441. private static applyColorGradingSliderNonlinear;
  8442. /**
  8443. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8444. * @param hue The hue (H) input.
  8445. * @param saturation The saturation (S) input.
  8446. * @param brightness The brightness (B) input.
  8447. * @result An RGBA color represented as Vector4.
  8448. */
  8449. private static fromHSBToRef;
  8450. /**
  8451. * Returns a value clamped between min and max
  8452. * @param value The value to clamp
  8453. * @param min The minimum of value
  8454. * @param max The maximum of value
  8455. * @returns The clamped value.
  8456. */
  8457. private static clamp;
  8458. /**
  8459. * Clones the current color curve instance.
  8460. * @return The cloned curves
  8461. */
  8462. clone(): ColorCurves;
  8463. /**
  8464. * Serializes the current color curve instance to a json representation.
  8465. * @return a JSON representation
  8466. */
  8467. serialize(): any;
  8468. /**
  8469. * Parses the color curve from a json representation.
  8470. * @param source the JSON source to parse
  8471. * @return The parsed curves
  8472. */
  8473. static Parse(source: any): ColorCurves;
  8474. }
  8475. }
  8476. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8477. import { Observable } from "babylonjs/Misc/observable";
  8478. import { Nullable } from "babylonjs/types";
  8479. import { Color4 } from "babylonjs/Maths/math.color";
  8480. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8481. import { Effect } from "babylonjs/Materials/effect";
  8482. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8483. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8484. /**
  8485. * Interface to follow in your material defines to integrate easily the
  8486. * Image proccessing functions.
  8487. * @hidden
  8488. */
  8489. export interface IImageProcessingConfigurationDefines {
  8490. IMAGEPROCESSING: boolean;
  8491. VIGNETTE: boolean;
  8492. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8493. VIGNETTEBLENDMODEOPAQUE: boolean;
  8494. TONEMAPPING: boolean;
  8495. TONEMAPPING_ACES: boolean;
  8496. CONTRAST: boolean;
  8497. EXPOSURE: boolean;
  8498. COLORCURVES: boolean;
  8499. COLORGRADING: boolean;
  8500. COLORGRADING3D: boolean;
  8501. SAMPLER3DGREENDEPTH: boolean;
  8502. SAMPLER3DBGRMAP: boolean;
  8503. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8504. }
  8505. /**
  8506. * @hidden
  8507. */
  8508. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8509. IMAGEPROCESSING: boolean;
  8510. VIGNETTE: boolean;
  8511. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8512. VIGNETTEBLENDMODEOPAQUE: boolean;
  8513. TONEMAPPING: boolean;
  8514. TONEMAPPING_ACES: boolean;
  8515. CONTRAST: boolean;
  8516. COLORCURVES: boolean;
  8517. COLORGRADING: boolean;
  8518. COLORGRADING3D: boolean;
  8519. SAMPLER3DGREENDEPTH: boolean;
  8520. SAMPLER3DBGRMAP: boolean;
  8521. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8522. EXPOSURE: boolean;
  8523. constructor();
  8524. }
  8525. /**
  8526. * This groups together the common properties used for image processing either in direct forward pass
  8527. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8528. * or not.
  8529. */
  8530. export class ImageProcessingConfiguration {
  8531. /**
  8532. * Default tone mapping applied in BabylonJS.
  8533. */
  8534. static readonly TONEMAPPING_STANDARD: number;
  8535. /**
  8536. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8537. * to other engines rendering to increase portability.
  8538. */
  8539. static readonly TONEMAPPING_ACES: number;
  8540. /**
  8541. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8542. */
  8543. colorCurves: Nullable<ColorCurves>;
  8544. private _colorCurvesEnabled;
  8545. /**
  8546. * Gets wether the color curves effect is enabled.
  8547. */
  8548. get colorCurvesEnabled(): boolean;
  8549. /**
  8550. * Sets wether the color curves effect is enabled.
  8551. */
  8552. set colorCurvesEnabled(value: boolean);
  8553. private _colorGradingTexture;
  8554. /**
  8555. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8556. */
  8557. get colorGradingTexture(): Nullable<BaseTexture>;
  8558. /**
  8559. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8560. */
  8561. set colorGradingTexture(value: Nullable<BaseTexture>);
  8562. private _colorGradingEnabled;
  8563. /**
  8564. * Gets wether the color grading effect is enabled.
  8565. */
  8566. get colorGradingEnabled(): boolean;
  8567. /**
  8568. * Sets wether the color grading effect is enabled.
  8569. */
  8570. set colorGradingEnabled(value: boolean);
  8571. private _colorGradingWithGreenDepth;
  8572. /**
  8573. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8574. */
  8575. get colorGradingWithGreenDepth(): boolean;
  8576. /**
  8577. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8578. */
  8579. set colorGradingWithGreenDepth(value: boolean);
  8580. private _colorGradingBGR;
  8581. /**
  8582. * Gets wether the color grading texture contains BGR values.
  8583. */
  8584. get colorGradingBGR(): boolean;
  8585. /**
  8586. * Sets wether the color grading texture contains BGR values.
  8587. */
  8588. set colorGradingBGR(value: boolean);
  8589. /** @hidden */
  8590. _exposure: number;
  8591. /**
  8592. * Gets the Exposure used in the effect.
  8593. */
  8594. get exposure(): number;
  8595. /**
  8596. * Sets the Exposure used in the effect.
  8597. */
  8598. set exposure(value: number);
  8599. private _toneMappingEnabled;
  8600. /**
  8601. * Gets wether the tone mapping effect is enabled.
  8602. */
  8603. get toneMappingEnabled(): boolean;
  8604. /**
  8605. * Sets wether the tone mapping effect is enabled.
  8606. */
  8607. set toneMappingEnabled(value: boolean);
  8608. private _toneMappingType;
  8609. /**
  8610. * Gets the type of tone mapping effect.
  8611. */
  8612. get toneMappingType(): number;
  8613. /**
  8614. * Sets the type of tone mapping effect used in BabylonJS.
  8615. */
  8616. set toneMappingType(value: number);
  8617. protected _contrast: number;
  8618. /**
  8619. * Gets the contrast used in the effect.
  8620. */
  8621. get contrast(): number;
  8622. /**
  8623. * Sets the contrast used in the effect.
  8624. */
  8625. set contrast(value: number);
  8626. /**
  8627. * Vignette stretch size.
  8628. */
  8629. vignetteStretch: number;
  8630. /**
  8631. * Vignette centre X Offset.
  8632. */
  8633. vignetteCentreX: number;
  8634. /**
  8635. * Vignette centre Y Offset.
  8636. */
  8637. vignetteCentreY: number;
  8638. /**
  8639. * Vignette weight or intensity of the vignette effect.
  8640. */
  8641. vignetteWeight: number;
  8642. /**
  8643. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8644. * if vignetteEnabled is set to true.
  8645. */
  8646. vignetteColor: Color4;
  8647. /**
  8648. * Camera field of view used by the Vignette effect.
  8649. */
  8650. vignetteCameraFov: number;
  8651. private _vignetteBlendMode;
  8652. /**
  8653. * Gets the vignette blend mode allowing different kind of effect.
  8654. */
  8655. get vignetteBlendMode(): number;
  8656. /**
  8657. * Sets the vignette blend mode allowing different kind of effect.
  8658. */
  8659. set vignetteBlendMode(value: number);
  8660. private _vignetteEnabled;
  8661. /**
  8662. * Gets wether the vignette effect is enabled.
  8663. */
  8664. get vignetteEnabled(): boolean;
  8665. /**
  8666. * Sets wether the vignette effect is enabled.
  8667. */
  8668. set vignetteEnabled(value: boolean);
  8669. private _applyByPostProcess;
  8670. /**
  8671. * Gets wether the image processing is applied through a post process or not.
  8672. */
  8673. get applyByPostProcess(): boolean;
  8674. /**
  8675. * Sets wether the image processing is applied through a post process or not.
  8676. */
  8677. set applyByPostProcess(value: boolean);
  8678. private _isEnabled;
  8679. /**
  8680. * Gets wether the image processing is enabled or not.
  8681. */
  8682. get isEnabled(): boolean;
  8683. /**
  8684. * Sets wether the image processing is enabled or not.
  8685. */
  8686. set isEnabled(value: boolean);
  8687. /**
  8688. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8689. */
  8690. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8691. /**
  8692. * Method called each time the image processing information changes requires to recompile the effect.
  8693. */
  8694. protected _updateParameters(): void;
  8695. /**
  8696. * Gets the current class name.
  8697. * @return "ImageProcessingConfiguration"
  8698. */
  8699. getClassName(): string;
  8700. /**
  8701. * Prepare the list of uniforms associated with the Image Processing effects.
  8702. * @param uniforms The list of uniforms used in the effect
  8703. * @param defines the list of defines currently in use
  8704. */
  8705. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8706. /**
  8707. * Prepare the list of samplers associated with the Image Processing effects.
  8708. * @param samplersList The list of uniforms used in the effect
  8709. * @param defines the list of defines currently in use
  8710. */
  8711. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8712. /**
  8713. * Prepare the list of defines associated to the shader.
  8714. * @param defines the list of defines to complete
  8715. * @param forPostProcess Define if we are currently in post process mode or not
  8716. */
  8717. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8718. /**
  8719. * Returns true if all the image processing information are ready.
  8720. * @returns True if ready, otherwise, false
  8721. */
  8722. isReady(): boolean;
  8723. /**
  8724. * Binds the image processing to the shader.
  8725. * @param effect The effect to bind to
  8726. * @param overrideAspectRatio Override the aspect ratio of the effect
  8727. */
  8728. bind(effect: Effect, overrideAspectRatio?: number): void;
  8729. /**
  8730. * Clones the current image processing instance.
  8731. * @return The cloned image processing
  8732. */
  8733. clone(): ImageProcessingConfiguration;
  8734. /**
  8735. * Serializes the current image processing instance to a json representation.
  8736. * @return a JSON representation
  8737. */
  8738. serialize(): any;
  8739. /**
  8740. * Parses the image processing from a json representation.
  8741. * @param source the JSON source to parse
  8742. * @return The parsed image processing
  8743. */
  8744. static Parse(source: any): ImageProcessingConfiguration;
  8745. private static _VIGNETTEMODE_MULTIPLY;
  8746. private static _VIGNETTEMODE_OPAQUE;
  8747. /**
  8748. * Used to apply the vignette as a mix with the pixel color.
  8749. */
  8750. static get VIGNETTEMODE_MULTIPLY(): number;
  8751. /**
  8752. * Used to apply the vignette as a replacement of the pixel color.
  8753. */
  8754. static get VIGNETTEMODE_OPAQUE(): number;
  8755. }
  8756. }
  8757. declare module "babylonjs/Shaders/postprocess.vertex" {
  8758. /** @hidden */
  8759. export var postprocessVertexShader: {
  8760. name: string;
  8761. shader: string;
  8762. };
  8763. }
  8764. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8765. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8766. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8767. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8768. /**
  8769. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8770. */
  8771. export type RenderTargetTextureSize = number | {
  8772. width: number;
  8773. height: number;
  8774. layers?: number;
  8775. };
  8776. module "babylonjs/Engines/thinEngine" {
  8777. interface ThinEngine {
  8778. /**
  8779. * Creates a new render target texture
  8780. * @param size defines the size of the texture
  8781. * @param options defines the options used to create the texture
  8782. * @returns a new render target texture stored in an InternalTexture
  8783. */
  8784. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8785. /**
  8786. * Creates a depth stencil texture.
  8787. * This is only available in WebGL 2 or with the depth texture extension available.
  8788. * @param size The size of face edge in the texture.
  8789. * @param options The options defining the texture.
  8790. * @returns The texture
  8791. */
  8792. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8793. /** @hidden */
  8794. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8795. }
  8796. }
  8797. }
  8798. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8799. /**
  8800. * Defines the kind of connection point for node based material
  8801. */
  8802. export enum NodeMaterialBlockConnectionPointTypes {
  8803. /** Float */
  8804. Float = 1,
  8805. /** Int */
  8806. Int = 2,
  8807. /** Vector2 */
  8808. Vector2 = 4,
  8809. /** Vector3 */
  8810. Vector3 = 8,
  8811. /** Vector4 */
  8812. Vector4 = 16,
  8813. /** Color3 */
  8814. Color3 = 32,
  8815. /** Color4 */
  8816. Color4 = 64,
  8817. /** Matrix */
  8818. Matrix = 128,
  8819. /** Custom object */
  8820. Object = 256,
  8821. /** Detect type based on connection */
  8822. AutoDetect = 1024,
  8823. /** Output type that will be defined by input type */
  8824. BasedOnInput = 2048
  8825. }
  8826. }
  8827. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8828. /**
  8829. * Enum used to define the target of a block
  8830. */
  8831. export enum NodeMaterialBlockTargets {
  8832. /** Vertex shader */
  8833. Vertex = 1,
  8834. /** Fragment shader */
  8835. Fragment = 2,
  8836. /** Neutral */
  8837. Neutral = 4,
  8838. /** Vertex and Fragment */
  8839. VertexAndFragment = 3
  8840. }
  8841. }
  8842. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8843. /**
  8844. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8845. */
  8846. export enum NodeMaterialBlockConnectionPointMode {
  8847. /** Value is an uniform */
  8848. Uniform = 0,
  8849. /** Value is a mesh attribute */
  8850. Attribute = 1,
  8851. /** Value is a varying between vertex and fragment shaders */
  8852. Varying = 2,
  8853. /** Mode is undefined */
  8854. Undefined = 3
  8855. }
  8856. }
  8857. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8858. /**
  8859. * Enum used to define system values e.g. values automatically provided by the system
  8860. */
  8861. export enum NodeMaterialSystemValues {
  8862. /** World */
  8863. World = 1,
  8864. /** View */
  8865. View = 2,
  8866. /** Projection */
  8867. Projection = 3,
  8868. /** ViewProjection */
  8869. ViewProjection = 4,
  8870. /** WorldView */
  8871. WorldView = 5,
  8872. /** WorldViewProjection */
  8873. WorldViewProjection = 6,
  8874. /** CameraPosition */
  8875. CameraPosition = 7,
  8876. /** Fog Color */
  8877. FogColor = 8,
  8878. /** Delta time */
  8879. DeltaTime = 9
  8880. }
  8881. }
  8882. declare module "babylonjs/Maths/math.axis" {
  8883. import { Vector3 } from "babylonjs/Maths/math.vector";
  8884. /** Defines supported spaces */
  8885. export enum Space {
  8886. /** Local (object) space */
  8887. LOCAL = 0,
  8888. /** World space */
  8889. WORLD = 1,
  8890. /** Bone space */
  8891. BONE = 2
  8892. }
  8893. /** Defines the 3 main axes */
  8894. export class Axis {
  8895. /** X axis */
  8896. static X: Vector3;
  8897. /** Y axis */
  8898. static Y: Vector3;
  8899. /** Z axis */
  8900. static Z: Vector3;
  8901. }
  8902. /**
  8903. * Defines cartesian components.
  8904. */
  8905. export enum Coordinate {
  8906. /** X axis */
  8907. X = 0,
  8908. /** Y axis */
  8909. Y = 1,
  8910. /** Z axis */
  8911. Z = 2
  8912. }
  8913. }
  8914. declare module "babylonjs/Maths/math.frustum" {
  8915. import { Matrix } from "babylonjs/Maths/math.vector";
  8916. import { DeepImmutable } from "babylonjs/types";
  8917. import { Plane } from "babylonjs/Maths/math.plane";
  8918. /**
  8919. * Represents a camera frustum
  8920. */
  8921. export class Frustum {
  8922. /**
  8923. * Gets the planes representing the frustum
  8924. * @param transform matrix to be applied to the returned planes
  8925. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8926. */
  8927. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8928. /**
  8929. * Gets the near frustum plane transformed by the transform matrix
  8930. * @param transform transformation matrix to be applied to the resulting frustum plane
  8931. * @param frustumPlane the resuling frustum plane
  8932. */
  8933. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8934. /**
  8935. * Gets the far frustum plane transformed by the transform matrix
  8936. * @param transform transformation matrix to be applied to the resulting frustum plane
  8937. * @param frustumPlane the resuling frustum plane
  8938. */
  8939. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8940. /**
  8941. * Gets the left frustum plane transformed by the transform matrix
  8942. * @param transform transformation matrix to be applied to the resulting frustum plane
  8943. * @param frustumPlane the resuling frustum plane
  8944. */
  8945. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8946. /**
  8947. * Gets the right frustum plane transformed by the transform matrix
  8948. * @param transform transformation matrix to be applied to the resulting frustum plane
  8949. * @param frustumPlane the resuling frustum plane
  8950. */
  8951. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8952. /**
  8953. * Gets the top frustum plane transformed by the transform matrix
  8954. * @param transform transformation matrix to be applied to the resulting frustum plane
  8955. * @param frustumPlane the resuling frustum plane
  8956. */
  8957. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8958. /**
  8959. * Gets the bottom frustum plane transformed by the transform matrix
  8960. * @param transform transformation matrix to be applied to the resulting frustum plane
  8961. * @param frustumPlane the resuling frustum plane
  8962. */
  8963. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8964. /**
  8965. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8966. * @param transform transformation matrix to be applied to the resulting frustum planes
  8967. * @param frustumPlanes the resuling frustum planes
  8968. */
  8969. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8970. }
  8971. }
  8972. declare module "babylonjs/Maths/math.size" {
  8973. /**
  8974. * Interface for the size containing width and height
  8975. */
  8976. export interface ISize {
  8977. /**
  8978. * Width
  8979. */
  8980. width: number;
  8981. /**
  8982. * Heighht
  8983. */
  8984. height: number;
  8985. }
  8986. /**
  8987. * Size containing widht and height
  8988. */
  8989. export class Size implements ISize {
  8990. /**
  8991. * Width
  8992. */
  8993. width: number;
  8994. /**
  8995. * Height
  8996. */
  8997. height: number;
  8998. /**
  8999. * Creates a Size object from the given width and height (floats).
  9000. * @param width width of the new size
  9001. * @param height height of the new size
  9002. */
  9003. constructor(width: number, height: number);
  9004. /**
  9005. * Returns a string with the Size width and height
  9006. * @returns a string with the Size width and height
  9007. */
  9008. toString(): string;
  9009. /**
  9010. * "Size"
  9011. * @returns the string "Size"
  9012. */
  9013. getClassName(): string;
  9014. /**
  9015. * Returns the Size hash code.
  9016. * @returns a hash code for a unique width and height
  9017. */
  9018. getHashCode(): number;
  9019. /**
  9020. * Updates the current size from the given one.
  9021. * @param src the given size
  9022. */
  9023. copyFrom(src: Size): void;
  9024. /**
  9025. * Updates in place the current Size from the given floats.
  9026. * @param width width of the new size
  9027. * @param height height of the new size
  9028. * @returns the updated Size.
  9029. */
  9030. copyFromFloats(width: number, height: number): Size;
  9031. /**
  9032. * Updates in place the current Size from the given floats.
  9033. * @param width width to set
  9034. * @param height height to set
  9035. * @returns the updated Size.
  9036. */
  9037. set(width: number, height: number): Size;
  9038. /**
  9039. * Multiplies the width and height by numbers
  9040. * @param w factor to multiple the width by
  9041. * @param h factor to multiple the height by
  9042. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9043. */
  9044. multiplyByFloats(w: number, h: number): Size;
  9045. /**
  9046. * Clones the size
  9047. * @returns a new Size copied from the given one.
  9048. */
  9049. clone(): Size;
  9050. /**
  9051. * True if the current Size and the given one width and height are strictly equal.
  9052. * @param other the other size to compare against
  9053. * @returns True if the current Size and the given one width and height are strictly equal.
  9054. */
  9055. equals(other: Size): boolean;
  9056. /**
  9057. * The surface of the Size : width * height (float).
  9058. */
  9059. get surface(): number;
  9060. /**
  9061. * Create a new size of zero
  9062. * @returns a new Size set to (0.0, 0.0)
  9063. */
  9064. static Zero(): Size;
  9065. /**
  9066. * Sums the width and height of two sizes
  9067. * @param otherSize size to add to this size
  9068. * @returns a new Size set as the addition result of the current Size and the given one.
  9069. */
  9070. add(otherSize: Size): Size;
  9071. /**
  9072. * Subtracts the width and height of two
  9073. * @param otherSize size to subtract to this size
  9074. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9075. */
  9076. subtract(otherSize: Size): Size;
  9077. /**
  9078. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9079. * @param start starting size to lerp between
  9080. * @param end end size to lerp between
  9081. * @param amount amount to lerp between the start and end values
  9082. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9083. */
  9084. static Lerp(start: Size, end: Size, amount: number): Size;
  9085. }
  9086. }
  9087. declare module "babylonjs/Maths/math.vertexFormat" {
  9088. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9089. /**
  9090. * Contains position and normal vectors for a vertex
  9091. */
  9092. export class PositionNormalVertex {
  9093. /** the position of the vertex (defaut: 0,0,0) */
  9094. position: Vector3;
  9095. /** the normal of the vertex (defaut: 0,1,0) */
  9096. normal: Vector3;
  9097. /**
  9098. * Creates a PositionNormalVertex
  9099. * @param position the position of the vertex (defaut: 0,0,0)
  9100. * @param normal the normal of the vertex (defaut: 0,1,0)
  9101. */
  9102. constructor(
  9103. /** the position of the vertex (defaut: 0,0,0) */
  9104. position?: Vector3,
  9105. /** the normal of the vertex (defaut: 0,1,0) */
  9106. normal?: Vector3);
  9107. /**
  9108. * Clones the PositionNormalVertex
  9109. * @returns the cloned PositionNormalVertex
  9110. */
  9111. clone(): PositionNormalVertex;
  9112. }
  9113. /**
  9114. * Contains position, normal and uv vectors for a vertex
  9115. */
  9116. export class PositionNormalTextureVertex {
  9117. /** the position of the vertex (defaut: 0,0,0) */
  9118. position: Vector3;
  9119. /** the normal of the vertex (defaut: 0,1,0) */
  9120. normal: Vector3;
  9121. /** the uv of the vertex (default: 0,0) */
  9122. uv: Vector2;
  9123. /**
  9124. * Creates a PositionNormalTextureVertex
  9125. * @param position the position of the vertex (defaut: 0,0,0)
  9126. * @param normal the normal of the vertex (defaut: 0,1,0)
  9127. * @param uv the uv of the vertex (default: 0,0)
  9128. */
  9129. constructor(
  9130. /** the position of the vertex (defaut: 0,0,0) */
  9131. position?: Vector3,
  9132. /** the normal of the vertex (defaut: 0,1,0) */
  9133. normal?: Vector3,
  9134. /** the uv of the vertex (default: 0,0) */
  9135. uv?: Vector2);
  9136. /**
  9137. * Clones the PositionNormalTextureVertex
  9138. * @returns the cloned PositionNormalTextureVertex
  9139. */
  9140. clone(): PositionNormalTextureVertex;
  9141. }
  9142. }
  9143. declare module "babylonjs/Maths/math" {
  9144. export * from "babylonjs/Maths/math.axis";
  9145. export * from "babylonjs/Maths/math.color";
  9146. export * from "babylonjs/Maths/math.constants";
  9147. export * from "babylonjs/Maths/math.frustum";
  9148. export * from "babylonjs/Maths/math.path";
  9149. export * from "babylonjs/Maths/math.plane";
  9150. export * from "babylonjs/Maths/math.size";
  9151. export * from "babylonjs/Maths/math.vector";
  9152. export * from "babylonjs/Maths/math.vertexFormat";
  9153. export * from "babylonjs/Maths/math.viewport";
  9154. }
  9155. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9156. /**
  9157. * Enum defining the type of animations supported by InputBlock
  9158. */
  9159. export enum AnimatedInputBlockTypes {
  9160. /** No animation */
  9161. None = 0,
  9162. /** Time based animation. Will only work for floats */
  9163. Time = 1
  9164. }
  9165. }
  9166. declare module "babylonjs/Lights/shadowLight" {
  9167. import { Camera } from "babylonjs/Cameras/camera";
  9168. import { Scene } from "babylonjs/scene";
  9169. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9171. import { Light } from "babylonjs/Lights/light";
  9172. /**
  9173. * Interface describing all the common properties and methods a shadow light needs to implement.
  9174. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9175. * as well as binding the different shadow properties to the effects.
  9176. */
  9177. export interface IShadowLight extends Light {
  9178. /**
  9179. * The light id in the scene (used in scene.findLighById for instance)
  9180. */
  9181. id: string;
  9182. /**
  9183. * The position the shdow will be casted from.
  9184. */
  9185. position: Vector3;
  9186. /**
  9187. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9188. */
  9189. direction: Vector3;
  9190. /**
  9191. * The transformed position. Position of the light in world space taking parenting in account.
  9192. */
  9193. transformedPosition: Vector3;
  9194. /**
  9195. * The transformed direction. Direction of the light in world space taking parenting in account.
  9196. */
  9197. transformedDirection: Vector3;
  9198. /**
  9199. * The friendly name of the light in the scene.
  9200. */
  9201. name: string;
  9202. /**
  9203. * Defines the shadow projection clipping minimum z value.
  9204. */
  9205. shadowMinZ: number;
  9206. /**
  9207. * Defines the shadow projection clipping maximum z value.
  9208. */
  9209. shadowMaxZ: number;
  9210. /**
  9211. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9212. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9213. */
  9214. computeTransformedInformation(): boolean;
  9215. /**
  9216. * Gets the scene the light belongs to.
  9217. * @returns The scene
  9218. */
  9219. getScene(): Scene;
  9220. /**
  9221. * Callback defining a custom Projection Matrix Builder.
  9222. * This can be used to override the default projection matrix computation.
  9223. */
  9224. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9225. /**
  9226. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9227. * @param matrix The materix to updated with the projection information
  9228. * @param viewMatrix The transform matrix of the light
  9229. * @param renderList The list of mesh to render in the map
  9230. * @returns The current light
  9231. */
  9232. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9233. /**
  9234. * Gets the current depth scale used in ESM.
  9235. * @returns The scale
  9236. */
  9237. getDepthScale(): number;
  9238. /**
  9239. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9240. * @returns true if a cube texture needs to be use
  9241. */
  9242. needCube(): boolean;
  9243. /**
  9244. * Detects if the projection matrix requires to be recomputed this frame.
  9245. * @returns true if it requires to be recomputed otherwise, false.
  9246. */
  9247. needProjectionMatrixCompute(): boolean;
  9248. /**
  9249. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9250. */
  9251. forceProjectionMatrixCompute(): void;
  9252. /**
  9253. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9254. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9255. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9256. */
  9257. getShadowDirection(faceIndex?: number): Vector3;
  9258. /**
  9259. * Gets the minZ used for shadow according to both the scene and the light.
  9260. * @param activeCamera The camera we are returning the min for
  9261. * @returns the depth min z
  9262. */
  9263. getDepthMinZ(activeCamera: Camera): number;
  9264. /**
  9265. * Gets the maxZ used for shadow according to both the scene and the light.
  9266. * @param activeCamera The camera we are returning the max for
  9267. * @returns the depth max z
  9268. */
  9269. getDepthMaxZ(activeCamera: Camera): number;
  9270. }
  9271. /**
  9272. * Base implementation IShadowLight
  9273. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9274. */
  9275. export abstract class ShadowLight extends Light implements IShadowLight {
  9276. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9277. protected _position: Vector3;
  9278. protected _setPosition(value: Vector3): void;
  9279. /**
  9280. * Sets the position the shadow will be casted from. Also use as the light position for both
  9281. * point and spot lights.
  9282. */
  9283. get position(): Vector3;
  9284. /**
  9285. * Sets the position the shadow will be casted from. Also use as the light position for both
  9286. * point and spot lights.
  9287. */
  9288. set position(value: Vector3);
  9289. protected _direction: Vector3;
  9290. protected _setDirection(value: Vector3): void;
  9291. /**
  9292. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9293. * Also use as the light direction on spot and directional lights.
  9294. */
  9295. get direction(): Vector3;
  9296. /**
  9297. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9298. * Also use as the light direction on spot and directional lights.
  9299. */
  9300. set direction(value: Vector3);
  9301. protected _shadowMinZ: number;
  9302. /**
  9303. * Gets the shadow projection clipping minimum z value.
  9304. */
  9305. get shadowMinZ(): number;
  9306. /**
  9307. * Sets the shadow projection clipping minimum z value.
  9308. */
  9309. set shadowMinZ(value: number);
  9310. protected _shadowMaxZ: number;
  9311. /**
  9312. * Sets the shadow projection clipping maximum z value.
  9313. */
  9314. get shadowMaxZ(): number;
  9315. /**
  9316. * Gets the shadow projection clipping maximum z value.
  9317. */
  9318. set shadowMaxZ(value: number);
  9319. /**
  9320. * Callback defining a custom Projection Matrix Builder.
  9321. * This can be used to override the default projection matrix computation.
  9322. */
  9323. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9324. /**
  9325. * The transformed position. Position of the light in world space taking parenting in account.
  9326. */
  9327. transformedPosition: Vector3;
  9328. /**
  9329. * The transformed direction. Direction of the light in world space taking parenting in account.
  9330. */
  9331. transformedDirection: Vector3;
  9332. private _needProjectionMatrixCompute;
  9333. /**
  9334. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9335. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9336. */
  9337. computeTransformedInformation(): boolean;
  9338. /**
  9339. * Return the depth scale used for the shadow map.
  9340. * @returns the depth scale.
  9341. */
  9342. getDepthScale(): number;
  9343. /**
  9344. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9345. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9346. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9347. */
  9348. getShadowDirection(faceIndex?: number): Vector3;
  9349. /**
  9350. * Returns the ShadowLight absolute position in the World.
  9351. * @returns the position vector in world space
  9352. */
  9353. getAbsolutePosition(): Vector3;
  9354. /**
  9355. * Sets the ShadowLight direction toward the passed target.
  9356. * @param target The point to target in local space
  9357. * @returns the updated ShadowLight direction
  9358. */
  9359. setDirectionToTarget(target: Vector3): Vector3;
  9360. /**
  9361. * Returns the light rotation in euler definition.
  9362. * @returns the x y z rotation in local space.
  9363. */
  9364. getRotation(): Vector3;
  9365. /**
  9366. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9367. * @returns true if a cube texture needs to be use
  9368. */
  9369. needCube(): boolean;
  9370. /**
  9371. * Detects if the projection matrix requires to be recomputed this frame.
  9372. * @returns true if it requires to be recomputed otherwise, false.
  9373. */
  9374. needProjectionMatrixCompute(): boolean;
  9375. /**
  9376. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9377. */
  9378. forceProjectionMatrixCompute(): void;
  9379. /** @hidden */
  9380. _initCache(): void;
  9381. /** @hidden */
  9382. _isSynchronized(): boolean;
  9383. /**
  9384. * Computes the world matrix of the node
  9385. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9386. * @returns the world matrix
  9387. */
  9388. computeWorldMatrix(force?: boolean): Matrix;
  9389. /**
  9390. * Gets the minZ used for shadow according to both the scene and the light.
  9391. * @param activeCamera The camera we are returning the min for
  9392. * @returns the depth min z
  9393. */
  9394. getDepthMinZ(activeCamera: Camera): number;
  9395. /**
  9396. * Gets the maxZ used for shadow according to both the scene and the light.
  9397. * @param activeCamera The camera we are returning the max for
  9398. * @returns the depth max z
  9399. */
  9400. getDepthMaxZ(activeCamera: Camera): number;
  9401. /**
  9402. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9403. * @param matrix The materix to updated with the projection information
  9404. * @param viewMatrix The transform matrix of the light
  9405. * @param renderList The list of mesh to render in the map
  9406. * @returns The current light
  9407. */
  9408. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9409. }
  9410. }
  9411. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9412. /** @hidden */
  9413. export var packingFunctions: {
  9414. name: string;
  9415. shader: string;
  9416. };
  9417. }
  9418. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9419. /** @hidden */
  9420. export var bayerDitherFunctions: {
  9421. name: string;
  9422. shader: string;
  9423. };
  9424. }
  9425. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9426. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9427. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9428. /** @hidden */
  9429. export var shadowMapFragmentDeclaration: {
  9430. name: string;
  9431. shader: string;
  9432. };
  9433. }
  9434. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9435. /** @hidden */
  9436. export var clipPlaneFragmentDeclaration: {
  9437. name: string;
  9438. shader: string;
  9439. };
  9440. }
  9441. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9442. /** @hidden */
  9443. export var clipPlaneFragment: {
  9444. name: string;
  9445. shader: string;
  9446. };
  9447. }
  9448. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9449. /** @hidden */
  9450. export var shadowMapFragment: {
  9451. name: string;
  9452. shader: string;
  9453. };
  9454. }
  9455. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9456. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9457. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9458. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9459. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9460. /** @hidden */
  9461. export var shadowMapPixelShader: {
  9462. name: string;
  9463. shader: string;
  9464. };
  9465. }
  9466. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9467. /** @hidden */
  9468. export var bonesDeclaration: {
  9469. name: string;
  9470. shader: string;
  9471. };
  9472. }
  9473. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9474. /** @hidden */
  9475. export var morphTargetsVertexGlobalDeclaration: {
  9476. name: string;
  9477. shader: string;
  9478. };
  9479. }
  9480. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9481. /** @hidden */
  9482. export var morphTargetsVertexDeclaration: {
  9483. name: string;
  9484. shader: string;
  9485. };
  9486. }
  9487. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9488. /** @hidden */
  9489. export var instancesDeclaration: {
  9490. name: string;
  9491. shader: string;
  9492. };
  9493. }
  9494. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9495. /** @hidden */
  9496. export var helperFunctions: {
  9497. name: string;
  9498. shader: string;
  9499. };
  9500. }
  9501. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9502. /** @hidden */
  9503. export var shadowMapVertexDeclaration: {
  9504. name: string;
  9505. shader: string;
  9506. };
  9507. }
  9508. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9509. /** @hidden */
  9510. export var clipPlaneVertexDeclaration: {
  9511. name: string;
  9512. shader: string;
  9513. };
  9514. }
  9515. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9516. /** @hidden */
  9517. export var morphTargetsVertex: {
  9518. name: string;
  9519. shader: string;
  9520. };
  9521. }
  9522. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9523. /** @hidden */
  9524. export var instancesVertex: {
  9525. name: string;
  9526. shader: string;
  9527. };
  9528. }
  9529. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9530. /** @hidden */
  9531. export var bonesVertex: {
  9532. name: string;
  9533. shader: string;
  9534. };
  9535. }
  9536. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9537. /** @hidden */
  9538. export var shadowMapVertexNormalBias: {
  9539. name: string;
  9540. shader: string;
  9541. };
  9542. }
  9543. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9544. /** @hidden */
  9545. export var shadowMapVertexMetric: {
  9546. name: string;
  9547. shader: string;
  9548. };
  9549. }
  9550. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9551. /** @hidden */
  9552. export var clipPlaneVertex: {
  9553. name: string;
  9554. shader: string;
  9555. };
  9556. }
  9557. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9558. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9559. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9560. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9561. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9562. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9563. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9564. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9565. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9566. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9567. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9568. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9569. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9570. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9571. /** @hidden */
  9572. export var shadowMapVertexShader: {
  9573. name: string;
  9574. shader: string;
  9575. };
  9576. }
  9577. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9578. /** @hidden */
  9579. export var depthBoxBlurPixelShader: {
  9580. name: string;
  9581. shader: string;
  9582. };
  9583. }
  9584. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9585. /** @hidden */
  9586. export var shadowMapFragmentSoftTransparentShadow: {
  9587. name: string;
  9588. shader: string;
  9589. };
  9590. }
  9591. declare module "babylonjs/Materials/effectFallbacks" {
  9592. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9593. import { Effect } from "babylonjs/Materials/effect";
  9594. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9595. /**
  9596. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9597. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9598. */
  9599. export class EffectFallbacks implements IEffectFallbacks {
  9600. private _defines;
  9601. private _currentRank;
  9602. private _maxRank;
  9603. private _mesh;
  9604. /**
  9605. * Removes the fallback from the bound mesh.
  9606. */
  9607. unBindMesh(): void;
  9608. /**
  9609. * Adds a fallback on the specified property.
  9610. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9611. * @param define The name of the define in the shader
  9612. */
  9613. addFallback(rank: number, define: string): void;
  9614. /**
  9615. * Sets the mesh to use CPU skinning when needing to fallback.
  9616. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9617. * @param mesh The mesh to use the fallbacks.
  9618. */
  9619. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9620. /**
  9621. * Checks to see if more fallbacks are still availible.
  9622. */
  9623. get hasMoreFallbacks(): boolean;
  9624. /**
  9625. * Removes the defines that should be removed when falling back.
  9626. * @param currentDefines defines the current define statements for the shader.
  9627. * @param effect defines the current effect we try to compile
  9628. * @returns The resulting defines with defines of the current rank removed.
  9629. */
  9630. reduce(currentDefines: string, effect: Effect): string;
  9631. }
  9632. }
  9633. declare module "babylonjs/Actions/action" {
  9634. import { Observable } from "babylonjs/Misc/observable";
  9635. import { Condition } from "babylonjs/Actions/condition";
  9636. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9637. import { Nullable } from "babylonjs/types";
  9638. import { Scene } from "babylonjs/scene";
  9639. import { ActionManager } from "babylonjs/Actions/actionManager";
  9640. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9641. import { Node } from "babylonjs/node";
  9642. /**
  9643. * Interface used to define Action
  9644. */
  9645. export interface IAction {
  9646. /**
  9647. * Trigger for the action
  9648. */
  9649. trigger: number;
  9650. /** Options of the trigger */
  9651. triggerOptions: any;
  9652. /**
  9653. * Gets the trigger parameters
  9654. * @returns the trigger parameters
  9655. */
  9656. getTriggerParameter(): any;
  9657. /**
  9658. * Internal only - executes current action event
  9659. * @hidden
  9660. */
  9661. _executeCurrent(evt?: ActionEvent): void;
  9662. /**
  9663. * Serialize placeholder for child classes
  9664. * @param parent of child
  9665. * @returns the serialized object
  9666. */
  9667. serialize(parent: any): any;
  9668. /**
  9669. * Internal only
  9670. * @hidden
  9671. */
  9672. _prepare(): void;
  9673. /**
  9674. * Internal only - manager for action
  9675. * @hidden
  9676. */
  9677. _actionManager: Nullable<AbstractActionManager>;
  9678. /**
  9679. * Adds action to chain of actions, may be a DoNothingAction
  9680. * @param action defines the next action to execute
  9681. * @returns The action passed in
  9682. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9683. */
  9684. then(action: IAction): IAction;
  9685. }
  9686. /**
  9687. * The action to be carried out following a trigger
  9688. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9689. */
  9690. export class Action implements IAction {
  9691. /** the trigger, with or without parameters, for the action */
  9692. triggerOptions: any;
  9693. /**
  9694. * Trigger for the action
  9695. */
  9696. trigger: number;
  9697. /**
  9698. * Internal only - manager for action
  9699. * @hidden
  9700. */
  9701. _actionManager: ActionManager;
  9702. private _nextActiveAction;
  9703. private _child;
  9704. private _condition?;
  9705. private _triggerParameter;
  9706. /**
  9707. * An event triggered prior to action being executed.
  9708. */
  9709. onBeforeExecuteObservable: Observable<Action>;
  9710. /**
  9711. * Creates a new Action
  9712. * @param triggerOptions the trigger, with or without parameters, for the action
  9713. * @param condition an optional determinant of action
  9714. */
  9715. constructor(
  9716. /** the trigger, with or without parameters, for the action */
  9717. triggerOptions: any, condition?: Condition);
  9718. /**
  9719. * Internal only
  9720. * @hidden
  9721. */
  9722. _prepare(): void;
  9723. /**
  9724. * Gets the trigger parameters
  9725. * @returns the trigger parameters
  9726. */
  9727. getTriggerParameter(): any;
  9728. /**
  9729. * Internal only - executes current action event
  9730. * @hidden
  9731. */
  9732. _executeCurrent(evt?: ActionEvent): void;
  9733. /**
  9734. * Execute placeholder for child classes
  9735. * @param evt optional action event
  9736. */
  9737. execute(evt?: ActionEvent): void;
  9738. /**
  9739. * Skips to next active action
  9740. */
  9741. skipToNextActiveAction(): void;
  9742. /**
  9743. * Adds action to chain of actions, may be a DoNothingAction
  9744. * @param action defines the next action to execute
  9745. * @returns The action passed in
  9746. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9747. */
  9748. then(action: Action): Action;
  9749. /**
  9750. * Internal only
  9751. * @hidden
  9752. */
  9753. _getProperty(propertyPath: string): string;
  9754. /**
  9755. * Internal only
  9756. * @hidden
  9757. */
  9758. _getEffectiveTarget(target: any, propertyPath: string): any;
  9759. /**
  9760. * Serialize placeholder for child classes
  9761. * @param parent of child
  9762. * @returns the serialized object
  9763. */
  9764. serialize(parent: any): any;
  9765. /**
  9766. * Internal only called by serialize
  9767. * @hidden
  9768. */
  9769. protected _serialize(serializedAction: any, parent?: any): any;
  9770. /**
  9771. * Internal only
  9772. * @hidden
  9773. */
  9774. static _SerializeValueAsString: (value: any) => string;
  9775. /**
  9776. * Internal only
  9777. * @hidden
  9778. */
  9779. static _GetTargetProperty: (target: Scene | Node) => {
  9780. name: string;
  9781. targetType: string;
  9782. value: string;
  9783. };
  9784. }
  9785. }
  9786. declare module "babylonjs/Actions/condition" {
  9787. import { ActionManager } from "babylonjs/Actions/actionManager";
  9788. /**
  9789. * A Condition applied to an Action
  9790. */
  9791. export class Condition {
  9792. /**
  9793. * Internal only - manager for action
  9794. * @hidden
  9795. */
  9796. _actionManager: ActionManager;
  9797. /**
  9798. * Internal only
  9799. * @hidden
  9800. */
  9801. _evaluationId: number;
  9802. /**
  9803. * Internal only
  9804. * @hidden
  9805. */
  9806. _currentResult: boolean;
  9807. /**
  9808. * Creates a new Condition
  9809. * @param actionManager the manager of the action the condition is applied to
  9810. */
  9811. constructor(actionManager: ActionManager);
  9812. /**
  9813. * Check if the current condition is valid
  9814. * @returns a boolean
  9815. */
  9816. isValid(): boolean;
  9817. /**
  9818. * Internal only
  9819. * @hidden
  9820. */
  9821. _getProperty(propertyPath: string): string;
  9822. /**
  9823. * Internal only
  9824. * @hidden
  9825. */
  9826. _getEffectiveTarget(target: any, propertyPath: string): any;
  9827. /**
  9828. * Serialize placeholder for child classes
  9829. * @returns the serialized object
  9830. */
  9831. serialize(): any;
  9832. /**
  9833. * Internal only
  9834. * @hidden
  9835. */
  9836. protected _serialize(serializedCondition: any): any;
  9837. }
  9838. /**
  9839. * Defines specific conditional operators as extensions of Condition
  9840. */
  9841. export class ValueCondition extends Condition {
  9842. /** path to specify the property of the target the conditional operator uses */
  9843. propertyPath: string;
  9844. /** the value compared by the conditional operator against the current value of the property */
  9845. value: any;
  9846. /** the conditional operator, default ValueCondition.IsEqual */
  9847. operator: number;
  9848. /**
  9849. * Internal only
  9850. * @hidden
  9851. */
  9852. private static _IsEqual;
  9853. /**
  9854. * Internal only
  9855. * @hidden
  9856. */
  9857. private static _IsDifferent;
  9858. /**
  9859. * Internal only
  9860. * @hidden
  9861. */
  9862. private static _IsGreater;
  9863. /**
  9864. * Internal only
  9865. * @hidden
  9866. */
  9867. private static _IsLesser;
  9868. /**
  9869. * returns the number for IsEqual
  9870. */
  9871. static get IsEqual(): number;
  9872. /**
  9873. * Returns the number for IsDifferent
  9874. */
  9875. static get IsDifferent(): number;
  9876. /**
  9877. * Returns the number for IsGreater
  9878. */
  9879. static get IsGreater(): number;
  9880. /**
  9881. * Returns the number for IsLesser
  9882. */
  9883. static get IsLesser(): number;
  9884. /**
  9885. * Internal only The action manager for the condition
  9886. * @hidden
  9887. */
  9888. _actionManager: ActionManager;
  9889. /**
  9890. * Internal only
  9891. * @hidden
  9892. */
  9893. private _target;
  9894. /**
  9895. * Internal only
  9896. * @hidden
  9897. */
  9898. private _effectiveTarget;
  9899. /**
  9900. * Internal only
  9901. * @hidden
  9902. */
  9903. private _property;
  9904. /**
  9905. * Creates a new ValueCondition
  9906. * @param actionManager manager for the action the condition applies to
  9907. * @param target for the action
  9908. * @param propertyPath path to specify the property of the target the conditional operator uses
  9909. * @param value the value compared by the conditional operator against the current value of the property
  9910. * @param operator the conditional operator, default ValueCondition.IsEqual
  9911. */
  9912. constructor(actionManager: ActionManager, target: any,
  9913. /** path to specify the property of the target the conditional operator uses */
  9914. propertyPath: string,
  9915. /** the value compared by the conditional operator against the current value of the property */
  9916. value: any,
  9917. /** the conditional operator, default ValueCondition.IsEqual */
  9918. operator?: number);
  9919. /**
  9920. * Compares the given value with the property value for the specified conditional operator
  9921. * @returns the result of the comparison
  9922. */
  9923. isValid(): boolean;
  9924. /**
  9925. * Serialize the ValueCondition into a JSON compatible object
  9926. * @returns serialization object
  9927. */
  9928. serialize(): any;
  9929. /**
  9930. * Gets the name of the conditional operator for the ValueCondition
  9931. * @param operator the conditional operator
  9932. * @returns the name
  9933. */
  9934. static GetOperatorName(operator: number): string;
  9935. }
  9936. /**
  9937. * Defines a predicate condition as an extension of Condition
  9938. */
  9939. export class PredicateCondition extends Condition {
  9940. /** defines the predicate function used to validate the condition */
  9941. predicate: () => boolean;
  9942. /**
  9943. * Internal only - manager for action
  9944. * @hidden
  9945. */
  9946. _actionManager: ActionManager;
  9947. /**
  9948. * Creates a new PredicateCondition
  9949. * @param actionManager manager for the action the condition applies to
  9950. * @param predicate defines the predicate function used to validate the condition
  9951. */
  9952. constructor(actionManager: ActionManager,
  9953. /** defines the predicate function used to validate the condition */
  9954. predicate: () => boolean);
  9955. /**
  9956. * @returns the validity of the predicate condition
  9957. */
  9958. isValid(): boolean;
  9959. }
  9960. /**
  9961. * Defines a state condition as an extension of Condition
  9962. */
  9963. export class StateCondition extends Condition {
  9964. /** Value to compare with target state */
  9965. value: string;
  9966. /**
  9967. * Internal only - manager for action
  9968. * @hidden
  9969. */
  9970. _actionManager: ActionManager;
  9971. /**
  9972. * Internal only
  9973. * @hidden
  9974. */
  9975. private _target;
  9976. /**
  9977. * Creates a new StateCondition
  9978. * @param actionManager manager for the action the condition applies to
  9979. * @param target of the condition
  9980. * @param value to compare with target state
  9981. */
  9982. constructor(actionManager: ActionManager, target: any,
  9983. /** Value to compare with target state */
  9984. value: string);
  9985. /**
  9986. * Gets a boolean indicating if the current condition is met
  9987. * @returns the validity of the state
  9988. */
  9989. isValid(): boolean;
  9990. /**
  9991. * Serialize the StateCondition into a JSON compatible object
  9992. * @returns serialization object
  9993. */
  9994. serialize(): any;
  9995. }
  9996. }
  9997. declare module "babylonjs/Actions/directActions" {
  9998. import { Action } from "babylonjs/Actions/action";
  9999. import { Condition } from "babylonjs/Actions/condition";
  10000. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10001. /**
  10002. * This defines an action responsible to toggle a boolean once triggered.
  10003. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10004. */
  10005. export class SwitchBooleanAction extends Action {
  10006. /**
  10007. * The path to the boolean property in the target object
  10008. */
  10009. propertyPath: string;
  10010. private _target;
  10011. private _effectiveTarget;
  10012. private _property;
  10013. /**
  10014. * Instantiate the action
  10015. * @param triggerOptions defines the trigger options
  10016. * @param target defines the object containing the boolean
  10017. * @param propertyPath defines the path to the boolean property in the target object
  10018. * @param condition defines the trigger related conditions
  10019. */
  10020. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10021. /** @hidden */
  10022. _prepare(): void;
  10023. /**
  10024. * Execute the action toggle the boolean value.
  10025. */
  10026. execute(): void;
  10027. /**
  10028. * Serializes the actions and its related information.
  10029. * @param parent defines the object to serialize in
  10030. * @returns the serialized object
  10031. */
  10032. serialize(parent: any): any;
  10033. }
  10034. /**
  10035. * This defines an action responsible to set a the state field of the target
  10036. * to a desired value once triggered.
  10037. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10038. */
  10039. export class SetStateAction extends Action {
  10040. /**
  10041. * The value to store in the state field.
  10042. */
  10043. value: string;
  10044. private _target;
  10045. /**
  10046. * Instantiate the action
  10047. * @param triggerOptions defines the trigger options
  10048. * @param target defines the object containing the state property
  10049. * @param value defines the value to store in the state field
  10050. * @param condition defines the trigger related conditions
  10051. */
  10052. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10053. /**
  10054. * Execute the action and store the value on the target state property.
  10055. */
  10056. execute(): void;
  10057. /**
  10058. * Serializes the actions and its related information.
  10059. * @param parent defines the object to serialize in
  10060. * @returns the serialized object
  10061. */
  10062. serialize(parent: any): any;
  10063. }
  10064. /**
  10065. * This defines an action responsible to set a property of the target
  10066. * to a desired value once triggered.
  10067. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10068. */
  10069. export class SetValueAction extends Action {
  10070. /**
  10071. * The path of the property to set in the target.
  10072. */
  10073. propertyPath: string;
  10074. /**
  10075. * The value to set in the property
  10076. */
  10077. value: any;
  10078. private _target;
  10079. private _effectiveTarget;
  10080. private _property;
  10081. /**
  10082. * Instantiate the action
  10083. * @param triggerOptions defines the trigger options
  10084. * @param target defines the object containing the property
  10085. * @param propertyPath defines the path of the property to set in the target
  10086. * @param value defines the value to set in the property
  10087. * @param condition defines the trigger related conditions
  10088. */
  10089. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10090. /** @hidden */
  10091. _prepare(): void;
  10092. /**
  10093. * Execute the action and set the targetted property to the desired value.
  10094. */
  10095. execute(): void;
  10096. /**
  10097. * Serializes the actions and its related information.
  10098. * @param parent defines the object to serialize in
  10099. * @returns the serialized object
  10100. */
  10101. serialize(parent: any): any;
  10102. }
  10103. /**
  10104. * This defines an action responsible to increment the target value
  10105. * to a desired value once triggered.
  10106. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10107. */
  10108. export class IncrementValueAction extends Action {
  10109. /**
  10110. * The path of the property to increment in the target.
  10111. */
  10112. propertyPath: string;
  10113. /**
  10114. * The value we should increment the property by.
  10115. */
  10116. value: any;
  10117. private _target;
  10118. private _effectiveTarget;
  10119. private _property;
  10120. /**
  10121. * Instantiate the action
  10122. * @param triggerOptions defines the trigger options
  10123. * @param target defines the object containing the property
  10124. * @param propertyPath defines the path of the property to increment in the target
  10125. * @param value defines the value value we should increment the property by
  10126. * @param condition defines the trigger related conditions
  10127. */
  10128. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10129. /** @hidden */
  10130. _prepare(): void;
  10131. /**
  10132. * Execute the action and increment the target of the value amount.
  10133. */
  10134. execute(): void;
  10135. /**
  10136. * Serializes the actions and its related information.
  10137. * @param parent defines the object to serialize in
  10138. * @returns the serialized object
  10139. */
  10140. serialize(parent: any): any;
  10141. }
  10142. /**
  10143. * This defines an action responsible to start an animation once triggered.
  10144. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10145. */
  10146. export class PlayAnimationAction extends Action {
  10147. /**
  10148. * Where the animation should start (animation frame)
  10149. */
  10150. from: number;
  10151. /**
  10152. * Where the animation should stop (animation frame)
  10153. */
  10154. to: number;
  10155. /**
  10156. * Define if the animation should loop or stop after the first play.
  10157. */
  10158. loop?: boolean;
  10159. private _target;
  10160. /**
  10161. * Instantiate the action
  10162. * @param triggerOptions defines the trigger options
  10163. * @param target defines the target animation or animation name
  10164. * @param from defines from where the animation should start (animation frame)
  10165. * @param end defines where the animation should stop (animation frame)
  10166. * @param loop defines if the animation should loop or stop after the first play
  10167. * @param condition defines the trigger related conditions
  10168. */
  10169. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10170. /** @hidden */
  10171. _prepare(): void;
  10172. /**
  10173. * Execute the action and play the animation.
  10174. */
  10175. execute(): void;
  10176. /**
  10177. * Serializes the actions and its related information.
  10178. * @param parent defines the object to serialize in
  10179. * @returns the serialized object
  10180. */
  10181. serialize(parent: any): any;
  10182. }
  10183. /**
  10184. * This defines an action responsible to stop an animation once triggered.
  10185. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10186. */
  10187. export class StopAnimationAction extends Action {
  10188. private _target;
  10189. /**
  10190. * Instantiate the action
  10191. * @param triggerOptions defines the trigger options
  10192. * @param target defines the target animation or animation name
  10193. * @param condition defines the trigger related conditions
  10194. */
  10195. constructor(triggerOptions: any, target: any, condition?: Condition);
  10196. /** @hidden */
  10197. _prepare(): void;
  10198. /**
  10199. * Execute the action and stop the animation.
  10200. */
  10201. execute(): void;
  10202. /**
  10203. * Serializes the actions and its related information.
  10204. * @param parent defines the object to serialize in
  10205. * @returns the serialized object
  10206. */
  10207. serialize(parent: any): any;
  10208. }
  10209. /**
  10210. * This defines an action responsible that does nothing once triggered.
  10211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10212. */
  10213. export class DoNothingAction extends Action {
  10214. /**
  10215. * Instantiate the action
  10216. * @param triggerOptions defines the trigger options
  10217. * @param condition defines the trigger related conditions
  10218. */
  10219. constructor(triggerOptions?: any, condition?: Condition);
  10220. /**
  10221. * Execute the action and do nothing.
  10222. */
  10223. execute(): void;
  10224. /**
  10225. * Serializes the actions and its related information.
  10226. * @param parent defines the object to serialize in
  10227. * @returns the serialized object
  10228. */
  10229. serialize(parent: any): any;
  10230. }
  10231. /**
  10232. * This defines an action responsible to trigger several actions once triggered.
  10233. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10234. */
  10235. export class CombineAction extends Action {
  10236. /**
  10237. * The list of aggregated animations to run.
  10238. */
  10239. children: Action[];
  10240. /**
  10241. * Instantiate the action
  10242. * @param triggerOptions defines the trigger options
  10243. * @param children defines the list of aggregated animations to run
  10244. * @param condition defines the trigger related conditions
  10245. */
  10246. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10247. /** @hidden */
  10248. _prepare(): void;
  10249. /**
  10250. * Execute the action and executes all the aggregated actions.
  10251. */
  10252. execute(evt: ActionEvent): void;
  10253. /**
  10254. * Serializes the actions and its related information.
  10255. * @param parent defines the object to serialize in
  10256. * @returns the serialized object
  10257. */
  10258. serialize(parent: any): any;
  10259. }
  10260. /**
  10261. * This defines an action responsible to run code (external event) once triggered.
  10262. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10263. */
  10264. export class ExecuteCodeAction extends Action {
  10265. /**
  10266. * The callback function to run.
  10267. */
  10268. func: (evt: ActionEvent) => void;
  10269. /**
  10270. * Instantiate the action
  10271. * @param triggerOptions defines the trigger options
  10272. * @param func defines the callback function to run
  10273. * @param condition defines the trigger related conditions
  10274. */
  10275. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10276. /**
  10277. * Execute the action and run the attached code.
  10278. */
  10279. execute(evt: ActionEvent): void;
  10280. }
  10281. /**
  10282. * This defines an action responsible to set the parent property of the target once triggered.
  10283. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10284. */
  10285. export class SetParentAction extends Action {
  10286. private _parent;
  10287. private _target;
  10288. /**
  10289. * Instantiate the action
  10290. * @param triggerOptions defines the trigger options
  10291. * @param target defines the target containing the parent property
  10292. * @param parent defines from where the animation should start (animation frame)
  10293. * @param condition defines the trigger related conditions
  10294. */
  10295. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10296. /** @hidden */
  10297. _prepare(): void;
  10298. /**
  10299. * Execute the action and set the parent property.
  10300. */
  10301. execute(): void;
  10302. /**
  10303. * Serializes the actions and its related information.
  10304. * @param parent defines the object to serialize in
  10305. * @returns the serialized object
  10306. */
  10307. serialize(parent: any): any;
  10308. }
  10309. }
  10310. declare module "babylonjs/Actions/actionManager" {
  10311. import { Nullable } from "babylonjs/types";
  10312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10313. import { Scene } from "babylonjs/scene";
  10314. import { IAction } from "babylonjs/Actions/action";
  10315. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10316. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10317. /**
  10318. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10319. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10320. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10321. */
  10322. export class ActionManager extends AbstractActionManager {
  10323. /**
  10324. * Nothing
  10325. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10326. */
  10327. static readonly NothingTrigger: number;
  10328. /**
  10329. * On pick
  10330. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10331. */
  10332. static readonly OnPickTrigger: number;
  10333. /**
  10334. * On left pick
  10335. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10336. */
  10337. static readonly OnLeftPickTrigger: number;
  10338. /**
  10339. * On right pick
  10340. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10341. */
  10342. static readonly OnRightPickTrigger: number;
  10343. /**
  10344. * On center pick
  10345. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10346. */
  10347. static readonly OnCenterPickTrigger: number;
  10348. /**
  10349. * On pick down
  10350. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10351. */
  10352. static readonly OnPickDownTrigger: number;
  10353. /**
  10354. * On double pick
  10355. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10356. */
  10357. static readonly OnDoublePickTrigger: number;
  10358. /**
  10359. * On pick up
  10360. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10361. */
  10362. static readonly OnPickUpTrigger: number;
  10363. /**
  10364. * On pick out.
  10365. * This trigger will only be raised if you also declared a OnPickDown
  10366. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10367. */
  10368. static readonly OnPickOutTrigger: number;
  10369. /**
  10370. * On long press
  10371. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10372. */
  10373. static readonly OnLongPressTrigger: number;
  10374. /**
  10375. * On pointer over
  10376. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10377. */
  10378. static readonly OnPointerOverTrigger: number;
  10379. /**
  10380. * On pointer out
  10381. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10382. */
  10383. static readonly OnPointerOutTrigger: number;
  10384. /**
  10385. * On every frame
  10386. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10387. */
  10388. static readonly OnEveryFrameTrigger: number;
  10389. /**
  10390. * On intersection enter
  10391. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10392. */
  10393. static readonly OnIntersectionEnterTrigger: number;
  10394. /**
  10395. * On intersection exit
  10396. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10397. */
  10398. static readonly OnIntersectionExitTrigger: number;
  10399. /**
  10400. * On key down
  10401. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10402. */
  10403. static readonly OnKeyDownTrigger: number;
  10404. /**
  10405. * On key up
  10406. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10407. */
  10408. static readonly OnKeyUpTrigger: number;
  10409. private _scene;
  10410. /**
  10411. * Creates a new action manager
  10412. * @param scene defines the hosting scene
  10413. */
  10414. constructor(scene: Scene);
  10415. /**
  10416. * Releases all associated resources
  10417. */
  10418. dispose(): void;
  10419. /**
  10420. * Gets hosting scene
  10421. * @returns the hosting scene
  10422. */
  10423. getScene(): Scene;
  10424. /**
  10425. * Does this action manager handles actions of any of the given triggers
  10426. * @param triggers defines the triggers to be tested
  10427. * @return a boolean indicating whether one (or more) of the triggers is handled
  10428. */
  10429. hasSpecificTriggers(triggers: number[]): boolean;
  10430. /**
  10431. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10432. * speed.
  10433. * @param triggerA defines the trigger to be tested
  10434. * @param triggerB defines the trigger to be tested
  10435. * @return a boolean indicating whether one (or more) of the triggers is handled
  10436. */
  10437. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10438. /**
  10439. * Does this action manager handles actions of a given trigger
  10440. * @param trigger defines the trigger to be tested
  10441. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10442. * @return whether the trigger is handled
  10443. */
  10444. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10445. /**
  10446. * Does this action manager has pointer triggers
  10447. */
  10448. get hasPointerTriggers(): boolean;
  10449. /**
  10450. * Does this action manager has pick triggers
  10451. */
  10452. get hasPickTriggers(): boolean;
  10453. /**
  10454. * Registers an action to this action manager
  10455. * @param action defines the action to be registered
  10456. * @return the action amended (prepared) after registration
  10457. */
  10458. registerAction(action: IAction): Nullable<IAction>;
  10459. /**
  10460. * Unregisters an action to this action manager
  10461. * @param action defines the action to be unregistered
  10462. * @return a boolean indicating whether the action has been unregistered
  10463. */
  10464. unregisterAction(action: IAction): Boolean;
  10465. /**
  10466. * Process a specific trigger
  10467. * @param trigger defines the trigger to process
  10468. * @param evt defines the event details to be processed
  10469. */
  10470. processTrigger(trigger: number, evt?: IActionEvent): void;
  10471. /** @hidden */
  10472. _getEffectiveTarget(target: any, propertyPath: string): any;
  10473. /** @hidden */
  10474. _getProperty(propertyPath: string): string;
  10475. /**
  10476. * Serialize this manager to a JSON object
  10477. * @param name defines the property name to store this manager
  10478. * @returns a JSON representation of this manager
  10479. */
  10480. serialize(name: string): any;
  10481. /**
  10482. * Creates a new ActionManager from a JSON data
  10483. * @param parsedActions defines the JSON data to read from
  10484. * @param object defines the hosting mesh
  10485. * @param scene defines the hosting scene
  10486. */
  10487. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10488. /**
  10489. * Get a trigger name by index
  10490. * @param trigger defines the trigger index
  10491. * @returns a trigger name
  10492. */
  10493. static GetTriggerName(trigger: number): string;
  10494. }
  10495. }
  10496. declare module "babylonjs/Sprites/sprite" {
  10497. import { Vector3 } from "babylonjs/Maths/math.vector";
  10498. import { Nullable } from "babylonjs/types";
  10499. import { ActionManager } from "babylonjs/Actions/actionManager";
  10500. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10501. import { Color4 } from "babylonjs/Maths/math.color";
  10502. import { Observable } from "babylonjs/Misc/observable";
  10503. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10504. import { Animation } from "babylonjs/Animations/animation";
  10505. /**
  10506. * Class used to represent a sprite
  10507. * @see https://doc.babylonjs.com/babylon101/sprites
  10508. */
  10509. export class Sprite implements IAnimatable {
  10510. /** defines the name */
  10511. name: string;
  10512. /** Gets or sets the current world position */
  10513. position: Vector3;
  10514. /** Gets or sets the main color */
  10515. color: Color4;
  10516. /** Gets or sets the width */
  10517. width: number;
  10518. /** Gets or sets the height */
  10519. height: number;
  10520. /** Gets or sets rotation angle */
  10521. angle: number;
  10522. /** Gets or sets the cell index in the sprite sheet */
  10523. cellIndex: number;
  10524. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10525. cellRef: string;
  10526. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10527. invertU: boolean;
  10528. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10529. invertV: boolean;
  10530. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10531. disposeWhenFinishedAnimating: boolean;
  10532. /** Gets the list of attached animations */
  10533. animations: Nullable<Array<Animation>>;
  10534. /** Gets or sets a boolean indicating if the sprite can be picked */
  10535. isPickable: boolean;
  10536. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10537. useAlphaForPicking: boolean;
  10538. /** @hidden */
  10539. _xOffset: number;
  10540. /** @hidden */
  10541. _yOffset: number;
  10542. /** @hidden */
  10543. _xSize: number;
  10544. /** @hidden */
  10545. _ySize: number;
  10546. /**
  10547. * Gets or sets the associated action manager
  10548. */
  10549. actionManager: Nullable<ActionManager>;
  10550. /**
  10551. * An event triggered when the control has been disposed
  10552. */
  10553. onDisposeObservable: Observable<Sprite>;
  10554. private _animationStarted;
  10555. private _loopAnimation;
  10556. private _fromIndex;
  10557. private _toIndex;
  10558. private _delay;
  10559. private _direction;
  10560. private _manager;
  10561. private _time;
  10562. private _onAnimationEnd;
  10563. /**
  10564. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10565. */
  10566. isVisible: boolean;
  10567. /**
  10568. * Gets or sets the sprite size
  10569. */
  10570. get size(): number;
  10571. set size(value: number);
  10572. /**
  10573. * Returns a boolean indicating if the animation is started
  10574. */
  10575. get animationStarted(): boolean;
  10576. /**
  10577. * Gets or sets the unique id of the sprite
  10578. */
  10579. uniqueId: number;
  10580. /**
  10581. * Gets the manager of this sprite
  10582. */
  10583. get manager(): ISpriteManager;
  10584. /**
  10585. * Creates a new Sprite
  10586. * @param name defines the name
  10587. * @param manager defines the manager
  10588. */
  10589. constructor(
  10590. /** defines the name */
  10591. name: string, manager: ISpriteManager);
  10592. /**
  10593. * Returns the string "Sprite"
  10594. * @returns "Sprite"
  10595. */
  10596. getClassName(): string;
  10597. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10598. get fromIndex(): number;
  10599. set fromIndex(value: number);
  10600. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10601. get toIndex(): number;
  10602. set toIndex(value: number);
  10603. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10604. get loopAnimation(): boolean;
  10605. set loopAnimation(value: boolean);
  10606. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10607. get delay(): number;
  10608. set delay(value: number);
  10609. /**
  10610. * Starts an animation
  10611. * @param from defines the initial key
  10612. * @param to defines the end key
  10613. * @param loop defines if the animation must loop
  10614. * @param delay defines the start delay (in ms)
  10615. * @param onAnimationEnd defines a callback to call when animation ends
  10616. */
  10617. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10618. /** Stops current animation (if any) */
  10619. stopAnimation(): void;
  10620. /** @hidden */
  10621. _animate(deltaTime: number): void;
  10622. /** Release associated resources */
  10623. dispose(): void;
  10624. /**
  10625. * Serializes the sprite to a JSON object
  10626. * @returns the JSON object
  10627. */
  10628. serialize(): any;
  10629. /**
  10630. * Parses a JSON object to create a new sprite
  10631. * @param parsedSprite The JSON object to parse
  10632. * @param manager defines the hosting manager
  10633. * @returns the new sprite
  10634. */
  10635. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10636. }
  10637. }
  10638. declare module "babylonjs/Collisions/pickingInfo" {
  10639. import { Nullable } from "babylonjs/types";
  10640. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10641. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10642. import { Sprite } from "babylonjs/Sprites/sprite";
  10643. import { Ray } from "babylonjs/Culling/ray";
  10644. /**
  10645. * Information about the result of picking within a scene
  10646. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10647. */
  10648. export class PickingInfo {
  10649. /** @hidden */
  10650. _pickingUnavailable: boolean;
  10651. /**
  10652. * If the pick collided with an object
  10653. */
  10654. hit: boolean;
  10655. /**
  10656. * Distance away where the pick collided
  10657. */
  10658. distance: number;
  10659. /**
  10660. * The location of pick collision
  10661. */
  10662. pickedPoint: Nullable<Vector3>;
  10663. /**
  10664. * The mesh corresponding the the pick collision
  10665. */
  10666. pickedMesh: Nullable<AbstractMesh>;
  10667. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10668. bu: number;
  10669. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10670. bv: number;
  10671. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10672. faceId: number;
  10673. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10674. subMeshFaceId: number;
  10675. /** Id of the the submesh that was picked */
  10676. subMeshId: number;
  10677. /** If a sprite was picked, this will be the sprite the pick collided with */
  10678. pickedSprite: Nullable<Sprite>;
  10679. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10680. thinInstanceIndex: number;
  10681. /**
  10682. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10683. */
  10684. originMesh: Nullable<AbstractMesh>;
  10685. /**
  10686. * The ray that was used to perform the picking.
  10687. */
  10688. ray: Nullable<Ray>;
  10689. /**
  10690. * Gets the normal correspodning to the face the pick collided with
  10691. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10692. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10693. * @returns The normal correspodning to the face the pick collided with
  10694. */
  10695. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10696. /**
  10697. * Gets the texture coordinates of where the pick occured
  10698. * @returns the vector containing the coordnates of the texture
  10699. */
  10700. getTextureCoordinates(): Nullable<Vector2>;
  10701. }
  10702. }
  10703. declare module "babylonjs/Culling/ray" {
  10704. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10705. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10706. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10707. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10708. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10709. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10710. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10711. import { Plane } from "babylonjs/Maths/math.plane";
  10712. /**
  10713. * Class representing a ray with position and direction
  10714. */
  10715. export class Ray {
  10716. /** origin point */
  10717. origin: Vector3;
  10718. /** direction */
  10719. direction: Vector3;
  10720. /** length of the ray */
  10721. length: number;
  10722. private static readonly _TmpVector3;
  10723. private _tmpRay;
  10724. /**
  10725. * Creates a new ray
  10726. * @param origin origin point
  10727. * @param direction direction
  10728. * @param length length of the ray
  10729. */
  10730. constructor(
  10731. /** origin point */
  10732. origin: Vector3,
  10733. /** direction */
  10734. direction: Vector3,
  10735. /** length of the ray */
  10736. length?: number);
  10737. /**
  10738. * Checks if the ray intersects a box
  10739. * This does not account for the ray lenght by design to improve perfs.
  10740. * @param minimum bound of the box
  10741. * @param maximum bound of the box
  10742. * @param intersectionTreshold extra extend to be added to the box in all direction
  10743. * @returns if the box was hit
  10744. */
  10745. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10746. /**
  10747. * Checks if the ray intersects a box
  10748. * This does not account for the ray lenght by design to improve perfs.
  10749. * @param box the bounding box to check
  10750. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10751. * @returns if the box was hit
  10752. */
  10753. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10754. /**
  10755. * If the ray hits a sphere
  10756. * @param sphere the bounding sphere to check
  10757. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10758. * @returns true if it hits the sphere
  10759. */
  10760. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10761. /**
  10762. * If the ray hits a triange
  10763. * @param vertex0 triangle vertex
  10764. * @param vertex1 triangle vertex
  10765. * @param vertex2 triangle vertex
  10766. * @returns intersection information if hit
  10767. */
  10768. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10769. /**
  10770. * Checks if ray intersects a plane
  10771. * @param plane the plane to check
  10772. * @returns the distance away it was hit
  10773. */
  10774. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10775. /**
  10776. * Calculate the intercept of a ray on a given axis
  10777. * @param axis to check 'x' | 'y' | 'z'
  10778. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10779. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10780. */
  10781. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10782. /**
  10783. * Checks if ray intersects a mesh
  10784. * @param mesh the mesh to check
  10785. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10786. * @returns picking info of the intersecton
  10787. */
  10788. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10789. /**
  10790. * Checks if ray intersects a mesh
  10791. * @param meshes the meshes to check
  10792. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10793. * @param results array to store result in
  10794. * @returns Array of picking infos
  10795. */
  10796. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10797. private _comparePickingInfo;
  10798. private static smallnum;
  10799. private static rayl;
  10800. /**
  10801. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10802. * @param sega the first point of the segment to test the intersection against
  10803. * @param segb the second point of the segment to test the intersection against
  10804. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10805. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10806. */
  10807. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10808. /**
  10809. * Update the ray from viewport position
  10810. * @param x position
  10811. * @param y y position
  10812. * @param viewportWidth viewport width
  10813. * @param viewportHeight viewport height
  10814. * @param world world matrix
  10815. * @param view view matrix
  10816. * @param projection projection matrix
  10817. * @returns this ray updated
  10818. */
  10819. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10820. /**
  10821. * Creates a ray with origin and direction of 0,0,0
  10822. * @returns the new ray
  10823. */
  10824. static Zero(): Ray;
  10825. /**
  10826. * Creates a new ray from screen space and viewport
  10827. * @param x position
  10828. * @param y y position
  10829. * @param viewportWidth viewport width
  10830. * @param viewportHeight viewport height
  10831. * @param world world matrix
  10832. * @param view view matrix
  10833. * @param projection projection matrix
  10834. * @returns new ray
  10835. */
  10836. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10837. /**
  10838. * 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
  10839. * transformed to the given world matrix.
  10840. * @param origin The origin point
  10841. * @param end The end point
  10842. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10843. * @returns the new ray
  10844. */
  10845. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10846. /**
  10847. * Transforms a ray by a matrix
  10848. * @param ray ray to transform
  10849. * @param matrix matrix to apply
  10850. * @returns the resulting new ray
  10851. */
  10852. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10853. /**
  10854. * Transforms a ray by a matrix
  10855. * @param ray ray to transform
  10856. * @param matrix matrix to apply
  10857. * @param result ray to store result in
  10858. */
  10859. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10860. /**
  10861. * Unproject a ray from screen space to object space
  10862. * @param sourceX defines the screen space x coordinate to use
  10863. * @param sourceY defines the screen space y coordinate to use
  10864. * @param viewportWidth defines the current width of the viewport
  10865. * @param viewportHeight defines the current height of the viewport
  10866. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10867. * @param view defines the view matrix to use
  10868. * @param projection defines the projection matrix to use
  10869. */
  10870. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10871. }
  10872. /**
  10873. * Type used to define predicate used to select faces when a mesh intersection is detected
  10874. */
  10875. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10876. module "babylonjs/scene" {
  10877. interface Scene {
  10878. /** @hidden */
  10879. _tempPickingRay: Nullable<Ray>;
  10880. /** @hidden */
  10881. _cachedRayForTransform: Ray;
  10882. /** @hidden */
  10883. _pickWithRayInverseMatrix: Matrix;
  10884. /** @hidden */
  10885. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10886. /** @hidden */
  10887. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10888. /** @hidden */
  10889. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10890. }
  10891. }
  10892. }
  10893. declare module "babylonjs/sceneComponent" {
  10894. import { Scene } from "babylonjs/scene";
  10895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10896. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10897. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10898. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10899. import { Nullable } from "babylonjs/types";
  10900. import { Camera } from "babylonjs/Cameras/camera";
  10901. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10902. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10903. import { AbstractScene } from "babylonjs/abstractScene";
  10904. import { Mesh } from "babylonjs/Meshes/mesh";
  10905. /**
  10906. * Groups all the scene component constants in one place to ease maintenance.
  10907. * @hidden
  10908. */
  10909. export class SceneComponentConstants {
  10910. static readonly NAME_EFFECTLAYER: string;
  10911. static readonly NAME_LAYER: string;
  10912. static readonly NAME_LENSFLARESYSTEM: string;
  10913. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10914. static readonly NAME_PARTICLESYSTEM: string;
  10915. static readonly NAME_GAMEPAD: string;
  10916. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10917. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10918. static readonly NAME_PREPASSRENDERER: string;
  10919. static readonly NAME_DEPTHRENDERER: string;
  10920. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10921. static readonly NAME_SPRITE: string;
  10922. static readonly NAME_SUBSURFACE: string;
  10923. static readonly NAME_OUTLINERENDERER: string;
  10924. static readonly NAME_PROCEDURALTEXTURE: string;
  10925. static readonly NAME_SHADOWGENERATOR: string;
  10926. static readonly NAME_OCTREE: string;
  10927. static readonly NAME_PHYSICSENGINE: string;
  10928. static readonly NAME_AUDIO: string;
  10929. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10930. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10931. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10932. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10933. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10934. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10935. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10936. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10937. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10938. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10939. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10940. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10941. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10942. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10943. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10944. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10945. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10946. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10947. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10948. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10949. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10950. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10951. static readonly STEP_AFTERRENDER_AUDIO: number;
  10952. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10953. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10954. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10955. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10956. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10957. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10958. static readonly STEP_POINTERMOVE_SPRITE: number;
  10959. static readonly STEP_POINTERDOWN_SPRITE: number;
  10960. static readonly STEP_POINTERUP_SPRITE: number;
  10961. }
  10962. /**
  10963. * This represents a scene component.
  10964. *
  10965. * This is used to decouple the dependency the scene is having on the different workloads like
  10966. * layers, post processes...
  10967. */
  10968. export interface ISceneComponent {
  10969. /**
  10970. * The name of the component. Each component must have a unique name.
  10971. */
  10972. name: string;
  10973. /**
  10974. * The scene the component belongs to.
  10975. */
  10976. scene: Scene;
  10977. /**
  10978. * Register the component to one instance of a scene.
  10979. */
  10980. register(): void;
  10981. /**
  10982. * Rebuilds the elements related to this component in case of
  10983. * context lost for instance.
  10984. */
  10985. rebuild(): void;
  10986. /**
  10987. * Disposes the component and the associated ressources.
  10988. */
  10989. dispose(): void;
  10990. }
  10991. /**
  10992. * This represents a SERIALIZABLE scene component.
  10993. *
  10994. * This extends Scene Component to add Serialization methods on top.
  10995. */
  10996. export interface ISceneSerializableComponent extends ISceneComponent {
  10997. /**
  10998. * Adds all the elements from the container to the scene
  10999. * @param container the container holding the elements
  11000. */
  11001. addFromContainer(container: AbstractScene): void;
  11002. /**
  11003. * Removes all the elements in the container from the scene
  11004. * @param container contains the elements to remove
  11005. * @param dispose if the removed element should be disposed (default: false)
  11006. */
  11007. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11008. /**
  11009. * Serializes the component data to the specified json object
  11010. * @param serializationObject The object to serialize to
  11011. */
  11012. serialize(serializationObject: any): void;
  11013. }
  11014. /**
  11015. * Strong typing of a Mesh related stage step action
  11016. */
  11017. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11018. /**
  11019. * Strong typing of a Evaluate Sub Mesh related stage step action
  11020. */
  11021. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11022. /**
  11023. * Strong typing of a pre active Mesh related stage step action
  11024. */
  11025. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  11026. /**
  11027. * Strong typing of a Camera related stage step action
  11028. */
  11029. export type CameraStageAction = (camera: Camera) => void;
  11030. /**
  11031. * Strong typing of a Camera Frame buffer related stage step action
  11032. */
  11033. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11034. /**
  11035. * Strong typing of a Render Target related stage step action
  11036. */
  11037. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11038. /**
  11039. * Strong typing of a RenderingGroup related stage step action
  11040. */
  11041. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11042. /**
  11043. * Strong typing of a Mesh Render related stage step action
  11044. */
  11045. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11046. /**
  11047. * Strong typing of a simple stage step action
  11048. */
  11049. export type SimpleStageAction = () => void;
  11050. /**
  11051. * Strong typing of a render target action.
  11052. */
  11053. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11054. /**
  11055. * Strong typing of a pointer move action.
  11056. */
  11057. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11058. /**
  11059. * Strong typing of a pointer up/down action.
  11060. */
  11061. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11062. /**
  11063. * Representation of a stage in the scene (Basically a list of ordered steps)
  11064. * @hidden
  11065. */
  11066. export class Stage<T extends Function> extends Array<{
  11067. index: number;
  11068. component: ISceneComponent;
  11069. action: T;
  11070. }> {
  11071. /**
  11072. * Hide ctor from the rest of the world.
  11073. * @param items The items to add.
  11074. */
  11075. private constructor();
  11076. /**
  11077. * Creates a new Stage.
  11078. * @returns A new instance of a Stage
  11079. */
  11080. static Create<T extends Function>(): Stage<T>;
  11081. /**
  11082. * Registers a step in an ordered way in the targeted stage.
  11083. * @param index Defines the position to register the step in
  11084. * @param component Defines the component attached to the step
  11085. * @param action Defines the action to launch during the step
  11086. */
  11087. registerStep(index: number, component: ISceneComponent, action: T): void;
  11088. /**
  11089. * Clears all the steps from the stage.
  11090. */
  11091. clear(): void;
  11092. }
  11093. }
  11094. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11095. import { Nullable } from "babylonjs/types";
  11096. import { Observable } from "babylonjs/Misc/observable";
  11097. import { Scene } from "babylonjs/scene";
  11098. import { Sprite } from "babylonjs/Sprites/sprite";
  11099. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11100. import { Ray } from "babylonjs/Culling/ray";
  11101. import { Camera } from "babylonjs/Cameras/camera";
  11102. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11103. import { ISceneComponent } from "babylonjs/sceneComponent";
  11104. module "babylonjs/scene" {
  11105. interface Scene {
  11106. /** @hidden */
  11107. _pointerOverSprite: Nullable<Sprite>;
  11108. /** @hidden */
  11109. _pickedDownSprite: Nullable<Sprite>;
  11110. /** @hidden */
  11111. _tempSpritePickingRay: Nullable<Ray>;
  11112. /**
  11113. * All of the sprite managers added to this scene
  11114. * @see https://doc.babylonjs.com/babylon101/sprites
  11115. */
  11116. spriteManagers: Array<ISpriteManager>;
  11117. /**
  11118. * An event triggered when sprites rendering is about to start
  11119. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11120. */
  11121. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11122. /**
  11123. * An event triggered when sprites rendering is done
  11124. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11125. */
  11126. onAfterSpritesRenderingObservable: Observable<Scene>;
  11127. /** @hidden */
  11128. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11129. /** Launch a ray to try to pick a sprite in the scene
  11130. * @param x position on screen
  11131. * @param y position on screen
  11132. * @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
  11133. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11134. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11135. * @returns a PickingInfo
  11136. */
  11137. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11138. /** Use the given ray to pick a sprite in the scene
  11139. * @param ray The ray (in world space) to use to pick meshes
  11140. * @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
  11141. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11142. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11143. * @returns a PickingInfo
  11144. */
  11145. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11146. /** @hidden */
  11147. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11148. /** Launch a ray to try to pick sprites in the scene
  11149. * @param x position on screen
  11150. * @param y position on screen
  11151. * @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
  11152. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11153. * @returns a PickingInfo array
  11154. */
  11155. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11156. /** Use the given ray to pick sprites in the scene
  11157. * @param ray The ray (in world space) to use to pick meshes
  11158. * @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
  11159. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11160. * @returns a PickingInfo array
  11161. */
  11162. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11163. /**
  11164. * Force the sprite under the pointer
  11165. * @param sprite defines the sprite to use
  11166. */
  11167. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11168. /**
  11169. * Gets the sprite under the pointer
  11170. * @returns a Sprite or null if no sprite is under the pointer
  11171. */
  11172. getPointerOverSprite(): Nullable<Sprite>;
  11173. }
  11174. }
  11175. /**
  11176. * Defines the sprite scene component responsible to manage sprites
  11177. * in a given scene.
  11178. */
  11179. export class SpriteSceneComponent implements ISceneComponent {
  11180. /**
  11181. * The component name helpfull to identify the component in the list of scene components.
  11182. */
  11183. readonly name: string;
  11184. /**
  11185. * The scene the component belongs to.
  11186. */
  11187. scene: Scene;
  11188. /** @hidden */
  11189. private _spritePredicate;
  11190. /**
  11191. * Creates a new instance of the component for the given scene
  11192. * @param scene Defines the scene to register the component in
  11193. */
  11194. constructor(scene: Scene);
  11195. /**
  11196. * Registers the component in a given scene
  11197. */
  11198. register(): void;
  11199. /**
  11200. * Rebuilds the elements related to this component in case of
  11201. * context lost for instance.
  11202. */
  11203. rebuild(): void;
  11204. /**
  11205. * Disposes the component and the associated ressources.
  11206. */
  11207. dispose(): void;
  11208. private _pickSpriteButKeepRay;
  11209. private _pointerMove;
  11210. private _pointerDown;
  11211. private _pointerUp;
  11212. }
  11213. }
  11214. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11215. /** @hidden */
  11216. export var fogFragmentDeclaration: {
  11217. name: string;
  11218. shader: string;
  11219. };
  11220. }
  11221. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11222. /** @hidden */
  11223. export var fogFragment: {
  11224. name: string;
  11225. shader: string;
  11226. };
  11227. }
  11228. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility" {
  11229. /** @hidden */
  11230. export var imageProcessingCompatibility: {
  11231. name: string;
  11232. shader: string;
  11233. };
  11234. }
  11235. declare module "babylonjs/Shaders/sprites.fragment" {
  11236. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11237. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11238. import "babylonjs/Shaders/ShadersInclude/imageProcessingCompatibility";
  11239. /** @hidden */
  11240. export var spritesPixelShader: {
  11241. name: string;
  11242. shader: string;
  11243. };
  11244. }
  11245. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11246. /** @hidden */
  11247. export var fogVertexDeclaration: {
  11248. name: string;
  11249. shader: string;
  11250. };
  11251. }
  11252. declare module "babylonjs/Shaders/sprites.vertex" {
  11253. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11254. /** @hidden */
  11255. export var spritesVertexShader: {
  11256. name: string;
  11257. shader: string;
  11258. };
  11259. }
  11260. declare module "babylonjs/Sprites/spriteManager" {
  11261. import { IDisposable, Scene } from "babylonjs/scene";
  11262. import { Nullable } from "babylonjs/types";
  11263. import { Observable } from "babylonjs/Misc/observable";
  11264. import { Sprite } from "babylonjs/Sprites/sprite";
  11265. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11266. import { Camera } from "babylonjs/Cameras/camera";
  11267. import { Texture } from "babylonjs/Materials/Textures/texture";
  11268. import "babylonjs/Shaders/sprites.fragment";
  11269. import "babylonjs/Shaders/sprites.vertex";
  11270. import { Ray } from "babylonjs/Culling/ray";
  11271. /**
  11272. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11273. */
  11274. export interface ISpriteManager extends IDisposable {
  11275. /**
  11276. * Gets manager's name
  11277. */
  11278. name: string;
  11279. /**
  11280. * Restricts the camera to viewing objects with the same layerMask.
  11281. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11282. */
  11283. layerMask: number;
  11284. /**
  11285. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11286. */
  11287. isPickable: boolean;
  11288. /**
  11289. * Gets the hosting scene
  11290. */
  11291. scene: Scene;
  11292. /**
  11293. * Specifies the rendering group id for this mesh (0 by default)
  11294. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11295. */
  11296. renderingGroupId: number;
  11297. /**
  11298. * Defines the list of sprites managed by the manager.
  11299. */
  11300. sprites: Array<Sprite>;
  11301. /**
  11302. * Gets or sets the spritesheet texture
  11303. */
  11304. texture: Texture;
  11305. /** Defines the default width of a cell in the spritesheet */
  11306. cellWidth: number;
  11307. /** Defines the default height of a cell in the spritesheet */
  11308. cellHeight: number;
  11309. /**
  11310. * Tests the intersection of a sprite with a specific ray.
  11311. * @param ray The ray we are sending to test the collision
  11312. * @param camera The camera space we are sending rays in
  11313. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11314. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11315. * @returns picking info or null.
  11316. */
  11317. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11318. /**
  11319. * Intersects the sprites with a ray
  11320. * @param ray defines the ray to intersect with
  11321. * @param camera defines the current active camera
  11322. * @param predicate defines a predicate used to select candidate sprites
  11323. * @returns null if no hit or a PickingInfo array
  11324. */
  11325. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11326. /**
  11327. * Renders the list of sprites on screen.
  11328. */
  11329. render(): void;
  11330. }
  11331. /**
  11332. * Class used to manage multiple sprites on the same spritesheet
  11333. * @see https://doc.babylonjs.com/babylon101/sprites
  11334. */
  11335. export class SpriteManager implements ISpriteManager {
  11336. /** defines the manager's name */
  11337. name: string;
  11338. /** Define the Url to load snippets */
  11339. static SnippetUrl: string;
  11340. /** Snippet ID if the manager was created from the snippet server */
  11341. snippetId: string;
  11342. /** Gets the list of sprites */
  11343. sprites: Sprite[];
  11344. /** Gets or sets the rendering group id (0 by default) */
  11345. renderingGroupId: number;
  11346. /** Gets or sets camera layer mask */
  11347. layerMask: number;
  11348. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11349. fogEnabled: boolean;
  11350. /** Gets or sets a boolean indicating if the sprites are pickable */
  11351. isPickable: boolean;
  11352. /** Defines the default width of a cell in the spritesheet */
  11353. cellWidth: number;
  11354. /** Defines the default height of a cell in the spritesheet */
  11355. cellHeight: number;
  11356. /** Associative array from JSON sprite data file */
  11357. private _cellData;
  11358. /** Array of sprite names from JSON sprite data file */
  11359. private _spriteMap;
  11360. /** True when packed cell data from JSON file is ready*/
  11361. private _packedAndReady;
  11362. private _textureContent;
  11363. private _useInstancing;
  11364. /**
  11365. * An event triggered when the manager is disposed.
  11366. */
  11367. onDisposeObservable: Observable<SpriteManager>;
  11368. private _onDisposeObserver;
  11369. /**
  11370. * Callback called when the manager is disposed
  11371. */
  11372. set onDispose(callback: () => void);
  11373. private _capacity;
  11374. private _fromPacked;
  11375. private _spriteTexture;
  11376. private _epsilon;
  11377. private _scene;
  11378. private _vertexData;
  11379. private _buffer;
  11380. private _vertexBuffers;
  11381. private _spriteBuffer;
  11382. private _indexBuffer;
  11383. private _effectBase;
  11384. private _effectFog;
  11385. private _vertexBufferSize;
  11386. /**
  11387. * Gets or sets the unique id of the sprite
  11388. */
  11389. uniqueId: number;
  11390. /**
  11391. * Gets the array of sprites
  11392. */
  11393. get children(): Sprite[];
  11394. /**
  11395. * Gets the hosting scene
  11396. */
  11397. get scene(): Scene;
  11398. /**
  11399. * Gets the capacity of the manager
  11400. */
  11401. get capacity(): number;
  11402. /**
  11403. * Gets or sets the spritesheet texture
  11404. */
  11405. get texture(): Texture;
  11406. set texture(value: Texture);
  11407. private _blendMode;
  11408. /**
  11409. * Blend mode use to render the particle, it can be any of
  11410. * the static Constants.ALPHA_x properties provided in this class.
  11411. * Default value is Constants.ALPHA_COMBINE
  11412. */
  11413. get blendMode(): number;
  11414. set blendMode(blendMode: number);
  11415. /** Disables writing to the depth buffer when rendering the sprites.
  11416. * It can be handy to disable depth writing when using textures without alpha channel
  11417. * and setting some specific blend modes.
  11418. */
  11419. disableDepthWrite: boolean;
  11420. /**
  11421. * Creates a new sprite manager
  11422. * @param name defines the manager's name
  11423. * @param imgUrl defines the sprite sheet url
  11424. * @param capacity defines the maximum allowed number of sprites
  11425. * @param cellSize defines the size of a sprite cell
  11426. * @param scene defines the hosting scene
  11427. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11428. * @param samplingMode defines the smapling mode to use with spritesheet
  11429. * @param fromPacked set to false; do not alter
  11430. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11431. */
  11432. constructor(
  11433. /** defines the manager's name */
  11434. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11435. /**
  11436. * Returns the string "SpriteManager"
  11437. * @returns "SpriteManager"
  11438. */
  11439. getClassName(): string;
  11440. private _makePacked;
  11441. private _appendSpriteVertex;
  11442. private _checkTextureAlpha;
  11443. /**
  11444. * Intersects the sprites with a ray
  11445. * @param ray defines the ray to intersect with
  11446. * @param camera defines the current active camera
  11447. * @param predicate defines a predicate used to select candidate sprites
  11448. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11449. * @returns null if no hit or a PickingInfo
  11450. */
  11451. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11452. /**
  11453. * Intersects the sprites with a ray
  11454. * @param ray defines the ray to intersect with
  11455. * @param camera defines the current active camera
  11456. * @param predicate defines a predicate used to select candidate sprites
  11457. * @returns null if no hit or a PickingInfo array
  11458. */
  11459. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11460. /**
  11461. * Render all child sprites
  11462. */
  11463. render(): void;
  11464. /**
  11465. * Release associated resources
  11466. */
  11467. dispose(): void;
  11468. /**
  11469. * Serializes the sprite manager to a JSON object
  11470. * @param serializeTexture defines if the texture must be serialized as well
  11471. * @returns the JSON object
  11472. */
  11473. serialize(serializeTexture?: boolean): any;
  11474. /**
  11475. * Parses a JSON object to create a new sprite manager.
  11476. * @param parsedManager The JSON object to parse
  11477. * @param scene The scene to create the sprite managerin
  11478. * @param rootUrl The root url to use to load external dependencies like texture
  11479. * @returns the new sprite manager
  11480. */
  11481. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11482. /**
  11483. * Creates a sprite manager from a snippet saved in a remote file
  11484. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11485. * @param url defines the url to load from
  11486. * @param scene defines the hosting scene
  11487. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11488. * @returns a promise that will resolve to the new sprite manager
  11489. */
  11490. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11491. /**
  11492. * Creates a sprite manager from a snippet saved by the sprite editor
  11493. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11494. * @param scene defines the hosting scene
  11495. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11496. * @returns a promise that will resolve to the new sprite manager
  11497. */
  11498. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11499. }
  11500. }
  11501. declare module "babylonjs/Misc/gradients" {
  11502. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11503. /** Interface used by value gradients (color, factor, ...) */
  11504. export interface IValueGradient {
  11505. /**
  11506. * Gets or sets the gradient value (between 0 and 1)
  11507. */
  11508. gradient: number;
  11509. }
  11510. /** Class used to store color4 gradient */
  11511. export class ColorGradient implements IValueGradient {
  11512. /**
  11513. * Gets or sets the gradient value (between 0 and 1)
  11514. */
  11515. gradient: number;
  11516. /**
  11517. * Gets or sets first associated color
  11518. */
  11519. color1: Color4;
  11520. /**
  11521. * Gets or sets second associated color
  11522. */
  11523. color2?: Color4 | undefined;
  11524. /**
  11525. * Creates a new color4 gradient
  11526. * @param gradient gets or sets the gradient value (between 0 and 1)
  11527. * @param color1 gets or sets first associated color
  11528. * @param color2 gets or sets first second color
  11529. */
  11530. constructor(
  11531. /**
  11532. * Gets or sets the gradient value (between 0 and 1)
  11533. */
  11534. gradient: number,
  11535. /**
  11536. * Gets or sets first associated color
  11537. */
  11538. color1: Color4,
  11539. /**
  11540. * Gets or sets second associated color
  11541. */
  11542. color2?: Color4 | undefined);
  11543. /**
  11544. * Will get a color picked randomly between color1 and color2.
  11545. * If color2 is undefined then color1 will be used
  11546. * @param result defines the target Color4 to store the result in
  11547. */
  11548. getColorToRef(result: Color4): void;
  11549. }
  11550. /** Class used to store color 3 gradient */
  11551. export class Color3Gradient implements IValueGradient {
  11552. /**
  11553. * Gets or sets the gradient value (between 0 and 1)
  11554. */
  11555. gradient: number;
  11556. /**
  11557. * Gets or sets the associated color
  11558. */
  11559. color: Color3;
  11560. /**
  11561. * Creates a new color3 gradient
  11562. * @param gradient gets or sets the gradient value (between 0 and 1)
  11563. * @param color gets or sets associated color
  11564. */
  11565. constructor(
  11566. /**
  11567. * Gets or sets the gradient value (between 0 and 1)
  11568. */
  11569. gradient: number,
  11570. /**
  11571. * Gets or sets the associated color
  11572. */
  11573. color: Color3);
  11574. }
  11575. /** Class used to store factor gradient */
  11576. export class FactorGradient implements IValueGradient {
  11577. /**
  11578. * Gets or sets the gradient value (between 0 and 1)
  11579. */
  11580. gradient: number;
  11581. /**
  11582. * Gets or sets first associated factor
  11583. */
  11584. factor1: number;
  11585. /**
  11586. * Gets or sets second associated factor
  11587. */
  11588. factor2?: number | undefined;
  11589. /**
  11590. * Creates a new factor gradient
  11591. * @param gradient gets or sets the gradient value (between 0 and 1)
  11592. * @param factor1 gets or sets first associated factor
  11593. * @param factor2 gets or sets second associated factor
  11594. */
  11595. constructor(
  11596. /**
  11597. * Gets or sets the gradient value (between 0 and 1)
  11598. */
  11599. gradient: number,
  11600. /**
  11601. * Gets or sets first associated factor
  11602. */
  11603. factor1: number,
  11604. /**
  11605. * Gets or sets second associated factor
  11606. */
  11607. factor2?: number | undefined);
  11608. /**
  11609. * Will get a number picked randomly between factor1 and factor2.
  11610. * If factor2 is undefined then factor1 will be used
  11611. * @returns the picked number
  11612. */
  11613. getFactor(): number;
  11614. }
  11615. /**
  11616. * Helper used to simplify some generic gradient tasks
  11617. */
  11618. export class GradientHelper {
  11619. /**
  11620. * Gets the current gradient from an array of IValueGradient
  11621. * @param ratio defines the current ratio to get
  11622. * @param gradients defines the array of IValueGradient
  11623. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11624. */
  11625. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11626. }
  11627. }
  11628. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11629. import { Nullable } from "babylonjs/types";
  11630. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11631. import { Scene } from "babylonjs/scene";
  11632. module "babylonjs/Engines/thinEngine" {
  11633. interface ThinEngine {
  11634. /**
  11635. * Creates a raw texture
  11636. * @param data defines the data to store in the texture
  11637. * @param width defines the width of the texture
  11638. * @param height defines the height of the texture
  11639. * @param format defines the format of the data
  11640. * @param generateMipMaps defines if the engine should generate the mip levels
  11641. * @param invertY defines if data must be stored with Y axis inverted
  11642. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11643. * @param compression defines the compression used (null by default)
  11644. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11645. * @returns the raw texture inside an InternalTexture
  11646. */
  11647. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11648. /**
  11649. * Update a raw texture
  11650. * @param texture defines the texture to update
  11651. * @param data defines the data to store in the texture
  11652. * @param format defines the format of the data
  11653. * @param invertY defines if data must be stored with Y axis inverted
  11654. */
  11655. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11656. /**
  11657. * Update a raw texture
  11658. * @param texture defines the texture to update
  11659. * @param data defines the data to store in the texture
  11660. * @param format defines the format of the data
  11661. * @param invertY defines if data must be stored with Y axis inverted
  11662. * @param compression defines the compression used (null by default)
  11663. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11664. */
  11665. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11666. /**
  11667. * Creates a new raw cube texture
  11668. * @param data defines the array of data to use to create each face
  11669. * @param size defines the size of the textures
  11670. * @param format defines the format of the data
  11671. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11672. * @param generateMipMaps defines if the engine should generate the mip levels
  11673. * @param invertY defines if data must be stored with Y axis inverted
  11674. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11675. * @param compression defines the compression used (null by default)
  11676. * @returns the cube texture as an InternalTexture
  11677. */
  11678. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11679. /**
  11680. * Update a raw cube texture
  11681. * @param texture defines the texture to udpdate
  11682. * @param data defines the data to store
  11683. * @param format defines the data format
  11684. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11685. * @param invertY defines if data must be stored with Y axis inverted
  11686. */
  11687. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11688. /**
  11689. * Update a raw cube texture
  11690. * @param texture defines the texture to udpdate
  11691. * @param data defines the data to store
  11692. * @param format defines the data format
  11693. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11694. * @param invertY defines if data must be stored with Y axis inverted
  11695. * @param compression defines the compression used (null by default)
  11696. */
  11697. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11698. /**
  11699. * Update a raw cube texture
  11700. * @param texture defines the texture to udpdate
  11701. * @param data defines the data to store
  11702. * @param format defines the data format
  11703. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11704. * @param invertY defines if data must be stored with Y axis inverted
  11705. * @param compression defines the compression used (null by default)
  11706. * @param level defines which level of the texture to update
  11707. */
  11708. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11709. /**
  11710. * Creates a new raw cube texture from a specified url
  11711. * @param url defines the url where the data is located
  11712. * @param scene defines the current scene
  11713. * @param size defines the size of the textures
  11714. * @param format defines the format of the data
  11715. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11716. * @param noMipmap defines if the engine should avoid generating the mip levels
  11717. * @param callback defines a callback used to extract texture data from loaded data
  11718. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11719. * @param onLoad defines a callback called when texture is loaded
  11720. * @param onError defines a callback called if there is an error
  11721. * @returns the cube texture as an InternalTexture
  11722. */
  11723. 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;
  11724. /**
  11725. * Creates a new raw cube texture from a specified url
  11726. * @param url defines the url where the data is located
  11727. * @param scene defines the current scene
  11728. * @param size defines the size of the textures
  11729. * @param format defines the format of the data
  11730. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11731. * @param noMipmap defines if the engine should avoid generating the mip levels
  11732. * @param callback defines a callback used to extract texture data from loaded data
  11733. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11734. * @param onLoad defines a callback called when texture is loaded
  11735. * @param onError defines a callback called if there is an error
  11736. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11737. * @param invertY defines if data must be stored with Y axis inverted
  11738. * @returns the cube texture as an InternalTexture
  11739. */
  11740. 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;
  11741. /**
  11742. * Creates a new raw 3D texture
  11743. * @param data defines the data used to create the texture
  11744. * @param width defines the width of the texture
  11745. * @param height defines the height of the texture
  11746. * @param depth defines the depth of the texture
  11747. * @param format defines the format of the texture
  11748. * @param generateMipMaps defines if the engine must generate mip levels
  11749. * @param invertY defines if data must be stored with Y axis inverted
  11750. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11751. * @param compression defines the compressed used (can be null)
  11752. * @param textureType defines the compressed used (can be null)
  11753. * @returns a new raw 3D texture (stored in an InternalTexture)
  11754. */
  11755. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11756. /**
  11757. * Update a raw 3D texture
  11758. * @param texture defines the texture to update
  11759. * @param data defines the data to store
  11760. * @param format defines the data format
  11761. * @param invertY defines if data must be stored with Y axis inverted
  11762. */
  11763. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11764. /**
  11765. * Update a raw 3D texture
  11766. * @param texture defines the texture to update
  11767. * @param data defines the data to store
  11768. * @param format defines the data format
  11769. * @param invertY defines if data must be stored with Y axis inverted
  11770. * @param compression defines the used compression (can be null)
  11771. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11772. */
  11773. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11774. /**
  11775. * Creates a new raw 2D array texture
  11776. * @param data defines the data used to create the texture
  11777. * @param width defines the width of the texture
  11778. * @param height defines the height of the texture
  11779. * @param depth defines the number of layers of the texture
  11780. * @param format defines the format of the texture
  11781. * @param generateMipMaps defines if the engine must generate mip levels
  11782. * @param invertY defines if data must be stored with Y axis inverted
  11783. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11784. * @param compression defines the compressed used (can be null)
  11785. * @param textureType defines the compressed used (can be null)
  11786. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11787. */
  11788. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11789. /**
  11790. * Update a raw 2D array texture
  11791. * @param texture defines the texture to update
  11792. * @param data defines the data to store
  11793. * @param format defines the data format
  11794. * @param invertY defines if data must be stored with Y axis inverted
  11795. */
  11796. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11797. /**
  11798. * Update a raw 2D array texture
  11799. * @param texture defines the texture to update
  11800. * @param data defines the data to store
  11801. * @param format defines the data format
  11802. * @param invertY defines if data must be stored with Y axis inverted
  11803. * @param compression defines the used compression (can be null)
  11804. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11805. */
  11806. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11807. }
  11808. }
  11809. }
  11810. declare module "babylonjs/Materials/Textures/rawTexture" {
  11811. import { Texture } from "babylonjs/Materials/Textures/texture";
  11812. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11813. import { Nullable } from "babylonjs/types";
  11814. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11815. import { Scene } from "babylonjs/scene";
  11816. /**
  11817. * Raw texture can help creating a texture directly from an array of data.
  11818. * This can be super useful if you either get the data from an uncompressed source or
  11819. * if you wish to create your texture pixel by pixel.
  11820. */
  11821. export class RawTexture extends Texture {
  11822. /**
  11823. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11824. */
  11825. format: number;
  11826. /**
  11827. * Instantiates a new RawTexture.
  11828. * Raw texture can help creating a texture directly from an array of data.
  11829. * This can be super useful if you either get the data from an uncompressed source or
  11830. * if you wish to create your texture pixel by pixel.
  11831. * @param data define the array of data to use to create the texture
  11832. * @param width define the width of the texture
  11833. * @param height define the height of the texture
  11834. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11835. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11836. * @param generateMipMaps define whether mip maps should be generated or not
  11837. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11838. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11839. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11840. */
  11841. constructor(data: ArrayBufferView, width: number, height: number,
  11842. /**
  11843. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11844. */
  11845. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11846. /**
  11847. * Updates the texture underlying data.
  11848. * @param data Define the new data of the texture
  11849. */
  11850. update(data: ArrayBufferView): void;
  11851. /**
  11852. * Creates a luminance texture from some data.
  11853. * @param data Define the texture data
  11854. * @param width Define the width of the texture
  11855. * @param height Define the height of the texture
  11856. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11857. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11858. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11859. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11860. * @returns the luminance texture
  11861. */
  11862. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11863. /**
  11864. * Creates a luminance alpha texture from some data.
  11865. * @param data Define the texture data
  11866. * @param width Define the width of the texture
  11867. * @param height Define the height of the texture
  11868. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11869. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11870. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11871. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11872. * @returns the luminance alpha texture
  11873. */
  11874. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11875. /**
  11876. * Creates an alpha texture from some data.
  11877. * @param data Define the texture data
  11878. * @param width Define the width of the texture
  11879. * @param height Define the height of the texture
  11880. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11881. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11882. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11883. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11884. * @returns the alpha texture
  11885. */
  11886. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11887. /**
  11888. * Creates a RGB texture from some data.
  11889. * @param data Define the texture data
  11890. * @param width Define the width of the texture
  11891. * @param height Define the height of the texture
  11892. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11893. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11894. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11895. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11896. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11897. * @returns the RGB alpha texture
  11898. */
  11899. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11900. /**
  11901. * Creates a RGBA texture from some data.
  11902. * @param data Define the texture data
  11903. * @param width Define the width of the texture
  11904. * @param height Define the height of the texture
  11905. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11906. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11907. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11908. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11909. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11910. * @returns the RGBA texture
  11911. */
  11912. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11913. /**
  11914. * Creates a R texture from some data.
  11915. * @param data Define the texture data
  11916. * @param width Define the width of the texture
  11917. * @param height Define the height of the texture
  11918. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11919. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11920. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11921. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11922. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11923. * @returns the R texture
  11924. */
  11925. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11926. }
  11927. }
  11928. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11929. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11930. import { IndicesArray, DataArray } from "babylonjs/types";
  11931. module "babylonjs/Engines/thinEngine" {
  11932. interface ThinEngine {
  11933. /**
  11934. * Update a dynamic index buffer
  11935. * @param indexBuffer defines the target index buffer
  11936. * @param indices defines the data to update
  11937. * @param offset defines the offset in the target index buffer where update should start
  11938. */
  11939. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11940. /**
  11941. * Updates a dynamic vertex buffer.
  11942. * @param vertexBuffer the vertex buffer to update
  11943. * @param data the data used to update the vertex buffer
  11944. * @param byteOffset the byte offset of the data
  11945. * @param byteLength the byte length of the data
  11946. */
  11947. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11948. }
  11949. }
  11950. }
  11951. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11952. import { Scene } from "babylonjs/scene";
  11953. import { ISceneComponent } from "babylonjs/sceneComponent";
  11954. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11955. module "babylonjs/abstractScene" {
  11956. interface AbstractScene {
  11957. /**
  11958. * The list of procedural textures added to the scene
  11959. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11960. */
  11961. proceduralTextures: Array<ProceduralTexture>;
  11962. }
  11963. }
  11964. /**
  11965. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11966. * in a given scene.
  11967. */
  11968. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11969. /**
  11970. * The component name helpfull to identify the component in the list of scene components.
  11971. */
  11972. readonly name: string;
  11973. /**
  11974. * The scene the component belongs to.
  11975. */
  11976. scene: Scene;
  11977. /**
  11978. * Creates a new instance of the component for the given scene
  11979. * @param scene Defines the scene to register the component in
  11980. */
  11981. constructor(scene: Scene);
  11982. /**
  11983. * Registers the component in a given scene
  11984. */
  11985. register(): void;
  11986. /**
  11987. * Rebuilds the elements related to this component in case of
  11988. * context lost for instance.
  11989. */
  11990. rebuild(): void;
  11991. /**
  11992. * Disposes the component and the associated ressources.
  11993. */
  11994. dispose(): void;
  11995. private _beforeClear;
  11996. }
  11997. }
  11998. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11999. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12000. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  12001. module "babylonjs/Engines/thinEngine" {
  12002. interface ThinEngine {
  12003. /**
  12004. * Creates a new render target cube texture
  12005. * @param size defines the size of the texture
  12006. * @param options defines the options used to create the texture
  12007. * @returns a new render target cube texture stored in an InternalTexture
  12008. */
  12009. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  12010. }
  12011. }
  12012. }
  12013. declare module "babylonjs/Shaders/procedural.vertex" {
  12014. /** @hidden */
  12015. export var proceduralVertexShader: {
  12016. name: string;
  12017. shader: string;
  12018. };
  12019. }
  12020. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  12021. import { Observable } from "babylonjs/Misc/observable";
  12022. import { Nullable } from "babylonjs/types";
  12023. import { Scene } from "babylonjs/scene";
  12024. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  12025. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12026. import { Effect } from "babylonjs/Materials/effect";
  12027. import { Texture } from "babylonjs/Materials/Textures/texture";
  12028. import "babylonjs/Engines/Extensions/engine.renderTarget";
  12029. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  12030. import "babylonjs/Shaders/procedural.vertex";
  12031. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  12032. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  12033. /**
  12034. * 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.
  12035. * This is the base class of any Procedural texture and contains most of the shareable code.
  12036. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12037. */
  12038. export class ProceduralTexture extends Texture {
  12039. /**
  12040. * Define if the texture is enabled or not (disabled texture will not render)
  12041. */
  12042. isEnabled: boolean;
  12043. /**
  12044. * Define if the texture must be cleared before rendering (default is true)
  12045. */
  12046. autoClear: boolean;
  12047. /**
  12048. * Callback called when the texture is generated
  12049. */
  12050. onGenerated: () => void;
  12051. /**
  12052. * Event raised when the texture is generated
  12053. */
  12054. onGeneratedObservable: Observable<ProceduralTexture>;
  12055. /**
  12056. * Event raised before the texture is generated
  12057. */
  12058. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12059. /**
  12060. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12061. */
  12062. nodeMaterialSource: Nullable<NodeMaterial>;
  12063. /** @hidden */
  12064. _generateMipMaps: boolean;
  12065. /** @hidden **/
  12066. _effect: Effect;
  12067. /** @hidden */
  12068. _textures: {
  12069. [key: string]: Texture;
  12070. };
  12071. /** @hidden */
  12072. protected _fallbackTexture: Nullable<Texture>;
  12073. private _size;
  12074. private _currentRefreshId;
  12075. private _frameId;
  12076. private _refreshRate;
  12077. private _vertexBuffers;
  12078. private _indexBuffer;
  12079. private _uniforms;
  12080. private _samplers;
  12081. private _fragment;
  12082. private _floats;
  12083. private _ints;
  12084. private _floatsArrays;
  12085. private _colors3;
  12086. private _colors4;
  12087. private _vectors2;
  12088. private _vectors3;
  12089. private _matrices;
  12090. private _fallbackTextureUsed;
  12091. private _fullEngine;
  12092. private _cachedDefines;
  12093. private _contentUpdateId;
  12094. private _contentData;
  12095. /**
  12096. * Instantiates a new procedural texture.
  12097. * 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.
  12098. * This is the base class of any Procedural texture and contains most of the shareable code.
  12099. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12100. * @param name Define the name of the texture
  12101. * @param size Define the size of the texture to create
  12102. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12103. * @param scene Define the scene the texture belongs to
  12104. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12105. * @param generateMipMaps Define if the texture should creates mip maps or not
  12106. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12107. * @param textureType The FBO internal texture type
  12108. */
  12109. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  12110. /**
  12111. * The effect that is created when initializing the post process.
  12112. * @returns The created effect corresponding the the postprocess.
  12113. */
  12114. getEffect(): Effect;
  12115. /**
  12116. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12117. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12118. */
  12119. getContent(): Nullable<ArrayBufferView>;
  12120. private _createIndexBuffer;
  12121. /** @hidden */
  12122. _rebuild(): void;
  12123. /**
  12124. * Resets the texture in order to recreate its associated resources.
  12125. * This can be called in case of context loss
  12126. */
  12127. reset(): void;
  12128. protected _getDefines(): string;
  12129. /**
  12130. * Is the texture ready to be used ? (rendered at least once)
  12131. * @returns true if ready, otherwise, false.
  12132. */
  12133. isReady(): boolean;
  12134. /**
  12135. * Resets the refresh counter of the texture and start bak from scratch.
  12136. * Could be useful to regenerate the texture if it is setup to render only once.
  12137. */
  12138. resetRefreshCounter(): void;
  12139. /**
  12140. * Set the fragment shader to use in order to render the texture.
  12141. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12142. */
  12143. setFragment(fragment: any): void;
  12144. /**
  12145. * Define the refresh rate of the texture or the rendering frequency.
  12146. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12147. */
  12148. get refreshRate(): number;
  12149. set refreshRate(value: number);
  12150. /** @hidden */
  12151. _shouldRender(): boolean;
  12152. /**
  12153. * Get the size the texture is rendering at.
  12154. * @returns the size (on cube texture it is always squared)
  12155. */
  12156. getRenderSize(): RenderTargetTextureSize;
  12157. /**
  12158. * Resize the texture to new value.
  12159. * @param size Define the new size the texture should have
  12160. * @param generateMipMaps Define whether the new texture should create mip maps
  12161. */
  12162. resize(size: number, generateMipMaps: boolean): void;
  12163. private _checkUniform;
  12164. /**
  12165. * Set a texture in the shader program used to render.
  12166. * @param name Define the name of the uniform samplers as defined in the shader
  12167. * @param texture Define the texture to bind to this sampler
  12168. * @return the texture itself allowing "fluent" like uniform updates
  12169. */
  12170. setTexture(name: string, texture: Texture): ProceduralTexture;
  12171. /**
  12172. * Set a float in the shader.
  12173. * @param name Define the name of the uniform as defined in the shader
  12174. * @param value Define the value to give to the uniform
  12175. * @return the texture itself allowing "fluent" like uniform updates
  12176. */
  12177. setFloat(name: string, value: number): ProceduralTexture;
  12178. /**
  12179. * Set a int in the shader.
  12180. * @param name Define the name of the uniform as defined in the shader
  12181. * @param value Define the value to give to the uniform
  12182. * @return the texture itself allowing "fluent" like uniform updates
  12183. */
  12184. setInt(name: string, value: number): ProceduralTexture;
  12185. /**
  12186. * Set an array of floats in the shader.
  12187. * @param name Define the name of the uniform as defined in the shader
  12188. * @param value Define the value to give to the uniform
  12189. * @return the texture itself allowing "fluent" like uniform updates
  12190. */
  12191. setFloats(name: string, value: number[]): ProceduralTexture;
  12192. /**
  12193. * Set a vec3 in the shader from a Color3.
  12194. * @param name Define the name of the uniform as defined in the shader
  12195. * @param value Define the value to give to the uniform
  12196. * @return the texture itself allowing "fluent" like uniform updates
  12197. */
  12198. setColor3(name: string, value: Color3): ProceduralTexture;
  12199. /**
  12200. * Set a vec4 in the shader from a Color4.
  12201. * @param name Define the name of the uniform as defined in the shader
  12202. * @param value Define the value to give to the uniform
  12203. * @return the texture itself allowing "fluent" like uniform updates
  12204. */
  12205. setColor4(name: string, value: Color4): ProceduralTexture;
  12206. /**
  12207. * Set a vec2 in the shader from a Vector2.
  12208. * @param name Define the name of the uniform as defined in the shader
  12209. * @param value Define the value to give to the uniform
  12210. * @return the texture itself allowing "fluent" like uniform updates
  12211. */
  12212. setVector2(name: string, value: Vector2): ProceduralTexture;
  12213. /**
  12214. * Set a vec3 in the shader from a Vector3.
  12215. * @param name Define the name of the uniform as defined in the shader
  12216. * @param value Define the value to give to the uniform
  12217. * @return the texture itself allowing "fluent" like uniform updates
  12218. */
  12219. setVector3(name: string, value: Vector3): ProceduralTexture;
  12220. /**
  12221. * Set a mat4 in the shader from a MAtrix.
  12222. * @param name Define the name of the uniform as defined in the shader
  12223. * @param value Define the value to give to the uniform
  12224. * @return the texture itself allowing "fluent" like uniform updates
  12225. */
  12226. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12227. /**
  12228. * Render the texture to its associated render target.
  12229. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12230. */
  12231. render(useCameraPostProcess?: boolean): void;
  12232. /**
  12233. * Clone the texture.
  12234. * @returns the cloned texture
  12235. */
  12236. clone(): ProceduralTexture;
  12237. /**
  12238. * Dispose the texture and release its asoociated resources.
  12239. */
  12240. dispose(): void;
  12241. }
  12242. }
  12243. declare module "babylonjs/Particles/baseParticleSystem" {
  12244. import { Nullable } from "babylonjs/types";
  12245. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12247. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12248. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12249. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12250. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12251. import { Color4 } from "babylonjs/Maths/math.color";
  12252. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12253. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12254. import { Animation } from "babylonjs/Animations/animation";
  12255. import { Scene } from "babylonjs/scene";
  12256. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12257. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12258. /**
  12259. * This represents the base class for particle system in Babylon.
  12260. * 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.
  12261. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12262. * @example https://doc.babylonjs.com/babylon101/particles
  12263. */
  12264. export class BaseParticleSystem {
  12265. /**
  12266. * Source color is added to the destination color without alpha affecting the result
  12267. */
  12268. static BLENDMODE_ONEONE: number;
  12269. /**
  12270. * Blend current color and particle color using particle’s alpha
  12271. */
  12272. static BLENDMODE_STANDARD: number;
  12273. /**
  12274. * Add current color and particle color multiplied by particle’s alpha
  12275. */
  12276. static BLENDMODE_ADD: number;
  12277. /**
  12278. * Multiply current color with particle color
  12279. */
  12280. static BLENDMODE_MULTIPLY: number;
  12281. /**
  12282. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12283. */
  12284. static BLENDMODE_MULTIPLYADD: number;
  12285. /**
  12286. * List of animations used by the particle system.
  12287. */
  12288. animations: Animation[];
  12289. /**
  12290. * Gets or sets the unique id of the particle system
  12291. */
  12292. uniqueId: number;
  12293. /**
  12294. * The id of the Particle system.
  12295. */
  12296. id: string;
  12297. /**
  12298. * The friendly name of the Particle system.
  12299. */
  12300. name: string;
  12301. /**
  12302. * Snippet ID if the particle system was created from the snippet server
  12303. */
  12304. snippetId: string;
  12305. /**
  12306. * The rendering group used by the Particle system to chose when to render.
  12307. */
  12308. renderingGroupId: number;
  12309. /**
  12310. * The emitter represents the Mesh or position we are attaching the particle system to.
  12311. */
  12312. emitter: Nullable<AbstractMesh | Vector3>;
  12313. /**
  12314. * The maximum number of particles to emit per frame
  12315. */
  12316. emitRate: number;
  12317. /**
  12318. * If you want to launch only a few particles at once, that can be done, as well.
  12319. */
  12320. manualEmitCount: number;
  12321. /**
  12322. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12323. */
  12324. updateSpeed: number;
  12325. /**
  12326. * The amount of time the particle system is running (depends of the overall update speed).
  12327. */
  12328. targetStopDuration: number;
  12329. /**
  12330. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12331. */
  12332. disposeOnStop: boolean;
  12333. /**
  12334. * Minimum power of emitting particles.
  12335. */
  12336. minEmitPower: number;
  12337. /**
  12338. * Maximum power of emitting particles.
  12339. */
  12340. maxEmitPower: number;
  12341. /**
  12342. * Minimum life time of emitting particles.
  12343. */
  12344. minLifeTime: number;
  12345. /**
  12346. * Maximum life time of emitting particles.
  12347. */
  12348. maxLifeTime: number;
  12349. /**
  12350. * Minimum Size of emitting particles.
  12351. */
  12352. minSize: number;
  12353. /**
  12354. * Maximum Size of emitting particles.
  12355. */
  12356. maxSize: number;
  12357. /**
  12358. * Minimum scale of emitting particles on X axis.
  12359. */
  12360. minScaleX: number;
  12361. /**
  12362. * Maximum scale of emitting particles on X axis.
  12363. */
  12364. maxScaleX: number;
  12365. /**
  12366. * Minimum scale of emitting particles on Y axis.
  12367. */
  12368. minScaleY: number;
  12369. /**
  12370. * Maximum scale of emitting particles on Y axis.
  12371. */
  12372. maxScaleY: number;
  12373. /**
  12374. * Gets or sets the minimal initial rotation in radians.
  12375. */
  12376. minInitialRotation: number;
  12377. /**
  12378. * Gets or sets the maximal initial rotation in radians.
  12379. */
  12380. maxInitialRotation: number;
  12381. /**
  12382. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12383. */
  12384. minAngularSpeed: number;
  12385. /**
  12386. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12387. */
  12388. maxAngularSpeed: number;
  12389. /**
  12390. * The texture used to render each particle. (this can be a spritesheet)
  12391. */
  12392. particleTexture: Nullable<BaseTexture>;
  12393. /**
  12394. * The layer mask we are rendering the particles through.
  12395. */
  12396. layerMask: number;
  12397. /**
  12398. * This can help using your own shader to render the particle system.
  12399. * The according effect will be created
  12400. */
  12401. customShader: any;
  12402. /**
  12403. * By default particle system starts as soon as they are created. This prevents the
  12404. * automatic start to happen and let you decide when to start emitting particles.
  12405. */
  12406. preventAutoStart: boolean;
  12407. private _noiseTexture;
  12408. /**
  12409. * Gets or sets a texture used to add random noise to particle positions
  12410. */
  12411. get noiseTexture(): Nullable<ProceduralTexture>;
  12412. set noiseTexture(value: Nullable<ProceduralTexture>);
  12413. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12414. noiseStrength: Vector3;
  12415. /**
  12416. * Callback triggered when the particle animation is ending.
  12417. */
  12418. onAnimationEnd: Nullable<() => void>;
  12419. /**
  12420. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12421. */
  12422. blendMode: number;
  12423. /**
  12424. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12425. * to override the particles.
  12426. */
  12427. forceDepthWrite: boolean;
  12428. /** 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 */
  12429. preWarmCycles: number;
  12430. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12431. preWarmStepOffset: number;
  12432. /**
  12433. * 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)
  12434. */
  12435. spriteCellChangeSpeed: number;
  12436. /**
  12437. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12438. */
  12439. startSpriteCellID: number;
  12440. /**
  12441. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12442. */
  12443. endSpriteCellID: number;
  12444. /**
  12445. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12446. */
  12447. spriteCellWidth: number;
  12448. /**
  12449. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12450. */
  12451. spriteCellHeight: number;
  12452. /**
  12453. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12454. */
  12455. spriteRandomStartCell: boolean;
  12456. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12457. translationPivot: Vector2;
  12458. /** @hidden */
  12459. protected _isAnimationSheetEnabled: boolean;
  12460. /**
  12461. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12462. */
  12463. beginAnimationOnStart: boolean;
  12464. /**
  12465. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12466. */
  12467. beginAnimationFrom: number;
  12468. /**
  12469. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12470. */
  12471. beginAnimationTo: number;
  12472. /**
  12473. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12474. */
  12475. beginAnimationLoop: boolean;
  12476. /**
  12477. * Gets or sets a world offset applied to all particles
  12478. */
  12479. worldOffset: Vector3;
  12480. /**
  12481. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12482. */
  12483. get isAnimationSheetEnabled(): boolean;
  12484. set isAnimationSheetEnabled(value: boolean);
  12485. /**
  12486. * Get hosting scene
  12487. * @returns the scene
  12488. */
  12489. getScene(): Nullable<Scene>;
  12490. /**
  12491. * You can use gravity if you want to give an orientation to your particles.
  12492. */
  12493. gravity: Vector3;
  12494. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12495. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12496. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12497. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12498. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12499. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12500. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12501. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12502. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12503. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12504. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12505. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12506. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12507. /**
  12508. * Defines the delay in milliseconds before starting the system (0 by default)
  12509. */
  12510. startDelay: number;
  12511. /**
  12512. * Gets the current list of drag gradients.
  12513. * You must use addDragGradient and removeDragGradient to udpate this list
  12514. * @returns the list of drag gradients
  12515. */
  12516. getDragGradients(): Nullable<Array<FactorGradient>>;
  12517. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12518. limitVelocityDamping: number;
  12519. /**
  12520. * Gets the current list of limit velocity gradients.
  12521. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12522. * @returns the list of limit velocity gradients
  12523. */
  12524. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12525. /**
  12526. * Gets the current list of color gradients.
  12527. * You must use addColorGradient and removeColorGradient to udpate this list
  12528. * @returns the list of color gradients
  12529. */
  12530. getColorGradients(): Nullable<Array<ColorGradient>>;
  12531. /**
  12532. * Gets the current list of size gradients.
  12533. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12534. * @returns the list of size gradients
  12535. */
  12536. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12537. /**
  12538. * Gets the current list of color remap gradients.
  12539. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12540. * @returns the list of color remap gradients
  12541. */
  12542. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12543. /**
  12544. * Gets the current list of alpha remap gradients.
  12545. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12546. * @returns the list of alpha remap gradients
  12547. */
  12548. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12549. /**
  12550. * Gets the current list of life time gradients.
  12551. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12552. * @returns the list of life time gradients
  12553. */
  12554. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12555. /**
  12556. * Gets the current list of angular speed gradients.
  12557. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12558. * @returns the list of angular speed gradients
  12559. */
  12560. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12561. /**
  12562. * Gets the current list of velocity gradients.
  12563. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12564. * @returns the list of velocity gradients
  12565. */
  12566. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12567. /**
  12568. * Gets the current list of start size gradients.
  12569. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12570. * @returns the list of start size gradients
  12571. */
  12572. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12573. /**
  12574. * Gets the current list of emit rate gradients.
  12575. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12576. * @returns the list of emit rate gradients
  12577. */
  12578. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12579. /**
  12580. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12581. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12582. */
  12583. get direction1(): Vector3;
  12584. set direction1(value: Vector3);
  12585. /**
  12586. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12587. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12588. */
  12589. get direction2(): Vector3;
  12590. set direction2(value: Vector3);
  12591. /**
  12592. * 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.
  12593. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12594. */
  12595. get minEmitBox(): Vector3;
  12596. set minEmitBox(value: Vector3);
  12597. /**
  12598. * 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.
  12599. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12600. */
  12601. get maxEmitBox(): Vector3;
  12602. set maxEmitBox(value: Vector3);
  12603. /**
  12604. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12605. */
  12606. color1: Color4;
  12607. /**
  12608. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12609. */
  12610. color2: Color4;
  12611. /**
  12612. * Color the particle will have at the end of its lifetime
  12613. */
  12614. colorDead: Color4;
  12615. /**
  12616. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12617. */
  12618. textureMask: Color4;
  12619. /**
  12620. * The particle emitter type defines the emitter used by the particle system.
  12621. * It can be for example box, sphere, or cone...
  12622. */
  12623. particleEmitterType: IParticleEmitterType;
  12624. /** @hidden */
  12625. _isSubEmitter: boolean;
  12626. /**
  12627. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12628. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12629. */
  12630. billboardMode: number;
  12631. protected _isBillboardBased: boolean;
  12632. /**
  12633. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12634. */
  12635. get isBillboardBased(): boolean;
  12636. set isBillboardBased(value: boolean);
  12637. /**
  12638. * The scene the particle system belongs to.
  12639. */
  12640. protected _scene: Nullable<Scene>;
  12641. /**
  12642. * The engine the particle system belongs to.
  12643. */
  12644. protected _engine: ThinEngine;
  12645. /**
  12646. * Local cache of defines for image processing.
  12647. */
  12648. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12649. /**
  12650. * Default configuration related to image processing available in the standard Material.
  12651. */
  12652. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12653. /**
  12654. * Gets the image processing configuration used either in this material.
  12655. */
  12656. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12657. /**
  12658. * Sets the Default image processing configuration used either in the this material.
  12659. *
  12660. * If sets to null, the scene one is in use.
  12661. */
  12662. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12663. /**
  12664. * Attaches a new image processing configuration to the Standard Material.
  12665. * @param configuration
  12666. */
  12667. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12668. /** @hidden */
  12669. protected _reset(): void;
  12670. /** @hidden */
  12671. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12672. /**
  12673. * Instantiates a particle system.
  12674. * 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.
  12675. * @param name The name of the particle system
  12676. */
  12677. constructor(name: string);
  12678. /**
  12679. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12680. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12681. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12682. * @returns the emitter
  12683. */
  12684. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12685. /**
  12686. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12687. * @param radius The radius of the hemisphere to emit from
  12688. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12689. * @returns the emitter
  12690. */
  12691. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12692. /**
  12693. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12694. * @param radius The radius of the sphere to emit from
  12695. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12696. * @returns the emitter
  12697. */
  12698. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12699. /**
  12700. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12701. * @param radius The radius of the sphere to emit from
  12702. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12703. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12704. * @returns the emitter
  12705. */
  12706. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12707. /**
  12708. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12709. * @param radius The radius of the emission cylinder
  12710. * @param height The height of the emission cylinder
  12711. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12712. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12713. * @returns the emitter
  12714. */
  12715. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12716. /**
  12717. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12718. * @param radius The radius of the cylinder to emit from
  12719. * @param height The height of the emission cylinder
  12720. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12721. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12722. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12723. * @returns the emitter
  12724. */
  12725. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12726. /**
  12727. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12728. * @param radius The radius of the cone to emit from
  12729. * @param angle The base angle of the cone
  12730. * @returns the emitter
  12731. */
  12732. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12733. /**
  12734. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12735. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12736. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12737. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12738. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12739. * @returns the emitter
  12740. */
  12741. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12742. }
  12743. }
  12744. declare module "babylonjs/Particles/subEmitter" {
  12745. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12746. import { Scene } from "babylonjs/scene";
  12747. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12748. /**
  12749. * Type of sub emitter
  12750. */
  12751. export enum SubEmitterType {
  12752. /**
  12753. * Attached to the particle over it's lifetime
  12754. */
  12755. ATTACHED = 0,
  12756. /**
  12757. * Created when the particle dies
  12758. */
  12759. END = 1
  12760. }
  12761. /**
  12762. * Sub emitter class used to emit particles from an existing particle
  12763. */
  12764. export class SubEmitter {
  12765. /**
  12766. * the particle system to be used by the sub emitter
  12767. */
  12768. particleSystem: ParticleSystem;
  12769. /**
  12770. * Type of the submitter (Default: END)
  12771. */
  12772. type: SubEmitterType;
  12773. /**
  12774. * 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)
  12775. * Note: This only is supported when using an emitter of type Mesh
  12776. */
  12777. inheritDirection: boolean;
  12778. /**
  12779. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12780. */
  12781. inheritedVelocityAmount: number;
  12782. /**
  12783. * Creates a sub emitter
  12784. * @param particleSystem the particle system to be used by the sub emitter
  12785. */
  12786. constructor(
  12787. /**
  12788. * the particle system to be used by the sub emitter
  12789. */
  12790. particleSystem: ParticleSystem);
  12791. /**
  12792. * Clones the sub emitter
  12793. * @returns the cloned sub emitter
  12794. */
  12795. clone(): SubEmitter;
  12796. /**
  12797. * Serialize current object to a JSON object
  12798. * @returns the serialized object
  12799. */
  12800. serialize(): any;
  12801. /** @hidden */
  12802. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12803. /**
  12804. * Creates a new SubEmitter from a serialized JSON version
  12805. * @param serializationObject defines the JSON object to read from
  12806. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12807. * @param rootUrl defines the rootUrl for data loading
  12808. * @returns a new SubEmitter
  12809. */
  12810. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12811. /** Release associated resources */
  12812. dispose(): void;
  12813. }
  12814. }
  12815. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12816. /** @hidden */
  12817. export var imageProcessingDeclaration: {
  12818. name: string;
  12819. shader: string;
  12820. };
  12821. }
  12822. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12823. /** @hidden */
  12824. export var imageProcessingFunctions: {
  12825. name: string;
  12826. shader: string;
  12827. };
  12828. }
  12829. declare module "babylonjs/Shaders/particles.fragment" {
  12830. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12831. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12832. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12833. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12834. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12835. /** @hidden */
  12836. export var particlesPixelShader: {
  12837. name: string;
  12838. shader: string;
  12839. };
  12840. }
  12841. declare module "babylonjs/Shaders/particles.vertex" {
  12842. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12843. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12844. /** @hidden */
  12845. export var particlesVertexShader: {
  12846. name: string;
  12847. shader: string;
  12848. };
  12849. }
  12850. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12851. import { Nullable } from "babylonjs/types";
  12852. import { Plane } from "babylonjs/Maths/math";
  12853. /**
  12854. * Interface used to define entities containing multiple clip planes
  12855. */
  12856. export interface IClipPlanesHolder {
  12857. /**
  12858. * Gets or sets the active clipplane 1
  12859. */
  12860. clipPlane: Nullable<Plane>;
  12861. /**
  12862. * Gets or sets the active clipplane 2
  12863. */
  12864. clipPlane2: Nullable<Plane>;
  12865. /**
  12866. * Gets or sets the active clipplane 3
  12867. */
  12868. clipPlane3: Nullable<Plane>;
  12869. /**
  12870. * Gets or sets the active clipplane 4
  12871. */
  12872. clipPlane4: Nullable<Plane>;
  12873. /**
  12874. * Gets or sets the active clipplane 5
  12875. */
  12876. clipPlane5: Nullable<Plane>;
  12877. /**
  12878. * Gets or sets the active clipplane 6
  12879. */
  12880. clipPlane6: Nullable<Plane>;
  12881. }
  12882. }
  12883. declare module "babylonjs/Materials/thinMaterialHelper" {
  12884. import { Effect } from "babylonjs/Materials/effect";
  12885. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12886. /**
  12887. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12888. *
  12889. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12890. *
  12891. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12892. */
  12893. export class ThinMaterialHelper {
  12894. /**
  12895. * Binds the clip plane information from the holder to the effect.
  12896. * @param effect The effect we are binding the data to
  12897. * @param holder The entity containing the clip plane information
  12898. */
  12899. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12900. }
  12901. }
  12902. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12903. module "babylonjs/Engines/thinEngine" {
  12904. interface ThinEngine {
  12905. /**
  12906. * Sets alpha constants used by some alpha blending modes
  12907. * @param r defines the red component
  12908. * @param g defines the green component
  12909. * @param b defines the blue component
  12910. * @param a defines the alpha component
  12911. */
  12912. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12913. /**
  12914. * Sets the current alpha mode
  12915. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12916. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12917. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12918. */
  12919. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12920. /**
  12921. * Gets the current alpha mode
  12922. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12923. * @returns the current alpha mode
  12924. */
  12925. getAlphaMode(): number;
  12926. /**
  12927. * Sets the current alpha equation
  12928. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12929. */
  12930. setAlphaEquation(equation: number): void;
  12931. /**
  12932. * Gets the current alpha equation.
  12933. * @returns the current alpha equation
  12934. */
  12935. getAlphaEquation(): number;
  12936. }
  12937. }
  12938. }
  12939. declare module "babylonjs/Particles/particleSystem" {
  12940. import { Nullable } from "babylonjs/types";
  12941. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12942. import { Observable } from "babylonjs/Misc/observable";
  12943. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12944. import { Effect } from "babylonjs/Materials/effect";
  12945. import { IDisposable } from "babylonjs/scene";
  12946. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12947. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12948. import { Particle } from "babylonjs/Particles/particle";
  12949. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12950. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12951. import "babylonjs/Shaders/particles.fragment";
  12952. import "babylonjs/Shaders/particles.vertex";
  12953. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12954. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12955. import "babylonjs/Engines/Extensions/engine.alpha";
  12956. import { Scene } from "babylonjs/scene";
  12957. /**
  12958. * This represents a particle system in Babylon.
  12959. * 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.
  12960. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12961. * @example https://doc.babylonjs.com/babylon101/particles
  12962. */
  12963. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12964. /**
  12965. * Billboard mode will only apply to Y axis
  12966. */
  12967. static readonly BILLBOARDMODE_Y: number;
  12968. /**
  12969. * Billboard mode will apply to all axes
  12970. */
  12971. static readonly BILLBOARDMODE_ALL: number;
  12972. /**
  12973. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12974. */
  12975. static readonly BILLBOARDMODE_STRETCHED: number;
  12976. /**
  12977. * This function can be defined to provide custom update for active particles.
  12978. * This function will be called instead of regular update (age, position, color, etc.).
  12979. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12980. */
  12981. updateFunction: (particles: Particle[]) => void;
  12982. private _emitterWorldMatrix;
  12983. /**
  12984. * This function can be defined to specify initial direction for every new particle.
  12985. * It by default use the emitterType defined function
  12986. */
  12987. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12988. /**
  12989. * This function can be defined to specify initial position for every new particle.
  12990. * It by default use the emitterType defined function
  12991. */
  12992. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12993. /**
  12994. * @hidden
  12995. */
  12996. _inheritedVelocityOffset: Vector3;
  12997. /**
  12998. * An event triggered when the system is disposed
  12999. */
  13000. onDisposeObservable: Observable<IParticleSystem>;
  13001. /**
  13002. * An event triggered when the system is stopped
  13003. */
  13004. onStoppedObservable: Observable<IParticleSystem>;
  13005. private _onDisposeObserver;
  13006. /**
  13007. * Sets a callback that will be triggered when the system is disposed
  13008. */
  13009. set onDispose(callback: () => void);
  13010. private _particles;
  13011. private _epsilon;
  13012. private _capacity;
  13013. private _stockParticles;
  13014. private _newPartsExcess;
  13015. private _vertexData;
  13016. private _vertexBuffer;
  13017. private _vertexBuffers;
  13018. private _spriteBuffer;
  13019. private _indexBuffer;
  13020. private _effect;
  13021. private _customEffect;
  13022. private _cachedDefines;
  13023. private _scaledColorStep;
  13024. private _colorDiff;
  13025. private _scaledDirection;
  13026. private _scaledGravity;
  13027. private _currentRenderId;
  13028. private _alive;
  13029. private _useInstancing;
  13030. private _vertexArrayObject;
  13031. private _started;
  13032. private _stopped;
  13033. private _actualFrame;
  13034. private _scaledUpdateSpeed;
  13035. private _vertexBufferSize;
  13036. /** @hidden */
  13037. _currentEmitRateGradient: Nullable<FactorGradient>;
  13038. /** @hidden */
  13039. _currentEmitRate1: number;
  13040. /** @hidden */
  13041. _currentEmitRate2: number;
  13042. /** @hidden */
  13043. _currentStartSizeGradient: Nullable<FactorGradient>;
  13044. /** @hidden */
  13045. _currentStartSize1: number;
  13046. /** @hidden */
  13047. _currentStartSize2: number;
  13048. private readonly _rawTextureWidth;
  13049. private _rampGradientsTexture;
  13050. private _useRampGradients;
  13051. /** Gets or sets a matrix to use to compute projection */
  13052. defaultProjectionMatrix: Matrix;
  13053. /** Gets or sets a matrix to use to compute view */
  13054. defaultViewMatrix: Matrix;
  13055. /** Gets or sets a boolean indicating that ramp gradients must be used
  13056. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13057. */
  13058. get useRampGradients(): boolean;
  13059. set useRampGradients(value: boolean);
  13060. /**
  13061. * 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.
  13062. * 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: [])
  13063. */
  13064. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13065. private _subEmitters;
  13066. /**
  13067. * @hidden
  13068. * If the particle systems emitter should be disposed when the particle system is disposed
  13069. */
  13070. _disposeEmitterOnDispose: boolean;
  13071. /**
  13072. * The current active Sub-systems, this property is used by the root particle system only.
  13073. */
  13074. activeSubSystems: Array<ParticleSystem>;
  13075. /**
  13076. * Specifies if the particles are updated in emitter local space or world space
  13077. */
  13078. isLocal: boolean;
  13079. private _rootParticleSystem;
  13080. /**
  13081. * Gets the current list of active particles
  13082. */
  13083. get particles(): Particle[];
  13084. /**
  13085. * Gets the number of particles active at the same time.
  13086. * @returns The number of active particles.
  13087. */
  13088. getActiveCount(): number;
  13089. /**
  13090. * Returns the string "ParticleSystem"
  13091. * @returns a string containing the class name
  13092. */
  13093. getClassName(): string;
  13094. /**
  13095. * Gets a boolean indicating that the system is stopping
  13096. * @returns true if the system is currently stopping
  13097. */
  13098. isStopping(): boolean;
  13099. /**
  13100. * Gets the custom effect used to render the particles
  13101. * @param blendMode Blend mode for which the effect should be retrieved
  13102. * @returns The effect
  13103. */
  13104. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13105. /**
  13106. * Sets the custom effect used to render the particles
  13107. * @param effect The effect to set
  13108. * @param blendMode Blend mode for which the effect should be set
  13109. */
  13110. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13111. /** @hidden */
  13112. private _onBeforeDrawParticlesObservable;
  13113. /**
  13114. * Observable that will be called just before the particles are drawn
  13115. */
  13116. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13117. /**
  13118. * Gets the name of the particle vertex shader
  13119. */
  13120. get vertexShaderName(): string;
  13121. /**
  13122. * Instantiates a particle system.
  13123. * 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.
  13124. * @param name The name of the particle system
  13125. * @param capacity The max number of particles alive at the same time
  13126. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13127. * @param customEffect a custom effect used to change the way particles are rendered by default
  13128. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13129. * @param epsilon Offset used to render the particles
  13130. */
  13131. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13132. private _addFactorGradient;
  13133. private _removeFactorGradient;
  13134. /**
  13135. * Adds a new life time gradient
  13136. * @param gradient defines the gradient to use (between 0 and 1)
  13137. * @param factor defines the life time factor to affect to the specified gradient
  13138. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13139. * @returns the current particle system
  13140. */
  13141. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13142. /**
  13143. * Remove a specific life time gradient
  13144. * @param gradient defines the gradient to remove
  13145. * @returns the current particle system
  13146. */
  13147. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13148. /**
  13149. * Adds a new size gradient
  13150. * @param gradient defines the gradient to use (between 0 and 1)
  13151. * @param factor defines the size factor to affect to the specified gradient
  13152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13153. * @returns the current particle system
  13154. */
  13155. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13156. /**
  13157. * Remove a specific size gradient
  13158. * @param gradient defines the gradient to remove
  13159. * @returns the current particle system
  13160. */
  13161. removeSizeGradient(gradient: number): IParticleSystem;
  13162. /**
  13163. * Adds a new color remap gradient
  13164. * @param gradient defines the gradient to use (between 0 and 1)
  13165. * @param min defines the color remap minimal range
  13166. * @param max defines the color remap maximal range
  13167. * @returns the current particle system
  13168. */
  13169. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13170. /**
  13171. * Remove a specific color remap gradient
  13172. * @param gradient defines the gradient to remove
  13173. * @returns the current particle system
  13174. */
  13175. removeColorRemapGradient(gradient: number): IParticleSystem;
  13176. /**
  13177. * Adds a new alpha remap gradient
  13178. * @param gradient defines the gradient to use (between 0 and 1)
  13179. * @param min defines the alpha remap minimal range
  13180. * @param max defines the alpha remap maximal range
  13181. * @returns the current particle system
  13182. */
  13183. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13184. /**
  13185. * Remove a specific alpha remap gradient
  13186. * @param gradient defines the gradient to remove
  13187. * @returns the current particle system
  13188. */
  13189. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13190. /**
  13191. * Adds a new angular speed gradient
  13192. * @param gradient defines the gradient to use (between 0 and 1)
  13193. * @param factor defines the angular speed to affect to the specified gradient
  13194. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13195. * @returns the current particle system
  13196. */
  13197. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13198. /**
  13199. * Remove a specific angular speed gradient
  13200. * @param gradient defines the gradient to remove
  13201. * @returns the current particle system
  13202. */
  13203. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13204. /**
  13205. * Adds a new velocity gradient
  13206. * @param gradient defines the gradient to use (between 0 and 1)
  13207. * @param factor defines the velocity to affect to the specified gradient
  13208. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13209. * @returns the current particle system
  13210. */
  13211. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13212. /**
  13213. * Remove a specific velocity gradient
  13214. * @param gradient defines the gradient to remove
  13215. * @returns the current particle system
  13216. */
  13217. removeVelocityGradient(gradient: number): IParticleSystem;
  13218. /**
  13219. * Adds a new limit velocity gradient
  13220. * @param gradient defines the gradient to use (between 0 and 1)
  13221. * @param factor defines the limit velocity value to affect to the specified gradient
  13222. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13223. * @returns the current particle system
  13224. */
  13225. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13226. /**
  13227. * Remove a specific limit velocity gradient
  13228. * @param gradient defines the gradient to remove
  13229. * @returns the current particle system
  13230. */
  13231. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13232. /**
  13233. * Adds a new drag gradient
  13234. * @param gradient defines the gradient to use (between 0 and 1)
  13235. * @param factor defines the drag value to affect to the specified gradient
  13236. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13237. * @returns the current particle system
  13238. */
  13239. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13240. /**
  13241. * Remove a specific drag gradient
  13242. * @param gradient defines the gradient to remove
  13243. * @returns the current particle system
  13244. */
  13245. removeDragGradient(gradient: number): IParticleSystem;
  13246. /**
  13247. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13248. * @param gradient defines the gradient to use (between 0 and 1)
  13249. * @param factor defines the emit rate value to affect to the specified gradient
  13250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13251. * @returns the current particle system
  13252. */
  13253. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13254. /**
  13255. * Remove a specific emit rate gradient
  13256. * @param gradient defines the gradient to remove
  13257. * @returns the current particle system
  13258. */
  13259. removeEmitRateGradient(gradient: number): IParticleSystem;
  13260. /**
  13261. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13262. * @param gradient defines the gradient to use (between 0 and 1)
  13263. * @param factor defines the start size value to affect to the specified gradient
  13264. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13265. * @returns the current particle system
  13266. */
  13267. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13268. /**
  13269. * Remove a specific start size gradient
  13270. * @param gradient defines the gradient to remove
  13271. * @returns the current particle system
  13272. */
  13273. removeStartSizeGradient(gradient: number): IParticleSystem;
  13274. private _createRampGradientTexture;
  13275. /**
  13276. * Gets the current list of ramp gradients.
  13277. * You must use addRampGradient and removeRampGradient to udpate this list
  13278. * @returns the list of ramp gradients
  13279. */
  13280. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13281. /** Force the system to rebuild all gradients that need to be resync */
  13282. forceRefreshGradients(): void;
  13283. private _syncRampGradientTexture;
  13284. /**
  13285. * Adds a new ramp gradient used to remap particle colors
  13286. * @param gradient defines the gradient to use (between 0 and 1)
  13287. * @param color defines the color to affect to the specified gradient
  13288. * @returns the current particle system
  13289. */
  13290. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13291. /**
  13292. * Remove a specific ramp gradient
  13293. * @param gradient defines the gradient to remove
  13294. * @returns the current particle system
  13295. */
  13296. removeRampGradient(gradient: number): ParticleSystem;
  13297. /**
  13298. * Adds a new color gradient
  13299. * @param gradient defines the gradient to use (between 0 and 1)
  13300. * @param color1 defines the color to affect to the specified gradient
  13301. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13302. * @returns this particle system
  13303. */
  13304. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13305. /**
  13306. * Remove a specific color gradient
  13307. * @param gradient defines the gradient to remove
  13308. * @returns this particle system
  13309. */
  13310. removeColorGradient(gradient: number): IParticleSystem;
  13311. private _fetchR;
  13312. protected _reset(): void;
  13313. private _resetEffect;
  13314. private _createVertexBuffers;
  13315. private _createIndexBuffer;
  13316. /**
  13317. * Gets the maximum number of particles active at the same time.
  13318. * @returns The max number of active particles.
  13319. */
  13320. getCapacity(): number;
  13321. /**
  13322. * Gets whether there are still active particles in the system.
  13323. * @returns True if it is alive, otherwise false.
  13324. */
  13325. isAlive(): boolean;
  13326. /**
  13327. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13328. * @returns True if it has been started, otherwise false.
  13329. */
  13330. isStarted(): boolean;
  13331. private _prepareSubEmitterInternalArray;
  13332. /**
  13333. * Starts the particle system and begins to emit
  13334. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13335. */
  13336. start(delay?: number): void;
  13337. /**
  13338. * Stops the particle system.
  13339. * @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.
  13340. */
  13341. stop(stopSubEmitters?: boolean): void;
  13342. /**
  13343. * Remove all active particles
  13344. */
  13345. reset(): void;
  13346. /**
  13347. * @hidden (for internal use only)
  13348. */
  13349. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13350. /**
  13351. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13352. * Its lifetime will start back at 0.
  13353. */
  13354. recycleParticle: (particle: Particle) => void;
  13355. private _stopSubEmitters;
  13356. private _createParticle;
  13357. private _removeFromRoot;
  13358. private _emitFromParticle;
  13359. private _update;
  13360. /** @hidden */
  13361. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13362. /** @hidden */
  13363. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13364. /**
  13365. * Fill the defines array according to the current settings of the particle system
  13366. * @param defines Array to be updated
  13367. * @param blendMode blend mode to take into account when updating the array
  13368. */
  13369. fillDefines(defines: Array<string>, blendMode: number): void;
  13370. /**
  13371. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13372. * @param uniforms Uniforms array to fill
  13373. * @param attributes Attributes array to fill
  13374. * @param samplers Samplers array to fill
  13375. */
  13376. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13377. /** @hidden */
  13378. private _getEffect;
  13379. /**
  13380. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13381. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13382. */
  13383. animate(preWarmOnly?: boolean): void;
  13384. private _appendParticleVertices;
  13385. /**
  13386. * Rebuilds the particle system.
  13387. */
  13388. rebuild(): void;
  13389. /**
  13390. * Is this system ready to be used/rendered
  13391. * @return true if the system is ready
  13392. */
  13393. isReady(): boolean;
  13394. private _render;
  13395. /**
  13396. * Renders the particle system in its current state.
  13397. * @returns the current number of particles
  13398. */
  13399. render(): number;
  13400. /**
  13401. * Disposes the particle system and free the associated resources
  13402. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13403. */
  13404. dispose(disposeTexture?: boolean): void;
  13405. /**
  13406. * Clones the particle system.
  13407. * @param name The name of the cloned object
  13408. * @param newEmitter The new emitter to use
  13409. * @returns the cloned particle system
  13410. */
  13411. clone(name: string, newEmitter: any): ParticleSystem;
  13412. /**
  13413. * Serializes the particle system to a JSON object
  13414. * @param serializeTexture defines if the texture must be serialized as well
  13415. * @returns the JSON object
  13416. */
  13417. serialize(serializeTexture?: boolean): any;
  13418. /** @hidden */
  13419. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13420. /** @hidden */
  13421. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13422. /**
  13423. * Parses a JSON object to create a particle system.
  13424. * @param parsedParticleSystem The JSON object to parse
  13425. * @param sceneOrEngine The scene or the engine to create the particle system in
  13426. * @param rootUrl The root url to use to load external dependencies like texture
  13427. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13428. * @returns the Parsed particle system
  13429. */
  13430. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13431. }
  13432. }
  13433. declare module "babylonjs/Particles/particle" {
  13434. import { Nullable } from "babylonjs/types";
  13435. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13436. import { Color4 } from "babylonjs/Maths/math.color";
  13437. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13438. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13439. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13440. /**
  13441. * A particle represents one of the element emitted by a particle system.
  13442. * This is mainly define by its coordinates, direction, velocity and age.
  13443. */
  13444. export class Particle {
  13445. /**
  13446. * The particle system the particle belongs to.
  13447. */
  13448. particleSystem: ParticleSystem;
  13449. private static _Count;
  13450. /**
  13451. * Unique ID of the particle
  13452. */
  13453. id: number;
  13454. /**
  13455. * The world position of the particle in the scene.
  13456. */
  13457. position: Vector3;
  13458. /**
  13459. * The world direction of the particle in the scene.
  13460. */
  13461. direction: Vector3;
  13462. /**
  13463. * The color of the particle.
  13464. */
  13465. color: Color4;
  13466. /**
  13467. * The color change of the particle per step.
  13468. */
  13469. colorStep: Color4;
  13470. /**
  13471. * Defines how long will the life of the particle be.
  13472. */
  13473. lifeTime: number;
  13474. /**
  13475. * The current age of the particle.
  13476. */
  13477. age: number;
  13478. /**
  13479. * The current size of the particle.
  13480. */
  13481. size: number;
  13482. /**
  13483. * The current scale of the particle.
  13484. */
  13485. scale: Vector2;
  13486. /**
  13487. * The current angle of the particle.
  13488. */
  13489. angle: number;
  13490. /**
  13491. * Defines how fast is the angle changing.
  13492. */
  13493. angularSpeed: number;
  13494. /**
  13495. * Defines the cell index used by the particle to be rendered from a sprite.
  13496. */
  13497. cellIndex: number;
  13498. /**
  13499. * The information required to support color remapping
  13500. */
  13501. remapData: Vector4;
  13502. /** @hidden */
  13503. _randomCellOffset?: number;
  13504. /** @hidden */
  13505. _initialDirection: Nullable<Vector3>;
  13506. /** @hidden */
  13507. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13508. /** @hidden */
  13509. _initialStartSpriteCellID: number;
  13510. /** @hidden */
  13511. _initialEndSpriteCellID: number;
  13512. /** @hidden */
  13513. _currentColorGradient: Nullable<ColorGradient>;
  13514. /** @hidden */
  13515. _currentColor1: Color4;
  13516. /** @hidden */
  13517. _currentColor2: Color4;
  13518. /** @hidden */
  13519. _currentSizeGradient: Nullable<FactorGradient>;
  13520. /** @hidden */
  13521. _currentSize1: number;
  13522. /** @hidden */
  13523. _currentSize2: number;
  13524. /** @hidden */
  13525. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13526. /** @hidden */
  13527. _currentAngularSpeed1: number;
  13528. /** @hidden */
  13529. _currentAngularSpeed2: number;
  13530. /** @hidden */
  13531. _currentVelocityGradient: Nullable<FactorGradient>;
  13532. /** @hidden */
  13533. _currentVelocity1: number;
  13534. /** @hidden */
  13535. _currentVelocity2: number;
  13536. /** @hidden */
  13537. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13538. /** @hidden */
  13539. _currentLimitVelocity1: number;
  13540. /** @hidden */
  13541. _currentLimitVelocity2: number;
  13542. /** @hidden */
  13543. _currentDragGradient: Nullable<FactorGradient>;
  13544. /** @hidden */
  13545. _currentDrag1: number;
  13546. /** @hidden */
  13547. _currentDrag2: number;
  13548. /** @hidden */
  13549. _randomNoiseCoordinates1: Vector3;
  13550. /** @hidden */
  13551. _randomNoiseCoordinates2: Vector3;
  13552. /** @hidden */
  13553. _localPosition?: Vector3;
  13554. /**
  13555. * Creates a new instance Particle
  13556. * @param particleSystem the particle system the particle belongs to
  13557. */
  13558. constructor(
  13559. /**
  13560. * The particle system the particle belongs to.
  13561. */
  13562. particleSystem: ParticleSystem);
  13563. private updateCellInfoFromSystem;
  13564. /**
  13565. * Defines how the sprite cell index is updated for the particle
  13566. */
  13567. updateCellIndex(): void;
  13568. /** @hidden */
  13569. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13570. /** @hidden */
  13571. _inheritParticleInfoToSubEmitters(): void;
  13572. /** @hidden */
  13573. _reset(): void;
  13574. /**
  13575. * Copy the properties of particle to another one.
  13576. * @param other the particle to copy the information to.
  13577. */
  13578. copyTo(other: Particle): void;
  13579. }
  13580. }
  13581. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13582. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13583. import { Effect } from "babylonjs/Materials/effect";
  13584. import { Particle } from "babylonjs/Particles/particle";
  13585. import { Nullable } from "babylonjs/types";
  13586. import { Scene } from "babylonjs/scene";
  13587. /**
  13588. * Particle emitter represents a volume emitting particles.
  13589. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13590. */
  13591. export interface IParticleEmitterType {
  13592. /**
  13593. * Called by the particle System when the direction is computed for the created particle.
  13594. * @param worldMatrix is the world matrix of the particle system
  13595. * @param directionToUpdate is the direction vector to update with the result
  13596. * @param particle is the particle we are computed the direction for
  13597. * @param isLocal defines if the direction should be set in local space
  13598. */
  13599. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13600. /**
  13601. * Called by the particle System when the position is computed for the created particle.
  13602. * @param worldMatrix is the world matrix of the particle system
  13603. * @param positionToUpdate is the position vector to update with the result
  13604. * @param particle is the particle we are computed the position for
  13605. * @param isLocal defines if the position should be set in local space
  13606. */
  13607. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13608. /**
  13609. * Clones the current emitter and returns a copy of it
  13610. * @returns the new emitter
  13611. */
  13612. clone(): IParticleEmitterType;
  13613. /**
  13614. * Called by the GPUParticleSystem to setup the update shader
  13615. * @param effect defines the update shader
  13616. */
  13617. applyToShader(effect: Effect): void;
  13618. /**
  13619. * Returns a string to use to update the GPU particles update shader
  13620. * @returns the effect defines string
  13621. */
  13622. getEffectDefines(): string;
  13623. /**
  13624. * Returns a string representing the class name
  13625. * @returns a string containing the class name
  13626. */
  13627. getClassName(): string;
  13628. /**
  13629. * Serializes the particle system to a JSON object.
  13630. * @returns the JSON object
  13631. */
  13632. serialize(): any;
  13633. /**
  13634. * Parse properties from a JSON object
  13635. * @param serializationObject defines the JSON object
  13636. * @param scene defines the hosting scene
  13637. */
  13638. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13639. }
  13640. }
  13641. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13642. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13643. import { Effect } from "babylonjs/Materials/effect";
  13644. import { Particle } from "babylonjs/Particles/particle";
  13645. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13646. /**
  13647. * Particle emitter emitting particles from the inside of a box.
  13648. * It emits the particles randomly between 2 given directions.
  13649. */
  13650. export class BoxParticleEmitter implements IParticleEmitterType {
  13651. /**
  13652. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13653. */
  13654. direction1: Vector3;
  13655. /**
  13656. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13657. */
  13658. direction2: Vector3;
  13659. /**
  13660. * 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.
  13661. */
  13662. minEmitBox: Vector3;
  13663. /**
  13664. * 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.
  13665. */
  13666. maxEmitBox: Vector3;
  13667. /**
  13668. * Creates a new instance BoxParticleEmitter
  13669. */
  13670. constructor();
  13671. /**
  13672. * Called by the particle System when the direction is computed for the created particle.
  13673. * @param worldMatrix is the world matrix of the particle system
  13674. * @param directionToUpdate is the direction vector to update with the result
  13675. * @param particle is the particle we are computed the direction for
  13676. * @param isLocal defines if the direction should be set in local space
  13677. */
  13678. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13679. /**
  13680. * Called by the particle System when the position is computed for the created particle.
  13681. * @param worldMatrix is the world matrix of the particle system
  13682. * @param positionToUpdate is the position vector to update with the result
  13683. * @param particle is the particle we are computed the position for
  13684. * @param isLocal defines if the position should be set in local space
  13685. */
  13686. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13687. /**
  13688. * Clones the current emitter and returns a copy of it
  13689. * @returns the new emitter
  13690. */
  13691. clone(): BoxParticleEmitter;
  13692. /**
  13693. * Called by the GPUParticleSystem to setup the update shader
  13694. * @param effect defines the update shader
  13695. */
  13696. applyToShader(effect: Effect): void;
  13697. /**
  13698. * Returns a string to use to update the GPU particles update shader
  13699. * @returns a string containng the defines string
  13700. */
  13701. getEffectDefines(): string;
  13702. /**
  13703. * Returns the string "BoxParticleEmitter"
  13704. * @returns a string containing the class name
  13705. */
  13706. getClassName(): string;
  13707. /**
  13708. * Serializes the particle system to a JSON object.
  13709. * @returns the JSON object
  13710. */
  13711. serialize(): any;
  13712. /**
  13713. * Parse properties from a JSON object
  13714. * @param serializationObject defines the JSON object
  13715. */
  13716. parse(serializationObject: any): void;
  13717. }
  13718. }
  13719. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13720. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13721. import { Effect } from "babylonjs/Materials/effect";
  13722. import { Particle } from "babylonjs/Particles/particle";
  13723. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13724. /**
  13725. * Particle emitter emitting particles from the inside of a cone.
  13726. * It emits the particles alongside the cone volume from the base to the particle.
  13727. * The emission direction might be randomized.
  13728. */
  13729. export class ConeParticleEmitter implements IParticleEmitterType {
  13730. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13731. directionRandomizer: number;
  13732. private _radius;
  13733. private _angle;
  13734. private _height;
  13735. /**
  13736. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13737. */
  13738. radiusRange: number;
  13739. /**
  13740. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13741. */
  13742. heightRange: number;
  13743. /**
  13744. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13745. */
  13746. emitFromSpawnPointOnly: boolean;
  13747. /**
  13748. * Gets or sets the radius of the emission cone
  13749. */
  13750. get radius(): number;
  13751. set radius(value: number);
  13752. /**
  13753. * Gets or sets the angle of the emission cone
  13754. */
  13755. get angle(): number;
  13756. set angle(value: number);
  13757. private _buildHeight;
  13758. /**
  13759. * Creates a new instance ConeParticleEmitter
  13760. * @param radius the radius of the emission cone (1 by default)
  13761. * @param angle the cone base angle (PI by default)
  13762. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13763. */
  13764. constructor(radius?: number, angle?: number,
  13765. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13766. directionRandomizer?: number);
  13767. /**
  13768. * Called by the particle System when the direction is computed for the created particle.
  13769. * @param worldMatrix is the world matrix of the particle system
  13770. * @param directionToUpdate is the direction vector to update with the result
  13771. * @param particle is the particle we are computed the direction for
  13772. * @param isLocal defines if the direction should be set in local space
  13773. */
  13774. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13775. /**
  13776. * Called by the particle System when the position is computed for the created particle.
  13777. * @param worldMatrix is the world matrix of the particle system
  13778. * @param positionToUpdate is the position vector to update with the result
  13779. * @param particle is the particle we are computed the position for
  13780. * @param isLocal defines if the position should be set in local space
  13781. */
  13782. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13783. /**
  13784. * Clones the current emitter and returns a copy of it
  13785. * @returns the new emitter
  13786. */
  13787. clone(): ConeParticleEmitter;
  13788. /**
  13789. * Called by the GPUParticleSystem to setup the update shader
  13790. * @param effect defines the update shader
  13791. */
  13792. applyToShader(effect: Effect): void;
  13793. /**
  13794. * Returns a string to use to update the GPU particles update shader
  13795. * @returns a string containng the defines string
  13796. */
  13797. getEffectDefines(): string;
  13798. /**
  13799. * Returns the string "ConeParticleEmitter"
  13800. * @returns a string containing the class name
  13801. */
  13802. getClassName(): string;
  13803. /**
  13804. * Serializes the particle system to a JSON object.
  13805. * @returns the JSON object
  13806. */
  13807. serialize(): any;
  13808. /**
  13809. * Parse properties from a JSON object
  13810. * @param serializationObject defines the JSON object
  13811. */
  13812. parse(serializationObject: any): void;
  13813. }
  13814. }
  13815. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13816. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13817. import { Effect } from "babylonjs/Materials/effect";
  13818. import { Particle } from "babylonjs/Particles/particle";
  13819. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13820. /**
  13821. * Particle emitter emitting particles from the inside of a cylinder.
  13822. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13823. */
  13824. export class CylinderParticleEmitter implements IParticleEmitterType {
  13825. /**
  13826. * The radius of the emission cylinder.
  13827. */
  13828. radius: number;
  13829. /**
  13830. * The height of the emission cylinder.
  13831. */
  13832. height: number;
  13833. /**
  13834. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13835. */
  13836. radiusRange: number;
  13837. /**
  13838. * How much to randomize the particle direction [0-1].
  13839. */
  13840. directionRandomizer: number;
  13841. /**
  13842. * Creates a new instance CylinderParticleEmitter
  13843. * @param radius the radius of the emission cylinder (1 by default)
  13844. * @param height the height of the emission cylinder (1 by default)
  13845. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13846. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13847. */
  13848. constructor(
  13849. /**
  13850. * The radius of the emission cylinder.
  13851. */
  13852. radius?: number,
  13853. /**
  13854. * The height of the emission cylinder.
  13855. */
  13856. height?: number,
  13857. /**
  13858. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13859. */
  13860. radiusRange?: number,
  13861. /**
  13862. * How much to randomize the particle direction [0-1].
  13863. */
  13864. directionRandomizer?: number);
  13865. /**
  13866. * Called by the particle System when the direction is computed for the created particle.
  13867. * @param worldMatrix is the world matrix of the particle system
  13868. * @param directionToUpdate is the direction vector to update with the result
  13869. * @param particle is the particle we are computed the direction for
  13870. * @param isLocal defines if the direction should be set in local space
  13871. */
  13872. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13873. /**
  13874. * Called by the particle System when the position is computed for the created particle.
  13875. * @param worldMatrix is the world matrix of the particle system
  13876. * @param positionToUpdate is the position vector to update with the result
  13877. * @param particle is the particle we are computed the position for
  13878. * @param isLocal defines if the position should be set in local space
  13879. */
  13880. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13881. /**
  13882. * Clones the current emitter and returns a copy of it
  13883. * @returns the new emitter
  13884. */
  13885. clone(): CylinderParticleEmitter;
  13886. /**
  13887. * Called by the GPUParticleSystem to setup the update shader
  13888. * @param effect defines the update shader
  13889. */
  13890. applyToShader(effect: Effect): void;
  13891. /**
  13892. * Returns a string to use to update the GPU particles update shader
  13893. * @returns a string containng the defines string
  13894. */
  13895. getEffectDefines(): string;
  13896. /**
  13897. * Returns the string "CylinderParticleEmitter"
  13898. * @returns a string containing the class name
  13899. */
  13900. getClassName(): string;
  13901. /**
  13902. * Serializes the particle system to a JSON object.
  13903. * @returns the JSON object
  13904. */
  13905. serialize(): any;
  13906. /**
  13907. * Parse properties from a JSON object
  13908. * @param serializationObject defines the JSON object
  13909. */
  13910. parse(serializationObject: any): void;
  13911. }
  13912. /**
  13913. * Particle emitter emitting particles from the inside of a cylinder.
  13914. * It emits the particles randomly between two vectors.
  13915. */
  13916. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13917. /**
  13918. * The min limit of the emission direction.
  13919. */
  13920. direction1: Vector3;
  13921. /**
  13922. * The max limit of the emission direction.
  13923. */
  13924. direction2: Vector3;
  13925. /**
  13926. * Creates a new instance CylinderDirectedParticleEmitter
  13927. * @param radius the radius of the emission cylinder (1 by default)
  13928. * @param height the height of the emission cylinder (1 by default)
  13929. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13930. * @param direction1 the min limit of the emission direction (up vector by default)
  13931. * @param direction2 the max limit of the emission direction (up vector by default)
  13932. */
  13933. constructor(radius?: number, height?: number, radiusRange?: number,
  13934. /**
  13935. * The min limit of the emission direction.
  13936. */
  13937. direction1?: Vector3,
  13938. /**
  13939. * The max limit of the emission direction.
  13940. */
  13941. direction2?: Vector3);
  13942. /**
  13943. * Called by the particle System when the direction is computed for the created particle.
  13944. * @param worldMatrix is the world matrix of the particle system
  13945. * @param directionToUpdate is the direction vector to update with the result
  13946. * @param particle is the particle we are computed the direction for
  13947. */
  13948. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13949. /**
  13950. * Clones the current emitter and returns a copy of it
  13951. * @returns the new emitter
  13952. */
  13953. clone(): CylinderDirectedParticleEmitter;
  13954. /**
  13955. * Called by the GPUParticleSystem to setup the update shader
  13956. * @param effect defines the update shader
  13957. */
  13958. applyToShader(effect: Effect): void;
  13959. /**
  13960. * Returns a string to use to update the GPU particles update shader
  13961. * @returns a string containng the defines string
  13962. */
  13963. getEffectDefines(): string;
  13964. /**
  13965. * Returns the string "CylinderDirectedParticleEmitter"
  13966. * @returns a string containing the class name
  13967. */
  13968. getClassName(): string;
  13969. /**
  13970. * Serializes the particle system to a JSON object.
  13971. * @returns the JSON object
  13972. */
  13973. serialize(): any;
  13974. /**
  13975. * Parse properties from a JSON object
  13976. * @param serializationObject defines the JSON object
  13977. */
  13978. parse(serializationObject: any): void;
  13979. }
  13980. }
  13981. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13982. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13983. import { Effect } from "babylonjs/Materials/effect";
  13984. import { Particle } from "babylonjs/Particles/particle";
  13985. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13986. /**
  13987. * Particle emitter emitting particles from the inside of a hemisphere.
  13988. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13989. */
  13990. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13991. /**
  13992. * The radius of the emission hemisphere.
  13993. */
  13994. radius: number;
  13995. /**
  13996. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13997. */
  13998. radiusRange: number;
  13999. /**
  14000. * How much to randomize the particle direction [0-1].
  14001. */
  14002. directionRandomizer: number;
  14003. /**
  14004. * Creates a new instance HemisphericParticleEmitter
  14005. * @param radius the radius of the emission hemisphere (1 by default)
  14006. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14007. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14008. */
  14009. constructor(
  14010. /**
  14011. * The radius of the emission hemisphere.
  14012. */
  14013. radius?: number,
  14014. /**
  14015. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14016. */
  14017. radiusRange?: number,
  14018. /**
  14019. * How much to randomize the particle direction [0-1].
  14020. */
  14021. directionRandomizer?: number);
  14022. /**
  14023. * Called by the particle System when the direction is computed for the created particle.
  14024. * @param worldMatrix is the world matrix of the particle system
  14025. * @param directionToUpdate is the direction vector to update with the result
  14026. * @param particle is the particle we are computed the direction for
  14027. * @param isLocal defines if the direction should be set in local space
  14028. */
  14029. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14030. /**
  14031. * Called by the particle System when the position is computed for the created particle.
  14032. * @param worldMatrix is the world matrix of the particle system
  14033. * @param positionToUpdate is the position vector to update with the result
  14034. * @param particle is the particle we are computed the position for
  14035. * @param isLocal defines if the position should be set in local space
  14036. */
  14037. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14038. /**
  14039. * Clones the current emitter and returns a copy of it
  14040. * @returns the new emitter
  14041. */
  14042. clone(): HemisphericParticleEmitter;
  14043. /**
  14044. * Called by the GPUParticleSystem to setup the update shader
  14045. * @param effect defines the update shader
  14046. */
  14047. applyToShader(effect: Effect): void;
  14048. /**
  14049. * Returns a string to use to update the GPU particles update shader
  14050. * @returns a string containng the defines string
  14051. */
  14052. getEffectDefines(): string;
  14053. /**
  14054. * Returns the string "HemisphericParticleEmitter"
  14055. * @returns a string containing the class name
  14056. */
  14057. getClassName(): string;
  14058. /**
  14059. * Serializes the particle system to a JSON object.
  14060. * @returns the JSON object
  14061. */
  14062. serialize(): any;
  14063. /**
  14064. * Parse properties from a JSON object
  14065. * @param serializationObject defines the JSON object
  14066. */
  14067. parse(serializationObject: any): void;
  14068. }
  14069. }
  14070. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14071. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14072. import { Effect } from "babylonjs/Materials/effect";
  14073. import { Particle } from "babylonjs/Particles/particle";
  14074. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14075. /**
  14076. * Particle emitter emitting particles from a point.
  14077. * It emits the particles randomly between 2 given directions.
  14078. */
  14079. export class PointParticleEmitter implements IParticleEmitterType {
  14080. /**
  14081. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14082. */
  14083. direction1: Vector3;
  14084. /**
  14085. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14086. */
  14087. direction2: Vector3;
  14088. /**
  14089. * Creates a new instance PointParticleEmitter
  14090. */
  14091. constructor();
  14092. /**
  14093. * Called by the particle System when the direction is computed for the created particle.
  14094. * @param worldMatrix is the world matrix of the particle system
  14095. * @param directionToUpdate is the direction vector to update with the result
  14096. * @param particle is the particle we are computed the direction for
  14097. * @param isLocal defines if the direction should be set in local space
  14098. */
  14099. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14100. /**
  14101. * Called by the particle System when the position is computed for the created particle.
  14102. * @param worldMatrix is the world matrix of the particle system
  14103. * @param positionToUpdate is the position vector to update with the result
  14104. * @param particle is the particle we are computed the position for
  14105. * @param isLocal defines if the position should be set in local space
  14106. */
  14107. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14108. /**
  14109. * Clones the current emitter and returns a copy of it
  14110. * @returns the new emitter
  14111. */
  14112. clone(): PointParticleEmitter;
  14113. /**
  14114. * Called by the GPUParticleSystem to setup the update shader
  14115. * @param effect defines the update shader
  14116. */
  14117. applyToShader(effect: Effect): void;
  14118. /**
  14119. * Returns a string to use to update the GPU particles update shader
  14120. * @returns a string containng the defines string
  14121. */
  14122. getEffectDefines(): string;
  14123. /**
  14124. * Returns the string "PointParticleEmitter"
  14125. * @returns a string containing the class name
  14126. */
  14127. getClassName(): string;
  14128. /**
  14129. * Serializes the particle system to a JSON object.
  14130. * @returns the JSON object
  14131. */
  14132. serialize(): any;
  14133. /**
  14134. * Parse properties from a JSON object
  14135. * @param serializationObject defines the JSON object
  14136. */
  14137. parse(serializationObject: any): void;
  14138. }
  14139. }
  14140. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14141. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14142. import { Effect } from "babylonjs/Materials/effect";
  14143. import { Particle } from "babylonjs/Particles/particle";
  14144. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14145. /**
  14146. * Particle emitter emitting particles from the inside of a sphere.
  14147. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14148. */
  14149. export class SphereParticleEmitter implements IParticleEmitterType {
  14150. /**
  14151. * The radius of the emission sphere.
  14152. */
  14153. radius: number;
  14154. /**
  14155. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14156. */
  14157. radiusRange: number;
  14158. /**
  14159. * How much to randomize the particle direction [0-1].
  14160. */
  14161. directionRandomizer: number;
  14162. /**
  14163. * Creates a new instance SphereParticleEmitter
  14164. * @param radius the radius of the emission sphere (1 by default)
  14165. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14166. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14167. */
  14168. constructor(
  14169. /**
  14170. * The radius of the emission sphere.
  14171. */
  14172. radius?: number,
  14173. /**
  14174. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14175. */
  14176. radiusRange?: number,
  14177. /**
  14178. * How much to randomize the particle direction [0-1].
  14179. */
  14180. directionRandomizer?: number);
  14181. /**
  14182. * Called by the particle System when the direction is computed for the created particle.
  14183. * @param worldMatrix is the world matrix of the particle system
  14184. * @param directionToUpdate is the direction vector to update with the result
  14185. * @param particle is the particle we are computed the direction for
  14186. * @param isLocal defines if the direction should be set in local space
  14187. */
  14188. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14189. /**
  14190. * Called by the particle System when the position is computed for the created particle.
  14191. * @param worldMatrix is the world matrix of the particle system
  14192. * @param positionToUpdate is the position vector to update with the result
  14193. * @param particle is the particle we are computed the position for
  14194. * @param isLocal defines if the position should be set in local space
  14195. */
  14196. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14197. /**
  14198. * Clones the current emitter and returns a copy of it
  14199. * @returns the new emitter
  14200. */
  14201. clone(): SphereParticleEmitter;
  14202. /**
  14203. * Called by the GPUParticleSystem to setup the update shader
  14204. * @param effect defines the update shader
  14205. */
  14206. applyToShader(effect: Effect): void;
  14207. /**
  14208. * Returns a string to use to update the GPU particles update shader
  14209. * @returns a string containng the defines string
  14210. */
  14211. getEffectDefines(): string;
  14212. /**
  14213. * Returns the string "SphereParticleEmitter"
  14214. * @returns a string containing the class name
  14215. */
  14216. getClassName(): string;
  14217. /**
  14218. * Serializes the particle system to a JSON object.
  14219. * @returns the JSON object
  14220. */
  14221. serialize(): any;
  14222. /**
  14223. * Parse properties from a JSON object
  14224. * @param serializationObject defines the JSON object
  14225. */
  14226. parse(serializationObject: any): void;
  14227. }
  14228. /**
  14229. * Particle emitter emitting particles from the inside of a sphere.
  14230. * It emits the particles randomly between two vectors.
  14231. */
  14232. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14233. /**
  14234. * The min limit of the emission direction.
  14235. */
  14236. direction1: Vector3;
  14237. /**
  14238. * The max limit of the emission direction.
  14239. */
  14240. direction2: Vector3;
  14241. /**
  14242. * Creates a new instance SphereDirectedParticleEmitter
  14243. * @param radius the radius of the emission sphere (1 by default)
  14244. * @param direction1 the min limit of the emission direction (up vector by default)
  14245. * @param direction2 the max limit of the emission direction (up vector by default)
  14246. */
  14247. constructor(radius?: number,
  14248. /**
  14249. * The min limit of the emission direction.
  14250. */
  14251. direction1?: Vector3,
  14252. /**
  14253. * The max limit of the emission direction.
  14254. */
  14255. direction2?: Vector3);
  14256. /**
  14257. * Called by the particle System when the direction is computed for the created particle.
  14258. * @param worldMatrix is the world matrix of the particle system
  14259. * @param directionToUpdate is the direction vector to update with the result
  14260. * @param particle is the particle we are computed the direction for
  14261. */
  14262. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14263. /**
  14264. * Clones the current emitter and returns a copy of it
  14265. * @returns the new emitter
  14266. */
  14267. clone(): SphereDirectedParticleEmitter;
  14268. /**
  14269. * Called by the GPUParticleSystem to setup the update shader
  14270. * @param effect defines the update shader
  14271. */
  14272. applyToShader(effect: Effect): void;
  14273. /**
  14274. * Returns a string to use to update the GPU particles update shader
  14275. * @returns a string containng the defines string
  14276. */
  14277. getEffectDefines(): string;
  14278. /**
  14279. * Returns the string "SphereDirectedParticleEmitter"
  14280. * @returns a string containing the class name
  14281. */
  14282. getClassName(): string;
  14283. /**
  14284. * Serializes the particle system to a JSON object.
  14285. * @returns the JSON object
  14286. */
  14287. serialize(): any;
  14288. /**
  14289. * Parse properties from a JSON object
  14290. * @param serializationObject defines the JSON object
  14291. */
  14292. parse(serializationObject: any): void;
  14293. }
  14294. }
  14295. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14296. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14297. import { Effect } from "babylonjs/Materials/effect";
  14298. import { Particle } from "babylonjs/Particles/particle";
  14299. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14300. import { Nullable } from "babylonjs/types";
  14301. /**
  14302. * Particle emitter emitting particles from a custom list of positions.
  14303. */
  14304. export class CustomParticleEmitter implements IParticleEmitterType {
  14305. /**
  14306. * Gets or sets the position generator that will create the inital position of each particle.
  14307. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14308. */
  14309. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14310. /**
  14311. * Gets or sets the destination generator that will create the final destination of each particle.
  14312. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14313. */
  14314. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14315. /**
  14316. * Creates a new instance CustomParticleEmitter
  14317. */
  14318. constructor();
  14319. /**
  14320. * Called by the particle System when the direction is computed for the created particle.
  14321. * @param worldMatrix is the world matrix of the particle system
  14322. * @param directionToUpdate is the direction vector to update with the result
  14323. * @param particle is the particle we are computed the direction for
  14324. * @param isLocal defines if the direction should be set in local space
  14325. */
  14326. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14327. /**
  14328. * Called by the particle System when the position is computed for the created particle.
  14329. * @param worldMatrix is the world matrix of the particle system
  14330. * @param positionToUpdate is the position vector to update with the result
  14331. * @param particle is the particle we are computed the position for
  14332. * @param isLocal defines if the position should be set in local space
  14333. */
  14334. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14335. /**
  14336. * Clones the current emitter and returns a copy of it
  14337. * @returns the new emitter
  14338. */
  14339. clone(): CustomParticleEmitter;
  14340. /**
  14341. * Called by the GPUParticleSystem to setup the update shader
  14342. * @param effect defines the update shader
  14343. */
  14344. applyToShader(effect: Effect): void;
  14345. /**
  14346. * Returns a string to use to update the GPU particles update shader
  14347. * @returns a string containng the defines string
  14348. */
  14349. getEffectDefines(): string;
  14350. /**
  14351. * Returns the string "PointParticleEmitter"
  14352. * @returns a string containing the class name
  14353. */
  14354. getClassName(): string;
  14355. /**
  14356. * Serializes the particle system to a JSON object.
  14357. * @returns the JSON object
  14358. */
  14359. serialize(): any;
  14360. /**
  14361. * Parse properties from a JSON object
  14362. * @param serializationObject defines the JSON object
  14363. */
  14364. parse(serializationObject: any): void;
  14365. }
  14366. }
  14367. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14368. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14369. import { Effect } from "babylonjs/Materials/effect";
  14370. import { Particle } from "babylonjs/Particles/particle";
  14371. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14372. import { Nullable } from "babylonjs/types";
  14373. import { Scene } from "babylonjs/scene";
  14374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14375. /**
  14376. * Particle emitter emitting particles from the inside of a box.
  14377. * It emits the particles randomly between 2 given directions.
  14378. */
  14379. export class MeshParticleEmitter implements IParticleEmitterType {
  14380. private _indices;
  14381. private _positions;
  14382. private _normals;
  14383. private _storedNormal;
  14384. private _mesh;
  14385. /**
  14386. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14387. */
  14388. direction1: Vector3;
  14389. /**
  14390. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14391. */
  14392. direction2: Vector3;
  14393. /**
  14394. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14395. */
  14396. useMeshNormalsForDirection: boolean;
  14397. /** Defines the mesh to use as source */
  14398. get mesh(): Nullable<AbstractMesh>;
  14399. set mesh(value: Nullable<AbstractMesh>);
  14400. /**
  14401. * Creates a new instance MeshParticleEmitter
  14402. * @param mesh defines the mesh to use as source
  14403. */
  14404. constructor(mesh?: Nullable<AbstractMesh>);
  14405. /**
  14406. * Called by the particle System when the direction is computed for the created particle.
  14407. * @param worldMatrix is the world matrix of the particle system
  14408. * @param directionToUpdate is the direction vector to update with the result
  14409. * @param particle is the particle we are computed the direction for
  14410. * @param isLocal defines if the direction should be set in local space
  14411. */
  14412. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14413. /**
  14414. * Called by the particle System when the position is computed for the created particle.
  14415. * @param worldMatrix is the world matrix of the particle system
  14416. * @param positionToUpdate is the position vector to update with the result
  14417. * @param particle is the particle we are computed the position for
  14418. * @param isLocal defines if the position should be set in local space
  14419. */
  14420. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14421. /**
  14422. * Clones the current emitter and returns a copy of it
  14423. * @returns the new emitter
  14424. */
  14425. clone(): MeshParticleEmitter;
  14426. /**
  14427. * Called by the GPUParticleSystem to setup the update shader
  14428. * @param effect defines the update shader
  14429. */
  14430. applyToShader(effect: Effect): void;
  14431. /**
  14432. * Returns a string to use to update the GPU particles update shader
  14433. * @returns a string containng the defines string
  14434. */
  14435. getEffectDefines(): string;
  14436. /**
  14437. * Returns the string "BoxParticleEmitter"
  14438. * @returns a string containing the class name
  14439. */
  14440. getClassName(): string;
  14441. /**
  14442. * Serializes the particle system to a JSON object.
  14443. * @returns the JSON object
  14444. */
  14445. serialize(): any;
  14446. /**
  14447. * Parse properties from a JSON object
  14448. * @param serializationObject defines the JSON object
  14449. * @param scene defines the hosting scene
  14450. */
  14451. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14452. }
  14453. }
  14454. declare module "babylonjs/Particles/EmitterTypes/index" {
  14455. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14456. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14457. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14458. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14459. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14460. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14461. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14462. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14463. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14464. }
  14465. declare module "babylonjs/Particles/IParticleSystem" {
  14466. import { Nullable } from "babylonjs/types";
  14467. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14468. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14470. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14471. import { Scene } from "babylonjs/scene";
  14472. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14473. import { Effect } from "babylonjs/Materials/effect";
  14474. import { Observable } from "babylonjs/Misc/observable";
  14475. import { Animation } from "babylonjs/Animations/animation";
  14476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14477. /**
  14478. * Interface representing a particle system in Babylon.js.
  14479. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14480. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14481. */
  14482. export interface IParticleSystem {
  14483. /**
  14484. * List of animations used by the particle system.
  14485. */
  14486. animations: Animation[];
  14487. /**
  14488. * The id of the Particle system.
  14489. */
  14490. id: string;
  14491. /**
  14492. * The name of the Particle system.
  14493. */
  14494. name: string;
  14495. /**
  14496. * The emitter represents the Mesh or position we are attaching the particle system to.
  14497. */
  14498. emitter: Nullable<AbstractMesh | Vector3>;
  14499. /**
  14500. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14501. */
  14502. isBillboardBased: boolean;
  14503. /**
  14504. * The rendering group used by the Particle system to chose when to render.
  14505. */
  14506. renderingGroupId: number;
  14507. /**
  14508. * The layer mask we are rendering the particles through.
  14509. */
  14510. layerMask: number;
  14511. /**
  14512. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14513. */
  14514. updateSpeed: number;
  14515. /**
  14516. * The amount of time the particle system is running (depends of the overall update speed).
  14517. */
  14518. targetStopDuration: number;
  14519. /**
  14520. * The texture used to render each particle. (this can be a spritesheet)
  14521. */
  14522. particleTexture: Nullable<BaseTexture>;
  14523. /**
  14524. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14525. */
  14526. blendMode: number;
  14527. /**
  14528. * Minimum life time of emitting particles.
  14529. */
  14530. minLifeTime: number;
  14531. /**
  14532. * Maximum life time of emitting particles.
  14533. */
  14534. maxLifeTime: number;
  14535. /**
  14536. * Minimum Size of emitting particles.
  14537. */
  14538. minSize: number;
  14539. /**
  14540. * Maximum Size of emitting particles.
  14541. */
  14542. maxSize: number;
  14543. /**
  14544. * Minimum scale of emitting particles on X axis.
  14545. */
  14546. minScaleX: number;
  14547. /**
  14548. * Maximum scale of emitting particles on X axis.
  14549. */
  14550. maxScaleX: number;
  14551. /**
  14552. * Minimum scale of emitting particles on Y axis.
  14553. */
  14554. minScaleY: number;
  14555. /**
  14556. * Maximum scale of emitting particles on Y axis.
  14557. */
  14558. maxScaleY: number;
  14559. /**
  14560. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14561. */
  14562. color1: Color4;
  14563. /**
  14564. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14565. */
  14566. color2: Color4;
  14567. /**
  14568. * Color the particle will have at the end of its lifetime.
  14569. */
  14570. colorDead: Color4;
  14571. /**
  14572. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14573. */
  14574. emitRate: number;
  14575. /**
  14576. * You can use gravity if you want to give an orientation to your particles.
  14577. */
  14578. gravity: Vector3;
  14579. /**
  14580. * Minimum power of emitting particles.
  14581. */
  14582. minEmitPower: number;
  14583. /**
  14584. * Maximum power of emitting particles.
  14585. */
  14586. maxEmitPower: number;
  14587. /**
  14588. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14589. */
  14590. minAngularSpeed: number;
  14591. /**
  14592. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14593. */
  14594. maxAngularSpeed: number;
  14595. /**
  14596. * Gets or sets the minimal initial rotation in radians.
  14597. */
  14598. minInitialRotation: number;
  14599. /**
  14600. * Gets or sets the maximal initial rotation in radians.
  14601. */
  14602. maxInitialRotation: number;
  14603. /**
  14604. * The particle emitter type defines the emitter used by the particle system.
  14605. * It can be for example box, sphere, or cone...
  14606. */
  14607. particleEmitterType: Nullable<IParticleEmitterType>;
  14608. /**
  14609. * Defines the delay in milliseconds before starting the system (0 by default)
  14610. */
  14611. startDelay: number;
  14612. /**
  14613. * 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
  14614. */
  14615. preWarmCycles: number;
  14616. /**
  14617. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14618. */
  14619. preWarmStepOffset: number;
  14620. /**
  14621. * 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)
  14622. */
  14623. spriteCellChangeSpeed: number;
  14624. /**
  14625. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14626. */
  14627. startSpriteCellID: number;
  14628. /**
  14629. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14630. */
  14631. endSpriteCellID: number;
  14632. /**
  14633. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14634. */
  14635. spriteCellWidth: number;
  14636. /**
  14637. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14638. */
  14639. spriteCellHeight: number;
  14640. /**
  14641. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14642. */
  14643. spriteRandomStartCell: boolean;
  14644. /**
  14645. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14646. */
  14647. isAnimationSheetEnabled: boolean;
  14648. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14649. translationPivot: Vector2;
  14650. /**
  14651. * Gets or sets a texture used to add random noise to particle positions
  14652. */
  14653. noiseTexture: Nullable<BaseTexture>;
  14654. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14655. noiseStrength: Vector3;
  14656. /**
  14657. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14658. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14659. */
  14660. billboardMode: number;
  14661. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14662. limitVelocityDamping: number;
  14663. /**
  14664. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14665. */
  14666. beginAnimationOnStart: boolean;
  14667. /**
  14668. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14669. */
  14670. beginAnimationFrom: number;
  14671. /**
  14672. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14673. */
  14674. beginAnimationTo: number;
  14675. /**
  14676. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14677. */
  14678. beginAnimationLoop: boolean;
  14679. /**
  14680. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14681. */
  14682. disposeOnStop: boolean;
  14683. /**
  14684. * Specifies if the particles are updated in emitter local space or world space
  14685. */
  14686. isLocal: boolean;
  14687. /** Snippet ID if the particle system was created from the snippet server */
  14688. snippetId: string;
  14689. /** Gets or sets a matrix to use to compute projection */
  14690. defaultProjectionMatrix: Matrix;
  14691. /**
  14692. * Gets the maximum number of particles active at the same time.
  14693. * @returns The max number of active particles.
  14694. */
  14695. getCapacity(): number;
  14696. /**
  14697. * Gets the number of particles active at the same time.
  14698. * @returns The number of active particles.
  14699. */
  14700. getActiveCount(): number;
  14701. /**
  14702. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14703. * @returns True if it has been started, otherwise false.
  14704. */
  14705. isStarted(): boolean;
  14706. /**
  14707. * Animates the particle system for this frame.
  14708. */
  14709. animate(): void;
  14710. /**
  14711. * Renders the particle system in its current state.
  14712. * @returns the current number of particles
  14713. */
  14714. render(): number;
  14715. /**
  14716. * Dispose the particle system and frees its associated resources.
  14717. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14718. */
  14719. dispose(disposeTexture?: boolean): void;
  14720. /**
  14721. * An event triggered when the system is disposed
  14722. */
  14723. onDisposeObservable: Observable<IParticleSystem>;
  14724. /**
  14725. * An event triggered when the system is stopped
  14726. */
  14727. onStoppedObservable: Observable<IParticleSystem>;
  14728. /**
  14729. * Clones the particle system.
  14730. * @param name The name of the cloned object
  14731. * @param newEmitter The new emitter to use
  14732. * @returns the cloned particle system
  14733. */
  14734. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14735. /**
  14736. * Serializes the particle system to a JSON object
  14737. * @param serializeTexture defines if the texture must be serialized as well
  14738. * @returns the JSON object
  14739. */
  14740. serialize(serializeTexture: boolean): any;
  14741. /**
  14742. * Rebuild the particle system
  14743. */
  14744. rebuild(): void;
  14745. /** Force the system to rebuild all gradients that need to be resync */
  14746. forceRefreshGradients(): void;
  14747. /**
  14748. * Starts the particle system and begins to emit
  14749. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14750. */
  14751. start(delay?: number): void;
  14752. /**
  14753. * Stops the particle system.
  14754. */
  14755. stop(): void;
  14756. /**
  14757. * Remove all active particles
  14758. */
  14759. reset(): void;
  14760. /**
  14761. * Gets a boolean indicating that the system is stopping
  14762. * @returns true if the system is currently stopping
  14763. */
  14764. isStopping(): boolean;
  14765. /**
  14766. * Is this system ready to be used/rendered
  14767. * @return true if the system is ready
  14768. */
  14769. isReady(): boolean;
  14770. /**
  14771. * Returns the string "ParticleSystem"
  14772. * @returns a string containing the class name
  14773. */
  14774. getClassName(): string;
  14775. /**
  14776. * Gets the custom effect used to render the particles
  14777. * @param blendMode Blend mode for which the effect should be retrieved
  14778. * @returns The effect
  14779. */
  14780. getCustomEffect(blendMode: number): Nullable<Effect>;
  14781. /**
  14782. * Sets the custom effect used to render the particles
  14783. * @param effect The effect to set
  14784. * @param blendMode Blend mode for which the effect should be set
  14785. */
  14786. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14787. /**
  14788. * Fill the defines array according to the current settings of the particle system
  14789. * @param defines Array to be updated
  14790. * @param blendMode blend mode to take into account when updating the array
  14791. */
  14792. fillDefines(defines: Array<string>, blendMode: number): void;
  14793. /**
  14794. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14795. * @param uniforms Uniforms array to fill
  14796. * @param attributes Attributes array to fill
  14797. * @param samplers Samplers array to fill
  14798. */
  14799. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14800. /**
  14801. * Observable that will be called just before the particles are drawn
  14802. */
  14803. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14804. /**
  14805. * Gets the name of the particle vertex shader
  14806. */
  14807. vertexShaderName: string;
  14808. /**
  14809. * Adds a new color gradient
  14810. * @param gradient defines the gradient to use (between 0 and 1)
  14811. * @param color1 defines the color to affect to the specified gradient
  14812. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14813. * @returns the current particle system
  14814. */
  14815. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14816. /**
  14817. * Remove a specific color gradient
  14818. * @param gradient defines the gradient to remove
  14819. * @returns the current particle system
  14820. */
  14821. removeColorGradient(gradient: number): IParticleSystem;
  14822. /**
  14823. * Adds a new size gradient
  14824. * @param gradient defines the gradient to use (between 0 and 1)
  14825. * @param factor defines the size factor to affect to the specified gradient
  14826. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14827. * @returns the current particle system
  14828. */
  14829. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14830. /**
  14831. * Remove a specific size gradient
  14832. * @param gradient defines the gradient to remove
  14833. * @returns the current particle system
  14834. */
  14835. removeSizeGradient(gradient: number): IParticleSystem;
  14836. /**
  14837. * Gets the current list of color gradients.
  14838. * You must use addColorGradient and removeColorGradient to udpate this list
  14839. * @returns the list of color gradients
  14840. */
  14841. getColorGradients(): Nullable<Array<ColorGradient>>;
  14842. /**
  14843. * Gets the current list of size gradients.
  14844. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14845. * @returns the list of size gradients
  14846. */
  14847. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14848. /**
  14849. * Gets the current list of angular speed gradients.
  14850. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14851. * @returns the list of angular speed gradients
  14852. */
  14853. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14854. /**
  14855. * Adds a new angular speed gradient
  14856. * @param gradient defines the gradient to use (between 0 and 1)
  14857. * @param factor defines the angular speed to affect to the specified gradient
  14858. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14859. * @returns the current particle system
  14860. */
  14861. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14862. /**
  14863. * Remove a specific angular speed gradient
  14864. * @param gradient defines the gradient to remove
  14865. * @returns the current particle system
  14866. */
  14867. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14868. /**
  14869. * Gets the current list of velocity gradients.
  14870. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14871. * @returns the list of velocity gradients
  14872. */
  14873. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14874. /**
  14875. * Adds a new velocity gradient
  14876. * @param gradient defines the gradient to use (between 0 and 1)
  14877. * @param factor defines the velocity to affect to the specified gradient
  14878. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14879. * @returns the current particle system
  14880. */
  14881. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14882. /**
  14883. * Remove a specific velocity gradient
  14884. * @param gradient defines the gradient to remove
  14885. * @returns the current particle system
  14886. */
  14887. removeVelocityGradient(gradient: number): IParticleSystem;
  14888. /**
  14889. * Gets the current list of limit velocity gradients.
  14890. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14891. * @returns the list of limit velocity gradients
  14892. */
  14893. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14894. /**
  14895. * Adds a new limit velocity gradient
  14896. * @param gradient defines the gradient to use (between 0 and 1)
  14897. * @param factor defines the limit velocity to affect to the specified gradient
  14898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14899. * @returns the current particle system
  14900. */
  14901. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14902. /**
  14903. * Remove a specific limit velocity gradient
  14904. * @param gradient defines the gradient to remove
  14905. * @returns the current particle system
  14906. */
  14907. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14908. /**
  14909. * Adds a new drag gradient
  14910. * @param gradient defines the gradient to use (between 0 and 1)
  14911. * @param factor defines the drag to affect to the specified gradient
  14912. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14913. * @returns the current particle system
  14914. */
  14915. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14916. /**
  14917. * Remove a specific drag gradient
  14918. * @param gradient defines the gradient to remove
  14919. * @returns the current particle system
  14920. */
  14921. removeDragGradient(gradient: number): IParticleSystem;
  14922. /**
  14923. * Gets the current list of drag gradients.
  14924. * You must use addDragGradient and removeDragGradient to udpate this list
  14925. * @returns the list of drag gradients
  14926. */
  14927. getDragGradients(): Nullable<Array<FactorGradient>>;
  14928. /**
  14929. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14930. * @param gradient defines the gradient to use (between 0 and 1)
  14931. * @param factor defines the emit rate to affect to the specified gradient
  14932. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14933. * @returns the current particle system
  14934. */
  14935. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14936. /**
  14937. * Remove a specific emit rate gradient
  14938. * @param gradient defines the gradient to remove
  14939. * @returns the current particle system
  14940. */
  14941. removeEmitRateGradient(gradient: number): IParticleSystem;
  14942. /**
  14943. * Gets the current list of emit rate gradients.
  14944. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14945. * @returns the list of emit rate gradients
  14946. */
  14947. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14948. /**
  14949. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14950. * @param gradient defines the gradient to use (between 0 and 1)
  14951. * @param factor defines the start size to affect to the specified gradient
  14952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14953. * @returns the current particle system
  14954. */
  14955. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14956. /**
  14957. * Remove a specific start size gradient
  14958. * @param gradient defines the gradient to remove
  14959. * @returns the current particle system
  14960. */
  14961. removeStartSizeGradient(gradient: number): IParticleSystem;
  14962. /**
  14963. * Gets the current list of start size gradients.
  14964. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14965. * @returns the list of start size gradients
  14966. */
  14967. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14968. /**
  14969. * Adds a new life time gradient
  14970. * @param gradient defines the gradient to use (between 0 and 1)
  14971. * @param factor defines the life time factor to affect to the specified gradient
  14972. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14973. * @returns the current particle system
  14974. */
  14975. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14976. /**
  14977. * Remove a specific life time gradient
  14978. * @param gradient defines the gradient to remove
  14979. * @returns the current particle system
  14980. */
  14981. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14982. /**
  14983. * Gets the current list of life time gradients.
  14984. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14985. * @returns the list of life time gradients
  14986. */
  14987. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14988. /**
  14989. * Gets the current list of color gradients.
  14990. * You must use addColorGradient and removeColorGradient to udpate this list
  14991. * @returns the list of color gradients
  14992. */
  14993. getColorGradients(): Nullable<Array<ColorGradient>>;
  14994. /**
  14995. * Adds a new ramp gradient used to remap particle colors
  14996. * @param gradient defines the gradient to use (between 0 and 1)
  14997. * @param color defines the color to affect to the specified gradient
  14998. * @returns the current particle system
  14999. */
  15000. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  15001. /**
  15002. * Gets the current list of ramp gradients.
  15003. * You must use addRampGradient and removeRampGradient to udpate this list
  15004. * @returns the list of ramp gradients
  15005. */
  15006. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15007. /** Gets or sets a boolean indicating that ramp gradients must be used
  15008. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15009. */
  15010. useRampGradients: boolean;
  15011. /**
  15012. * Adds a new color remap gradient
  15013. * @param gradient defines the gradient to use (between 0 and 1)
  15014. * @param min defines the color remap minimal range
  15015. * @param max defines the color remap maximal range
  15016. * @returns the current particle system
  15017. */
  15018. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15019. /**
  15020. * Gets the current list of color remap gradients.
  15021. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  15022. * @returns the list of color remap gradients
  15023. */
  15024. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  15025. /**
  15026. * Adds a new alpha remap gradient
  15027. * @param gradient defines the gradient to use (between 0 and 1)
  15028. * @param min defines the alpha remap minimal range
  15029. * @param max defines the alpha remap maximal range
  15030. * @returns the current particle system
  15031. */
  15032. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15033. /**
  15034. * Gets the current list of alpha remap gradients.
  15035. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  15036. * @returns the list of alpha remap gradients
  15037. */
  15038. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  15039. /**
  15040. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  15041. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15042. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15043. * @returns the emitter
  15044. */
  15045. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  15046. /**
  15047. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  15048. * @param radius The radius of the hemisphere to emit from
  15049. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15050. * @returns the emitter
  15051. */
  15052. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15053. /**
  15054. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15055. * @param radius The radius of the sphere to emit from
  15056. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15057. * @returns the emitter
  15058. */
  15059. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15060. /**
  15061. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15062. * @param radius The radius of the sphere to emit from
  15063. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15064. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15065. * @returns the emitter
  15066. */
  15067. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15068. /**
  15069. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15070. * @param radius The radius of the emission cylinder
  15071. * @param height The height of the emission cylinder
  15072. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15073. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15074. * @returns the emitter
  15075. */
  15076. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15077. /**
  15078. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15079. * @param radius The radius of the cylinder to emit from
  15080. * @param height The height of the emission cylinder
  15081. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15082. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15083. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15084. * @returns the emitter
  15085. */
  15086. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15087. /**
  15088. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15089. * @param radius The radius of the cone to emit from
  15090. * @param angle The base angle of the cone
  15091. * @returns the emitter
  15092. */
  15093. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15094. /**
  15095. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15096. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15097. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15098. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15099. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15100. * @returns the emitter
  15101. */
  15102. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15103. /**
  15104. * Get hosting scene
  15105. * @returns the scene
  15106. */
  15107. getScene(): Nullable<Scene>;
  15108. }
  15109. }
  15110. declare module "babylonjs/Meshes/transformNode" {
  15111. import { DeepImmutable } from "babylonjs/types";
  15112. import { Observable } from "babylonjs/Misc/observable";
  15113. import { Nullable } from "babylonjs/types";
  15114. import { Camera } from "babylonjs/Cameras/camera";
  15115. import { Scene } from "babylonjs/scene";
  15116. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15117. import { Node } from "babylonjs/node";
  15118. import { Bone } from "babylonjs/Bones/bone";
  15119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15120. import { Space } from "babylonjs/Maths/math.axis";
  15121. /**
  15122. * 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.
  15123. * @see https://doc.babylonjs.com/how_to/transformnode
  15124. */
  15125. export class TransformNode extends Node {
  15126. /**
  15127. * Object will not rotate to face the camera
  15128. */
  15129. static BILLBOARDMODE_NONE: number;
  15130. /**
  15131. * Object will rotate to face the camera but only on the x axis
  15132. */
  15133. static BILLBOARDMODE_X: number;
  15134. /**
  15135. * Object will rotate to face the camera but only on the y axis
  15136. */
  15137. static BILLBOARDMODE_Y: number;
  15138. /**
  15139. * Object will rotate to face the camera but only on the z axis
  15140. */
  15141. static BILLBOARDMODE_Z: number;
  15142. /**
  15143. * Object will rotate to face the camera
  15144. */
  15145. static BILLBOARDMODE_ALL: number;
  15146. /**
  15147. * Object will rotate to face the camera's position instead of orientation
  15148. */
  15149. static BILLBOARDMODE_USE_POSITION: number;
  15150. private static _TmpRotation;
  15151. private static _TmpScaling;
  15152. private static _TmpTranslation;
  15153. private _forward;
  15154. private _forwardInverted;
  15155. private _up;
  15156. private _right;
  15157. private _rightInverted;
  15158. private _position;
  15159. private _rotation;
  15160. private _rotationQuaternion;
  15161. protected _scaling: Vector3;
  15162. protected _isDirty: boolean;
  15163. private _transformToBoneReferal;
  15164. private _isAbsoluteSynced;
  15165. private _billboardMode;
  15166. /**
  15167. * Gets or sets the billboard mode. Default is 0.
  15168. *
  15169. * | Value | Type | Description |
  15170. * | --- | --- | --- |
  15171. * | 0 | BILLBOARDMODE_NONE | |
  15172. * | 1 | BILLBOARDMODE_X | |
  15173. * | 2 | BILLBOARDMODE_Y | |
  15174. * | 4 | BILLBOARDMODE_Z | |
  15175. * | 7 | BILLBOARDMODE_ALL | |
  15176. *
  15177. */
  15178. get billboardMode(): number;
  15179. set billboardMode(value: number);
  15180. private _preserveParentRotationForBillboard;
  15181. /**
  15182. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15183. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15184. */
  15185. get preserveParentRotationForBillboard(): boolean;
  15186. set preserveParentRotationForBillboard(value: boolean);
  15187. /**
  15188. * 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
  15189. */
  15190. scalingDeterminant: number;
  15191. private _infiniteDistance;
  15192. /**
  15193. * Gets or sets the distance of the object to max, often used by skybox
  15194. */
  15195. get infiniteDistance(): boolean;
  15196. set infiniteDistance(value: boolean);
  15197. /**
  15198. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15199. * By default the system will update normals to compensate
  15200. */
  15201. ignoreNonUniformScaling: boolean;
  15202. /**
  15203. * 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
  15204. */
  15205. reIntegrateRotationIntoRotationQuaternion: boolean;
  15206. /** @hidden */
  15207. _poseMatrix: Nullable<Matrix>;
  15208. /** @hidden */
  15209. _localMatrix: Matrix;
  15210. private _usePivotMatrix;
  15211. private _absolutePosition;
  15212. private _absoluteScaling;
  15213. private _absoluteRotationQuaternion;
  15214. private _pivotMatrix;
  15215. private _pivotMatrixInverse;
  15216. /** @hidden */
  15217. _postMultiplyPivotMatrix: boolean;
  15218. protected _isWorldMatrixFrozen: boolean;
  15219. /** @hidden */
  15220. _indexInSceneTransformNodesArray: number;
  15221. /**
  15222. * An event triggered after the world matrix is updated
  15223. */
  15224. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15225. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15226. /**
  15227. * Gets a string identifying the name of the class
  15228. * @returns "TransformNode" string
  15229. */
  15230. getClassName(): string;
  15231. /**
  15232. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15233. */
  15234. get position(): Vector3;
  15235. set position(newPosition: Vector3);
  15236. /**
  15237. * 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)).
  15238. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15239. */
  15240. get rotation(): Vector3;
  15241. set rotation(newRotation: Vector3);
  15242. /**
  15243. * 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)).
  15244. */
  15245. get scaling(): Vector3;
  15246. set scaling(newScaling: Vector3);
  15247. /**
  15248. * 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).
  15249. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15250. */
  15251. get rotationQuaternion(): Nullable<Quaternion>;
  15252. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15253. /**
  15254. * The forward direction of that transform in world space.
  15255. */
  15256. get forward(): Vector3;
  15257. /**
  15258. * The up direction of that transform in world space.
  15259. */
  15260. get up(): Vector3;
  15261. /**
  15262. * The right direction of that transform in world space.
  15263. */
  15264. get right(): Vector3;
  15265. /**
  15266. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15267. * @param matrix the matrix to copy the pose from
  15268. * @returns this TransformNode.
  15269. */
  15270. updatePoseMatrix(matrix: Matrix): TransformNode;
  15271. /**
  15272. * Returns the mesh Pose matrix.
  15273. * @returns the pose matrix
  15274. */
  15275. getPoseMatrix(): Matrix;
  15276. /** @hidden */
  15277. _isSynchronized(): boolean;
  15278. /** @hidden */
  15279. _initCache(): void;
  15280. /**
  15281. * Flag the transform node as dirty (Forcing it to update everything)
  15282. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15283. * @returns this transform node
  15284. */
  15285. markAsDirty(property: string): TransformNode;
  15286. /**
  15287. * Returns the current mesh absolute position.
  15288. * Returns a Vector3.
  15289. */
  15290. get absolutePosition(): Vector3;
  15291. /**
  15292. * Returns the current mesh absolute scaling.
  15293. * Returns a Vector3.
  15294. */
  15295. get absoluteScaling(): Vector3;
  15296. /**
  15297. * Returns the current mesh absolute rotation.
  15298. * Returns a Quaternion.
  15299. */
  15300. get absoluteRotationQuaternion(): Quaternion;
  15301. /**
  15302. * Sets a new matrix to apply before all other transformation
  15303. * @param matrix defines the transform matrix
  15304. * @returns the current TransformNode
  15305. */
  15306. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15307. /**
  15308. * Sets a new pivot matrix to the current node
  15309. * @param matrix defines the new pivot matrix to use
  15310. * @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
  15311. * @returns the current TransformNode
  15312. */
  15313. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15314. /**
  15315. * Returns the mesh pivot matrix.
  15316. * Default : Identity.
  15317. * @returns the matrix
  15318. */
  15319. getPivotMatrix(): Matrix;
  15320. /**
  15321. * Instantiate (when possible) or clone that node with its hierarchy
  15322. * @param newParent defines the new parent to use for the instance (or clone)
  15323. * @param options defines options to configure how copy is done
  15324. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15325. * @returns an instance (or a clone) of the current node with its hiearchy
  15326. */
  15327. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15328. doNotInstantiate: boolean;
  15329. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15330. /**
  15331. * Prevents the World matrix to be computed any longer
  15332. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15333. * @returns the TransformNode.
  15334. */
  15335. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15336. /**
  15337. * Allows back the World matrix computation.
  15338. * @returns the TransformNode.
  15339. */
  15340. unfreezeWorldMatrix(): this;
  15341. /**
  15342. * True if the World matrix has been frozen.
  15343. */
  15344. get isWorldMatrixFrozen(): boolean;
  15345. /**
  15346. * Retuns the mesh absolute position in the World.
  15347. * @returns a Vector3.
  15348. */
  15349. getAbsolutePosition(): Vector3;
  15350. /**
  15351. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15352. * @param absolutePosition the absolute position to set
  15353. * @returns the TransformNode.
  15354. */
  15355. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15356. /**
  15357. * Sets the mesh position in its local space.
  15358. * @param vector3 the position to set in localspace
  15359. * @returns the TransformNode.
  15360. */
  15361. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15362. /**
  15363. * Returns the mesh position in the local space from the current World matrix values.
  15364. * @returns a new Vector3.
  15365. */
  15366. getPositionExpressedInLocalSpace(): Vector3;
  15367. /**
  15368. * Translates the mesh along the passed Vector3 in its local space.
  15369. * @param vector3 the distance to translate in localspace
  15370. * @returns the TransformNode.
  15371. */
  15372. locallyTranslate(vector3: Vector3): TransformNode;
  15373. private static _lookAtVectorCache;
  15374. /**
  15375. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15376. * @param targetPoint the position (must be in same space as current mesh) to look at
  15377. * @param yawCor optional yaw (y-axis) correction in radians
  15378. * @param pitchCor optional pitch (x-axis) correction in radians
  15379. * @param rollCor optional roll (z-axis) correction in radians
  15380. * @param space the choosen space of the target
  15381. * @returns the TransformNode.
  15382. */
  15383. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15384. /**
  15385. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15386. * This Vector3 is expressed in the World space.
  15387. * @param localAxis axis to rotate
  15388. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15389. */
  15390. getDirection(localAxis: Vector3): Vector3;
  15391. /**
  15392. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15393. * localAxis is expressed in the mesh local space.
  15394. * result is computed in the Wordl space from the mesh World matrix.
  15395. * @param localAxis axis to rotate
  15396. * @param result the resulting transformnode
  15397. * @returns this TransformNode.
  15398. */
  15399. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15400. /**
  15401. * Sets this transform node rotation to the given local axis.
  15402. * @param localAxis the axis in local space
  15403. * @param yawCor optional yaw (y-axis) correction in radians
  15404. * @param pitchCor optional pitch (x-axis) correction in radians
  15405. * @param rollCor optional roll (z-axis) correction in radians
  15406. * @returns this TransformNode
  15407. */
  15408. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15409. /**
  15410. * Sets a new pivot point to the current node
  15411. * @param point defines the new pivot point to use
  15412. * @param space defines if the point is in world or local space (local by default)
  15413. * @returns the current TransformNode
  15414. */
  15415. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15416. /**
  15417. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15418. * @returns the pivot point
  15419. */
  15420. getPivotPoint(): Vector3;
  15421. /**
  15422. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15423. * @param result the vector3 to store the result
  15424. * @returns this TransformNode.
  15425. */
  15426. getPivotPointToRef(result: Vector3): TransformNode;
  15427. /**
  15428. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15429. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15430. */
  15431. getAbsolutePivotPoint(): Vector3;
  15432. /**
  15433. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15434. * @param result vector3 to store the result
  15435. * @returns this TransformNode.
  15436. */
  15437. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15438. /**
  15439. * Defines the passed node as the parent of the current node.
  15440. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15441. * @see https://doc.babylonjs.com/how_to/parenting
  15442. * @param node the node ot set as the parent
  15443. * @returns this TransformNode.
  15444. */
  15445. setParent(node: Nullable<Node>): TransformNode;
  15446. private _nonUniformScaling;
  15447. /**
  15448. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15449. */
  15450. get nonUniformScaling(): boolean;
  15451. /** @hidden */
  15452. _updateNonUniformScalingState(value: boolean): boolean;
  15453. /**
  15454. * Attach the current TransformNode to another TransformNode associated with a bone
  15455. * @param bone Bone affecting the TransformNode
  15456. * @param affectedTransformNode TransformNode associated with the bone
  15457. * @returns this object
  15458. */
  15459. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15460. /**
  15461. * Detach the transform node if its associated with a bone
  15462. * @returns this object
  15463. */
  15464. detachFromBone(): TransformNode;
  15465. private static _rotationAxisCache;
  15466. /**
  15467. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15468. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15469. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15470. * The passed axis is also normalized.
  15471. * @param axis the axis to rotate around
  15472. * @param amount the amount to rotate in radians
  15473. * @param space Space to rotate in (Default: local)
  15474. * @returns the TransformNode.
  15475. */
  15476. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15477. /**
  15478. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15479. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15480. * The passed axis is also normalized. .
  15481. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15482. * @param point the point to rotate around
  15483. * @param axis the axis to rotate around
  15484. * @param amount the amount to rotate in radians
  15485. * @returns the TransformNode
  15486. */
  15487. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15488. /**
  15489. * Translates the mesh along the axis vector for the passed distance in the given space.
  15490. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15491. * @param axis the axis to translate in
  15492. * @param distance the distance to translate
  15493. * @param space Space to rotate in (Default: local)
  15494. * @returns the TransformNode.
  15495. */
  15496. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15497. /**
  15498. * Adds a rotation step to the mesh current rotation.
  15499. * x, y, z are Euler angles expressed in radians.
  15500. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15501. * This means this rotation is made in the mesh local space only.
  15502. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15503. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15504. * ```javascript
  15505. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15506. * ```
  15507. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15508. * 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.
  15509. * @param x Rotation to add
  15510. * @param y Rotation to add
  15511. * @param z Rotation to add
  15512. * @returns the TransformNode.
  15513. */
  15514. addRotation(x: number, y: number, z: number): TransformNode;
  15515. /**
  15516. * @hidden
  15517. */
  15518. protected _getEffectiveParent(): Nullable<Node>;
  15519. /**
  15520. * Computes the world matrix of the node
  15521. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15522. * @returns the world matrix
  15523. */
  15524. computeWorldMatrix(force?: boolean): Matrix;
  15525. /**
  15526. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15527. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15528. */
  15529. resetLocalMatrix(independentOfChildren?: boolean): void;
  15530. protected _afterComputeWorldMatrix(): void;
  15531. /**
  15532. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15533. * @param func callback function to add
  15534. *
  15535. * @returns the TransformNode.
  15536. */
  15537. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15538. /**
  15539. * Removes a registered callback function.
  15540. * @param func callback function to remove
  15541. * @returns the TransformNode.
  15542. */
  15543. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15544. /**
  15545. * Gets the position of the current mesh in camera space
  15546. * @param camera defines the camera to use
  15547. * @returns a position
  15548. */
  15549. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15550. /**
  15551. * Returns the distance from the mesh to the active camera
  15552. * @param camera defines the camera to use
  15553. * @returns the distance
  15554. */
  15555. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15556. /**
  15557. * Clone the current transform node
  15558. * @param name Name of the new clone
  15559. * @param newParent New parent for the clone
  15560. * @param doNotCloneChildren Do not clone children hierarchy
  15561. * @returns the new transform node
  15562. */
  15563. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15564. /**
  15565. * Serializes the objects information.
  15566. * @param currentSerializationObject defines the object to serialize in
  15567. * @returns the serialized object
  15568. */
  15569. serialize(currentSerializationObject?: any): any;
  15570. /**
  15571. * Returns a new TransformNode object parsed from the source provided.
  15572. * @param parsedTransformNode is the source.
  15573. * @param scene the scne the object belongs to
  15574. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15575. * @returns a new TransformNode object parsed from the source provided.
  15576. */
  15577. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15578. /**
  15579. * Get all child-transformNodes of this node
  15580. * @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
  15581. * @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
  15582. * @returns an array of TransformNode
  15583. */
  15584. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15585. /**
  15586. * Releases resources associated with this transform node.
  15587. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15588. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15589. */
  15590. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15591. /**
  15592. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15593. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15594. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15595. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15596. * @returns the current mesh
  15597. */
  15598. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15599. private _syncAbsoluteScalingAndRotation;
  15600. }
  15601. }
  15602. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15603. /**
  15604. * Class used to override all child animations of a given target
  15605. */
  15606. export class AnimationPropertiesOverride {
  15607. /**
  15608. * Gets or sets a value indicating if animation blending must be used
  15609. */
  15610. enableBlending: boolean;
  15611. /**
  15612. * Gets or sets the blending speed to use when enableBlending is true
  15613. */
  15614. blendingSpeed: number;
  15615. /**
  15616. * Gets or sets the default loop mode to use
  15617. */
  15618. loopMode: number;
  15619. }
  15620. }
  15621. declare module "babylonjs/Bones/bone" {
  15622. import { Skeleton } from "babylonjs/Bones/skeleton";
  15623. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15624. import { Nullable } from "babylonjs/types";
  15625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15626. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15627. import { Node } from "babylonjs/node";
  15628. import { Space } from "babylonjs/Maths/math.axis";
  15629. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15630. /**
  15631. * Class used to store bone information
  15632. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15633. */
  15634. export class Bone extends Node {
  15635. /**
  15636. * defines the bone name
  15637. */
  15638. name: string;
  15639. private static _tmpVecs;
  15640. private static _tmpQuat;
  15641. private static _tmpMats;
  15642. /**
  15643. * Gets the list of child bones
  15644. */
  15645. children: Bone[];
  15646. /** Gets the animations associated with this bone */
  15647. animations: import("babylonjs/Animations/animation").Animation[];
  15648. /**
  15649. * Gets or sets bone length
  15650. */
  15651. length: number;
  15652. /**
  15653. * @hidden Internal only
  15654. * Set this value to map this bone to a different index in the transform matrices
  15655. * Set this value to -1 to exclude the bone from the transform matrices
  15656. */
  15657. _index: Nullable<number>;
  15658. private _skeleton;
  15659. private _localMatrix;
  15660. private _restPose;
  15661. private _bindPose;
  15662. private _baseMatrix;
  15663. private _absoluteTransform;
  15664. private _invertedAbsoluteTransform;
  15665. private _parent;
  15666. private _scalingDeterminant;
  15667. private _worldTransform;
  15668. private _localScaling;
  15669. private _localRotation;
  15670. private _localPosition;
  15671. private _needToDecompose;
  15672. private _needToCompose;
  15673. /** @hidden */
  15674. _linkedTransformNode: Nullable<TransformNode>;
  15675. /** @hidden */
  15676. _waitingTransformNodeId: Nullable<string>;
  15677. /** @hidden */
  15678. get _matrix(): Matrix;
  15679. /** @hidden */
  15680. set _matrix(value: Matrix);
  15681. /**
  15682. * Create a new bone
  15683. * @param name defines the bone name
  15684. * @param skeleton defines the parent skeleton
  15685. * @param parentBone defines the parent (can be null if the bone is the root)
  15686. * @param localMatrix defines the local matrix
  15687. * @param restPose defines the rest pose matrix
  15688. * @param baseMatrix defines the base matrix
  15689. * @param index defines index of the bone in the hiearchy
  15690. */
  15691. constructor(
  15692. /**
  15693. * defines the bone name
  15694. */
  15695. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15696. /**
  15697. * Gets the current object class name.
  15698. * @return the class name
  15699. */
  15700. getClassName(): string;
  15701. /**
  15702. * Gets the parent skeleton
  15703. * @returns a skeleton
  15704. */
  15705. getSkeleton(): Skeleton;
  15706. /**
  15707. * Gets parent bone
  15708. * @returns a bone or null if the bone is the root of the bone hierarchy
  15709. */
  15710. getParent(): Nullable<Bone>;
  15711. /**
  15712. * Returns an array containing the root bones
  15713. * @returns an array containing the root bones
  15714. */
  15715. getChildren(): Array<Bone>;
  15716. /**
  15717. * Gets the node index in matrix array generated for rendering
  15718. * @returns the node index
  15719. */
  15720. getIndex(): number;
  15721. /**
  15722. * Sets the parent bone
  15723. * @param parent defines the parent (can be null if the bone is the root)
  15724. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15725. */
  15726. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15727. /**
  15728. * Gets the local matrix
  15729. * @returns a matrix
  15730. */
  15731. getLocalMatrix(): Matrix;
  15732. /**
  15733. * Gets the base matrix (initial matrix which remains unchanged)
  15734. * @returns a matrix
  15735. */
  15736. getBaseMatrix(): Matrix;
  15737. /**
  15738. * Gets the rest pose matrix
  15739. * @returns a matrix
  15740. */
  15741. getRestPose(): Matrix;
  15742. /**
  15743. * Sets the rest pose matrix
  15744. * @param matrix the local-space rest pose to set for this bone
  15745. */
  15746. setRestPose(matrix: Matrix): void;
  15747. /**
  15748. * Gets the bind pose matrix
  15749. * @returns the bind pose matrix
  15750. */
  15751. getBindPose(): Matrix;
  15752. /**
  15753. * Sets the bind pose matrix
  15754. * @param matrix the local-space bind pose to set for this bone
  15755. */
  15756. setBindPose(matrix: Matrix): void;
  15757. /**
  15758. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15759. */
  15760. getWorldMatrix(): Matrix;
  15761. /**
  15762. * Sets the local matrix to rest pose matrix
  15763. */
  15764. returnToRest(): void;
  15765. /**
  15766. * Gets the inverse of the absolute transform matrix.
  15767. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15768. * @returns a matrix
  15769. */
  15770. getInvertedAbsoluteTransform(): Matrix;
  15771. /**
  15772. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15773. * @returns a matrix
  15774. */
  15775. getAbsoluteTransform(): Matrix;
  15776. /**
  15777. * Links with the given transform node.
  15778. * The local matrix of this bone is copied from the transform node every frame.
  15779. * @param transformNode defines the transform node to link to
  15780. */
  15781. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15782. /**
  15783. * Gets the node used to drive the bone's transformation
  15784. * @returns a transform node or null
  15785. */
  15786. getTransformNode(): Nullable<TransformNode>;
  15787. /** Gets or sets current position (in local space) */
  15788. get position(): Vector3;
  15789. set position(newPosition: Vector3);
  15790. /** Gets or sets current rotation (in local space) */
  15791. get rotation(): Vector3;
  15792. set rotation(newRotation: Vector3);
  15793. /** Gets or sets current rotation quaternion (in local space) */
  15794. get rotationQuaternion(): Quaternion;
  15795. set rotationQuaternion(newRotation: Quaternion);
  15796. /** Gets or sets current scaling (in local space) */
  15797. get scaling(): Vector3;
  15798. set scaling(newScaling: Vector3);
  15799. /**
  15800. * Gets the animation properties override
  15801. */
  15802. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15803. private _decompose;
  15804. private _compose;
  15805. /**
  15806. * Update the base and local matrices
  15807. * @param matrix defines the new base or local matrix
  15808. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15809. * @param updateLocalMatrix defines if the local matrix should be updated
  15810. */
  15811. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15812. /** @hidden */
  15813. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15814. /**
  15815. * Flag the bone as dirty (Forcing it to update everything)
  15816. */
  15817. markAsDirty(): void;
  15818. /** @hidden */
  15819. _markAsDirtyAndCompose(): void;
  15820. private _markAsDirtyAndDecompose;
  15821. /**
  15822. * Translate the bone in local or world space
  15823. * @param vec The amount to translate the bone
  15824. * @param space The space that the translation is in
  15825. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15826. */
  15827. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15828. /**
  15829. * Set the postion of the bone in local or world space
  15830. * @param position The position to set the bone
  15831. * @param space The space that the position is in
  15832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15833. */
  15834. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15835. /**
  15836. * Set the absolute position of the bone (world space)
  15837. * @param position The position to set the bone
  15838. * @param mesh The mesh that this bone is attached to
  15839. */
  15840. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15841. /**
  15842. * Scale the bone on the x, y and z axes (in local space)
  15843. * @param x The amount to scale the bone on the x axis
  15844. * @param y The amount to scale the bone on the y axis
  15845. * @param z The amount to scale the bone on the z axis
  15846. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15847. */
  15848. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15849. /**
  15850. * Set the bone scaling in local space
  15851. * @param scale defines the scaling vector
  15852. */
  15853. setScale(scale: Vector3): void;
  15854. /**
  15855. * Gets the current scaling in local space
  15856. * @returns the current scaling vector
  15857. */
  15858. getScale(): Vector3;
  15859. /**
  15860. * Gets the current scaling in local space and stores it in a target vector
  15861. * @param result defines the target vector
  15862. */
  15863. getScaleToRef(result: Vector3): void;
  15864. /**
  15865. * Set the yaw, pitch, and roll of the bone in local or world space
  15866. * @param yaw The rotation of the bone on the y axis
  15867. * @param pitch The rotation of the bone on the x axis
  15868. * @param roll The rotation of the bone on the z axis
  15869. * @param space The space that the axes of rotation are in
  15870. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15871. */
  15872. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15873. /**
  15874. * Add a rotation to the bone on an axis in local or world space
  15875. * @param axis The axis to rotate the bone on
  15876. * @param amount The amount to rotate the bone
  15877. * @param space The space that the axis is in
  15878. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15879. */
  15880. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15881. /**
  15882. * Set the rotation of the bone to a particular axis angle in local or world space
  15883. * @param axis The axis to rotate the bone on
  15884. * @param angle The angle that the bone should be rotated to
  15885. * @param space The space that the axis is in
  15886. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15887. */
  15888. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15889. /**
  15890. * Set the euler rotation of the bone in local or world space
  15891. * @param rotation The euler rotation that the bone should be set to
  15892. * @param space The space that the rotation is in
  15893. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15894. */
  15895. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15896. /**
  15897. * Set the quaternion rotation of the bone in local or world space
  15898. * @param quat The quaternion rotation that the bone should be set to
  15899. * @param space The space that the rotation is in
  15900. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15901. */
  15902. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15903. /**
  15904. * Set the rotation matrix of the bone in local or world space
  15905. * @param rotMat The rotation matrix that the bone should be set to
  15906. * @param space The space that the rotation is in
  15907. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15908. */
  15909. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15910. private _rotateWithMatrix;
  15911. private _getNegativeRotationToRef;
  15912. /**
  15913. * Get the position of the bone in local or world space
  15914. * @param space The space that the returned position is in
  15915. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15916. * @returns The position of the bone
  15917. */
  15918. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15919. /**
  15920. * Copy the position of the bone to a vector3 in local or world space
  15921. * @param space The space that the returned position is in
  15922. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15923. * @param result The vector3 to copy the position to
  15924. */
  15925. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15926. /**
  15927. * Get the absolute position of the bone (world space)
  15928. * @param mesh The mesh that this bone is attached to
  15929. * @returns The absolute position of the bone
  15930. */
  15931. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15932. /**
  15933. * Copy the absolute position of the bone (world space) to the result param
  15934. * @param mesh The mesh that this bone is attached to
  15935. * @param result The vector3 to copy the absolute position to
  15936. */
  15937. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15938. /**
  15939. * Compute the absolute transforms of this bone and its children
  15940. */
  15941. computeAbsoluteTransforms(): void;
  15942. /**
  15943. * Get the world direction from an axis that is in the local space of the bone
  15944. * @param localAxis The local direction that is used to compute the world direction
  15945. * @param mesh The mesh that this bone is attached to
  15946. * @returns The world direction
  15947. */
  15948. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15949. /**
  15950. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15951. * @param localAxis The local direction that is used to compute the world direction
  15952. * @param mesh The mesh that this bone is attached to
  15953. * @param result The vector3 that the world direction will be copied to
  15954. */
  15955. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15956. /**
  15957. * Get the euler rotation of the bone in local or world space
  15958. * @param space The space that the rotation should be in
  15959. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15960. * @returns The euler rotation
  15961. */
  15962. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15963. /**
  15964. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15965. * @param space The space that the rotation should be in
  15966. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15967. * @param result The vector3 that the rotation should be copied to
  15968. */
  15969. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15970. /**
  15971. * Get the quaternion rotation of the bone in either local or world space
  15972. * @param space The space that the rotation should be in
  15973. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15974. * @returns The quaternion rotation
  15975. */
  15976. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15977. /**
  15978. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15979. * @param space The space that the rotation should be in
  15980. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15981. * @param result The quaternion that the rotation should be copied to
  15982. */
  15983. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15984. /**
  15985. * Get the rotation matrix of the bone in local or world space
  15986. * @param space The space that the rotation should be in
  15987. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15988. * @returns The rotation matrix
  15989. */
  15990. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15991. /**
  15992. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15993. * @param space The space that the rotation should be in
  15994. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15995. * @param result The quaternion that the rotation should be copied to
  15996. */
  15997. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15998. /**
  15999. * Get the world position of a point that is in the local space of the bone
  16000. * @param position The local position
  16001. * @param mesh The mesh that this bone is attached to
  16002. * @returns The world position
  16003. */
  16004. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  16005. /**
  16006. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  16007. * @param position The local position
  16008. * @param mesh The mesh that this bone is attached to
  16009. * @param result The vector3 that the world position should be copied to
  16010. */
  16011. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  16012. /**
  16013. * Get the local position of a point that is in world space
  16014. * @param position The world position
  16015. * @param mesh The mesh that this bone is attached to
  16016. * @returns The local position
  16017. */
  16018. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  16019. /**
  16020. * Get the local position of a point that is in world space and copy it to the result param
  16021. * @param position The world position
  16022. * @param mesh The mesh that this bone is attached to
  16023. * @param result The vector3 that the local position should be copied to
  16024. */
  16025. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  16026. /**
  16027. * Set the current local matrix as the restPose for this bone.
  16028. */
  16029. setCurrentPoseAsRest(): void;
  16030. }
  16031. }
  16032. declare module "babylonjs/Animations/runtimeAnimation" {
  16033. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  16034. import { Animatable } from "babylonjs/Animations/animatable";
  16035. import { Scene } from "babylonjs/scene";
  16036. /**
  16037. * Defines a runtime animation
  16038. */
  16039. export class RuntimeAnimation {
  16040. private _events;
  16041. /**
  16042. * The current frame of the runtime animation
  16043. */
  16044. private _currentFrame;
  16045. /**
  16046. * The animation used by the runtime animation
  16047. */
  16048. private _animation;
  16049. /**
  16050. * The target of the runtime animation
  16051. */
  16052. private _target;
  16053. /**
  16054. * The initiating animatable
  16055. */
  16056. private _host;
  16057. /**
  16058. * The original value of the runtime animation
  16059. */
  16060. private _originalValue;
  16061. /**
  16062. * The original blend value of the runtime animation
  16063. */
  16064. private _originalBlendValue;
  16065. /**
  16066. * The offsets cache of the runtime animation
  16067. */
  16068. private _offsetsCache;
  16069. /**
  16070. * The high limits cache of the runtime animation
  16071. */
  16072. private _highLimitsCache;
  16073. /**
  16074. * Specifies if the runtime animation has been stopped
  16075. */
  16076. private _stopped;
  16077. /**
  16078. * The blending factor of the runtime animation
  16079. */
  16080. private _blendingFactor;
  16081. /**
  16082. * The BabylonJS scene
  16083. */
  16084. private _scene;
  16085. /**
  16086. * The current value of the runtime animation
  16087. */
  16088. private _currentValue;
  16089. /** @hidden */
  16090. _animationState: _IAnimationState;
  16091. /**
  16092. * The active target of the runtime animation
  16093. */
  16094. private _activeTargets;
  16095. private _currentActiveTarget;
  16096. private _directTarget;
  16097. /**
  16098. * The target path of the runtime animation
  16099. */
  16100. private _targetPath;
  16101. /**
  16102. * The weight of the runtime animation
  16103. */
  16104. private _weight;
  16105. /**
  16106. * The ratio offset of the runtime animation
  16107. */
  16108. private _ratioOffset;
  16109. /**
  16110. * The previous delay of the runtime animation
  16111. */
  16112. private _previousDelay;
  16113. /**
  16114. * The previous ratio of the runtime animation
  16115. */
  16116. private _previousRatio;
  16117. private _enableBlending;
  16118. private _keys;
  16119. private _minFrame;
  16120. private _maxFrame;
  16121. private _minValue;
  16122. private _maxValue;
  16123. private _targetIsArray;
  16124. /**
  16125. * Gets the current frame of the runtime animation
  16126. */
  16127. get currentFrame(): number;
  16128. /**
  16129. * Gets the weight of the runtime animation
  16130. */
  16131. get weight(): number;
  16132. /**
  16133. * Gets the current value of the runtime animation
  16134. */
  16135. get currentValue(): any;
  16136. /**
  16137. * Gets the target path of the runtime animation
  16138. */
  16139. get targetPath(): string;
  16140. /**
  16141. * Gets the actual target of the runtime animation
  16142. */
  16143. get target(): any;
  16144. /**
  16145. * Gets the additive state of the runtime animation
  16146. */
  16147. get isAdditive(): boolean;
  16148. /** @hidden */
  16149. _onLoop: () => void;
  16150. /**
  16151. * Create a new RuntimeAnimation object
  16152. * @param target defines the target of the animation
  16153. * @param animation defines the source animation object
  16154. * @param scene defines the hosting scene
  16155. * @param host defines the initiating Animatable
  16156. */
  16157. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16158. private _preparePath;
  16159. /**
  16160. * Gets the animation from the runtime animation
  16161. */
  16162. get animation(): Animation;
  16163. /**
  16164. * Resets the runtime animation to the beginning
  16165. * @param restoreOriginal defines whether to restore the target property to the original value
  16166. */
  16167. reset(restoreOriginal?: boolean): void;
  16168. /**
  16169. * Specifies if the runtime animation is stopped
  16170. * @returns Boolean specifying if the runtime animation is stopped
  16171. */
  16172. isStopped(): boolean;
  16173. /**
  16174. * Disposes of the runtime animation
  16175. */
  16176. dispose(): void;
  16177. /**
  16178. * Apply the interpolated value to the target
  16179. * @param currentValue defines the value computed by the animation
  16180. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16181. */
  16182. setValue(currentValue: any, weight: number): void;
  16183. private _getOriginalValues;
  16184. private _setValue;
  16185. /**
  16186. * Gets the loop pmode of the runtime animation
  16187. * @returns Loop Mode
  16188. */
  16189. private _getCorrectLoopMode;
  16190. /**
  16191. * Move the current animation to a given frame
  16192. * @param frame defines the frame to move to
  16193. */
  16194. goToFrame(frame: number): void;
  16195. /**
  16196. * @hidden Internal use only
  16197. */
  16198. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16199. /**
  16200. * Execute the current animation
  16201. * @param delay defines the delay to add to the current frame
  16202. * @param from defines the lower bound of the animation range
  16203. * @param to defines the upper bound of the animation range
  16204. * @param loop defines if the current animation must loop
  16205. * @param speedRatio defines the current speed ratio
  16206. * @param weight defines the weight of the animation (default is -1 so no weight)
  16207. * @param onLoop optional callback called when animation loops
  16208. * @returns a boolean indicating if the animation is running
  16209. */
  16210. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16211. }
  16212. }
  16213. declare module "babylonjs/Animations/animatable" {
  16214. import { Animation } from "babylonjs/Animations/animation";
  16215. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16216. import { Nullable } from "babylonjs/types";
  16217. import { Observable } from "babylonjs/Misc/observable";
  16218. import { Scene } from "babylonjs/scene";
  16219. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16220. import { Node } from "babylonjs/node";
  16221. /**
  16222. * Class used to store an actual running animation
  16223. */
  16224. export class Animatable {
  16225. /** defines the target object */
  16226. target: any;
  16227. /** defines the starting frame number (default is 0) */
  16228. fromFrame: number;
  16229. /** defines the ending frame number (default is 100) */
  16230. toFrame: number;
  16231. /** defines if the animation must loop (default is false) */
  16232. loopAnimation: boolean;
  16233. /** defines a callback to call when animation ends if it is not looping */
  16234. onAnimationEnd?: (() => void) | null | undefined;
  16235. /** defines a callback to call when animation loops */
  16236. onAnimationLoop?: (() => void) | null | undefined;
  16237. /** defines whether the animation should be evaluated additively */
  16238. isAdditive: boolean;
  16239. private _localDelayOffset;
  16240. private _pausedDelay;
  16241. private _runtimeAnimations;
  16242. private _paused;
  16243. private _scene;
  16244. private _speedRatio;
  16245. private _weight;
  16246. private _syncRoot;
  16247. /**
  16248. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16249. * This will only apply for non looping animation (default is true)
  16250. */
  16251. disposeOnEnd: boolean;
  16252. /**
  16253. * Gets a boolean indicating if the animation has started
  16254. */
  16255. animationStarted: boolean;
  16256. /**
  16257. * Observer raised when the animation ends
  16258. */
  16259. onAnimationEndObservable: Observable<Animatable>;
  16260. /**
  16261. * Observer raised when the animation loops
  16262. */
  16263. onAnimationLoopObservable: Observable<Animatable>;
  16264. /**
  16265. * Gets the root Animatable used to synchronize and normalize animations
  16266. */
  16267. get syncRoot(): Nullable<Animatable>;
  16268. /**
  16269. * Gets the current frame of the first RuntimeAnimation
  16270. * Used to synchronize Animatables
  16271. */
  16272. get masterFrame(): number;
  16273. /**
  16274. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16275. */
  16276. get weight(): number;
  16277. set weight(value: number);
  16278. /**
  16279. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16280. */
  16281. get speedRatio(): number;
  16282. set speedRatio(value: number);
  16283. /**
  16284. * Creates a new Animatable
  16285. * @param scene defines the hosting scene
  16286. * @param target defines the target object
  16287. * @param fromFrame defines the starting frame number (default is 0)
  16288. * @param toFrame defines the ending frame number (default is 100)
  16289. * @param loopAnimation defines if the animation must loop (default is false)
  16290. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16291. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16292. * @param animations defines a group of animation to add to the new Animatable
  16293. * @param onAnimationLoop defines a callback to call when animation loops
  16294. * @param isAdditive defines whether the animation should be evaluated additively
  16295. */
  16296. constructor(scene: Scene,
  16297. /** defines the target object */
  16298. target: any,
  16299. /** defines the starting frame number (default is 0) */
  16300. fromFrame?: number,
  16301. /** defines the ending frame number (default is 100) */
  16302. toFrame?: number,
  16303. /** defines if the animation must loop (default is false) */
  16304. loopAnimation?: boolean, speedRatio?: number,
  16305. /** defines a callback to call when animation ends if it is not looping */
  16306. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16307. /** defines a callback to call when animation loops */
  16308. onAnimationLoop?: (() => void) | null | undefined,
  16309. /** defines whether the animation should be evaluated additively */
  16310. isAdditive?: boolean);
  16311. /**
  16312. * Synchronize and normalize current Animatable with a source Animatable
  16313. * This is useful when using animation weights and when animations are not of the same length
  16314. * @param root defines the root Animatable to synchronize with
  16315. * @returns the current Animatable
  16316. */
  16317. syncWith(root: Animatable): Animatable;
  16318. /**
  16319. * Gets the list of runtime animations
  16320. * @returns an array of RuntimeAnimation
  16321. */
  16322. getAnimations(): RuntimeAnimation[];
  16323. /**
  16324. * Adds more animations to the current animatable
  16325. * @param target defines the target of the animations
  16326. * @param animations defines the new animations to add
  16327. */
  16328. appendAnimations(target: any, animations: Animation[]): void;
  16329. /**
  16330. * Gets the source animation for a specific property
  16331. * @param property defines the propertyu to look for
  16332. * @returns null or the source animation for the given property
  16333. */
  16334. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16335. /**
  16336. * Gets the runtime animation for a specific property
  16337. * @param property defines the propertyu to look for
  16338. * @returns null or the runtime animation for the given property
  16339. */
  16340. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16341. /**
  16342. * Resets the animatable to its original state
  16343. */
  16344. reset(): void;
  16345. /**
  16346. * Allows the animatable to blend with current running animations
  16347. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16348. * @param blendingSpeed defines the blending speed to use
  16349. */
  16350. enableBlending(blendingSpeed: number): void;
  16351. /**
  16352. * Disable animation blending
  16353. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16354. */
  16355. disableBlending(): void;
  16356. /**
  16357. * Jump directly to a given frame
  16358. * @param frame defines the frame to jump to
  16359. */
  16360. goToFrame(frame: number): void;
  16361. /**
  16362. * Pause the animation
  16363. */
  16364. pause(): void;
  16365. /**
  16366. * Restart the animation
  16367. */
  16368. restart(): void;
  16369. private _raiseOnAnimationEnd;
  16370. /**
  16371. * Stop and delete the current animation
  16372. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16373. * @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)
  16374. */
  16375. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16376. /**
  16377. * Wait asynchronously for the animation to end
  16378. * @returns a promise which will be fullfilled when the animation ends
  16379. */
  16380. waitAsync(): Promise<Animatable>;
  16381. /** @hidden */
  16382. _animate(delay: number): boolean;
  16383. }
  16384. module "babylonjs/scene" {
  16385. interface Scene {
  16386. /** @hidden */
  16387. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16388. /** @hidden */
  16389. _processLateAnimationBindingsForMatrices(holder: {
  16390. totalWeight: number;
  16391. totalAdditiveWeight: number;
  16392. animations: RuntimeAnimation[];
  16393. additiveAnimations: RuntimeAnimation[];
  16394. originalValue: Matrix;
  16395. }): any;
  16396. /** @hidden */
  16397. _processLateAnimationBindingsForQuaternions(holder: {
  16398. totalWeight: number;
  16399. totalAdditiveWeight: number;
  16400. animations: RuntimeAnimation[];
  16401. additiveAnimations: RuntimeAnimation[];
  16402. originalValue: Quaternion;
  16403. }, refQuaternion: Quaternion): Quaternion;
  16404. /** @hidden */
  16405. _processLateAnimationBindings(): void;
  16406. /**
  16407. * Will start the animation sequence of a given target
  16408. * @param target defines the target
  16409. * @param from defines from which frame should animation start
  16410. * @param to defines until which frame should animation run.
  16411. * @param weight defines the weight to apply to the animation (1.0 by default)
  16412. * @param loop defines if the animation loops
  16413. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16414. * @param onAnimationEnd defines the function to be executed when the animation ends
  16415. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16416. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16417. * @param onAnimationLoop defines the callback to call when an animation loops
  16418. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16419. * @returns the animatable object created for this animation
  16420. */
  16421. 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;
  16422. /**
  16423. * Will start the animation sequence of a given target
  16424. * @param target defines the target
  16425. * @param from defines from which frame should animation start
  16426. * @param to defines until which frame should animation run.
  16427. * @param loop defines if the animation loops
  16428. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16429. * @param onAnimationEnd defines the function to be executed when the animation ends
  16430. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16431. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16432. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16433. * @param onAnimationLoop defines the callback to call when an animation loops
  16434. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16435. * @returns the animatable object created for this animation
  16436. */
  16437. 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;
  16438. /**
  16439. * Will start the animation sequence of a given target and its hierarchy
  16440. * @param target defines the target
  16441. * @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.
  16442. * @param from defines from which frame should animation start
  16443. * @param to defines until which frame should animation run.
  16444. * @param loop defines if the animation loops
  16445. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16446. * @param onAnimationEnd defines the function to be executed when the animation ends
  16447. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16448. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16449. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16450. * @param onAnimationLoop defines the callback to call when an animation loops
  16451. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16452. * @returns the list of created animatables
  16453. */
  16454. 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[];
  16455. /**
  16456. * Begin a new animation on a given node
  16457. * @param target defines the target where the animation will take place
  16458. * @param animations defines the list of animations to start
  16459. * @param from defines the initial value
  16460. * @param to defines the final value
  16461. * @param loop defines if you want animation to loop (off by default)
  16462. * @param speedRatio defines the speed ratio to apply to all animations
  16463. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16464. * @param onAnimationLoop defines the callback to call when an animation loops
  16465. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16466. * @returns the list of created animatables
  16467. */
  16468. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16469. /**
  16470. * Begin a new animation on a given node and its hierarchy
  16471. * @param target defines the root node where the animation will take place
  16472. * @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.
  16473. * @param animations defines the list of animations to start
  16474. * @param from defines the initial value
  16475. * @param to defines the final value
  16476. * @param loop defines if you want animation to loop (off by default)
  16477. * @param speedRatio defines the speed ratio to apply to all animations
  16478. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16479. * @param onAnimationLoop defines the callback to call when an animation loops
  16480. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16481. * @returns the list of animatables created for all nodes
  16482. */
  16483. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16484. /**
  16485. * Gets the animatable associated with a specific target
  16486. * @param target defines the target of the animatable
  16487. * @returns the required animatable if found
  16488. */
  16489. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16490. /**
  16491. * Gets all animatables associated with a given target
  16492. * @param target defines the target to look animatables for
  16493. * @returns an array of Animatables
  16494. */
  16495. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16496. /**
  16497. * Stops and removes all animations that have been applied to the scene
  16498. */
  16499. stopAllAnimations(): void;
  16500. /**
  16501. * Gets the current delta time used by animation engine
  16502. */
  16503. deltaTime: number;
  16504. }
  16505. }
  16506. module "babylonjs/Bones/bone" {
  16507. interface Bone {
  16508. /**
  16509. * Copy an animation range from another bone
  16510. * @param source defines the source bone
  16511. * @param rangeName defines the range name to copy
  16512. * @param frameOffset defines the frame offset
  16513. * @param rescaleAsRequired defines if rescaling must be applied if required
  16514. * @param skelDimensionsRatio defines the scaling ratio
  16515. * @returns true if operation was successful
  16516. */
  16517. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16518. }
  16519. }
  16520. }
  16521. declare module "babylonjs/Bones/skeleton" {
  16522. import { Bone } from "babylonjs/Bones/bone";
  16523. import { Observable } from "babylonjs/Misc/observable";
  16524. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16525. import { Scene } from "babylonjs/scene";
  16526. import { Nullable } from "babylonjs/types";
  16527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16528. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16529. import { Animatable } from "babylonjs/Animations/animatable";
  16530. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16531. import { Animation } from "babylonjs/Animations/animation";
  16532. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16533. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16534. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16535. /**
  16536. * Class used to handle skinning animations
  16537. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16538. */
  16539. export class Skeleton implements IAnimatable {
  16540. /** defines the skeleton name */
  16541. name: string;
  16542. /** defines the skeleton Id */
  16543. id: string;
  16544. /**
  16545. * Defines the list of child bones
  16546. */
  16547. bones: Bone[];
  16548. /**
  16549. * Defines an estimate of the dimension of the skeleton at rest
  16550. */
  16551. dimensionsAtRest: Vector3;
  16552. /**
  16553. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16554. */
  16555. needInitialSkinMatrix: boolean;
  16556. /**
  16557. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16558. */
  16559. overrideMesh: Nullable<AbstractMesh>;
  16560. /**
  16561. * Gets the list of animations attached to this skeleton
  16562. */
  16563. animations: Array<Animation>;
  16564. private _scene;
  16565. private _isDirty;
  16566. private _transformMatrices;
  16567. private _transformMatrixTexture;
  16568. private _meshesWithPoseMatrix;
  16569. private _animatables;
  16570. private _identity;
  16571. private _synchronizedWithMesh;
  16572. private _ranges;
  16573. private _lastAbsoluteTransformsUpdateId;
  16574. private _canUseTextureForBones;
  16575. private _uniqueId;
  16576. /** @hidden */
  16577. _numBonesWithLinkedTransformNode: number;
  16578. /** @hidden */
  16579. _hasWaitingData: Nullable<boolean>;
  16580. /** @hidden */
  16581. _waitingOverrideMeshId: Nullable<string>;
  16582. /**
  16583. * Specifies if the skeleton should be serialized
  16584. */
  16585. doNotSerialize: boolean;
  16586. private _useTextureToStoreBoneMatrices;
  16587. /**
  16588. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16589. * Please note that this option is not available if the hardware does not support it
  16590. */
  16591. get useTextureToStoreBoneMatrices(): boolean;
  16592. set useTextureToStoreBoneMatrices(value: boolean);
  16593. private _animationPropertiesOverride;
  16594. /**
  16595. * Gets or sets the animation properties override
  16596. */
  16597. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16598. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16599. /**
  16600. * List of inspectable custom properties (used by the Inspector)
  16601. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16602. */
  16603. inspectableCustomProperties: IInspectable[];
  16604. /**
  16605. * An observable triggered before computing the skeleton's matrices
  16606. */
  16607. onBeforeComputeObservable: Observable<Skeleton>;
  16608. /**
  16609. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16610. */
  16611. get isUsingTextureForMatrices(): boolean;
  16612. /**
  16613. * Gets the unique ID of this skeleton
  16614. */
  16615. get uniqueId(): number;
  16616. /**
  16617. * Creates a new skeleton
  16618. * @param name defines the skeleton name
  16619. * @param id defines the skeleton Id
  16620. * @param scene defines the hosting scene
  16621. */
  16622. constructor(
  16623. /** defines the skeleton name */
  16624. name: string,
  16625. /** defines the skeleton Id */
  16626. id: string, scene: Scene);
  16627. /**
  16628. * Gets the current object class name.
  16629. * @return the class name
  16630. */
  16631. getClassName(): string;
  16632. /**
  16633. * Returns an array containing the root bones
  16634. * @returns an array containing the root bones
  16635. */
  16636. getChildren(): Array<Bone>;
  16637. /**
  16638. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16639. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16640. * @returns a Float32Array containing matrices data
  16641. */
  16642. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16643. /**
  16644. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16645. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16646. * @returns a raw texture containing the data
  16647. */
  16648. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16649. /**
  16650. * Gets the current hosting scene
  16651. * @returns a scene object
  16652. */
  16653. getScene(): Scene;
  16654. /**
  16655. * Gets a string representing the current skeleton data
  16656. * @param fullDetails defines a boolean indicating if we want a verbose version
  16657. * @returns a string representing the current skeleton data
  16658. */
  16659. toString(fullDetails?: boolean): string;
  16660. /**
  16661. * Get bone's index searching by name
  16662. * @param name defines bone's name to search for
  16663. * @return the indice of the bone. Returns -1 if not found
  16664. */
  16665. getBoneIndexByName(name: string): number;
  16666. /**
  16667. * Creater a new animation range
  16668. * @param name defines the name of the range
  16669. * @param from defines the start key
  16670. * @param to defines the end key
  16671. */
  16672. createAnimationRange(name: string, from: number, to: number): void;
  16673. /**
  16674. * Delete a specific animation range
  16675. * @param name defines the name of the range
  16676. * @param deleteFrames defines if frames must be removed as well
  16677. */
  16678. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16679. /**
  16680. * Gets a specific animation range
  16681. * @param name defines the name of the range to look for
  16682. * @returns the requested animation range or null if not found
  16683. */
  16684. getAnimationRange(name: string): Nullable<AnimationRange>;
  16685. /**
  16686. * Gets the list of all animation ranges defined on this skeleton
  16687. * @returns an array
  16688. */
  16689. getAnimationRanges(): Nullable<AnimationRange>[];
  16690. /**
  16691. * Copy animation range from a source skeleton.
  16692. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16693. * @param source defines the source skeleton
  16694. * @param name defines the name of the range to copy
  16695. * @param rescaleAsRequired defines if rescaling must be applied if required
  16696. * @returns true if operation was successful
  16697. */
  16698. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16699. /**
  16700. * Forces the skeleton to go to rest pose
  16701. */
  16702. returnToRest(): void;
  16703. private _getHighestAnimationFrame;
  16704. /**
  16705. * Begin a specific animation range
  16706. * @param name defines the name of the range to start
  16707. * @param loop defines if looping must be turned on (false by default)
  16708. * @param speedRatio defines the speed ratio to apply (1 by default)
  16709. * @param onAnimationEnd defines a callback which will be called when animation will end
  16710. * @returns a new animatable
  16711. */
  16712. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16713. /**
  16714. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16715. * @param skeleton defines the Skeleton containing the animation range to convert
  16716. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16717. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16718. * @returns the original skeleton
  16719. */
  16720. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16721. /** @hidden */
  16722. _markAsDirty(): void;
  16723. /** @hidden */
  16724. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16725. /** @hidden */
  16726. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16727. private _computeTransformMatrices;
  16728. /**
  16729. * Build all resources required to render a skeleton
  16730. */
  16731. prepare(): void;
  16732. /**
  16733. * Gets the list of animatables currently running for this skeleton
  16734. * @returns an array of animatables
  16735. */
  16736. getAnimatables(): IAnimatable[];
  16737. /**
  16738. * Clone the current skeleton
  16739. * @param name defines the name of the new skeleton
  16740. * @param id defines the id of the new skeleton
  16741. * @returns the new skeleton
  16742. */
  16743. clone(name: string, id?: string): Skeleton;
  16744. /**
  16745. * Enable animation blending for this skeleton
  16746. * @param blendingSpeed defines the blending speed to apply
  16747. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16748. */
  16749. enableBlending(blendingSpeed?: number): void;
  16750. /**
  16751. * Releases all resources associated with the current skeleton
  16752. */
  16753. dispose(): void;
  16754. /**
  16755. * Serialize the skeleton in a JSON object
  16756. * @returns a JSON object
  16757. */
  16758. serialize(): any;
  16759. /**
  16760. * Creates a new skeleton from serialized data
  16761. * @param parsedSkeleton defines the serialized data
  16762. * @param scene defines the hosting scene
  16763. * @returns a new skeleton
  16764. */
  16765. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16766. /**
  16767. * Compute all node absolute transforms
  16768. * @param forceUpdate defines if computation must be done even if cache is up to date
  16769. */
  16770. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16771. /**
  16772. * Gets the root pose matrix
  16773. * @returns a matrix
  16774. */
  16775. getPoseMatrix(): Nullable<Matrix>;
  16776. /**
  16777. * Sorts bones per internal index
  16778. */
  16779. sortBones(): void;
  16780. private _sortBones;
  16781. /**
  16782. * Set the current local matrix as the restPose for all bones in the skeleton.
  16783. */
  16784. setCurrentPoseAsRest(): void;
  16785. }
  16786. }
  16787. declare module "babylonjs/Meshes/instancedMesh" {
  16788. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16789. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16790. import { Camera } from "babylonjs/Cameras/camera";
  16791. import { Node } from "babylonjs/node";
  16792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16793. import { Mesh } from "babylonjs/Meshes/mesh";
  16794. import { Material } from "babylonjs/Materials/material";
  16795. import { Skeleton } from "babylonjs/Bones/skeleton";
  16796. import { Light } from "babylonjs/Lights/light";
  16797. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16798. /**
  16799. * Creates an instance based on a source mesh.
  16800. */
  16801. export class InstancedMesh extends AbstractMesh {
  16802. private _sourceMesh;
  16803. private _currentLOD;
  16804. /** @hidden */
  16805. _indexInSourceMeshInstanceArray: number;
  16806. constructor(name: string, source: Mesh);
  16807. /**
  16808. * Returns the string "InstancedMesh".
  16809. */
  16810. getClassName(): string;
  16811. /** Gets the list of lights affecting that mesh */
  16812. get lightSources(): Light[];
  16813. _resyncLightSources(): void;
  16814. _resyncLightSource(light: Light): void;
  16815. _removeLightSource(light: Light, dispose: boolean): void;
  16816. /**
  16817. * If the source mesh receives shadows
  16818. */
  16819. get receiveShadows(): boolean;
  16820. /**
  16821. * The material of the source mesh
  16822. */
  16823. get material(): Nullable<Material>;
  16824. /**
  16825. * Visibility of the source mesh
  16826. */
  16827. get visibility(): number;
  16828. /**
  16829. * Skeleton of the source mesh
  16830. */
  16831. get skeleton(): Nullable<Skeleton>;
  16832. /**
  16833. * Rendering ground id of the source mesh
  16834. */
  16835. get renderingGroupId(): number;
  16836. set renderingGroupId(value: number);
  16837. /**
  16838. * Returns the total number of vertices (integer).
  16839. */
  16840. getTotalVertices(): number;
  16841. /**
  16842. * Returns a positive integer : the total number of indices in this mesh geometry.
  16843. * @returns the numner of indices or zero if the mesh has no geometry.
  16844. */
  16845. getTotalIndices(): number;
  16846. /**
  16847. * The source mesh of the instance
  16848. */
  16849. get sourceMesh(): Mesh;
  16850. /**
  16851. * Creates a new InstancedMesh object from the mesh model.
  16852. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16853. * @param name defines the name of the new instance
  16854. * @returns a new InstancedMesh
  16855. */
  16856. createInstance(name: string): InstancedMesh;
  16857. /**
  16858. * Is this node ready to be used/rendered
  16859. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16860. * @return {boolean} is it ready
  16861. */
  16862. isReady(completeCheck?: boolean): boolean;
  16863. /**
  16864. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16865. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16866. * @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.
  16867. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16868. */
  16869. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16870. /**
  16871. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16872. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16873. * The `data` are either a numeric array either a Float32Array.
  16874. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16875. * 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).
  16876. * Note that a new underlying VertexBuffer object is created each call.
  16877. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16878. *
  16879. * Possible `kind` values :
  16880. * - VertexBuffer.PositionKind
  16881. * - VertexBuffer.UVKind
  16882. * - VertexBuffer.UV2Kind
  16883. * - VertexBuffer.UV3Kind
  16884. * - VertexBuffer.UV4Kind
  16885. * - VertexBuffer.UV5Kind
  16886. * - VertexBuffer.UV6Kind
  16887. * - VertexBuffer.ColorKind
  16888. * - VertexBuffer.MatricesIndicesKind
  16889. * - VertexBuffer.MatricesIndicesExtraKind
  16890. * - VertexBuffer.MatricesWeightsKind
  16891. * - VertexBuffer.MatricesWeightsExtraKind
  16892. *
  16893. * Returns the Mesh.
  16894. */
  16895. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16896. /**
  16897. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16898. * If the mesh has no geometry, it is simply returned as it is.
  16899. * The `data` are either a numeric array either a Float32Array.
  16900. * No new underlying VertexBuffer object is created.
  16901. * 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.
  16902. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16903. *
  16904. * Possible `kind` values :
  16905. * - VertexBuffer.PositionKind
  16906. * - VertexBuffer.UVKind
  16907. * - VertexBuffer.UV2Kind
  16908. * - VertexBuffer.UV3Kind
  16909. * - VertexBuffer.UV4Kind
  16910. * - VertexBuffer.UV5Kind
  16911. * - VertexBuffer.UV6Kind
  16912. * - VertexBuffer.ColorKind
  16913. * - VertexBuffer.MatricesIndicesKind
  16914. * - VertexBuffer.MatricesIndicesExtraKind
  16915. * - VertexBuffer.MatricesWeightsKind
  16916. * - VertexBuffer.MatricesWeightsExtraKind
  16917. *
  16918. * Returns the Mesh.
  16919. */
  16920. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16921. /**
  16922. * Sets the mesh indices.
  16923. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16924. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16925. * This method creates a new index buffer each call.
  16926. * Returns the Mesh.
  16927. */
  16928. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16929. /**
  16930. * Boolean : True if the mesh owns the requested kind of data.
  16931. */
  16932. isVerticesDataPresent(kind: string): boolean;
  16933. /**
  16934. * Returns an array of indices (IndicesArray).
  16935. */
  16936. getIndices(): Nullable<IndicesArray>;
  16937. get _positions(): Nullable<Vector3[]>;
  16938. /**
  16939. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16940. * This means the mesh underlying bounding box and sphere are recomputed.
  16941. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16942. * @returns the current mesh
  16943. */
  16944. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16945. /** @hidden */
  16946. _preActivate(): InstancedMesh;
  16947. /** @hidden */
  16948. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16949. /** @hidden */
  16950. _postActivate(): void;
  16951. getWorldMatrix(): Matrix;
  16952. get isAnInstance(): boolean;
  16953. /**
  16954. * Returns the current associated LOD AbstractMesh.
  16955. */
  16956. getLOD(camera: Camera): AbstractMesh;
  16957. /** @hidden */
  16958. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16959. /** @hidden */
  16960. _syncSubMeshes(): InstancedMesh;
  16961. /** @hidden */
  16962. _generatePointsArray(): boolean;
  16963. /** @hidden */
  16964. _updateBoundingInfo(): AbstractMesh;
  16965. /**
  16966. * Creates a new InstancedMesh from the current mesh.
  16967. * - name (string) : the cloned mesh name
  16968. * - newParent (optional Node) : the optional Node to parent the clone to.
  16969. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16970. *
  16971. * Returns the clone.
  16972. */
  16973. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16974. /**
  16975. * Disposes the InstancedMesh.
  16976. * Returns nothing.
  16977. */
  16978. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16979. }
  16980. module "babylonjs/Meshes/mesh" {
  16981. interface Mesh {
  16982. /**
  16983. * Register a custom buffer that will be instanced
  16984. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16985. * @param kind defines the buffer kind
  16986. * @param stride defines the stride in floats
  16987. */
  16988. registerInstancedBuffer(kind: string, stride: number): void;
  16989. /**
  16990. * true to use the edge renderer for all instances of this mesh
  16991. */
  16992. edgesShareWithInstances: boolean;
  16993. /** @hidden */
  16994. _userInstancedBuffersStorage: {
  16995. data: {
  16996. [key: string]: Float32Array;
  16997. };
  16998. sizes: {
  16999. [key: string]: number;
  17000. };
  17001. vertexBuffers: {
  17002. [key: string]: Nullable<VertexBuffer>;
  17003. };
  17004. strides: {
  17005. [key: string]: number;
  17006. };
  17007. };
  17008. }
  17009. }
  17010. module "babylonjs/Meshes/abstractMesh" {
  17011. interface AbstractMesh {
  17012. /**
  17013. * Object used to store instanced buffers defined by user
  17014. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  17015. */
  17016. instancedBuffers: {
  17017. [key: string]: any;
  17018. };
  17019. }
  17020. }
  17021. }
  17022. declare module "babylonjs/Materials/shaderMaterial" {
  17023. import { Nullable } from "babylonjs/types";
  17024. import { Scene } from "babylonjs/scene";
  17025. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  17026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17027. import { Mesh } from "babylonjs/Meshes/mesh";
  17028. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17029. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17030. import { Effect } from "babylonjs/Materials/effect";
  17031. import { Material } from "babylonjs/Materials/material";
  17032. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  17033. /**
  17034. * Defines the options associated with the creation of a shader material.
  17035. */
  17036. export interface IShaderMaterialOptions {
  17037. /**
  17038. * Does the material work in alpha blend mode
  17039. */
  17040. needAlphaBlending: boolean;
  17041. /**
  17042. * Does the material work in alpha test mode
  17043. */
  17044. needAlphaTesting: boolean;
  17045. /**
  17046. * The list of attribute names used in the shader
  17047. */
  17048. attributes: string[];
  17049. /**
  17050. * The list of unifrom names used in the shader
  17051. */
  17052. uniforms: string[];
  17053. /**
  17054. * The list of UBO names used in the shader
  17055. */
  17056. uniformBuffers: string[];
  17057. /**
  17058. * The list of sampler names used in the shader
  17059. */
  17060. samplers: string[];
  17061. /**
  17062. * The list of defines used in the shader
  17063. */
  17064. defines: string[];
  17065. }
  17066. /**
  17067. * 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.
  17068. *
  17069. * This returned material effects how the mesh will look based on the code in the shaders.
  17070. *
  17071. * @see https://doc.babylonjs.com/how_to/shader_material
  17072. */
  17073. export class ShaderMaterial extends Material {
  17074. private _shaderPath;
  17075. private _options;
  17076. private _textures;
  17077. private _textureArrays;
  17078. private _floats;
  17079. private _ints;
  17080. private _floatsArrays;
  17081. private _colors3;
  17082. private _colors3Arrays;
  17083. private _colors4;
  17084. private _colors4Arrays;
  17085. private _vectors2;
  17086. private _vectors3;
  17087. private _vectors4;
  17088. private _matrices;
  17089. private _matrixArrays;
  17090. private _matrices3x3;
  17091. private _matrices2x2;
  17092. private _vectors2Arrays;
  17093. private _vectors3Arrays;
  17094. private _vectors4Arrays;
  17095. private _cachedWorldViewMatrix;
  17096. private _cachedWorldViewProjectionMatrix;
  17097. private _renderId;
  17098. private _multiview;
  17099. private _cachedDefines;
  17100. /** Define the Url to load snippets */
  17101. static SnippetUrl: string;
  17102. /** Snippet ID if the material was created from the snippet server */
  17103. snippetId: string;
  17104. /**
  17105. * Instantiate a new shader material.
  17106. * 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.
  17107. * This returned material effects how the mesh will look based on the code in the shaders.
  17108. * @see https://doc.babylonjs.com/how_to/shader_material
  17109. * @param name Define the name of the material in the scene
  17110. * @param scene Define the scene the material belongs to
  17111. * @param shaderPath Defines the route to the shader code in one of three ways:
  17112. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17113. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17114. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17115. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17116. * @param options Define the options used to create the shader
  17117. */
  17118. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17119. /**
  17120. * Gets the shader path used to define the shader code
  17121. * It can be modified to trigger a new compilation
  17122. */
  17123. get shaderPath(): any;
  17124. /**
  17125. * Sets the shader path used to define the shader code
  17126. * It can be modified to trigger a new compilation
  17127. */
  17128. set shaderPath(shaderPath: any);
  17129. /**
  17130. * Gets the options used to compile the shader.
  17131. * They can be modified to trigger a new compilation
  17132. */
  17133. get options(): IShaderMaterialOptions;
  17134. /**
  17135. * Gets the current class name of the material e.g. "ShaderMaterial"
  17136. * Mainly use in serialization.
  17137. * @returns the class name
  17138. */
  17139. getClassName(): string;
  17140. /**
  17141. * Specifies if the material will require alpha blending
  17142. * @returns a boolean specifying if alpha blending is needed
  17143. */
  17144. needAlphaBlending(): boolean;
  17145. /**
  17146. * Specifies if this material should be rendered in alpha test mode
  17147. * @returns a boolean specifying if an alpha test is needed.
  17148. */
  17149. needAlphaTesting(): boolean;
  17150. private _checkUniform;
  17151. /**
  17152. * Set a texture in the shader.
  17153. * @param name Define the name of the uniform samplers as defined in the shader
  17154. * @param texture Define the texture to bind to this sampler
  17155. * @return the material itself allowing "fluent" like uniform updates
  17156. */
  17157. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17158. /**
  17159. * Set a texture array in the shader.
  17160. * @param name Define the name of the uniform sampler array as defined in the shader
  17161. * @param textures Define the list of textures to bind to this sampler
  17162. * @return the material itself allowing "fluent" like uniform updates
  17163. */
  17164. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17165. /**
  17166. * Set a float in the shader.
  17167. * @param name Define the name of the uniform as defined in the shader
  17168. * @param value Define the value to give to the uniform
  17169. * @return the material itself allowing "fluent" like uniform updates
  17170. */
  17171. setFloat(name: string, value: number): ShaderMaterial;
  17172. /**
  17173. * Set a int in the shader.
  17174. * @param name Define the name of the uniform as defined in the shader
  17175. * @param value Define the value to give to the uniform
  17176. * @return the material itself allowing "fluent" like uniform updates
  17177. */
  17178. setInt(name: string, value: number): ShaderMaterial;
  17179. /**
  17180. * Set an array of floats in the shader.
  17181. * @param name Define the name of the uniform as defined in the shader
  17182. * @param value Define the value to give to the uniform
  17183. * @return the material itself allowing "fluent" like uniform updates
  17184. */
  17185. setFloats(name: string, value: number[]): ShaderMaterial;
  17186. /**
  17187. * Set a vec3 in the shader from a Color3.
  17188. * @param name Define the name of the uniform as defined in the shader
  17189. * @param value Define the value to give to the uniform
  17190. * @return the material itself allowing "fluent" like uniform updates
  17191. */
  17192. setColor3(name: string, value: Color3): ShaderMaterial;
  17193. /**
  17194. * Set a vec3 array in the shader from a Color3 array.
  17195. * @param name Define the name of the uniform as defined in the shader
  17196. * @param value Define the value to give to the uniform
  17197. * @return the material itself allowing "fluent" like uniform updates
  17198. */
  17199. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17200. /**
  17201. * Set a vec4 in the shader from a Color4.
  17202. * @param name Define the name of the uniform as defined in the shader
  17203. * @param value Define the value to give to the uniform
  17204. * @return the material itself allowing "fluent" like uniform updates
  17205. */
  17206. setColor4(name: string, value: Color4): ShaderMaterial;
  17207. /**
  17208. * Set a vec4 array in the shader from a Color4 array.
  17209. * @param name Define the name of the uniform as defined in the shader
  17210. * @param value Define the value to give to the uniform
  17211. * @return the material itself allowing "fluent" like uniform updates
  17212. */
  17213. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17214. /**
  17215. * Set a vec2 in the shader from a Vector2.
  17216. * @param name Define the name of the uniform as defined in the shader
  17217. * @param value Define the value to give to the uniform
  17218. * @return the material itself allowing "fluent" like uniform updates
  17219. */
  17220. setVector2(name: string, value: Vector2): ShaderMaterial;
  17221. /**
  17222. * Set a vec3 in the shader from a Vector3.
  17223. * @param name Define the name of the uniform as defined in the shader
  17224. * @param value Define the value to give to the uniform
  17225. * @return the material itself allowing "fluent" like uniform updates
  17226. */
  17227. setVector3(name: string, value: Vector3): ShaderMaterial;
  17228. /**
  17229. * Set a vec4 in the shader from a Vector4.
  17230. * @param name Define the name of the uniform as defined in the shader
  17231. * @param value Define the value to give to the uniform
  17232. * @return the material itself allowing "fluent" like uniform updates
  17233. */
  17234. setVector4(name: string, value: Vector4): ShaderMaterial;
  17235. /**
  17236. * Set a mat4 in the shader from a Matrix.
  17237. * @param name Define the name of the uniform as defined in the shader
  17238. * @param value Define the value to give to the uniform
  17239. * @return the material itself allowing "fluent" like uniform updates
  17240. */
  17241. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17242. /**
  17243. * Set a float32Array in the shader from a matrix array.
  17244. * @param name Define the name of the uniform as defined in the shader
  17245. * @param value Define the value to give to the uniform
  17246. * @return the material itself allowing "fluent" like uniform updates
  17247. */
  17248. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17249. /**
  17250. * Set a mat3 in the shader from a Float32Array.
  17251. * @param name Define the name of the uniform as defined in the shader
  17252. * @param value Define the value to give to the uniform
  17253. * @return the material itself allowing "fluent" like uniform updates
  17254. */
  17255. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17256. /**
  17257. * Set a mat2 in the shader from a Float32Array.
  17258. * @param name Define the name of the uniform as defined in the shader
  17259. * @param value Define the value to give to the uniform
  17260. * @return the material itself allowing "fluent" like uniform updates
  17261. */
  17262. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17263. /**
  17264. * Set a vec2 array in the shader from a number array.
  17265. * @param name Define the name of the uniform as defined in the shader
  17266. * @param value Define the value to give to the uniform
  17267. * @return the material itself allowing "fluent" like uniform updates
  17268. */
  17269. setArray2(name: string, value: number[]): ShaderMaterial;
  17270. /**
  17271. * Set a vec3 array in the shader from a number array.
  17272. * @param name Define the name of the uniform as defined in the shader
  17273. * @param value Define the value to give to the uniform
  17274. * @return the material itself allowing "fluent" like uniform updates
  17275. */
  17276. setArray3(name: string, value: number[]): ShaderMaterial;
  17277. /**
  17278. * Set a vec4 array in the shader from a number array.
  17279. * @param name Define the name of the uniform as defined in the shader
  17280. * @param value Define the value to give to the uniform
  17281. * @return the material itself allowing "fluent" like uniform updates
  17282. */
  17283. setArray4(name: string, value: number[]): ShaderMaterial;
  17284. private _checkCache;
  17285. /**
  17286. * Specifies that the submesh is ready to be used
  17287. * @param mesh defines the mesh to check
  17288. * @param subMesh defines which submesh to check
  17289. * @param useInstances specifies that instances should be used
  17290. * @returns a boolean indicating that the submesh is ready or not
  17291. */
  17292. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17293. /**
  17294. * Checks if the material is ready to render the requested mesh
  17295. * @param mesh Define the mesh to render
  17296. * @param useInstances Define whether or not the material is used with instances
  17297. * @returns true if ready, otherwise false
  17298. */
  17299. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17300. /**
  17301. * Binds the world matrix to the material
  17302. * @param world defines the world transformation matrix
  17303. * @param effectOverride - If provided, use this effect instead of internal effect
  17304. */
  17305. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17306. /**
  17307. * Binds the submesh to this material by preparing the effect and shader to draw
  17308. * @param world defines the world transformation matrix
  17309. * @param mesh defines the mesh containing the submesh
  17310. * @param subMesh defines the submesh to bind the material to
  17311. */
  17312. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17313. /**
  17314. * Binds the material to the mesh
  17315. * @param world defines the world transformation matrix
  17316. * @param mesh defines the mesh to bind the material to
  17317. * @param effectOverride - If provided, use this effect instead of internal effect
  17318. */
  17319. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17320. protected _afterBind(mesh?: Mesh): void;
  17321. /**
  17322. * Gets the active textures from the material
  17323. * @returns an array of textures
  17324. */
  17325. getActiveTextures(): BaseTexture[];
  17326. /**
  17327. * Specifies if the material uses a texture
  17328. * @param texture defines the texture to check against the material
  17329. * @returns a boolean specifying if the material uses the texture
  17330. */
  17331. hasTexture(texture: BaseTexture): boolean;
  17332. /**
  17333. * Makes a duplicate of the material, and gives it a new name
  17334. * @param name defines the new name for the duplicated material
  17335. * @returns the cloned material
  17336. */
  17337. clone(name: string): ShaderMaterial;
  17338. /**
  17339. * Disposes the material
  17340. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17341. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17342. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17343. */
  17344. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17345. /**
  17346. * Serializes this material in a JSON representation
  17347. * @returns the serialized material object
  17348. */
  17349. serialize(): any;
  17350. /**
  17351. * Creates a shader material from parsed shader material data
  17352. * @param source defines the JSON represnetation of the material
  17353. * @param scene defines the hosting scene
  17354. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17355. * @returns a new material
  17356. */
  17357. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17358. /**
  17359. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17360. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17361. * @param url defines the url to load from
  17362. * @param scene defines the hosting scene
  17363. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17364. * @returns a promise that will resolve to the new ShaderMaterial
  17365. */
  17366. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17367. /**
  17368. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17369. * @param snippetId defines the snippet to load
  17370. * @param scene defines the hosting scene
  17371. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17372. * @returns a promise that will resolve to the new ShaderMaterial
  17373. */
  17374. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17375. }
  17376. }
  17377. declare module "babylonjs/Shaders/color.fragment" {
  17378. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17379. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17380. /** @hidden */
  17381. export var colorPixelShader: {
  17382. name: string;
  17383. shader: string;
  17384. };
  17385. }
  17386. declare module "babylonjs/Shaders/color.vertex" {
  17387. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17388. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17389. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17390. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17391. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17392. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17393. /** @hidden */
  17394. export var colorVertexShader: {
  17395. name: string;
  17396. shader: string;
  17397. };
  17398. }
  17399. declare module "babylonjs/Meshes/linesMesh" {
  17400. import { Nullable } from "babylonjs/types";
  17401. import { Scene } from "babylonjs/scene";
  17402. import { Color3 } from "babylonjs/Maths/math.color";
  17403. import { Node } from "babylonjs/node";
  17404. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17405. import { Mesh } from "babylonjs/Meshes/mesh";
  17406. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17407. import { Effect } from "babylonjs/Materials/effect";
  17408. import { Material } from "babylonjs/Materials/material";
  17409. import "babylonjs/Shaders/color.fragment";
  17410. import "babylonjs/Shaders/color.vertex";
  17411. /**
  17412. * Line mesh
  17413. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17414. */
  17415. export class LinesMesh extends Mesh {
  17416. /**
  17417. * If vertex color should be applied to the mesh
  17418. */
  17419. readonly useVertexColor?: boolean | undefined;
  17420. /**
  17421. * If vertex alpha should be applied to the mesh
  17422. */
  17423. readonly useVertexAlpha?: boolean | undefined;
  17424. /**
  17425. * Color of the line (Default: White)
  17426. */
  17427. color: Color3;
  17428. /**
  17429. * Alpha of the line (Default: 1)
  17430. */
  17431. alpha: number;
  17432. /**
  17433. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17434. * This margin is expressed in world space coordinates, so its value may vary.
  17435. * Default value is 0.1
  17436. */
  17437. intersectionThreshold: number;
  17438. private _colorShader;
  17439. private color4;
  17440. /**
  17441. * Creates a new LinesMesh
  17442. * @param name defines the name
  17443. * @param scene defines the hosting scene
  17444. * @param parent defines the parent mesh if any
  17445. * @param source defines the optional source LinesMesh used to clone data from
  17446. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17447. * When false, achieved by calling a clone(), also passing False.
  17448. * This will make creation of children, recursive.
  17449. * @param useVertexColor defines if this LinesMesh supports vertex color
  17450. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17451. */
  17452. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17453. /**
  17454. * If vertex color should be applied to the mesh
  17455. */
  17456. useVertexColor?: boolean | undefined,
  17457. /**
  17458. * If vertex alpha should be applied to the mesh
  17459. */
  17460. useVertexAlpha?: boolean | undefined);
  17461. private _addClipPlaneDefine;
  17462. private _removeClipPlaneDefine;
  17463. isReady(): boolean;
  17464. /**
  17465. * Returns the string "LineMesh"
  17466. */
  17467. getClassName(): string;
  17468. /**
  17469. * @hidden
  17470. */
  17471. get material(): Material;
  17472. /**
  17473. * @hidden
  17474. */
  17475. set material(value: Material);
  17476. /**
  17477. * @hidden
  17478. */
  17479. get checkCollisions(): boolean;
  17480. /** @hidden */
  17481. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17482. /** @hidden */
  17483. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17484. /**
  17485. * Disposes of the line mesh
  17486. * @param doNotRecurse If children should be disposed
  17487. */
  17488. dispose(doNotRecurse?: boolean): void;
  17489. /**
  17490. * Returns a new LineMesh object cloned from the current one.
  17491. */
  17492. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17493. /**
  17494. * Creates a new InstancedLinesMesh object from the mesh model.
  17495. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17496. * @param name defines the name of the new instance
  17497. * @returns a new InstancedLinesMesh
  17498. */
  17499. createInstance(name: string): InstancedLinesMesh;
  17500. }
  17501. /**
  17502. * Creates an instance based on a source LinesMesh
  17503. */
  17504. export class InstancedLinesMesh extends InstancedMesh {
  17505. /**
  17506. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17507. * This margin is expressed in world space coordinates, so its value may vary.
  17508. * Initilized with the intersectionThreshold value of the source LinesMesh
  17509. */
  17510. intersectionThreshold: number;
  17511. constructor(name: string, source: LinesMesh);
  17512. /**
  17513. * Returns the string "InstancedLinesMesh".
  17514. */
  17515. getClassName(): string;
  17516. }
  17517. }
  17518. declare module "babylonjs/Shaders/line.fragment" {
  17519. /** @hidden */
  17520. export var linePixelShader: {
  17521. name: string;
  17522. shader: string;
  17523. };
  17524. }
  17525. declare module "babylonjs/Shaders/line.vertex" {
  17526. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17527. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17528. /** @hidden */
  17529. export var lineVertexShader: {
  17530. name: string;
  17531. shader: string;
  17532. };
  17533. }
  17534. declare module "babylonjs/Rendering/edgesRenderer" {
  17535. import { Nullable } from "babylonjs/types";
  17536. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17538. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17539. import { IDisposable } from "babylonjs/scene";
  17540. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17541. import "babylonjs/Shaders/line.fragment";
  17542. import "babylonjs/Shaders/line.vertex";
  17543. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17544. import { SmartArray } from "babylonjs/Misc/smartArray";
  17545. module "babylonjs/scene" {
  17546. interface Scene {
  17547. /** @hidden */
  17548. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17549. }
  17550. }
  17551. module "babylonjs/Meshes/abstractMesh" {
  17552. interface AbstractMesh {
  17553. /**
  17554. * Gets the edgesRenderer associated with the mesh
  17555. */
  17556. edgesRenderer: Nullable<EdgesRenderer>;
  17557. }
  17558. }
  17559. module "babylonjs/Meshes/linesMesh" {
  17560. interface LinesMesh {
  17561. /**
  17562. * Enables the edge rendering mode on the mesh.
  17563. * This mode makes the mesh edges visible
  17564. * @param epsilon defines the maximal distance between two angles to detect a face
  17565. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17566. * @returns the currentAbstractMesh
  17567. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17568. */
  17569. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17570. }
  17571. }
  17572. module "babylonjs/Meshes/linesMesh" {
  17573. interface InstancedLinesMesh {
  17574. /**
  17575. * Enables the edge rendering mode on the mesh.
  17576. * This mode makes the mesh edges visible
  17577. * @param epsilon defines the maximal distance between two angles to detect a face
  17578. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17579. * @returns the current InstancedLinesMesh
  17580. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17581. */
  17582. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17583. }
  17584. }
  17585. /**
  17586. * Defines the minimum contract an Edges renderer should follow.
  17587. */
  17588. export interface IEdgesRenderer extends IDisposable {
  17589. /**
  17590. * Gets or sets a boolean indicating if the edgesRenderer is active
  17591. */
  17592. isEnabled: boolean;
  17593. /**
  17594. * Renders the edges of the attached mesh,
  17595. */
  17596. render(): void;
  17597. /**
  17598. * Checks wether or not the edges renderer is ready to render.
  17599. * @return true if ready, otherwise false.
  17600. */
  17601. isReady(): boolean;
  17602. /**
  17603. * List of instances to render in case the source mesh has instances
  17604. */
  17605. customInstances: SmartArray<Matrix>;
  17606. }
  17607. /**
  17608. * Defines the additional options of the edges renderer
  17609. */
  17610. export interface IEdgesRendererOptions {
  17611. /**
  17612. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17613. * If not defined, the default value is true
  17614. */
  17615. useAlternateEdgeFinder?: boolean;
  17616. /**
  17617. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17618. * If not defined, the default value is true.
  17619. * 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)
  17620. * This option is used only if useAlternateEdgeFinder = true
  17621. */
  17622. useFastVertexMerger?: boolean;
  17623. /**
  17624. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17625. * The default value is 1e-6
  17626. * This option is used only if useAlternateEdgeFinder = true
  17627. */
  17628. epsilonVertexMerge?: number;
  17629. /**
  17630. * 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
  17631. * 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.
  17632. * This option is used only if useAlternateEdgeFinder = true
  17633. */
  17634. applyTessellation?: boolean;
  17635. /**
  17636. * 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
  17637. * The default value is 1e-6
  17638. * This option is used only if useAlternateEdgeFinder = true
  17639. */
  17640. epsilonVertexAligned?: number;
  17641. }
  17642. /**
  17643. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17644. */
  17645. export class EdgesRenderer implements IEdgesRenderer {
  17646. /**
  17647. * Define the size of the edges with an orthographic camera
  17648. */
  17649. edgesWidthScalerForOrthographic: number;
  17650. /**
  17651. * Define the size of the edges with a perspective camera
  17652. */
  17653. edgesWidthScalerForPerspective: number;
  17654. protected _source: AbstractMesh;
  17655. protected _linesPositions: number[];
  17656. protected _linesNormals: number[];
  17657. protected _linesIndices: number[];
  17658. protected _epsilon: number;
  17659. protected _indicesCount: number;
  17660. protected _lineShader: ShaderMaterial;
  17661. protected _ib: DataBuffer;
  17662. protected _buffers: {
  17663. [key: string]: Nullable<VertexBuffer>;
  17664. };
  17665. protected _buffersForInstances: {
  17666. [key: string]: Nullable<VertexBuffer>;
  17667. };
  17668. protected _checkVerticesInsteadOfIndices: boolean;
  17669. protected _options: Nullable<IEdgesRendererOptions>;
  17670. private _meshRebuildObserver;
  17671. private _meshDisposeObserver;
  17672. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17673. isEnabled: boolean;
  17674. /**
  17675. * List of instances to render in case the source mesh has instances
  17676. */
  17677. customInstances: SmartArray<Matrix>;
  17678. private static GetShader;
  17679. /**
  17680. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17681. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17682. * @param source Mesh used to create edges
  17683. * @param epsilon sum of angles in adjacency to check for edge
  17684. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17685. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17686. * @param options The options to apply when generating the edges
  17687. */
  17688. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17689. protected _prepareRessources(): void;
  17690. /** @hidden */
  17691. _rebuild(): void;
  17692. /**
  17693. * Releases the required resources for the edges renderer
  17694. */
  17695. dispose(): void;
  17696. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17697. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17698. /**
  17699. * Checks if the pair of p0 and p1 is en edge
  17700. * @param faceIndex
  17701. * @param edge
  17702. * @param faceNormals
  17703. * @param p0
  17704. * @param p1
  17705. * @private
  17706. */
  17707. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17708. /**
  17709. * push line into the position, normal and index buffer
  17710. * @protected
  17711. */
  17712. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17713. /**
  17714. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17715. */
  17716. private _tessellateTriangle;
  17717. private _generateEdgesLinesAlternate;
  17718. /**
  17719. * Generates lines edges from adjacencjes
  17720. * @private
  17721. */
  17722. _generateEdgesLines(): void;
  17723. /**
  17724. * Checks wether or not the edges renderer is ready to render.
  17725. * @return true if ready, otherwise false.
  17726. */
  17727. isReady(): boolean;
  17728. /**
  17729. * Renders the edges of the attached mesh,
  17730. */
  17731. render(): void;
  17732. }
  17733. /**
  17734. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17735. */
  17736. export class LineEdgesRenderer extends EdgesRenderer {
  17737. /**
  17738. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17739. * @param source LineMesh used to generate edges
  17740. * @param epsilon not important (specified angle for edge detection)
  17741. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17742. */
  17743. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17744. /**
  17745. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17746. */
  17747. _generateEdgesLines(): void;
  17748. }
  17749. }
  17750. declare module "babylonjs/Rendering/renderingGroup" {
  17751. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17752. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17753. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17754. import { Nullable } from "babylonjs/types";
  17755. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17756. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17757. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17758. import { Material } from "babylonjs/Materials/material";
  17759. import { Scene } from "babylonjs/scene";
  17760. /**
  17761. * This represents the object necessary to create a rendering group.
  17762. * This is exclusively used and created by the rendering manager.
  17763. * To modify the behavior, you use the available helpers in your scene or meshes.
  17764. * @hidden
  17765. */
  17766. export class RenderingGroup {
  17767. index: number;
  17768. private static _zeroVector;
  17769. private _scene;
  17770. private _opaqueSubMeshes;
  17771. private _transparentSubMeshes;
  17772. private _alphaTestSubMeshes;
  17773. private _depthOnlySubMeshes;
  17774. private _particleSystems;
  17775. private _spriteManagers;
  17776. private _opaqueSortCompareFn;
  17777. private _alphaTestSortCompareFn;
  17778. private _transparentSortCompareFn;
  17779. private _renderOpaque;
  17780. private _renderAlphaTest;
  17781. private _renderTransparent;
  17782. /** @hidden */
  17783. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17784. onBeforeTransparentRendering: () => void;
  17785. /**
  17786. * Set the opaque sort comparison function.
  17787. * If null the sub meshes will be render in the order they were created
  17788. */
  17789. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17790. /**
  17791. * Set the alpha test sort comparison function.
  17792. * If null the sub meshes will be render in the order they were created
  17793. */
  17794. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17795. /**
  17796. * Set the transparent sort comparison function.
  17797. * If null the sub meshes will be render in the order they were created
  17798. */
  17799. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17800. /**
  17801. * Creates a new rendering group.
  17802. * @param index The rendering group index
  17803. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17804. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17805. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17806. */
  17807. 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>);
  17808. /**
  17809. * Render all the sub meshes contained in the group.
  17810. * @param customRenderFunction Used to override the default render behaviour of the group.
  17811. * @returns true if rendered some submeshes.
  17812. */
  17813. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17814. /**
  17815. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17816. * @param subMeshes The submeshes to render
  17817. */
  17818. private renderOpaqueSorted;
  17819. /**
  17820. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17821. * @param subMeshes The submeshes to render
  17822. */
  17823. private renderAlphaTestSorted;
  17824. /**
  17825. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17826. * @param subMeshes The submeshes to render
  17827. */
  17828. private renderTransparentSorted;
  17829. /**
  17830. * Renders the submeshes in a specified order.
  17831. * @param subMeshes The submeshes to sort before render
  17832. * @param sortCompareFn The comparison function use to sort
  17833. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17834. * @param transparent Specifies to activate blending if true
  17835. */
  17836. private static renderSorted;
  17837. /**
  17838. * Renders the submeshes in the order they were dispatched (no sort applied).
  17839. * @param subMeshes The submeshes to render
  17840. */
  17841. private static renderUnsorted;
  17842. /**
  17843. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17844. * are rendered back to front if in the same alpha index.
  17845. *
  17846. * @param a The first submesh
  17847. * @param b The second submesh
  17848. * @returns The result of the comparison
  17849. */
  17850. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17851. /**
  17852. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17853. * are rendered back to front.
  17854. *
  17855. * @param a The first submesh
  17856. * @param b The second submesh
  17857. * @returns The result of the comparison
  17858. */
  17859. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17860. /**
  17861. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17862. * are rendered front to back (prevent overdraw).
  17863. *
  17864. * @param a The first submesh
  17865. * @param b The second submesh
  17866. * @returns The result of the comparison
  17867. */
  17868. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17869. /**
  17870. * Resets the different lists of submeshes to prepare a new frame.
  17871. */
  17872. prepare(): void;
  17873. dispose(): void;
  17874. /**
  17875. * Inserts the submesh in its correct queue depending on its material.
  17876. * @param subMesh The submesh to dispatch
  17877. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17878. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17879. */
  17880. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17881. dispatchSprites(spriteManager: ISpriteManager): void;
  17882. dispatchParticles(particleSystem: IParticleSystem): void;
  17883. private _renderParticles;
  17884. private _renderSprites;
  17885. }
  17886. }
  17887. declare module "babylonjs/Rendering/renderingManager" {
  17888. import { Nullable } from "babylonjs/types";
  17889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17890. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17891. import { SmartArray } from "babylonjs/Misc/smartArray";
  17892. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17893. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17894. import { Material } from "babylonjs/Materials/material";
  17895. import { Scene } from "babylonjs/scene";
  17896. import { Camera } from "babylonjs/Cameras/camera";
  17897. /**
  17898. * Interface describing the different options available in the rendering manager
  17899. * regarding Auto Clear between groups.
  17900. */
  17901. export interface IRenderingManagerAutoClearSetup {
  17902. /**
  17903. * Defines whether or not autoclear is enable.
  17904. */
  17905. autoClear: boolean;
  17906. /**
  17907. * Defines whether or not to autoclear the depth buffer.
  17908. */
  17909. depth: boolean;
  17910. /**
  17911. * Defines whether or not to autoclear the stencil buffer.
  17912. */
  17913. stencil: boolean;
  17914. }
  17915. /**
  17916. * This class is used by the onRenderingGroupObservable
  17917. */
  17918. export class RenderingGroupInfo {
  17919. /**
  17920. * The Scene that being rendered
  17921. */
  17922. scene: Scene;
  17923. /**
  17924. * The camera currently used for the rendering pass
  17925. */
  17926. camera: Nullable<Camera>;
  17927. /**
  17928. * The ID of the renderingGroup being processed
  17929. */
  17930. renderingGroupId: number;
  17931. }
  17932. /**
  17933. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17934. * It is enable to manage the different groups as well as the different necessary sort functions.
  17935. * This should not be used directly aside of the few static configurations
  17936. */
  17937. export class RenderingManager {
  17938. /**
  17939. * The max id used for rendering groups (not included)
  17940. */
  17941. static MAX_RENDERINGGROUPS: number;
  17942. /**
  17943. * The min id used for rendering groups (included)
  17944. */
  17945. static MIN_RENDERINGGROUPS: number;
  17946. /**
  17947. * Used to globally prevent autoclearing scenes.
  17948. */
  17949. static AUTOCLEAR: boolean;
  17950. /**
  17951. * @hidden
  17952. */
  17953. _useSceneAutoClearSetup: boolean;
  17954. private _scene;
  17955. private _renderingGroups;
  17956. private _depthStencilBufferAlreadyCleaned;
  17957. private _autoClearDepthStencil;
  17958. private _customOpaqueSortCompareFn;
  17959. private _customAlphaTestSortCompareFn;
  17960. private _customTransparentSortCompareFn;
  17961. private _renderingGroupInfo;
  17962. /**
  17963. * Instantiates a new rendering group for a particular scene
  17964. * @param scene Defines the scene the groups belongs to
  17965. */
  17966. constructor(scene: Scene);
  17967. private _clearDepthStencilBuffer;
  17968. /**
  17969. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17970. * @hidden
  17971. */
  17972. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17973. /**
  17974. * Resets the different information of the group to prepare a new frame
  17975. * @hidden
  17976. */
  17977. reset(): void;
  17978. /**
  17979. * Dispose and release the group and its associated resources.
  17980. * @hidden
  17981. */
  17982. dispose(): void;
  17983. /**
  17984. * Clear the info related to rendering groups preventing retention points during dispose.
  17985. */
  17986. freeRenderingGroups(): void;
  17987. private _prepareRenderingGroup;
  17988. /**
  17989. * Add a sprite manager to the rendering manager in order to render it this frame.
  17990. * @param spriteManager Define the sprite manager to render
  17991. */
  17992. dispatchSprites(spriteManager: ISpriteManager): void;
  17993. /**
  17994. * Add a particle system to the rendering manager in order to render it this frame.
  17995. * @param particleSystem Define the particle system to render
  17996. */
  17997. dispatchParticles(particleSystem: IParticleSystem): void;
  17998. /**
  17999. * Add a submesh to the manager in order to render it this frame
  18000. * @param subMesh The submesh to dispatch
  18001. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18002. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18003. */
  18004. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18005. /**
  18006. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18007. * This allowed control for front to back rendering or reversly depending of the special needs.
  18008. *
  18009. * @param renderingGroupId The rendering group id corresponding to its index
  18010. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18011. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18012. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18013. */
  18014. 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;
  18015. /**
  18016. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18017. *
  18018. * @param renderingGroupId The rendering group id corresponding to its index
  18019. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18020. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18021. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18022. */
  18023. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18024. /**
  18025. * Gets the current auto clear configuration for one rendering group of the rendering
  18026. * manager.
  18027. * @param index the rendering group index to get the information for
  18028. * @returns The auto clear setup for the requested rendering group
  18029. */
  18030. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18031. }
  18032. }
  18033. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  18034. import { SmartArray } from "babylonjs/Misc/smartArray";
  18035. import { Nullable } from "babylonjs/types";
  18036. import { Scene } from "babylonjs/scene";
  18037. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  18038. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18040. import { Mesh } from "babylonjs/Meshes/mesh";
  18041. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  18042. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  18043. import { Effect } from "babylonjs/Materials/effect";
  18044. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18045. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18046. import "babylonjs/Shaders/shadowMap.fragment";
  18047. import "babylonjs/Shaders/shadowMap.vertex";
  18048. import "babylonjs/Shaders/depthBoxBlur.fragment";
  18049. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  18050. import { Observable } from "babylonjs/Misc/observable";
  18051. /**
  18052. * Defines the options associated with the creation of a custom shader for a shadow generator.
  18053. */
  18054. export interface ICustomShaderOptions {
  18055. /**
  18056. * Gets or sets the custom shader name to use
  18057. */
  18058. shaderName: string;
  18059. /**
  18060. * The list of attribute names used in the shader
  18061. */
  18062. attributes?: string[];
  18063. /**
  18064. * The list of unifrom names used in the shader
  18065. */
  18066. uniforms?: string[];
  18067. /**
  18068. * The list of sampler names used in the shader
  18069. */
  18070. samplers?: string[];
  18071. /**
  18072. * The list of defines used in the shader
  18073. */
  18074. defines?: string[];
  18075. }
  18076. /**
  18077. * Interface to implement to create a shadow generator compatible with BJS.
  18078. */
  18079. export interface IShadowGenerator {
  18080. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18081. id: string;
  18082. /**
  18083. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18084. * @returns The render target texture if present otherwise, null
  18085. */
  18086. getShadowMap(): Nullable<RenderTargetTexture>;
  18087. /**
  18088. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18089. * @param subMesh The submesh we want to render in the shadow map
  18090. * @param useInstances Defines wether will draw in the map using instances
  18091. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18092. * @returns true if ready otherwise, false
  18093. */
  18094. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18095. /**
  18096. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18097. * @param defines Defines of the material we want to update
  18098. * @param lightIndex Index of the light in the enabled light list of the material
  18099. */
  18100. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18101. /**
  18102. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18103. * defined in the generator but impacting the effect).
  18104. * It implies the unifroms available on the materials are the standard BJS ones.
  18105. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18106. * @param effect The effect we are binfing the information for
  18107. */
  18108. bindShadowLight(lightIndex: string, effect: Effect): void;
  18109. /**
  18110. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18111. * (eq to shadow prjection matrix * light transform matrix)
  18112. * @returns The transform matrix used to create the shadow map
  18113. */
  18114. getTransformMatrix(): Matrix;
  18115. /**
  18116. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18117. * Cube and 2D textures for instance.
  18118. */
  18119. recreateShadowMap(): void;
  18120. /**
  18121. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18122. * @param onCompiled Callback triggered at the and of the effects compilation
  18123. * @param options Sets of optional options forcing the compilation with different modes
  18124. */
  18125. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18126. useInstances: boolean;
  18127. }>): void;
  18128. /**
  18129. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18130. * @param options Sets of optional options forcing the compilation with different modes
  18131. * @returns A promise that resolves when the compilation completes
  18132. */
  18133. forceCompilationAsync(options?: Partial<{
  18134. useInstances: boolean;
  18135. }>): Promise<void>;
  18136. /**
  18137. * Serializes the shadow generator setup to a json object.
  18138. * @returns The serialized JSON object
  18139. */
  18140. serialize(): any;
  18141. /**
  18142. * Disposes the Shadow map and related Textures and effects.
  18143. */
  18144. dispose(): void;
  18145. }
  18146. /**
  18147. * Default implementation IShadowGenerator.
  18148. * This is the main object responsible of generating shadows in the framework.
  18149. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18150. */
  18151. export class ShadowGenerator implements IShadowGenerator {
  18152. /**
  18153. * Name of the shadow generator class
  18154. */
  18155. static CLASSNAME: string;
  18156. /**
  18157. * Shadow generator mode None: no filtering applied.
  18158. */
  18159. static readonly FILTER_NONE: number;
  18160. /**
  18161. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18162. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18163. */
  18164. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18165. /**
  18166. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18167. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18168. */
  18169. static readonly FILTER_POISSONSAMPLING: number;
  18170. /**
  18171. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18172. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18173. */
  18174. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18175. /**
  18176. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18177. * edge artifacts on steep falloff.
  18178. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18179. */
  18180. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18181. /**
  18182. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18183. * edge artifacts on steep falloff.
  18184. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18185. */
  18186. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18187. /**
  18188. * Shadow generator mode PCF: Percentage Closer Filtering
  18189. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18190. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18191. */
  18192. static readonly FILTER_PCF: number;
  18193. /**
  18194. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18195. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18196. * Contact Hardening
  18197. */
  18198. static readonly FILTER_PCSS: number;
  18199. /**
  18200. * Reserved for PCF and PCSS
  18201. * Highest Quality.
  18202. *
  18203. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18204. *
  18205. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18206. */
  18207. static readonly QUALITY_HIGH: number;
  18208. /**
  18209. * Reserved for PCF and PCSS
  18210. * Good tradeoff for quality/perf cross devices
  18211. *
  18212. * Execute PCF on a 3*3 kernel.
  18213. *
  18214. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18215. */
  18216. static readonly QUALITY_MEDIUM: number;
  18217. /**
  18218. * Reserved for PCF and PCSS
  18219. * The lowest quality but the fastest.
  18220. *
  18221. * Execute PCF on a 1*1 kernel.
  18222. *
  18223. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18224. */
  18225. static readonly QUALITY_LOW: number;
  18226. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18227. id: string;
  18228. /** Gets or sets the custom shader name to use */
  18229. customShaderOptions: ICustomShaderOptions;
  18230. /**
  18231. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18232. */
  18233. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18234. /**
  18235. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18236. */
  18237. onAfterShadowMapRenderObservable: Observable<Effect>;
  18238. /**
  18239. * Observable triggered before a mesh is rendered in the shadow map.
  18240. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18241. */
  18242. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18243. /**
  18244. * Observable triggered after a mesh is rendered in the shadow map.
  18245. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18246. */
  18247. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18248. protected _bias: number;
  18249. /**
  18250. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18251. */
  18252. get bias(): number;
  18253. /**
  18254. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18255. */
  18256. set bias(bias: number);
  18257. protected _normalBias: number;
  18258. /**
  18259. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18260. */
  18261. get normalBias(): number;
  18262. /**
  18263. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18264. */
  18265. set normalBias(normalBias: number);
  18266. protected _blurBoxOffset: number;
  18267. /**
  18268. * Gets the blur box offset: offset applied during the blur pass.
  18269. * Only useful if useKernelBlur = false
  18270. */
  18271. get blurBoxOffset(): number;
  18272. /**
  18273. * Sets the blur box offset: offset applied during the blur pass.
  18274. * Only useful if useKernelBlur = false
  18275. */
  18276. set blurBoxOffset(value: number);
  18277. protected _blurScale: number;
  18278. /**
  18279. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18280. * 2 means half of the size.
  18281. */
  18282. get blurScale(): number;
  18283. /**
  18284. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18285. * 2 means half of the size.
  18286. */
  18287. set blurScale(value: number);
  18288. protected _blurKernel: number;
  18289. /**
  18290. * Gets the blur kernel: kernel size of the blur pass.
  18291. * Only useful if useKernelBlur = true
  18292. */
  18293. get blurKernel(): number;
  18294. /**
  18295. * Sets the blur kernel: kernel size of the blur pass.
  18296. * Only useful if useKernelBlur = true
  18297. */
  18298. set blurKernel(value: number);
  18299. protected _useKernelBlur: boolean;
  18300. /**
  18301. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18302. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18303. */
  18304. get useKernelBlur(): boolean;
  18305. /**
  18306. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18307. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18308. */
  18309. set useKernelBlur(value: boolean);
  18310. protected _depthScale: number;
  18311. /**
  18312. * Gets the depth scale used in ESM mode.
  18313. */
  18314. get depthScale(): number;
  18315. /**
  18316. * Sets the depth scale used in ESM mode.
  18317. * This can override the scale stored on the light.
  18318. */
  18319. set depthScale(value: number);
  18320. protected _validateFilter(filter: number): number;
  18321. protected _filter: number;
  18322. /**
  18323. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18324. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18325. */
  18326. get filter(): number;
  18327. /**
  18328. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18329. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18330. */
  18331. set filter(value: number);
  18332. /**
  18333. * Gets if the current filter is set to Poisson Sampling.
  18334. */
  18335. get usePoissonSampling(): boolean;
  18336. /**
  18337. * Sets the current filter to Poisson Sampling.
  18338. */
  18339. set usePoissonSampling(value: boolean);
  18340. /**
  18341. * Gets if the current filter is set to ESM.
  18342. */
  18343. get useExponentialShadowMap(): boolean;
  18344. /**
  18345. * Sets the current filter is to ESM.
  18346. */
  18347. set useExponentialShadowMap(value: boolean);
  18348. /**
  18349. * Gets if the current filter is set to filtered ESM.
  18350. */
  18351. get useBlurExponentialShadowMap(): boolean;
  18352. /**
  18353. * Gets if the current filter is set to filtered ESM.
  18354. */
  18355. set useBlurExponentialShadowMap(value: boolean);
  18356. /**
  18357. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18358. * exponential to prevent steep falloff artifacts).
  18359. */
  18360. get useCloseExponentialShadowMap(): boolean;
  18361. /**
  18362. * Sets the current filter to "close ESM" (using the inverse of the
  18363. * exponential to prevent steep falloff artifacts).
  18364. */
  18365. set useCloseExponentialShadowMap(value: boolean);
  18366. /**
  18367. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18368. * exponential to prevent steep falloff artifacts).
  18369. */
  18370. get useBlurCloseExponentialShadowMap(): boolean;
  18371. /**
  18372. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18373. * exponential to prevent steep falloff artifacts).
  18374. */
  18375. set useBlurCloseExponentialShadowMap(value: boolean);
  18376. /**
  18377. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18378. */
  18379. get usePercentageCloserFiltering(): boolean;
  18380. /**
  18381. * Sets the current filter to "PCF" (percentage closer filtering).
  18382. */
  18383. set usePercentageCloserFiltering(value: boolean);
  18384. protected _filteringQuality: number;
  18385. /**
  18386. * Gets the PCF or PCSS Quality.
  18387. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18388. */
  18389. get filteringQuality(): number;
  18390. /**
  18391. * Sets the PCF or PCSS Quality.
  18392. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18393. */
  18394. set filteringQuality(filteringQuality: number);
  18395. /**
  18396. * Gets if the current filter is set to "PCSS" (contact hardening).
  18397. */
  18398. get useContactHardeningShadow(): boolean;
  18399. /**
  18400. * Sets the current filter to "PCSS" (contact hardening).
  18401. */
  18402. set useContactHardeningShadow(value: boolean);
  18403. protected _contactHardeningLightSizeUVRatio: number;
  18404. /**
  18405. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18406. * Using a ratio helps keeping shape stability independently of the map size.
  18407. *
  18408. * It does not account for the light projection as it was having too much
  18409. * instability during the light setup or during light position changes.
  18410. *
  18411. * Only valid if useContactHardeningShadow is true.
  18412. */
  18413. get contactHardeningLightSizeUVRatio(): number;
  18414. /**
  18415. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18416. * Using a ratio helps keeping shape stability independently of the map size.
  18417. *
  18418. * It does not account for the light projection as it was having too much
  18419. * instability during the light setup or during light position changes.
  18420. *
  18421. * Only valid if useContactHardeningShadow is true.
  18422. */
  18423. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18424. protected _darkness: number;
  18425. /** Gets or sets the actual darkness of a shadow */
  18426. get darkness(): number;
  18427. set darkness(value: number);
  18428. /**
  18429. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18430. * 0 means strongest and 1 would means no shadow.
  18431. * @returns the darkness.
  18432. */
  18433. getDarkness(): number;
  18434. /**
  18435. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18436. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18437. * @returns the shadow generator allowing fluent coding.
  18438. */
  18439. setDarkness(darkness: number): ShadowGenerator;
  18440. protected _transparencyShadow: boolean;
  18441. /** Gets or sets the ability to have transparent shadow */
  18442. get transparencyShadow(): boolean;
  18443. set transparencyShadow(value: boolean);
  18444. /**
  18445. * Sets the ability to have transparent shadow (boolean).
  18446. * @param transparent True if transparent else False
  18447. * @returns the shadow generator allowing fluent coding
  18448. */
  18449. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18450. /**
  18451. * Enables or disables shadows with varying strength based on the transparency
  18452. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18453. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18454. * mesh.visibility * alphaTexture.a
  18455. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18456. */
  18457. enableSoftTransparentShadow: boolean;
  18458. protected _shadowMap: Nullable<RenderTargetTexture>;
  18459. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18460. /**
  18461. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18462. * @returns The render target texture if present otherwise, null
  18463. */
  18464. getShadowMap(): Nullable<RenderTargetTexture>;
  18465. /**
  18466. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18467. * @returns The render target texture if the shadow map is present otherwise, null
  18468. */
  18469. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18470. /**
  18471. * Gets the class name of that object
  18472. * @returns "ShadowGenerator"
  18473. */
  18474. getClassName(): string;
  18475. /**
  18476. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18477. * @param mesh Mesh to add
  18478. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18479. * @returns the Shadow Generator itself
  18480. */
  18481. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18482. /**
  18483. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18484. * @param mesh Mesh to remove
  18485. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18486. * @returns the Shadow Generator itself
  18487. */
  18488. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18489. /**
  18490. * Controls the extent to which the shadows fade out at the edge of the frustum
  18491. */
  18492. frustumEdgeFalloff: number;
  18493. protected _light: IShadowLight;
  18494. /**
  18495. * Returns the associated light object.
  18496. * @returns the light generating the shadow
  18497. */
  18498. getLight(): IShadowLight;
  18499. /**
  18500. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18501. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18502. * It might on the other hand introduce peter panning.
  18503. */
  18504. forceBackFacesOnly: boolean;
  18505. protected _scene: Scene;
  18506. protected _lightDirection: Vector3;
  18507. protected _effect: Effect;
  18508. protected _viewMatrix: Matrix;
  18509. protected _projectionMatrix: Matrix;
  18510. protected _transformMatrix: Matrix;
  18511. protected _cachedPosition: Vector3;
  18512. protected _cachedDirection: Vector3;
  18513. protected _cachedDefines: string;
  18514. protected _currentRenderID: number;
  18515. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18516. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18517. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18518. protected _blurPostProcesses: PostProcess[];
  18519. protected _mapSize: number;
  18520. protected _currentFaceIndex: number;
  18521. protected _currentFaceIndexCache: number;
  18522. protected _textureType: number;
  18523. protected _defaultTextureMatrix: Matrix;
  18524. protected _storedUniqueId: Nullable<number>;
  18525. /** @hidden */
  18526. static _SceneComponentInitialization: (scene: Scene) => void;
  18527. /**
  18528. * Gets or sets the size of the texture what stores the shadows
  18529. */
  18530. get mapSize(): number;
  18531. set mapSize(size: number);
  18532. /**
  18533. * Creates a ShadowGenerator object.
  18534. * A ShadowGenerator is the required tool to use the shadows.
  18535. * Each light casting shadows needs to use its own ShadowGenerator.
  18536. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18537. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18538. * @param light The light object generating the shadows.
  18539. * @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.
  18540. */
  18541. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18542. protected _initializeGenerator(): void;
  18543. protected _createTargetRenderTexture(): void;
  18544. protected _initializeShadowMap(): void;
  18545. protected _initializeBlurRTTAndPostProcesses(): void;
  18546. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18547. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18548. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18549. protected _applyFilterValues(): void;
  18550. /**
  18551. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18552. * @param onCompiled Callback triggered at the and of the effects compilation
  18553. * @param options Sets of optional options forcing the compilation with different modes
  18554. */
  18555. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18556. useInstances: boolean;
  18557. }>): void;
  18558. /**
  18559. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18560. * @param options Sets of optional options forcing the compilation with different modes
  18561. * @returns A promise that resolves when the compilation completes
  18562. */
  18563. forceCompilationAsync(options?: Partial<{
  18564. useInstances: boolean;
  18565. }>): Promise<void>;
  18566. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18567. private _prepareShadowDefines;
  18568. /**
  18569. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18570. * @param subMesh The submesh we want to render in the shadow map
  18571. * @param useInstances Defines wether will draw in the map using instances
  18572. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18573. * @returns true if ready otherwise, false
  18574. */
  18575. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18576. /**
  18577. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18578. * @param defines Defines of the material we want to update
  18579. * @param lightIndex Index of the light in the enabled light list of the material
  18580. */
  18581. prepareDefines(defines: any, lightIndex: number): void;
  18582. /**
  18583. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18584. * defined in the generator but impacting the effect).
  18585. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18586. * @param effect The effect we are binfing the information for
  18587. */
  18588. bindShadowLight(lightIndex: string, effect: Effect): void;
  18589. /**
  18590. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18591. * (eq to shadow prjection matrix * light transform matrix)
  18592. * @returns The transform matrix used to create the shadow map
  18593. */
  18594. getTransformMatrix(): Matrix;
  18595. /**
  18596. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18597. * Cube and 2D textures for instance.
  18598. */
  18599. recreateShadowMap(): void;
  18600. protected _disposeBlurPostProcesses(): void;
  18601. protected _disposeRTTandPostProcesses(): void;
  18602. /**
  18603. * Disposes the ShadowGenerator.
  18604. * Returns nothing.
  18605. */
  18606. dispose(): void;
  18607. /**
  18608. * Serializes the shadow generator setup to a json object.
  18609. * @returns The serialized JSON object
  18610. */
  18611. serialize(): any;
  18612. /**
  18613. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18614. * @param parsedShadowGenerator The JSON object to parse
  18615. * @param scene The scene to create the shadow map for
  18616. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18617. * @returns The parsed shadow generator
  18618. */
  18619. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18620. }
  18621. }
  18622. declare module "babylonjs/Lights/light" {
  18623. import { Nullable } from "babylonjs/types";
  18624. import { Scene } from "babylonjs/scene";
  18625. import { Vector3 } from "babylonjs/Maths/math.vector";
  18626. import { Color3 } from "babylonjs/Maths/math.color";
  18627. import { Node } from "babylonjs/node";
  18628. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18629. import { Effect } from "babylonjs/Materials/effect";
  18630. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18631. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18632. /**
  18633. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18634. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18635. * 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.
  18636. */
  18637. export abstract class Light extends Node {
  18638. /**
  18639. * Falloff Default: light is falling off following the material specification:
  18640. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18641. */
  18642. static readonly FALLOFF_DEFAULT: number;
  18643. /**
  18644. * Falloff Physical: light is falling off following the inverse squared distance law.
  18645. */
  18646. static readonly FALLOFF_PHYSICAL: number;
  18647. /**
  18648. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18649. * to enhance interoperability with other engines.
  18650. */
  18651. static readonly FALLOFF_GLTF: number;
  18652. /**
  18653. * Falloff Standard: light is falling off like in the standard material
  18654. * to enhance interoperability with other materials.
  18655. */
  18656. static readonly FALLOFF_STANDARD: number;
  18657. /**
  18658. * If every light affecting the material is in this lightmapMode,
  18659. * material.lightmapTexture adds or multiplies
  18660. * (depends on material.useLightmapAsShadowmap)
  18661. * after every other light calculations.
  18662. */
  18663. static readonly LIGHTMAP_DEFAULT: number;
  18664. /**
  18665. * material.lightmapTexture as only diffuse lighting from this light
  18666. * adds only specular lighting from this light
  18667. * adds dynamic shadows
  18668. */
  18669. static readonly LIGHTMAP_SPECULAR: number;
  18670. /**
  18671. * material.lightmapTexture as only lighting
  18672. * no light calculation from this light
  18673. * only adds dynamic shadows from this light
  18674. */
  18675. static readonly LIGHTMAP_SHADOWSONLY: number;
  18676. /**
  18677. * Each light type uses the default quantity according to its type:
  18678. * point/spot lights use luminous intensity
  18679. * directional lights use illuminance
  18680. */
  18681. static readonly INTENSITYMODE_AUTOMATIC: number;
  18682. /**
  18683. * lumen (lm)
  18684. */
  18685. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18686. /**
  18687. * candela (lm/sr)
  18688. */
  18689. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18690. /**
  18691. * lux (lm/m^2)
  18692. */
  18693. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18694. /**
  18695. * nit (cd/m^2)
  18696. */
  18697. static readonly INTENSITYMODE_LUMINANCE: number;
  18698. /**
  18699. * Light type const id of the point light.
  18700. */
  18701. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18702. /**
  18703. * Light type const id of the directional light.
  18704. */
  18705. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18706. /**
  18707. * Light type const id of the spot light.
  18708. */
  18709. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18710. /**
  18711. * Light type const id of the hemispheric light.
  18712. */
  18713. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18714. /**
  18715. * Diffuse gives the basic color to an object.
  18716. */
  18717. diffuse: Color3;
  18718. /**
  18719. * Specular produces a highlight color on an object.
  18720. * Note: This is note affecting PBR materials.
  18721. */
  18722. specular: Color3;
  18723. /**
  18724. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18725. * falling off base on range or angle.
  18726. * This can be set to any values in Light.FALLOFF_x.
  18727. *
  18728. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18729. * other types of materials.
  18730. */
  18731. falloffType: number;
  18732. /**
  18733. * Strength of the light.
  18734. * Note: By default it is define in the framework own unit.
  18735. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18736. */
  18737. intensity: number;
  18738. private _range;
  18739. protected _inverseSquaredRange: number;
  18740. /**
  18741. * Defines how far from the source the light is impacting in scene units.
  18742. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18743. */
  18744. get range(): number;
  18745. /**
  18746. * Defines how far from the source the light is impacting in scene units.
  18747. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18748. */
  18749. set range(value: number);
  18750. /**
  18751. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18752. * of light.
  18753. */
  18754. private _photometricScale;
  18755. private _intensityMode;
  18756. /**
  18757. * Gets the photometric scale used to interpret the intensity.
  18758. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18759. */
  18760. get intensityMode(): number;
  18761. /**
  18762. * Sets the photometric scale used to interpret the intensity.
  18763. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18764. */
  18765. set intensityMode(value: number);
  18766. private _radius;
  18767. /**
  18768. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18769. */
  18770. get radius(): number;
  18771. /**
  18772. * sets the light radius used by PBR Materials to simulate soft area lights.
  18773. */
  18774. set radius(value: number);
  18775. private _renderPriority;
  18776. /**
  18777. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18778. * exceeding the number allowed of the materials.
  18779. */
  18780. renderPriority: number;
  18781. private _shadowEnabled;
  18782. /**
  18783. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18784. * the current shadow generator.
  18785. */
  18786. get shadowEnabled(): boolean;
  18787. /**
  18788. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18789. * the current shadow generator.
  18790. */
  18791. set shadowEnabled(value: boolean);
  18792. private _includedOnlyMeshes;
  18793. /**
  18794. * Gets the only meshes impacted by this light.
  18795. */
  18796. get includedOnlyMeshes(): AbstractMesh[];
  18797. /**
  18798. * Sets the only meshes impacted by this light.
  18799. */
  18800. set includedOnlyMeshes(value: AbstractMesh[]);
  18801. private _excludedMeshes;
  18802. /**
  18803. * Gets the meshes not impacted by this light.
  18804. */
  18805. get excludedMeshes(): AbstractMesh[];
  18806. /**
  18807. * Sets the meshes not impacted by this light.
  18808. */
  18809. set excludedMeshes(value: AbstractMesh[]);
  18810. private _excludeWithLayerMask;
  18811. /**
  18812. * Gets the layer id use to find what meshes are not impacted by the light.
  18813. * Inactive if 0
  18814. */
  18815. get excludeWithLayerMask(): number;
  18816. /**
  18817. * Sets the layer id use to find what meshes are not impacted by the light.
  18818. * Inactive if 0
  18819. */
  18820. set excludeWithLayerMask(value: number);
  18821. private _includeOnlyWithLayerMask;
  18822. /**
  18823. * Gets the layer id use to find what meshes are impacted by the light.
  18824. * Inactive if 0
  18825. */
  18826. get includeOnlyWithLayerMask(): number;
  18827. /**
  18828. * Sets the layer id use to find what meshes are impacted by the light.
  18829. * Inactive if 0
  18830. */
  18831. set includeOnlyWithLayerMask(value: number);
  18832. private _lightmapMode;
  18833. /**
  18834. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18835. */
  18836. get lightmapMode(): number;
  18837. /**
  18838. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18839. */
  18840. set lightmapMode(value: number);
  18841. /**
  18842. * Shadow generator associted to the light.
  18843. * @hidden Internal use only.
  18844. */
  18845. _shadowGenerator: Nullable<IShadowGenerator>;
  18846. /**
  18847. * @hidden Internal use only.
  18848. */
  18849. _excludedMeshesIds: string[];
  18850. /**
  18851. * @hidden Internal use only.
  18852. */
  18853. _includedOnlyMeshesIds: string[];
  18854. /**
  18855. * The current light unifom buffer.
  18856. * @hidden Internal use only.
  18857. */
  18858. _uniformBuffer: UniformBuffer;
  18859. /** @hidden */
  18860. _renderId: number;
  18861. /**
  18862. * Creates a Light object in the scene.
  18863. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18864. * @param name The firendly name of the light
  18865. * @param scene The scene the light belongs too
  18866. */
  18867. constructor(name: string, scene: Scene);
  18868. protected abstract _buildUniformLayout(): void;
  18869. /**
  18870. * Sets the passed Effect "effect" with the Light information.
  18871. * @param effect The effect to update
  18872. * @param lightIndex The index of the light in the effect to update
  18873. * @returns The light
  18874. */
  18875. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18876. /**
  18877. * Sets the passed Effect "effect" with the Light textures.
  18878. * @param effect The effect to update
  18879. * @param lightIndex The index of the light in the effect to update
  18880. * @returns The light
  18881. */
  18882. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18883. /**
  18884. * Binds the lights information from the scene to the effect for the given mesh.
  18885. * @param lightIndex Light index
  18886. * @param scene The scene where the light belongs to
  18887. * @param effect The effect we are binding the data to
  18888. * @param useSpecular Defines if specular is supported
  18889. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18890. */
  18891. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18892. /**
  18893. * Sets the passed Effect "effect" with the Light information.
  18894. * @param effect The effect to update
  18895. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18896. * @returns The light
  18897. */
  18898. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18899. /**
  18900. * Returns the string "Light".
  18901. * @returns the class name
  18902. */
  18903. getClassName(): string;
  18904. /** @hidden */
  18905. readonly _isLight: boolean;
  18906. /**
  18907. * Converts the light information to a readable string for debug purpose.
  18908. * @param fullDetails Supports for multiple levels of logging within scene loading
  18909. * @returns the human readable light info
  18910. */
  18911. toString(fullDetails?: boolean): string;
  18912. /** @hidden */
  18913. protected _syncParentEnabledState(): void;
  18914. /**
  18915. * Set the enabled state of this node.
  18916. * @param value - the new enabled state
  18917. */
  18918. setEnabled(value: boolean): void;
  18919. /**
  18920. * Returns the Light associated shadow generator if any.
  18921. * @return the associated shadow generator.
  18922. */
  18923. getShadowGenerator(): Nullable<IShadowGenerator>;
  18924. /**
  18925. * Returns a Vector3, the absolute light position in the World.
  18926. * @returns the world space position of the light
  18927. */
  18928. getAbsolutePosition(): Vector3;
  18929. /**
  18930. * Specifies if the light will affect the passed mesh.
  18931. * @param mesh The mesh to test against the light
  18932. * @return true the mesh is affected otherwise, false.
  18933. */
  18934. canAffectMesh(mesh: AbstractMesh): boolean;
  18935. /**
  18936. * Sort function to order lights for rendering.
  18937. * @param a First Light object to compare to second.
  18938. * @param b Second Light object to compare first.
  18939. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18940. */
  18941. static CompareLightsPriority(a: Light, b: Light): number;
  18942. /**
  18943. * Releases resources associated with this node.
  18944. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18945. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18946. */
  18947. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18948. /**
  18949. * Returns the light type ID (integer).
  18950. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18951. */
  18952. getTypeID(): number;
  18953. /**
  18954. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18955. * @returns the scaled intensity in intensity mode unit
  18956. */
  18957. getScaledIntensity(): number;
  18958. /**
  18959. * Returns a new Light object, named "name", from the current one.
  18960. * @param name The name of the cloned light
  18961. * @param newParent The parent of this light, if it has one
  18962. * @returns the new created light
  18963. */
  18964. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18965. /**
  18966. * Serializes the current light into a Serialization object.
  18967. * @returns the serialized object.
  18968. */
  18969. serialize(): any;
  18970. /**
  18971. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18972. * This new light is named "name" and added to the passed scene.
  18973. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18974. * @param name The friendly name of the light
  18975. * @param scene The scene the new light will belong to
  18976. * @returns the constructor function
  18977. */
  18978. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18979. /**
  18980. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18981. * @param parsedLight The JSON representation of the light
  18982. * @param scene The scene to create the parsed light in
  18983. * @returns the created light after parsing
  18984. */
  18985. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18986. private _hookArrayForExcluded;
  18987. private _hookArrayForIncludedOnly;
  18988. private _resyncMeshes;
  18989. /**
  18990. * Forces the meshes to update their light related information in their rendering used effects
  18991. * @hidden Internal Use Only
  18992. */
  18993. _markMeshesAsLightDirty(): void;
  18994. /**
  18995. * Recomputes the cached photometric scale if needed.
  18996. */
  18997. private _computePhotometricScale;
  18998. /**
  18999. * Returns the Photometric Scale according to the light type and intensity mode.
  19000. */
  19001. private _getPhotometricScale;
  19002. /**
  19003. * Reorder the light in the scene according to their defined priority.
  19004. * @hidden Internal Use Only
  19005. */
  19006. _reorderLightsInScene(): void;
  19007. /**
  19008. * Prepares the list of defines specific to the light type.
  19009. * @param defines the list of defines
  19010. * @param lightIndex defines the index of the light for the effect
  19011. */
  19012. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19013. }
  19014. }
  19015. declare module "babylonjs/Materials/prePassConfiguration" {
  19016. import { Matrix } from "babylonjs/Maths/math.vector";
  19017. import { Mesh } from "babylonjs/Meshes/mesh";
  19018. import { Scene } from "babylonjs/scene";
  19019. import { Effect } from "babylonjs/Materials/effect";
  19020. /**
  19021. * Configuration needed for prepass-capable materials
  19022. */
  19023. export class PrePassConfiguration {
  19024. /**
  19025. * Previous world matrices of meshes carrying this material
  19026. * Used for computing velocity
  19027. */
  19028. previousWorldMatrices: {
  19029. [index: number]: Matrix;
  19030. };
  19031. /**
  19032. * Previous view project matrix
  19033. * Used for computing velocity
  19034. */
  19035. previousViewProjection: Matrix;
  19036. /**
  19037. * Previous bones of meshes carrying this material
  19038. * Used for computing velocity
  19039. */
  19040. previousBones: {
  19041. [index: number]: Float32Array;
  19042. };
  19043. /**
  19044. * Add the required uniforms to the current list.
  19045. * @param uniforms defines the current uniform list.
  19046. */
  19047. static AddUniforms(uniforms: string[]): void;
  19048. /**
  19049. * Add the required samplers to the current list.
  19050. * @param samplers defines the current sampler list.
  19051. */
  19052. static AddSamplers(samplers: string[]): void;
  19053. /**
  19054. * Binds the material data.
  19055. * @param effect defines the effect to update
  19056. * @param scene defines the scene the material belongs to.
  19057. * @param mesh The mesh
  19058. * @param world World matrix of this mesh
  19059. * @param isFrozen Is the material frozen
  19060. */
  19061. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19062. }
  19063. }
  19064. declare module "babylonjs/Cameras/targetCamera" {
  19065. import { Nullable } from "babylonjs/types";
  19066. import { Camera } from "babylonjs/Cameras/camera";
  19067. import { Scene } from "babylonjs/scene";
  19068. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19069. /**
  19070. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19071. * This is the base of the follow, arc rotate cameras and Free camera
  19072. * @see https://doc.babylonjs.com/features/cameras
  19073. */
  19074. export class TargetCamera extends Camera {
  19075. private static _RigCamTransformMatrix;
  19076. private static _TargetTransformMatrix;
  19077. private static _TargetFocalPoint;
  19078. private _tmpUpVector;
  19079. private _tmpTargetVector;
  19080. /**
  19081. * Define the current direction the camera is moving to
  19082. */
  19083. cameraDirection: Vector3;
  19084. /**
  19085. * Define the current rotation the camera is rotating to
  19086. */
  19087. cameraRotation: Vector2;
  19088. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19089. ignoreParentScaling: boolean;
  19090. /**
  19091. * When set, the up vector of the camera will be updated by the rotation of the camera
  19092. */
  19093. updateUpVectorFromRotation: boolean;
  19094. private _tmpQuaternion;
  19095. /**
  19096. * Define the current rotation of the camera
  19097. */
  19098. rotation: Vector3;
  19099. /**
  19100. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19101. */
  19102. rotationQuaternion: Quaternion;
  19103. /**
  19104. * Define the current speed of the camera
  19105. */
  19106. speed: number;
  19107. /**
  19108. * Add constraint to the camera to prevent it to move freely in all directions and
  19109. * around all axis.
  19110. */
  19111. noRotationConstraint: boolean;
  19112. /**
  19113. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19114. * panning
  19115. */
  19116. invertRotation: boolean;
  19117. /**
  19118. * Speed multiplier for inverse camera panning
  19119. */
  19120. inverseRotationSpeed: number;
  19121. /**
  19122. * Define the current target of the camera as an object or a position.
  19123. */
  19124. lockedTarget: any;
  19125. /** @hidden */
  19126. _currentTarget: Vector3;
  19127. /** @hidden */
  19128. _initialFocalDistance: number;
  19129. /** @hidden */
  19130. _viewMatrix: Matrix;
  19131. /** @hidden */
  19132. _camMatrix: Matrix;
  19133. /** @hidden */
  19134. _cameraTransformMatrix: Matrix;
  19135. /** @hidden */
  19136. _cameraRotationMatrix: Matrix;
  19137. /** @hidden */
  19138. _referencePoint: Vector3;
  19139. /** @hidden */
  19140. _transformedReferencePoint: Vector3;
  19141. /** @hidden */
  19142. _reset: () => void;
  19143. private _defaultUp;
  19144. /**
  19145. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19146. * This is the base of the follow, arc rotate cameras and Free camera
  19147. * @see https://doc.babylonjs.com/features/cameras
  19148. * @param name Defines the name of the camera in the scene
  19149. * @param position Defines the start position of the camera in the scene
  19150. * @param scene Defines the scene the camera belongs to
  19151. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19152. */
  19153. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19154. /**
  19155. * Gets the position in front of the camera at a given distance.
  19156. * @param distance The distance from the camera we want the position to be
  19157. * @returns the position
  19158. */
  19159. getFrontPosition(distance: number): Vector3;
  19160. /** @hidden */
  19161. _getLockedTargetPosition(): Nullable<Vector3>;
  19162. private _storedPosition;
  19163. private _storedRotation;
  19164. private _storedRotationQuaternion;
  19165. /**
  19166. * Store current camera state of the camera (fov, position, rotation, etc..)
  19167. * @returns the camera
  19168. */
  19169. storeState(): Camera;
  19170. /**
  19171. * Restored camera state. You must call storeState() first
  19172. * @returns whether it was successful or not
  19173. * @hidden
  19174. */
  19175. _restoreStateValues(): boolean;
  19176. /** @hidden */
  19177. _initCache(): void;
  19178. /** @hidden */
  19179. _updateCache(ignoreParentClass?: boolean): void;
  19180. /** @hidden */
  19181. _isSynchronizedViewMatrix(): boolean;
  19182. /** @hidden */
  19183. _computeLocalCameraSpeed(): number;
  19184. /**
  19185. * Defines the target the camera should look at.
  19186. * @param target Defines the new target as a Vector or a mesh
  19187. */
  19188. setTarget(target: Vector3): void;
  19189. /**
  19190. * Defines the target point of the camera.
  19191. * The camera looks towards it form the radius distance.
  19192. */
  19193. get target(): Vector3;
  19194. set target(value: Vector3);
  19195. /**
  19196. * Return the current target position of the camera. This value is expressed in local space.
  19197. * @returns the target position
  19198. */
  19199. getTarget(): Vector3;
  19200. /** @hidden */
  19201. _decideIfNeedsToMove(): boolean;
  19202. /** @hidden */
  19203. _updatePosition(): void;
  19204. /** @hidden */
  19205. _checkInputs(): void;
  19206. protected _updateCameraRotationMatrix(): void;
  19207. /**
  19208. * 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)
  19209. * @returns the current camera
  19210. */
  19211. private _rotateUpVectorWithCameraRotationMatrix;
  19212. private _cachedRotationZ;
  19213. private _cachedQuaternionRotationZ;
  19214. /** @hidden */
  19215. _getViewMatrix(): Matrix;
  19216. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19217. /**
  19218. * @hidden
  19219. */
  19220. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19221. /**
  19222. * @hidden
  19223. */
  19224. _updateRigCameras(): void;
  19225. private _getRigCamPositionAndTarget;
  19226. /**
  19227. * Gets the current object class name.
  19228. * @return the class name
  19229. */
  19230. getClassName(): string;
  19231. }
  19232. }
  19233. declare module "babylonjs/Events/keyboardEvents" {
  19234. /**
  19235. * Gather the list of keyboard event types as constants.
  19236. */
  19237. export class KeyboardEventTypes {
  19238. /**
  19239. * The keydown event is fired when a key becomes active (pressed).
  19240. */
  19241. static readonly KEYDOWN: number;
  19242. /**
  19243. * The keyup event is fired when a key has been released.
  19244. */
  19245. static readonly KEYUP: number;
  19246. }
  19247. /**
  19248. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19249. */
  19250. export class KeyboardInfo {
  19251. /**
  19252. * Defines the type of event (KeyboardEventTypes)
  19253. */
  19254. type: number;
  19255. /**
  19256. * Defines the related dom event
  19257. */
  19258. event: KeyboardEvent;
  19259. /**
  19260. * Instantiates a new keyboard info.
  19261. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19262. * @param type Defines the type of event (KeyboardEventTypes)
  19263. * @param event Defines the related dom event
  19264. */
  19265. constructor(
  19266. /**
  19267. * Defines the type of event (KeyboardEventTypes)
  19268. */
  19269. type: number,
  19270. /**
  19271. * Defines the related dom event
  19272. */
  19273. event: KeyboardEvent);
  19274. }
  19275. /**
  19276. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19277. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19278. */
  19279. export class KeyboardInfoPre extends KeyboardInfo {
  19280. /**
  19281. * Defines the type of event (KeyboardEventTypes)
  19282. */
  19283. type: number;
  19284. /**
  19285. * Defines the related dom event
  19286. */
  19287. event: KeyboardEvent;
  19288. /**
  19289. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19290. */
  19291. skipOnPointerObservable: boolean;
  19292. /**
  19293. * Instantiates a new keyboard pre info.
  19294. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19295. * @param type Defines the type of event (KeyboardEventTypes)
  19296. * @param event Defines the related dom event
  19297. */
  19298. constructor(
  19299. /**
  19300. * Defines the type of event (KeyboardEventTypes)
  19301. */
  19302. type: number,
  19303. /**
  19304. * Defines the related dom event
  19305. */
  19306. event: KeyboardEvent);
  19307. }
  19308. }
  19309. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19310. import { Nullable } from "babylonjs/types";
  19311. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19312. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19313. /**
  19314. * Manage the keyboard inputs to control the movement of a free camera.
  19315. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19316. */
  19317. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19318. /**
  19319. * Defines the camera the input is attached to.
  19320. */
  19321. camera: FreeCamera;
  19322. /**
  19323. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19324. */
  19325. keysUp: number[];
  19326. /**
  19327. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19328. */
  19329. keysUpward: number[];
  19330. /**
  19331. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19332. */
  19333. keysDown: number[];
  19334. /**
  19335. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19336. */
  19337. keysDownward: number[];
  19338. /**
  19339. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19340. */
  19341. keysLeft: number[];
  19342. /**
  19343. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19344. */
  19345. keysRight: number[];
  19346. private _keys;
  19347. private _onCanvasBlurObserver;
  19348. private _onKeyboardObserver;
  19349. private _engine;
  19350. private _scene;
  19351. /**
  19352. * Attach the input controls to a specific dom element to get the input from.
  19353. * @param element Defines the element the controls should be listened from
  19354. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19355. */
  19356. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19357. /**
  19358. * Detach the current controls from the specified dom element.
  19359. * @param element Defines the element to stop listening the inputs from
  19360. */
  19361. detachControl(element: Nullable<HTMLElement>): void;
  19362. /**
  19363. * Update the current camera state depending on the inputs that have been used this frame.
  19364. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19365. */
  19366. checkInputs(): void;
  19367. /**
  19368. * Gets the class name of the current intput.
  19369. * @returns the class name
  19370. */
  19371. getClassName(): string;
  19372. /** @hidden */
  19373. _onLostFocus(): void;
  19374. /**
  19375. * Get the friendly name associated with the input class.
  19376. * @returns the input friendly name
  19377. */
  19378. getSimpleName(): string;
  19379. }
  19380. }
  19381. declare module "babylonjs/Events/pointerEvents" {
  19382. import { Nullable } from "babylonjs/types";
  19383. import { Vector2 } from "babylonjs/Maths/math.vector";
  19384. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19385. import { Ray } from "babylonjs/Culling/ray";
  19386. /**
  19387. * Gather the list of pointer event types as constants.
  19388. */
  19389. export class PointerEventTypes {
  19390. /**
  19391. * 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.
  19392. */
  19393. static readonly POINTERDOWN: number;
  19394. /**
  19395. * The pointerup event is fired when a pointer is no longer active.
  19396. */
  19397. static readonly POINTERUP: number;
  19398. /**
  19399. * The pointermove event is fired when a pointer changes coordinates.
  19400. */
  19401. static readonly POINTERMOVE: number;
  19402. /**
  19403. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19404. */
  19405. static readonly POINTERWHEEL: number;
  19406. /**
  19407. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19408. */
  19409. static readonly POINTERPICK: number;
  19410. /**
  19411. * The pointertap event is fired when a the object has been touched and released without drag.
  19412. */
  19413. static readonly POINTERTAP: number;
  19414. /**
  19415. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19416. */
  19417. static readonly POINTERDOUBLETAP: number;
  19418. }
  19419. /**
  19420. * Base class of pointer info types.
  19421. */
  19422. export class PointerInfoBase {
  19423. /**
  19424. * Defines the type of event (PointerEventTypes)
  19425. */
  19426. type: number;
  19427. /**
  19428. * Defines the related dom event
  19429. */
  19430. event: PointerEvent | MouseWheelEvent;
  19431. /**
  19432. * Instantiates the base class of pointers info.
  19433. * @param type Defines the type of event (PointerEventTypes)
  19434. * @param event Defines the related dom event
  19435. */
  19436. constructor(
  19437. /**
  19438. * Defines the type of event (PointerEventTypes)
  19439. */
  19440. type: number,
  19441. /**
  19442. * Defines the related dom event
  19443. */
  19444. event: PointerEvent | MouseWheelEvent);
  19445. }
  19446. /**
  19447. * This class is used to store pointer related info for the onPrePointerObservable event.
  19448. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19449. */
  19450. export class PointerInfoPre extends PointerInfoBase {
  19451. /**
  19452. * Ray from a pointer if availible (eg. 6dof controller)
  19453. */
  19454. ray: Nullable<Ray>;
  19455. /**
  19456. * Defines the local position of the pointer on the canvas.
  19457. */
  19458. localPosition: Vector2;
  19459. /**
  19460. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19461. */
  19462. skipOnPointerObservable: boolean;
  19463. /**
  19464. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19465. * @param type Defines the type of event (PointerEventTypes)
  19466. * @param event Defines the related dom event
  19467. * @param localX Defines the local x coordinates of the pointer when the event occured
  19468. * @param localY Defines the local y coordinates of the pointer when the event occured
  19469. */
  19470. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19471. }
  19472. /**
  19473. * This type contains all the data related to a pointer event in Babylon.js.
  19474. * 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.
  19475. */
  19476. export class PointerInfo extends PointerInfoBase {
  19477. /**
  19478. * Defines the picking info associated to the info (if any)\
  19479. */
  19480. pickInfo: Nullable<PickingInfo>;
  19481. /**
  19482. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19483. * @param type Defines the type of event (PointerEventTypes)
  19484. * @param event Defines the related dom event
  19485. * @param pickInfo Defines the picking info associated to the info (if any)\
  19486. */
  19487. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19488. /**
  19489. * Defines the picking info associated to the info (if any)\
  19490. */
  19491. pickInfo: Nullable<PickingInfo>);
  19492. }
  19493. /**
  19494. * Data relating to a touch event on the screen.
  19495. */
  19496. export interface PointerTouch {
  19497. /**
  19498. * X coordinate of touch.
  19499. */
  19500. x: number;
  19501. /**
  19502. * Y coordinate of touch.
  19503. */
  19504. y: number;
  19505. /**
  19506. * Id of touch. Unique for each finger.
  19507. */
  19508. pointerId: number;
  19509. /**
  19510. * Event type passed from DOM.
  19511. */
  19512. type: any;
  19513. }
  19514. }
  19515. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19516. import { Observable } from "babylonjs/Misc/observable";
  19517. import { Nullable } from "babylonjs/types";
  19518. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19519. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19520. /**
  19521. * Manage the mouse inputs to control the movement of a free camera.
  19522. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19523. */
  19524. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19525. /**
  19526. * Define if touch is enabled in the mouse input
  19527. */
  19528. touchEnabled: boolean;
  19529. /**
  19530. * Defines the camera the input is attached to.
  19531. */
  19532. camera: FreeCamera;
  19533. /**
  19534. * Defines the buttons associated with the input to handle camera move.
  19535. */
  19536. buttons: number[];
  19537. /**
  19538. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19539. */
  19540. angularSensibility: number;
  19541. private _pointerInput;
  19542. private _onMouseMove;
  19543. private _observer;
  19544. private previousPosition;
  19545. /**
  19546. * Observable for when a pointer move event occurs containing the move offset
  19547. */
  19548. onPointerMovedObservable: Observable<{
  19549. offsetX: number;
  19550. offsetY: number;
  19551. }>;
  19552. /**
  19553. * @hidden
  19554. * If the camera should be rotated automatically based on pointer movement
  19555. */
  19556. _allowCameraRotation: boolean;
  19557. /**
  19558. * Manage the mouse inputs to control the movement of a free camera.
  19559. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19560. * @param touchEnabled Defines if touch is enabled or not
  19561. */
  19562. constructor(
  19563. /**
  19564. * Define if touch is enabled in the mouse input
  19565. */
  19566. touchEnabled?: boolean);
  19567. /**
  19568. * Attach the input controls to a specific dom element to get the input from.
  19569. * @param element Defines the element the controls should be listened from
  19570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19571. */
  19572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19573. /**
  19574. * Called on JS contextmenu event.
  19575. * Override this method to provide functionality.
  19576. */
  19577. protected onContextMenu(evt: PointerEvent): void;
  19578. /**
  19579. * Detach the current controls from the specified dom element.
  19580. * @param element Defines the element to stop listening the inputs from
  19581. */
  19582. detachControl(element: Nullable<HTMLElement>): void;
  19583. /**
  19584. * Gets the class name of the current intput.
  19585. * @returns the class name
  19586. */
  19587. getClassName(): string;
  19588. /**
  19589. * Get the friendly name associated with the input class.
  19590. * @returns the input friendly name
  19591. */
  19592. getSimpleName(): string;
  19593. }
  19594. }
  19595. declare module "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput" {
  19596. import { Nullable } from "babylonjs/types";
  19597. import { Observable } from "babylonjs/Misc/observable";
  19598. import { Camera } from "babylonjs/Cameras/camera";
  19599. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19600. /**
  19601. * Base class for mouse wheel input..
  19602. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  19603. * for example usage.
  19604. */
  19605. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  19606. /**
  19607. * Defines the camera the input is attached to.
  19608. */
  19609. abstract camera: Camera;
  19610. /**
  19611. * How fast is the camera moves in relation to X axis mouseWheel events.
  19612. * Use negative value to reverse direction.
  19613. */
  19614. wheelPrecisionX: number;
  19615. /**
  19616. * How fast is the camera moves in relation to Y axis mouseWheel events.
  19617. * Use negative value to reverse direction.
  19618. */
  19619. wheelPrecisionY: number;
  19620. /**
  19621. * How fast is the camera moves in relation to Z axis mouseWheel events.
  19622. * Use negative value to reverse direction.
  19623. */
  19624. wheelPrecisionZ: number;
  19625. /**
  19626. * Observable for when a mouse wheel move event occurs.
  19627. */
  19628. onChangedObservable: Observable<{
  19629. wheelDeltaX: number;
  19630. wheelDeltaY: number;
  19631. wheelDeltaZ: number;
  19632. }>;
  19633. private _wheel;
  19634. private _observer;
  19635. /**
  19636. * Attach the input controls to a specific dom element to get the input from.
  19637. * @param element Defines the element the controls should be listened from
  19638. * @param noPreventDefault Defines whether event caught by the controls
  19639. * should call preventdefault().
  19640. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19641. */
  19642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19643. /**
  19644. * Detach the current controls from the specified dom element.
  19645. * @param element Defines the element to stop listening the inputs from
  19646. */
  19647. detachControl(element: Nullable<HTMLElement>): void;
  19648. /**
  19649. * Called for each rendered frame.
  19650. */
  19651. checkInputs(): void;
  19652. /**
  19653. * Gets the class name of the current intput.
  19654. * @returns the class name
  19655. */
  19656. getClassName(): string;
  19657. /**
  19658. * Get the friendly name associated with the input class.
  19659. * @returns the input friendly name
  19660. */
  19661. getSimpleName(): string;
  19662. /**
  19663. * Incremental value of multiple mouse wheel movements of the X axis.
  19664. * Should be zero-ed when read.
  19665. */
  19666. protected _wheelDeltaX: number;
  19667. /**
  19668. * Incremental value of multiple mouse wheel movements of the Y axis.
  19669. * Should be zero-ed when read.
  19670. */
  19671. protected _wheelDeltaY: number;
  19672. /**
  19673. * Incremental value of multiple mouse wheel movements of the Z axis.
  19674. * Should be zero-ed when read.
  19675. */
  19676. protected _wheelDeltaZ: number;
  19677. /**
  19678. * Firefox uses a different scheme to report scroll distances to other
  19679. * browsers. Rather than use complicated methods to calculate the exact
  19680. * multiple we need to apply, let's just cheat and use a constant.
  19681. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  19682. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  19683. */
  19684. private readonly _ffMultiplier;
  19685. /**
  19686. * Different event attributes for wheel data fall into a few set ranges.
  19687. * Some relevant but dated date here:
  19688. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  19689. */
  19690. private readonly _normalize;
  19691. }
  19692. }
  19693. declare module "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput" {
  19694. import { Nullable } from "babylonjs/types";
  19695. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19696. import { BaseCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/BaseCameraMouseWheelInput";
  19697. import { Coordinate } from "babylonjs/Maths/math.axis";
  19698. /**
  19699. * Manage the mouse wheel inputs to control a free camera.
  19700. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19701. */
  19702. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  19703. /**
  19704. * Defines the camera the input is attached to.
  19705. */
  19706. camera: FreeCamera;
  19707. /**
  19708. * Gets the class name of the current input.
  19709. * @returns the class name
  19710. */
  19711. getClassName(): string;
  19712. /**
  19713. * Set which movement axis (relative to camera's orientation) the mouse
  19714. * wheel's X axis controls.
  19715. * @param axis The axis to be moved. Set null to clear.
  19716. */
  19717. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  19718. /**
  19719. * Get the configured movement axis (relative to camera's orientation) the
  19720. * mouse wheel's X axis controls.
  19721. * @returns The configured axis or null if none.
  19722. */
  19723. get wheelXMoveRelative(): Nullable<Coordinate>;
  19724. /**
  19725. * Set which movement axis (relative to camera's orientation) the mouse
  19726. * wheel's Y axis controls.
  19727. * @param axis The axis to be moved. Set null to clear.
  19728. */
  19729. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  19730. /**
  19731. * Get the configured movement axis (relative to camera's orientation) the
  19732. * mouse wheel's Y axis controls.
  19733. * @returns The configured axis or null if none.
  19734. */
  19735. get wheelYMoveRelative(): Nullable<Coordinate>;
  19736. /**
  19737. * Set which movement axis (relative to camera's orientation) the mouse
  19738. * wheel's Z axis controls.
  19739. * @param axis The axis to be moved. Set null to clear.
  19740. */
  19741. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  19742. /**
  19743. * Get the configured movement axis (relative to camera's orientation) the
  19744. * mouse wheel's Z axis controls.
  19745. * @returns The configured axis or null if none.
  19746. */
  19747. get wheelZMoveRelative(): Nullable<Coordinate>;
  19748. /**
  19749. * Set which rotation axis (relative to camera's orientation) the mouse
  19750. * wheel's X axis controls.
  19751. * @param axis The axis to be moved. Set null to clear.
  19752. */
  19753. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  19754. /**
  19755. * Get the configured rotation axis (relative to camera's orientation) the
  19756. * mouse wheel's X axis controls.
  19757. * @returns The configured axis or null if none.
  19758. */
  19759. get wheelXRotateRelative(): Nullable<Coordinate>;
  19760. /**
  19761. * Set which rotation axis (relative to camera's orientation) the mouse
  19762. * wheel's Y axis controls.
  19763. * @param axis The axis to be moved. Set null to clear.
  19764. */
  19765. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  19766. /**
  19767. * Get the configured rotation axis (relative to camera's orientation) the
  19768. * mouse wheel's Y axis controls.
  19769. * @returns The configured axis or null if none.
  19770. */
  19771. get wheelYRotateRelative(): Nullable<Coordinate>;
  19772. /**
  19773. * Set which rotation axis (relative to camera's orientation) the mouse
  19774. * wheel's Z axis controls.
  19775. * @param axis The axis to be moved. Set null to clear.
  19776. */
  19777. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  19778. /**
  19779. * Get the configured rotation axis (relative to camera's orientation) the
  19780. * mouse wheel's Z axis controls.
  19781. * @returns The configured axis or null if none.
  19782. */
  19783. get wheelZRotateRelative(): Nullable<Coordinate>;
  19784. /**
  19785. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  19786. * controls.
  19787. * @param axis The axis to be moved. Set null to clear.
  19788. */
  19789. set wheelXMoveScene(axis: Nullable<Coordinate>);
  19790. /**
  19791. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19792. * X axis controls.
  19793. * @returns The configured axis or null if none.
  19794. */
  19795. get wheelXMoveScene(): Nullable<Coordinate>;
  19796. /**
  19797. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  19798. * controls.
  19799. * @param axis The axis to be moved. Set null to clear.
  19800. */
  19801. set wheelYMoveScene(axis: Nullable<Coordinate>);
  19802. /**
  19803. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19804. * Y axis controls.
  19805. * @returns The configured axis or null if none.
  19806. */
  19807. get wheelYMoveScene(): Nullable<Coordinate>;
  19808. /**
  19809. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  19810. * controls.
  19811. * @param axis The axis to be moved. Set null to clear.
  19812. */
  19813. set wheelZMoveScene(axis: Nullable<Coordinate>);
  19814. /**
  19815. * Get the configured movement axis (relative to the scene) the mouse wheel's
  19816. * Z axis controls.
  19817. * @returns The configured axis or null if none.
  19818. */
  19819. get wheelZMoveScene(): Nullable<Coordinate>;
  19820. /**
  19821. * Called for each rendered frame.
  19822. */
  19823. checkInputs(): void;
  19824. private _moveRelative;
  19825. private _rotateRelative;
  19826. private _moveScene;
  19827. /**
  19828. * These are set to the desired default behaviour.
  19829. */
  19830. private _wheelXAction;
  19831. private _wheelXActionCoordinate;
  19832. private _wheelYAction;
  19833. private _wheelYActionCoordinate;
  19834. private _wheelZAction;
  19835. private _wheelZActionCoordinate;
  19836. /**
  19837. * Update the camera according to any configured properties for the 3
  19838. * mouse-wheel axis.
  19839. */
  19840. private _updateCamera;
  19841. }
  19842. }
  19843. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19844. import { Nullable } from "babylonjs/types";
  19845. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19846. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19847. /**
  19848. * Manage the touch inputs to control the movement of a free camera.
  19849. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19850. */
  19851. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19852. /**
  19853. * Define if mouse events can be treated as touch events
  19854. */
  19855. allowMouse: boolean;
  19856. /**
  19857. * Defines the camera the input is attached to.
  19858. */
  19859. camera: FreeCamera;
  19860. /**
  19861. * Defines the touch sensibility for rotation.
  19862. * The higher the faster.
  19863. */
  19864. touchAngularSensibility: number;
  19865. /**
  19866. * Defines the touch sensibility for move.
  19867. * The higher the faster.
  19868. */
  19869. touchMoveSensibility: number;
  19870. private _offsetX;
  19871. private _offsetY;
  19872. private _pointerPressed;
  19873. private _pointerInput;
  19874. private _observer;
  19875. private _onLostFocus;
  19876. /**
  19877. * Manage the touch inputs to control the movement of a free camera.
  19878. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19879. * @param allowMouse Defines if mouse events can be treated as touch events
  19880. */
  19881. constructor(
  19882. /**
  19883. * Define if mouse events can be treated as touch events
  19884. */
  19885. allowMouse?: boolean);
  19886. /**
  19887. * Attach the input controls to a specific dom element to get the input from.
  19888. * @param element Defines the element the controls should be listened from
  19889. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19890. */
  19891. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19892. /**
  19893. * Detach the current controls from the specified dom element.
  19894. * @param element Defines the element to stop listening the inputs from
  19895. */
  19896. detachControl(element: Nullable<HTMLElement>): void;
  19897. /**
  19898. * Update the current camera state depending on the inputs that have been used this frame.
  19899. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19900. */
  19901. checkInputs(): void;
  19902. /**
  19903. * Gets the class name of the current intput.
  19904. * @returns the class name
  19905. */
  19906. getClassName(): string;
  19907. /**
  19908. * Get the friendly name associated with the input class.
  19909. * @returns the input friendly name
  19910. */
  19911. getSimpleName(): string;
  19912. }
  19913. }
  19914. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19915. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19916. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19917. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19918. import { FreeCameraMouseWheelInput } from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  19919. import { Nullable } from "babylonjs/types";
  19920. /**
  19921. * Default Inputs manager for the FreeCamera.
  19922. * It groups all the default supported inputs for ease of use.
  19923. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19924. */
  19925. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19926. /**
  19927. * @hidden
  19928. */
  19929. _mouseInput: Nullable<FreeCameraMouseInput>;
  19930. /**
  19931. * @hidden
  19932. */
  19933. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  19934. /**
  19935. * Instantiates a new FreeCameraInputsManager.
  19936. * @param camera Defines the camera the inputs belong to
  19937. */
  19938. constructor(camera: FreeCamera);
  19939. /**
  19940. * Add keyboard input support to the input manager.
  19941. * @returns the current input manager
  19942. */
  19943. addKeyboard(): FreeCameraInputsManager;
  19944. /**
  19945. * Add mouse input support to the input manager.
  19946. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19947. * @returns the current input manager
  19948. */
  19949. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19950. /**
  19951. * Removes the mouse input support from the manager
  19952. * @returns the current input manager
  19953. */
  19954. removeMouse(): FreeCameraInputsManager;
  19955. /**
  19956. * Add mouse wheel input support to the input manager.
  19957. * @returns the current input manager
  19958. */
  19959. addMouseWheel(): FreeCameraInputsManager;
  19960. /**
  19961. * Removes the mouse wheel input support from the manager
  19962. * @returns the current input manager
  19963. */
  19964. removeMouseWheel(): FreeCameraInputsManager;
  19965. /**
  19966. * Add touch input support to the input manager.
  19967. * @returns the current input manager
  19968. */
  19969. addTouch(): FreeCameraInputsManager;
  19970. /**
  19971. * Remove all attached input methods from a camera
  19972. */
  19973. clear(): void;
  19974. }
  19975. }
  19976. declare module "babylonjs/Cameras/freeCamera" {
  19977. import { Vector3 } from "babylonjs/Maths/math.vector";
  19978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19979. import { Scene } from "babylonjs/scene";
  19980. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19981. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19982. /**
  19983. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19984. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19985. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19986. */
  19987. export class FreeCamera extends TargetCamera {
  19988. /**
  19989. * Define the collision ellipsoid of the camera.
  19990. * This is helpful to simulate a camera body like the player body around the camera
  19991. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19992. */
  19993. ellipsoid: Vector3;
  19994. /**
  19995. * Define an offset for the position of the ellipsoid around the camera.
  19996. * This can be helpful to determine the center of the body near the gravity center of the body
  19997. * instead of its head.
  19998. */
  19999. ellipsoidOffset: Vector3;
  20000. /**
  20001. * Enable or disable collisions of the camera with the rest of the scene objects.
  20002. */
  20003. checkCollisions: boolean;
  20004. /**
  20005. * Enable or disable gravity on the camera.
  20006. */
  20007. applyGravity: boolean;
  20008. /**
  20009. * Define the input manager associated to the camera.
  20010. */
  20011. inputs: FreeCameraInputsManager;
  20012. /**
  20013. * Gets the input sensibility for a mouse input. (default is 2000.0)
  20014. * Higher values reduce sensitivity.
  20015. */
  20016. get angularSensibility(): number;
  20017. /**
  20018. * Sets the input sensibility for a mouse input. (default is 2000.0)
  20019. * Higher values reduce sensitivity.
  20020. */
  20021. set angularSensibility(value: number);
  20022. /**
  20023. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  20024. */
  20025. get keysUp(): number[];
  20026. set keysUp(value: number[]);
  20027. /**
  20028. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  20029. */
  20030. get keysUpward(): number[];
  20031. set keysUpward(value: number[]);
  20032. /**
  20033. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  20034. */
  20035. get keysDown(): number[];
  20036. set keysDown(value: number[]);
  20037. /**
  20038. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  20039. */
  20040. get keysDownward(): number[];
  20041. set keysDownward(value: number[]);
  20042. /**
  20043. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  20044. */
  20045. get keysLeft(): number[];
  20046. set keysLeft(value: number[]);
  20047. /**
  20048. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  20049. */
  20050. get keysRight(): number[];
  20051. set keysRight(value: number[]);
  20052. /**
  20053. * Event raised when the camera collide with a mesh in the scene.
  20054. */
  20055. onCollide: (collidedMesh: AbstractMesh) => void;
  20056. private _collider;
  20057. private _needMoveForGravity;
  20058. private _oldPosition;
  20059. private _diffPosition;
  20060. private _newPosition;
  20061. /** @hidden */
  20062. _localDirection: Vector3;
  20063. /** @hidden */
  20064. _transformedDirection: Vector3;
  20065. /**
  20066. * Instantiates a Free Camera.
  20067. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  20068. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  20069. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  20070. * @param name Define the name of the camera in the scene
  20071. * @param position Define the start position of the camera in the scene
  20072. * @param scene Define the scene the camera belongs to
  20073. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  20074. */
  20075. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  20076. /**
  20077. * Attached controls to the current camera.
  20078. * @param element Defines the element the controls should be listened from
  20079. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20080. */
  20081. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20082. /**
  20083. * Detach the current controls from the camera.
  20084. * The camera will stop reacting to inputs.
  20085. * @param element Defines the element to stop listening the inputs from
  20086. */
  20087. detachControl(element: HTMLElement): void;
  20088. private _collisionMask;
  20089. /**
  20090. * Define a collision mask to limit the list of object the camera can collide with
  20091. */
  20092. get collisionMask(): number;
  20093. set collisionMask(mask: number);
  20094. /** @hidden */
  20095. _collideWithWorld(displacement: Vector3): void;
  20096. private _onCollisionPositionChange;
  20097. /** @hidden */
  20098. _checkInputs(): void;
  20099. /** @hidden */
  20100. _decideIfNeedsToMove(): boolean;
  20101. /** @hidden */
  20102. _updatePosition(): void;
  20103. /**
  20104. * Destroy the camera and release the current resources hold by it.
  20105. */
  20106. dispose(): void;
  20107. /**
  20108. * Gets the current object class name.
  20109. * @return the class name
  20110. */
  20111. getClassName(): string;
  20112. }
  20113. }
  20114. declare module "babylonjs/Gamepads/gamepad" {
  20115. import { Observable } from "babylonjs/Misc/observable";
  20116. /**
  20117. * Represents a gamepad control stick position
  20118. */
  20119. export class StickValues {
  20120. /**
  20121. * The x component of the control stick
  20122. */
  20123. x: number;
  20124. /**
  20125. * The y component of the control stick
  20126. */
  20127. y: number;
  20128. /**
  20129. * Initializes the gamepad x and y control stick values
  20130. * @param x The x component of the gamepad control stick value
  20131. * @param y The y component of the gamepad control stick value
  20132. */
  20133. constructor(
  20134. /**
  20135. * The x component of the control stick
  20136. */
  20137. x: number,
  20138. /**
  20139. * The y component of the control stick
  20140. */
  20141. y: number);
  20142. }
  20143. /**
  20144. * An interface which manages callbacks for gamepad button changes
  20145. */
  20146. export interface GamepadButtonChanges {
  20147. /**
  20148. * Called when a gamepad has been changed
  20149. */
  20150. changed: boolean;
  20151. /**
  20152. * Called when a gamepad press event has been triggered
  20153. */
  20154. pressChanged: boolean;
  20155. /**
  20156. * Called when a touch event has been triggered
  20157. */
  20158. touchChanged: boolean;
  20159. /**
  20160. * Called when a value has changed
  20161. */
  20162. valueChanged: boolean;
  20163. }
  20164. /**
  20165. * Represents a gamepad
  20166. */
  20167. export class Gamepad {
  20168. /**
  20169. * The id of the gamepad
  20170. */
  20171. id: string;
  20172. /**
  20173. * The index of the gamepad
  20174. */
  20175. index: number;
  20176. /**
  20177. * The browser gamepad
  20178. */
  20179. browserGamepad: any;
  20180. /**
  20181. * Specifies what type of gamepad this represents
  20182. */
  20183. type: number;
  20184. private _leftStick;
  20185. private _rightStick;
  20186. /** @hidden */
  20187. _isConnected: boolean;
  20188. private _leftStickAxisX;
  20189. private _leftStickAxisY;
  20190. private _rightStickAxisX;
  20191. private _rightStickAxisY;
  20192. /**
  20193. * Triggered when the left control stick has been changed
  20194. */
  20195. private _onleftstickchanged;
  20196. /**
  20197. * Triggered when the right control stick has been changed
  20198. */
  20199. private _onrightstickchanged;
  20200. /**
  20201. * Represents a gamepad controller
  20202. */
  20203. static GAMEPAD: number;
  20204. /**
  20205. * Represents a generic controller
  20206. */
  20207. static GENERIC: number;
  20208. /**
  20209. * Represents an XBox controller
  20210. */
  20211. static XBOX: number;
  20212. /**
  20213. * Represents a pose-enabled controller
  20214. */
  20215. static POSE_ENABLED: number;
  20216. /**
  20217. * Represents an Dual Shock controller
  20218. */
  20219. static DUALSHOCK: number;
  20220. /**
  20221. * Specifies whether the left control stick should be Y-inverted
  20222. */
  20223. protected _invertLeftStickY: boolean;
  20224. /**
  20225. * Specifies if the gamepad has been connected
  20226. */
  20227. get isConnected(): boolean;
  20228. /**
  20229. * Initializes the gamepad
  20230. * @param id The id of the gamepad
  20231. * @param index The index of the gamepad
  20232. * @param browserGamepad The browser gamepad
  20233. * @param leftStickX The x component of the left joystick
  20234. * @param leftStickY The y component of the left joystick
  20235. * @param rightStickX The x component of the right joystick
  20236. * @param rightStickY The y component of the right joystick
  20237. */
  20238. constructor(
  20239. /**
  20240. * The id of the gamepad
  20241. */
  20242. id: string,
  20243. /**
  20244. * The index of the gamepad
  20245. */
  20246. index: number,
  20247. /**
  20248. * The browser gamepad
  20249. */
  20250. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  20251. /**
  20252. * Callback triggered when the left joystick has changed
  20253. * @param callback
  20254. */
  20255. onleftstickchanged(callback: (values: StickValues) => void): void;
  20256. /**
  20257. * Callback triggered when the right joystick has changed
  20258. * @param callback
  20259. */
  20260. onrightstickchanged(callback: (values: StickValues) => void): void;
  20261. /**
  20262. * Gets the left joystick
  20263. */
  20264. get leftStick(): StickValues;
  20265. /**
  20266. * Sets the left joystick values
  20267. */
  20268. set leftStick(newValues: StickValues);
  20269. /**
  20270. * Gets the right joystick
  20271. */
  20272. get rightStick(): StickValues;
  20273. /**
  20274. * Sets the right joystick value
  20275. */
  20276. set rightStick(newValues: StickValues);
  20277. /**
  20278. * Updates the gamepad joystick positions
  20279. */
  20280. update(): void;
  20281. /**
  20282. * Disposes the gamepad
  20283. */
  20284. dispose(): void;
  20285. }
  20286. /**
  20287. * Represents a generic gamepad
  20288. */
  20289. export class GenericPad extends Gamepad {
  20290. private _buttons;
  20291. private _onbuttondown;
  20292. private _onbuttonup;
  20293. /**
  20294. * Observable triggered when a button has been pressed
  20295. */
  20296. onButtonDownObservable: Observable<number>;
  20297. /**
  20298. * Observable triggered when a button has been released
  20299. */
  20300. onButtonUpObservable: Observable<number>;
  20301. /**
  20302. * Callback triggered when a button has been pressed
  20303. * @param callback Called when a button has been pressed
  20304. */
  20305. onbuttondown(callback: (buttonPressed: number) => void): void;
  20306. /**
  20307. * Callback triggered when a button has been released
  20308. * @param callback Called when a button has been released
  20309. */
  20310. onbuttonup(callback: (buttonReleased: number) => void): void;
  20311. /**
  20312. * Initializes the generic gamepad
  20313. * @param id The id of the generic gamepad
  20314. * @param index The index of the generic gamepad
  20315. * @param browserGamepad The browser gamepad
  20316. */
  20317. constructor(id: string, index: number, browserGamepad: any);
  20318. private _setButtonValue;
  20319. /**
  20320. * Updates the generic gamepad
  20321. */
  20322. update(): void;
  20323. /**
  20324. * Disposes the generic gamepad
  20325. */
  20326. dispose(): void;
  20327. }
  20328. }
  20329. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20330. import { Observable } from "babylonjs/Misc/observable";
  20331. import { Nullable } from "babylonjs/types";
  20332. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20333. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20334. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20335. import { Ray } from "babylonjs/Culling/ray";
  20336. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20337. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20338. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20339. /**
  20340. * Defines the types of pose enabled controllers that are supported
  20341. */
  20342. export enum PoseEnabledControllerType {
  20343. /**
  20344. * HTC Vive
  20345. */
  20346. VIVE = 0,
  20347. /**
  20348. * Oculus Rift
  20349. */
  20350. OCULUS = 1,
  20351. /**
  20352. * Windows mixed reality
  20353. */
  20354. WINDOWS = 2,
  20355. /**
  20356. * Samsung gear VR
  20357. */
  20358. GEAR_VR = 3,
  20359. /**
  20360. * Google Daydream
  20361. */
  20362. DAYDREAM = 4,
  20363. /**
  20364. * Generic
  20365. */
  20366. GENERIC = 5
  20367. }
  20368. /**
  20369. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20370. */
  20371. export interface MutableGamepadButton {
  20372. /**
  20373. * Value of the button/trigger
  20374. */
  20375. value: number;
  20376. /**
  20377. * If the button/trigger is currently touched
  20378. */
  20379. touched: boolean;
  20380. /**
  20381. * If the button/trigger is currently pressed
  20382. */
  20383. pressed: boolean;
  20384. }
  20385. /**
  20386. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20387. * @hidden
  20388. */
  20389. export interface ExtendedGamepadButton extends GamepadButton {
  20390. /**
  20391. * If the button/trigger is currently pressed
  20392. */
  20393. readonly pressed: boolean;
  20394. /**
  20395. * If the button/trigger is currently touched
  20396. */
  20397. readonly touched: boolean;
  20398. /**
  20399. * Value of the button/trigger
  20400. */
  20401. readonly value: number;
  20402. }
  20403. /** @hidden */
  20404. export interface _GamePadFactory {
  20405. /**
  20406. * Returns whether or not the current gamepad can be created for this type of controller.
  20407. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20408. * @returns true if it can be created, otherwise false
  20409. */
  20410. canCreate(gamepadInfo: any): boolean;
  20411. /**
  20412. * Creates a new instance of the Gamepad.
  20413. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20414. * @returns the new gamepad instance
  20415. */
  20416. create(gamepadInfo: any): Gamepad;
  20417. }
  20418. /**
  20419. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20420. */
  20421. export class PoseEnabledControllerHelper {
  20422. /** @hidden */
  20423. static _ControllerFactories: _GamePadFactory[];
  20424. /** @hidden */
  20425. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20426. /**
  20427. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20428. * @param vrGamepad the gamepad to initialized
  20429. * @returns a vr controller of the type the gamepad identified as
  20430. */
  20431. static InitiateController(vrGamepad: any): Gamepad;
  20432. }
  20433. /**
  20434. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20435. */
  20436. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20437. /**
  20438. * If the controller is used in a webXR session
  20439. */
  20440. isXR: boolean;
  20441. private _deviceRoomPosition;
  20442. private _deviceRoomRotationQuaternion;
  20443. /**
  20444. * The device position in babylon space
  20445. */
  20446. devicePosition: Vector3;
  20447. /**
  20448. * The device rotation in babylon space
  20449. */
  20450. deviceRotationQuaternion: Quaternion;
  20451. /**
  20452. * The scale factor of the device in babylon space
  20453. */
  20454. deviceScaleFactor: number;
  20455. /**
  20456. * (Likely devicePosition should be used instead) The device position in its room space
  20457. */
  20458. position: Vector3;
  20459. /**
  20460. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20461. */
  20462. rotationQuaternion: Quaternion;
  20463. /**
  20464. * The type of controller (Eg. Windows mixed reality)
  20465. */
  20466. controllerType: PoseEnabledControllerType;
  20467. protected _calculatedPosition: Vector3;
  20468. private _calculatedRotation;
  20469. /**
  20470. * The raw pose from the device
  20471. */
  20472. rawPose: DevicePose;
  20473. private _trackPosition;
  20474. private _maxRotationDistFromHeadset;
  20475. private _draggedRoomRotation;
  20476. /**
  20477. * @hidden
  20478. */
  20479. _disableTrackPosition(fixedPosition: Vector3): void;
  20480. /**
  20481. * Internal, the mesh attached to the controller
  20482. * @hidden
  20483. */
  20484. _mesh: Nullable<AbstractMesh>;
  20485. private _poseControlledCamera;
  20486. private _leftHandSystemQuaternion;
  20487. /**
  20488. * Internal, matrix used to convert room space to babylon space
  20489. * @hidden
  20490. */
  20491. _deviceToWorld: Matrix;
  20492. /**
  20493. * Node to be used when casting a ray from the controller
  20494. * @hidden
  20495. */
  20496. _pointingPoseNode: Nullable<TransformNode>;
  20497. /**
  20498. * Name of the child mesh that can be used to cast a ray from the controller
  20499. */
  20500. static readonly POINTING_POSE: string;
  20501. /**
  20502. * Creates a new PoseEnabledController from a gamepad
  20503. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20504. */
  20505. constructor(browserGamepad: any);
  20506. private _workingMatrix;
  20507. /**
  20508. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20509. */
  20510. update(): void;
  20511. /**
  20512. * Updates only the pose device and mesh without doing any button event checking
  20513. */
  20514. protected _updatePoseAndMesh(): void;
  20515. /**
  20516. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20517. * @param poseData raw pose fromthe device
  20518. */
  20519. updateFromDevice(poseData: DevicePose): void;
  20520. /**
  20521. * @hidden
  20522. */
  20523. _meshAttachedObservable: Observable<AbstractMesh>;
  20524. /**
  20525. * Attaches a mesh to the controller
  20526. * @param mesh the mesh to be attached
  20527. */
  20528. attachToMesh(mesh: AbstractMesh): void;
  20529. /**
  20530. * Attaches the controllers mesh to a camera
  20531. * @param camera the camera the mesh should be attached to
  20532. */
  20533. attachToPoseControlledCamera(camera: TargetCamera): void;
  20534. /**
  20535. * Disposes of the controller
  20536. */
  20537. dispose(): void;
  20538. /**
  20539. * The mesh that is attached to the controller
  20540. */
  20541. get mesh(): Nullable<AbstractMesh>;
  20542. /**
  20543. * Gets the ray of the controller in the direction the controller is pointing
  20544. * @param length the length the resulting ray should be
  20545. * @returns a ray in the direction the controller is pointing
  20546. */
  20547. getForwardRay(length?: number): Ray;
  20548. }
  20549. }
  20550. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20551. import { Observable } from "babylonjs/Misc/observable";
  20552. import { Scene } from "babylonjs/scene";
  20553. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20554. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20555. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20556. import { Nullable } from "babylonjs/types";
  20557. /**
  20558. * Defines the WebVRController object that represents controllers tracked in 3D space
  20559. */
  20560. export abstract class WebVRController extends PoseEnabledController {
  20561. /**
  20562. * Internal, the default controller model for the controller
  20563. */
  20564. protected _defaultModel: Nullable<AbstractMesh>;
  20565. /**
  20566. * Fired when the trigger state has changed
  20567. */
  20568. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20569. /**
  20570. * Fired when the main button state has changed
  20571. */
  20572. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20573. /**
  20574. * Fired when the secondary button state has changed
  20575. */
  20576. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20577. /**
  20578. * Fired when the pad state has changed
  20579. */
  20580. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20581. /**
  20582. * Fired when controllers stick values have changed
  20583. */
  20584. onPadValuesChangedObservable: Observable<StickValues>;
  20585. /**
  20586. * Array of button availible on the controller
  20587. */
  20588. protected _buttons: Array<MutableGamepadButton>;
  20589. private _onButtonStateChange;
  20590. /**
  20591. * Fired when a controller button's state has changed
  20592. * @param callback the callback containing the button that was modified
  20593. */
  20594. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20595. /**
  20596. * X and Y axis corresponding to the controllers joystick
  20597. */
  20598. pad: StickValues;
  20599. /**
  20600. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20601. */
  20602. hand: string;
  20603. /**
  20604. * The default controller model for the controller
  20605. */
  20606. get defaultModel(): Nullable<AbstractMesh>;
  20607. /**
  20608. * Creates a new WebVRController from a gamepad
  20609. * @param vrGamepad the gamepad that the WebVRController should be created from
  20610. */
  20611. constructor(vrGamepad: any);
  20612. /**
  20613. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20614. */
  20615. update(): void;
  20616. /**
  20617. * Function to be called when a button is modified
  20618. */
  20619. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20620. /**
  20621. * Loads a mesh and attaches it to the controller
  20622. * @param scene the scene the mesh should be added to
  20623. * @param meshLoaded callback for when the mesh has been loaded
  20624. */
  20625. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20626. private _setButtonValue;
  20627. private _changes;
  20628. private _checkChanges;
  20629. /**
  20630. * Disposes of th webVRCOntroller
  20631. */
  20632. dispose(): void;
  20633. }
  20634. }
  20635. declare module "babylonjs/Lights/hemisphericLight" {
  20636. import { Nullable } from "babylonjs/types";
  20637. import { Scene } from "babylonjs/scene";
  20638. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20639. import { Color3 } from "babylonjs/Maths/math.color";
  20640. import { Effect } from "babylonjs/Materials/effect";
  20641. import { Light } from "babylonjs/Lights/light";
  20642. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20643. /**
  20644. * The HemisphericLight simulates the ambient environment light,
  20645. * so the passed direction is the light reflection direction, not the incoming direction.
  20646. */
  20647. export class HemisphericLight extends Light {
  20648. /**
  20649. * The groundColor is the light in the opposite direction to the one specified during creation.
  20650. * 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.
  20651. */
  20652. groundColor: Color3;
  20653. /**
  20654. * The light reflection direction, not the incoming direction.
  20655. */
  20656. direction: Vector3;
  20657. /**
  20658. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20659. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20660. * The HemisphericLight can't cast shadows.
  20661. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20662. * @param name The friendly name of the light
  20663. * @param direction The direction of the light reflection
  20664. * @param scene The scene the light belongs to
  20665. */
  20666. constructor(name: string, direction: Vector3, scene: Scene);
  20667. protected _buildUniformLayout(): void;
  20668. /**
  20669. * Returns the string "HemisphericLight".
  20670. * @return The class name
  20671. */
  20672. getClassName(): string;
  20673. /**
  20674. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20675. * Returns the updated direction.
  20676. * @param target The target the direction should point to
  20677. * @return The computed direction
  20678. */
  20679. setDirectionToTarget(target: Vector3): Vector3;
  20680. /**
  20681. * Returns the shadow generator associated to the light.
  20682. * @returns Always null for hemispheric lights because it does not support shadows.
  20683. */
  20684. getShadowGenerator(): Nullable<IShadowGenerator>;
  20685. /**
  20686. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20687. * @param effect The effect to update
  20688. * @param lightIndex The index of the light in the effect to update
  20689. * @returns The hemispheric light
  20690. */
  20691. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20692. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20693. /**
  20694. * Computes the world matrix of the node
  20695. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20696. * @param useWasUpdatedFlag defines a reserved property
  20697. * @returns the world matrix
  20698. */
  20699. computeWorldMatrix(): Matrix;
  20700. /**
  20701. * Returns the integer 3.
  20702. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20703. */
  20704. getTypeID(): number;
  20705. /**
  20706. * Prepares the list of defines specific to the light type.
  20707. * @param defines the list of defines
  20708. * @param lightIndex defines the index of the light for the effect
  20709. */
  20710. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20711. }
  20712. }
  20713. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20714. /** @hidden */
  20715. export var vrMultiviewToSingleviewPixelShader: {
  20716. name: string;
  20717. shader: string;
  20718. };
  20719. }
  20720. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20721. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20722. import { Scene } from "babylonjs/scene";
  20723. /**
  20724. * Renders to multiple views with a single draw call
  20725. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20726. */
  20727. export class MultiviewRenderTarget extends RenderTargetTexture {
  20728. /**
  20729. * Creates a multiview render target
  20730. * @param scene scene used with the render target
  20731. * @param size the size of the render target (used for each view)
  20732. */
  20733. constructor(scene: Scene, size?: number | {
  20734. width: number;
  20735. height: number;
  20736. } | {
  20737. ratio: number;
  20738. });
  20739. /**
  20740. * @hidden
  20741. * @param faceIndex the face index, if its a cube texture
  20742. */
  20743. _bindFrameBuffer(faceIndex?: number): void;
  20744. /**
  20745. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20746. * @returns the view count
  20747. */
  20748. getViewCount(): number;
  20749. }
  20750. }
  20751. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20752. import { Camera } from "babylonjs/Cameras/camera";
  20753. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20754. import { Nullable } from "babylonjs/types";
  20755. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20756. import { Matrix } from "babylonjs/Maths/math.vector";
  20757. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20758. module "babylonjs/Engines/engine" {
  20759. interface Engine {
  20760. /**
  20761. * Creates a new multiview render target
  20762. * @param width defines the width of the texture
  20763. * @param height defines the height of the texture
  20764. * @returns the created multiview texture
  20765. */
  20766. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20767. /**
  20768. * Binds a multiview framebuffer to be drawn to
  20769. * @param multiviewTexture texture to bind
  20770. */
  20771. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20772. }
  20773. }
  20774. module "babylonjs/Cameras/camera" {
  20775. interface Camera {
  20776. /**
  20777. * @hidden
  20778. * 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)
  20779. */
  20780. _useMultiviewToSingleView: boolean;
  20781. /**
  20782. * @hidden
  20783. * 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)
  20784. */
  20785. _multiviewTexture: Nullable<RenderTargetTexture>;
  20786. /**
  20787. * @hidden
  20788. * ensures the multiview texture of the camera exists and has the specified width/height
  20789. * @param width height to set on the multiview texture
  20790. * @param height width to set on the multiview texture
  20791. */
  20792. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20793. }
  20794. }
  20795. module "babylonjs/scene" {
  20796. interface Scene {
  20797. /** @hidden */
  20798. _transformMatrixR: Matrix;
  20799. /** @hidden */
  20800. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20801. /** @hidden */
  20802. _createMultiviewUbo(): void;
  20803. /** @hidden */
  20804. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20805. /** @hidden */
  20806. _renderMultiviewToSingleView(camera: Camera): void;
  20807. }
  20808. }
  20809. }
  20810. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20811. import { Camera } from "babylonjs/Cameras/camera";
  20812. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20813. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20814. import "babylonjs/Engines/Extensions/engine.multiview";
  20815. /**
  20816. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20817. * This will not be used for webXR as it supports displaying texture arrays directly
  20818. */
  20819. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20820. /**
  20821. * Gets a string identifying the name of the class
  20822. * @returns "VRMultiviewToSingleviewPostProcess" string
  20823. */
  20824. getClassName(): string;
  20825. /**
  20826. * Initializes a VRMultiviewToSingleview
  20827. * @param name name of the post process
  20828. * @param camera camera to be applied to
  20829. * @param scaleFactor scaling factor to the size of the output texture
  20830. */
  20831. constructor(name: string, camera: Camera, scaleFactor: number);
  20832. }
  20833. }
  20834. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20835. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20836. import { Nullable } from "babylonjs/types";
  20837. import { Size } from "babylonjs/Maths/math.size";
  20838. import { Observable } from "babylonjs/Misc/observable";
  20839. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20840. /**
  20841. * Interface used to define additional presentation attributes
  20842. */
  20843. export interface IVRPresentationAttributes {
  20844. /**
  20845. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20846. */
  20847. highRefreshRate: boolean;
  20848. /**
  20849. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20850. */
  20851. foveationLevel: number;
  20852. }
  20853. module "babylonjs/Engines/engine" {
  20854. interface Engine {
  20855. /** @hidden */
  20856. _vrDisplay: any;
  20857. /** @hidden */
  20858. _vrSupported: boolean;
  20859. /** @hidden */
  20860. _oldSize: Size;
  20861. /** @hidden */
  20862. _oldHardwareScaleFactor: number;
  20863. /** @hidden */
  20864. _vrExclusivePointerMode: boolean;
  20865. /** @hidden */
  20866. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20867. /** @hidden */
  20868. _onVRDisplayPointerRestricted: () => void;
  20869. /** @hidden */
  20870. _onVRDisplayPointerUnrestricted: () => void;
  20871. /** @hidden */
  20872. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20873. /** @hidden */
  20874. _onVrDisplayDisconnect: Nullable<() => void>;
  20875. /** @hidden */
  20876. _onVrDisplayPresentChange: Nullable<() => void>;
  20877. /**
  20878. * Observable signaled when VR display mode changes
  20879. */
  20880. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20881. /**
  20882. * Observable signaled when VR request present is complete
  20883. */
  20884. onVRRequestPresentComplete: Observable<boolean>;
  20885. /**
  20886. * Observable signaled when VR request present starts
  20887. */
  20888. onVRRequestPresentStart: Observable<Engine>;
  20889. /**
  20890. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20891. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20892. */
  20893. isInVRExclusivePointerMode: boolean;
  20894. /**
  20895. * Gets a boolean indicating if a webVR device was detected
  20896. * @returns true if a webVR device was detected
  20897. */
  20898. isVRDevicePresent(): boolean;
  20899. /**
  20900. * Gets the current webVR device
  20901. * @returns the current webVR device (or null)
  20902. */
  20903. getVRDevice(): any;
  20904. /**
  20905. * Initializes a webVR display and starts listening to display change events
  20906. * The onVRDisplayChangedObservable will be notified upon these changes
  20907. * @returns A promise containing a VRDisplay and if vr is supported
  20908. */
  20909. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20910. /** @hidden */
  20911. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20912. /**
  20913. * Gets or sets the presentation attributes used to configure VR rendering
  20914. */
  20915. vrPresentationAttributes?: IVRPresentationAttributes;
  20916. /**
  20917. * Call this function to switch to webVR mode
  20918. * Will do nothing if webVR is not supported or if there is no webVR device
  20919. * @param options the webvr options provided to the camera. mainly used for multiview
  20920. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20921. */
  20922. enableVR(options: WebVROptions): void;
  20923. /** @hidden */
  20924. _onVRFullScreenTriggered(): void;
  20925. }
  20926. }
  20927. }
  20928. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20929. import { Nullable } from "babylonjs/types";
  20930. import { Observable } from "babylonjs/Misc/observable";
  20931. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20932. import { Scene } from "babylonjs/scene";
  20933. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20934. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20935. import { Node } from "babylonjs/node";
  20936. import { Ray } from "babylonjs/Culling/ray";
  20937. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20938. import "babylonjs/Engines/Extensions/engine.webVR";
  20939. /**
  20940. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20941. * IMPORTANT!! The data is right-hand data.
  20942. * @export
  20943. * @interface DevicePose
  20944. */
  20945. export interface DevicePose {
  20946. /**
  20947. * The position of the device, values in array are [x,y,z].
  20948. */
  20949. readonly position: Nullable<Float32Array>;
  20950. /**
  20951. * The linearVelocity of the device, values in array are [x,y,z].
  20952. */
  20953. readonly linearVelocity: Nullable<Float32Array>;
  20954. /**
  20955. * The linearAcceleration of the device, values in array are [x,y,z].
  20956. */
  20957. readonly linearAcceleration: Nullable<Float32Array>;
  20958. /**
  20959. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20960. */
  20961. readonly orientation: Nullable<Float32Array>;
  20962. /**
  20963. * The angularVelocity of the device, values in array are [x,y,z].
  20964. */
  20965. readonly angularVelocity: Nullable<Float32Array>;
  20966. /**
  20967. * The angularAcceleration of the device, values in array are [x,y,z].
  20968. */
  20969. readonly angularAcceleration: Nullable<Float32Array>;
  20970. }
  20971. /**
  20972. * Interface representing a pose controlled object in Babylon.
  20973. * A pose controlled object has both regular pose values as well as pose values
  20974. * from an external device such as a VR head mounted display
  20975. */
  20976. export interface PoseControlled {
  20977. /**
  20978. * The position of the object in babylon space.
  20979. */
  20980. position: Vector3;
  20981. /**
  20982. * The rotation quaternion of the object in babylon space.
  20983. */
  20984. rotationQuaternion: Quaternion;
  20985. /**
  20986. * The position of the device in babylon space.
  20987. */
  20988. devicePosition?: Vector3;
  20989. /**
  20990. * The rotation quaternion of the device in babylon space.
  20991. */
  20992. deviceRotationQuaternion: Quaternion;
  20993. /**
  20994. * The raw pose coming from the device.
  20995. */
  20996. rawPose: Nullable<DevicePose>;
  20997. /**
  20998. * The scale of the device to be used when translating from device space to babylon space.
  20999. */
  21000. deviceScaleFactor: number;
  21001. /**
  21002. * Updates the poseControlled values based on the input device pose.
  21003. * @param poseData the pose data to update the object with
  21004. */
  21005. updateFromDevice(poseData: DevicePose): void;
  21006. }
  21007. /**
  21008. * Set of options to customize the webVRCamera
  21009. */
  21010. export interface WebVROptions {
  21011. /**
  21012. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  21013. */
  21014. trackPosition?: boolean;
  21015. /**
  21016. * Sets the scale of the vrDevice in babylon space. (default: 1)
  21017. */
  21018. positionScale?: number;
  21019. /**
  21020. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  21021. */
  21022. displayName?: string;
  21023. /**
  21024. * Should the native controller meshes be initialized. (default: true)
  21025. */
  21026. controllerMeshes?: boolean;
  21027. /**
  21028. * Creating a default HemiLight only on controllers. (default: true)
  21029. */
  21030. defaultLightingOnControllers?: boolean;
  21031. /**
  21032. * If you don't want to use the default VR button of the helper. (default: false)
  21033. */
  21034. useCustomVRButton?: boolean;
  21035. /**
  21036. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  21037. */
  21038. customVRButton?: HTMLButtonElement;
  21039. /**
  21040. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  21041. */
  21042. rayLength?: number;
  21043. /**
  21044. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  21045. */
  21046. defaultHeight?: number;
  21047. /**
  21048. * If multiview should be used if availible (default: false)
  21049. */
  21050. useMultiview?: boolean;
  21051. }
  21052. /**
  21053. * This represents a WebVR camera.
  21054. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  21055. * @example https://doc.babylonjs.com/how_to/webvr_camera
  21056. */
  21057. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  21058. private webVROptions;
  21059. /**
  21060. * @hidden
  21061. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  21062. */
  21063. _vrDevice: any;
  21064. /**
  21065. * The rawPose of the vrDevice.
  21066. */
  21067. rawPose: Nullable<DevicePose>;
  21068. private _onVREnabled;
  21069. private _specsVersion;
  21070. private _attached;
  21071. private _frameData;
  21072. protected _descendants: Array<Node>;
  21073. private _deviceRoomPosition;
  21074. /** @hidden */
  21075. _deviceRoomRotationQuaternion: Quaternion;
  21076. private _standingMatrix;
  21077. /**
  21078. * Represents device position in babylon space.
  21079. */
  21080. devicePosition: Vector3;
  21081. /**
  21082. * Represents device rotation in babylon space.
  21083. */
  21084. deviceRotationQuaternion: Quaternion;
  21085. /**
  21086. * The scale of the device to be used when translating from device space to babylon space.
  21087. */
  21088. deviceScaleFactor: number;
  21089. private _deviceToWorld;
  21090. private _worldToDevice;
  21091. /**
  21092. * References to the webVR controllers for the vrDevice.
  21093. */
  21094. controllers: Array<WebVRController>;
  21095. /**
  21096. * Emits an event when a controller is attached.
  21097. */
  21098. onControllersAttachedObservable: Observable<WebVRController[]>;
  21099. /**
  21100. * Emits an event when a controller's mesh has been loaded;
  21101. */
  21102. onControllerMeshLoadedObservable: Observable<WebVRController>;
  21103. /**
  21104. * Emits an event when the HMD's pose has been updated.
  21105. */
  21106. onPoseUpdatedFromDeviceObservable: Observable<any>;
  21107. private _poseSet;
  21108. /**
  21109. * If the rig cameras be used as parent instead of this camera.
  21110. */
  21111. rigParenting: boolean;
  21112. private _lightOnControllers;
  21113. private _defaultHeight?;
  21114. /**
  21115. * Instantiates a WebVRFreeCamera.
  21116. * @param name The name of the WebVRFreeCamera
  21117. * @param position The starting anchor position for the camera
  21118. * @param scene The scene the camera belongs to
  21119. * @param webVROptions a set of customizable options for the webVRCamera
  21120. */
  21121. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  21122. /**
  21123. * Gets the device distance from the ground in meters.
  21124. * @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.
  21125. */
  21126. deviceDistanceToRoomGround(): number;
  21127. /**
  21128. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  21129. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  21130. */
  21131. useStandingMatrix(callback?: (bool: boolean) => void): void;
  21132. /**
  21133. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  21134. * @returns A promise with a boolean set to if the standing matrix is supported.
  21135. */
  21136. useStandingMatrixAsync(): Promise<boolean>;
  21137. /**
  21138. * Disposes the camera
  21139. */
  21140. dispose(): void;
  21141. /**
  21142. * Gets a vrController by name.
  21143. * @param name The name of the controller to retreive
  21144. * @returns the controller matching the name specified or null if not found
  21145. */
  21146. getControllerByName(name: string): Nullable<WebVRController>;
  21147. private _leftController;
  21148. /**
  21149. * The controller corresponding to the users left hand.
  21150. */
  21151. get leftController(): Nullable<WebVRController>;
  21152. private _rightController;
  21153. /**
  21154. * The controller corresponding to the users right hand.
  21155. */
  21156. get rightController(): Nullable<WebVRController>;
  21157. /**
  21158. * Casts a ray forward from the vrCamera's gaze.
  21159. * @param length Length of the ray (default: 100)
  21160. * @returns the ray corresponding to the gaze
  21161. */
  21162. getForwardRay(length?: number): Ray;
  21163. /**
  21164. * @hidden
  21165. * Updates the camera based on device's frame data
  21166. */
  21167. _checkInputs(): void;
  21168. /**
  21169. * Updates the poseControlled values based on the input device pose.
  21170. * @param poseData Pose coming from the device
  21171. */
  21172. updateFromDevice(poseData: DevicePose): void;
  21173. private _htmlElementAttached;
  21174. private _detachIfAttached;
  21175. /**
  21176. * WebVR's attach control will start broadcasting frames to the device.
  21177. * Note that in certain browsers (chrome for example) this function must be called
  21178. * within a user-interaction callback. Example:
  21179. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  21180. *
  21181. * @param element html element to attach the vrDevice to
  21182. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  21183. */
  21184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  21185. /**
  21186. * Detaches the camera from the html element and disables VR
  21187. *
  21188. * @param element html element to detach from
  21189. */
  21190. detachControl(element: HTMLElement): void;
  21191. /**
  21192. * @returns the name of this class
  21193. */
  21194. getClassName(): string;
  21195. /**
  21196. * Calls resetPose on the vrDisplay
  21197. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  21198. */
  21199. resetToCurrentRotation(): void;
  21200. /**
  21201. * @hidden
  21202. * Updates the rig cameras (left and right eye)
  21203. */
  21204. _updateRigCameras(): void;
  21205. private _workingVector;
  21206. private _oneVector;
  21207. private _workingMatrix;
  21208. private updateCacheCalled;
  21209. private _correctPositionIfNotTrackPosition;
  21210. /**
  21211. * @hidden
  21212. * Updates the cached values of the camera
  21213. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  21214. */
  21215. _updateCache(ignoreParentClass?: boolean): void;
  21216. /**
  21217. * @hidden
  21218. * Get current device position in babylon world
  21219. */
  21220. _computeDevicePosition(): void;
  21221. /**
  21222. * Updates the current device position and rotation in the babylon world
  21223. */
  21224. update(): void;
  21225. /**
  21226. * @hidden
  21227. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  21228. * @returns an identity matrix
  21229. */
  21230. _getViewMatrix(): Matrix;
  21231. private _tmpMatrix;
  21232. /**
  21233. * This function is called by the two RIG cameras.
  21234. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  21235. * @hidden
  21236. */
  21237. _getWebVRViewMatrix(): Matrix;
  21238. /** @hidden */
  21239. _getWebVRProjectionMatrix(): Matrix;
  21240. private _onGamepadConnectedObserver;
  21241. private _onGamepadDisconnectedObserver;
  21242. private _updateCacheWhenTrackingDisabledObserver;
  21243. /**
  21244. * Initializes the controllers and their meshes
  21245. */
  21246. initControllers(): void;
  21247. }
  21248. }
  21249. declare module "babylonjs/Materials/materialHelper" {
  21250. import { Nullable } from "babylonjs/types";
  21251. import { Scene } from "babylonjs/scene";
  21252. import { Engine } from "babylonjs/Engines/engine";
  21253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21254. import { Light } from "babylonjs/Lights/light";
  21255. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  21256. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21257. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  21258. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21259. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21260. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21261. /**
  21262. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  21263. *
  21264. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  21265. *
  21266. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  21267. */
  21268. export class MaterialHelper {
  21269. /**
  21270. * Bind the current view position to an effect.
  21271. * @param effect The effect to be bound
  21272. * @param scene The scene the eyes position is used from
  21273. * @param variableName name of the shader variable that will hold the eye position
  21274. */
  21275. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  21276. /**
  21277. * Helps preparing the defines values about the UVs in used in the effect.
  21278. * UVs are shared as much as we can accross channels in the shaders.
  21279. * @param texture The texture we are preparing the UVs for
  21280. * @param defines The defines to update
  21281. * @param key The channel key "diffuse", "specular"... used in the shader
  21282. */
  21283. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  21284. /**
  21285. * Binds a texture matrix value to its corrsponding uniform
  21286. * @param texture The texture to bind the matrix for
  21287. * @param uniformBuffer The uniform buffer receivin the data
  21288. * @param key The channel key "diffuse", "specular"... used in the shader
  21289. */
  21290. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  21291. /**
  21292. * Gets the current status of the fog (should it be enabled?)
  21293. * @param mesh defines the mesh to evaluate for fog support
  21294. * @param scene defines the hosting scene
  21295. * @returns true if fog must be enabled
  21296. */
  21297. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  21298. /**
  21299. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  21300. * @param mesh defines the current mesh
  21301. * @param scene defines the current scene
  21302. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  21303. * @param pointsCloud defines if point cloud rendering has to be turned on
  21304. * @param fogEnabled defines if fog has to be turned on
  21305. * @param alphaTest defines if alpha testing has to be turned on
  21306. * @param defines defines the current list of defines
  21307. */
  21308. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  21309. /**
  21310. * Helper used to prepare the list of defines associated with frame values for shader compilation
  21311. * @param scene defines the current scene
  21312. * @param engine defines the current engine
  21313. * @param defines specifies the list of active defines
  21314. * @param useInstances defines if instances have to be turned on
  21315. * @param useClipPlane defines if clip plane have to be turned on
  21316. * @param useInstances defines if instances have to be turned on
  21317. * @param useThinInstances defines if thin instances have to be turned on
  21318. */
  21319. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21320. /**
  21321. * Prepares the defines for bones
  21322. * @param mesh The mesh containing the geometry data we will draw
  21323. * @param defines The defines to update
  21324. */
  21325. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21326. /**
  21327. * Prepares the defines for morph targets
  21328. * @param mesh The mesh containing the geometry data we will draw
  21329. * @param defines The defines to update
  21330. */
  21331. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21332. /**
  21333. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21334. * @param mesh The mesh containing the geometry data we will draw
  21335. * @param defines The defines to update
  21336. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21337. * @param useBones Precise whether bones should be used or not (override mesh info)
  21338. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21339. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21340. * @returns false if defines are considered not dirty and have not been checked
  21341. */
  21342. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21343. /**
  21344. * Prepares the defines related to multiview
  21345. * @param scene The scene we are intending to draw
  21346. * @param defines The defines to update
  21347. */
  21348. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21349. /**
  21350. * Prepares the defines related to the prepass
  21351. * @param scene The scene we are intending to draw
  21352. * @param defines The defines to update
  21353. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21354. */
  21355. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21356. /**
  21357. * Prepares the defines related to the light information passed in parameter
  21358. * @param scene The scene we are intending to draw
  21359. * @param mesh The mesh the effect is compiling for
  21360. * @param light The light the effect is compiling for
  21361. * @param lightIndex The index of the light
  21362. * @param defines The defines to update
  21363. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21364. * @param state Defines the current state regarding what is needed (normals, etc...)
  21365. */
  21366. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21367. needNormals: boolean;
  21368. needRebuild: boolean;
  21369. shadowEnabled: boolean;
  21370. specularEnabled: boolean;
  21371. lightmapMode: boolean;
  21372. }): void;
  21373. /**
  21374. * Prepares the defines related to the light information passed in parameter
  21375. * @param scene The scene we are intending to draw
  21376. * @param mesh The mesh the effect is compiling for
  21377. * @param defines The defines to update
  21378. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21379. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21380. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21381. * @returns true if normals will be required for the rest of the effect
  21382. */
  21383. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21384. /**
  21385. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21386. * @param lightIndex defines the light index
  21387. * @param uniformsList The uniform list
  21388. * @param samplersList The sampler list
  21389. * @param projectedLightTexture defines if projected texture must be used
  21390. * @param uniformBuffersList defines an optional list of uniform buffers
  21391. */
  21392. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21393. /**
  21394. * Prepares the uniforms and samplers list to be used in the effect
  21395. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21396. * @param samplersList The sampler list
  21397. * @param defines The defines helping in the list generation
  21398. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21399. */
  21400. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21401. /**
  21402. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21403. * @param defines The defines to update while falling back
  21404. * @param fallbacks The authorized effect fallbacks
  21405. * @param maxSimultaneousLights The maximum number of lights allowed
  21406. * @param rank the current rank of the Effect
  21407. * @returns The newly affected rank
  21408. */
  21409. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21410. private static _TmpMorphInfluencers;
  21411. /**
  21412. * Prepares the list of attributes required for morph targets according to the effect defines.
  21413. * @param attribs The current list of supported attribs
  21414. * @param mesh The mesh to prepare the morph targets attributes for
  21415. * @param influencers The number of influencers
  21416. */
  21417. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21418. /**
  21419. * Prepares the list of attributes required for morph targets according to the effect defines.
  21420. * @param attribs The current list of supported attribs
  21421. * @param mesh The mesh to prepare the morph targets attributes for
  21422. * @param defines The current Defines of the effect
  21423. */
  21424. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21425. /**
  21426. * Prepares the list of attributes required for bones according to the effect defines.
  21427. * @param attribs The current list of supported attribs
  21428. * @param mesh The mesh to prepare the bones attributes for
  21429. * @param defines The current Defines of the effect
  21430. * @param fallbacks The current efffect fallback strategy
  21431. */
  21432. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21433. /**
  21434. * Check and prepare the list of attributes required for instances according to the effect defines.
  21435. * @param attribs The current list of supported attribs
  21436. * @param defines The current MaterialDefines of the effect
  21437. */
  21438. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21439. /**
  21440. * Add the list of attributes required for instances to the attribs array.
  21441. * @param attribs The current list of supported attribs
  21442. */
  21443. static PushAttributesForInstances(attribs: string[]): void;
  21444. /**
  21445. * Binds the light information to the effect.
  21446. * @param light The light containing the generator
  21447. * @param effect The effect we are binding the data to
  21448. * @param lightIndex The light index in the effect used to render
  21449. */
  21450. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21451. /**
  21452. * Binds the lights information from the scene to the effect for the given mesh.
  21453. * @param light Light to bind
  21454. * @param lightIndex Light index
  21455. * @param scene The scene where the light belongs to
  21456. * @param effect The effect we are binding the data to
  21457. * @param useSpecular Defines if specular is supported
  21458. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21459. */
  21460. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21461. /**
  21462. * Binds the lights information from the scene to the effect for the given mesh.
  21463. * @param scene The scene the lights belongs to
  21464. * @param mesh The mesh we are binding the information to render
  21465. * @param effect The effect we are binding the data to
  21466. * @param defines The generated defines for the effect
  21467. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21468. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21469. */
  21470. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21471. private static _tempFogColor;
  21472. /**
  21473. * Binds the fog information from the scene to the effect for the given mesh.
  21474. * @param scene The scene the lights belongs to
  21475. * @param mesh The mesh we are binding the information to render
  21476. * @param effect The effect we are binding the data to
  21477. * @param linearSpace Defines if the fog effect is applied in linear space
  21478. */
  21479. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21480. /**
  21481. * Binds the bones information from the mesh to the effect.
  21482. * @param mesh The mesh we are binding the information to render
  21483. * @param effect The effect we are binding the data to
  21484. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21485. */
  21486. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21487. private static _CopyBonesTransformationMatrices;
  21488. /**
  21489. * Binds the morph targets information from the mesh to the effect.
  21490. * @param abstractMesh The mesh we are binding the information to render
  21491. * @param effect The effect we are binding the data to
  21492. */
  21493. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21494. /**
  21495. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21496. * @param defines The generated defines used in the effect
  21497. * @param effect The effect we are binding the data to
  21498. * @param scene The scene we are willing to render with logarithmic scale for
  21499. */
  21500. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21501. /**
  21502. * Binds the clip plane information from the scene to the effect.
  21503. * @param scene The scene the clip plane information are extracted from
  21504. * @param effect The effect we are binding the data to
  21505. */
  21506. static BindClipPlane(effect: Effect, scene: Scene): void;
  21507. }
  21508. }
  21509. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21510. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21511. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21512. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21513. import { Nullable } from "babylonjs/types";
  21514. import { Effect } from "babylonjs/Materials/effect";
  21515. import { Matrix } from "babylonjs/Maths/math.vector";
  21516. import { Scene } from "babylonjs/scene";
  21517. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21518. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21519. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21520. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21521. import { Observable } from "babylonjs/Misc/observable";
  21522. /**
  21523. * Block used to expose an input value
  21524. */
  21525. export class InputBlock extends NodeMaterialBlock {
  21526. private _mode;
  21527. private _associatedVariableName;
  21528. private _storedValue;
  21529. private _valueCallback;
  21530. private _type;
  21531. private _animationType;
  21532. /** Gets or set a value used to limit the range of float values */
  21533. min: number;
  21534. /** Gets or set a value used to limit the range of float values */
  21535. max: number;
  21536. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21537. isBoolean: boolean;
  21538. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21539. matrixMode: number;
  21540. /** @hidden */
  21541. _systemValue: Nullable<NodeMaterialSystemValues>;
  21542. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21543. isConstant: boolean;
  21544. /** Gets or sets the group to use to display this block in the Inspector */
  21545. groupInInspector: string;
  21546. /** Gets an observable raised when the value is changed */
  21547. onValueChangedObservable: Observable<InputBlock>;
  21548. /**
  21549. * Gets or sets the connection point type (default is float)
  21550. */
  21551. get type(): NodeMaterialBlockConnectionPointTypes;
  21552. /**
  21553. * Creates a new InputBlock
  21554. * @param name defines the block name
  21555. * @param target defines the target of that block (Vertex by default)
  21556. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21557. */
  21558. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21559. /**
  21560. * Validates if a name is a reserve word.
  21561. * @param newName the new name to be given to the node.
  21562. * @returns false if the name is a reserve word, else true.
  21563. */
  21564. validateBlockName(newName: string): boolean;
  21565. /**
  21566. * Gets the output component
  21567. */
  21568. get output(): NodeMaterialConnectionPoint;
  21569. /**
  21570. * Set the source of this connection point to a vertex attribute
  21571. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21572. * @returns the current connection point
  21573. */
  21574. setAsAttribute(attributeName?: string): InputBlock;
  21575. /**
  21576. * Set the source of this connection point to a system value
  21577. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21578. * @returns the current connection point
  21579. */
  21580. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21581. /**
  21582. * Gets or sets the value of that point.
  21583. * Please note that this value will be ignored if valueCallback is defined
  21584. */
  21585. get value(): any;
  21586. set value(value: any);
  21587. /**
  21588. * Gets or sets a callback used to get the value of that point.
  21589. * Please note that setting this value will force the connection point to ignore the value property
  21590. */
  21591. get valueCallback(): () => any;
  21592. set valueCallback(value: () => any);
  21593. /**
  21594. * Gets or sets the associated variable name in the shader
  21595. */
  21596. get associatedVariableName(): string;
  21597. set associatedVariableName(value: string);
  21598. /** Gets or sets the type of animation applied to the input */
  21599. get animationType(): AnimatedInputBlockTypes;
  21600. set animationType(value: AnimatedInputBlockTypes);
  21601. /**
  21602. * Gets a boolean indicating that this connection point not defined yet
  21603. */
  21604. get isUndefined(): boolean;
  21605. /**
  21606. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21607. * In this case the connection point name must be the name of the uniform to use.
  21608. * Can only be set on inputs
  21609. */
  21610. get isUniform(): boolean;
  21611. set isUniform(value: boolean);
  21612. /**
  21613. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21614. * In this case the connection point name must be the name of the attribute to use
  21615. * Can only be set on inputs
  21616. */
  21617. get isAttribute(): boolean;
  21618. set isAttribute(value: boolean);
  21619. /**
  21620. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21621. * Can only be set on exit points
  21622. */
  21623. get isVarying(): boolean;
  21624. set isVarying(value: boolean);
  21625. /**
  21626. * Gets a boolean indicating that the current connection point is a system value
  21627. */
  21628. get isSystemValue(): boolean;
  21629. /**
  21630. * Gets or sets the current well known value or null if not defined as a system value
  21631. */
  21632. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21633. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21634. /**
  21635. * Gets the current class name
  21636. * @returns the class name
  21637. */
  21638. getClassName(): string;
  21639. /**
  21640. * Animate the input if animationType !== None
  21641. * @param scene defines the rendering scene
  21642. */
  21643. animate(scene: Scene): void;
  21644. private _emitDefine;
  21645. initialize(state: NodeMaterialBuildState): void;
  21646. /**
  21647. * Set the input block to its default value (based on its type)
  21648. */
  21649. setDefaultValue(): void;
  21650. private _emitConstant;
  21651. /** @hidden */
  21652. get _noContextSwitch(): boolean;
  21653. private _emit;
  21654. /** @hidden */
  21655. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21656. /** @hidden */
  21657. _transmit(effect: Effect, scene: Scene): void;
  21658. protected _buildBlock(state: NodeMaterialBuildState): void;
  21659. protected _dumpPropertiesCode(): string;
  21660. dispose(): void;
  21661. serialize(): any;
  21662. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21663. }
  21664. }
  21665. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21666. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21667. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21668. import { Nullable } from "babylonjs/types";
  21669. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21670. import { Observable } from "babylonjs/Misc/observable";
  21671. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21672. /**
  21673. * Enum used to define the compatibility state between two connection points
  21674. */
  21675. export enum NodeMaterialConnectionPointCompatibilityStates {
  21676. /** Points are compatibles */
  21677. Compatible = 0,
  21678. /** Points are incompatible because of their types */
  21679. TypeIncompatible = 1,
  21680. /** Points are incompatible because of their targets (vertex vs fragment) */
  21681. TargetIncompatible = 2
  21682. }
  21683. /**
  21684. * Defines the direction of a connection point
  21685. */
  21686. export enum NodeMaterialConnectionPointDirection {
  21687. /** Input */
  21688. Input = 0,
  21689. /** Output */
  21690. Output = 1
  21691. }
  21692. /**
  21693. * Defines a connection point for a block
  21694. */
  21695. export class NodeMaterialConnectionPoint {
  21696. /** @hidden */
  21697. _ownerBlock: NodeMaterialBlock;
  21698. /** @hidden */
  21699. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21700. private _endpoints;
  21701. private _associatedVariableName;
  21702. private _direction;
  21703. /** @hidden */
  21704. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21705. /** @hidden */
  21706. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21707. private _type;
  21708. /** @hidden */
  21709. _enforceAssociatedVariableName: boolean;
  21710. /** Gets the direction of the point */
  21711. get direction(): NodeMaterialConnectionPointDirection;
  21712. /** Indicates that this connection point needs dual validation before being connected to another point */
  21713. needDualDirectionValidation: boolean;
  21714. /**
  21715. * Gets or sets the additional types supported by this connection point
  21716. */
  21717. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21718. /**
  21719. * Gets or sets the additional types excluded by this connection point
  21720. */
  21721. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21722. /**
  21723. * Observable triggered when this point is connected
  21724. */
  21725. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21726. /**
  21727. * Gets or sets the associated variable name in the shader
  21728. */
  21729. get associatedVariableName(): string;
  21730. set associatedVariableName(value: string);
  21731. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21732. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21733. /**
  21734. * Gets or sets the connection point type (default is float)
  21735. */
  21736. get type(): NodeMaterialBlockConnectionPointTypes;
  21737. set type(value: NodeMaterialBlockConnectionPointTypes);
  21738. /**
  21739. * Gets or sets the connection point name
  21740. */
  21741. name: string;
  21742. /**
  21743. * Gets or sets the connection point name
  21744. */
  21745. displayName: string;
  21746. /**
  21747. * Gets or sets a boolean indicating that this connection point can be omitted
  21748. */
  21749. isOptional: boolean;
  21750. /**
  21751. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21752. */
  21753. isExposedOnFrame: boolean;
  21754. /**
  21755. * Gets or sets number indicating the position that the port is exposed to on a frame
  21756. */
  21757. exposedPortPosition: number;
  21758. /**
  21759. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21760. */
  21761. define: string;
  21762. /** @hidden */
  21763. _prioritizeVertex: boolean;
  21764. private _target;
  21765. /** Gets or sets the target of that connection point */
  21766. get target(): NodeMaterialBlockTargets;
  21767. set target(value: NodeMaterialBlockTargets);
  21768. /**
  21769. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21770. */
  21771. get isConnected(): boolean;
  21772. /**
  21773. * Gets a boolean indicating that the current point is connected to an input block
  21774. */
  21775. get isConnectedToInputBlock(): boolean;
  21776. /**
  21777. * Gets a the connected input block (if any)
  21778. */
  21779. get connectInputBlock(): Nullable<InputBlock>;
  21780. /** Get the other side of the connection (if any) */
  21781. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21782. /** Get the block that owns this connection point */
  21783. get ownerBlock(): NodeMaterialBlock;
  21784. /** Get the block connected on the other side of this connection (if any) */
  21785. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21786. /** Get the block connected on the endpoints of this connection (if any) */
  21787. get connectedBlocks(): Array<NodeMaterialBlock>;
  21788. /** Gets the list of connected endpoints */
  21789. get endpoints(): NodeMaterialConnectionPoint[];
  21790. /** Gets a boolean indicating if that output point is connected to at least one input */
  21791. get hasEndpoints(): boolean;
  21792. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21793. get isConnectedInVertexShader(): boolean;
  21794. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21795. get isConnectedInFragmentShader(): boolean;
  21796. /**
  21797. * Creates a block suitable to be used as an input for this input point.
  21798. * If null is returned, a block based on the point type will be created.
  21799. * @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
  21800. */
  21801. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21802. /**
  21803. * Creates a new connection point
  21804. * @param name defines the connection point name
  21805. * @param ownerBlock defines the block hosting this connection point
  21806. * @param direction defines the direction of the connection point
  21807. */
  21808. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21809. /**
  21810. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21811. * @returns the class name
  21812. */
  21813. getClassName(): string;
  21814. /**
  21815. * Gets a boolean indicating if the current point can be connected to another point
  21816. * @param connectionPoint defines the other connection point
  21817. * @returns a boolean
  21818. */
  21819. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21820. /**
  21821. * Gets a number indicating if the current point can be connected to another point
  21822. * @param connectionPoint defines the other connection point
  21823. * @returns a number defining the compatibility state
  21824. */
  21825. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21826. /**
  21827. * Connect this point to another connection point
  21828. * @param connectionPoint defines the other connection point
  21829. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21830. * @returns the current connection point
  21831. */
  21832. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21833. /**
  21834. * Disconnect this point from one of his endpoint
  21835. * @param endpoint defines the other connection point
  21836. * @returns the current connection point
  21837. */
  21838. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21839. /**
  21840. * Serializes this point in a JSON representation
  21841. * @param isInput defines if the connection point is an input (default is true)
  21842. * @returns the serialized point object
  21843. */
  21844. serialize(isInput?: boolean): any;
  21845. /**
  21846. * Release resources
  21847. */
  21848. dispose(): void;
  21849. }
  21850. }
  21851. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21852. /**
  21853. * Enum used to define the material modes
  21854. */
  21855. export enum NodeMaterialModes {
  21856. /** Regular material */
  21857. Material = 0,
  21858. /** For post process */
  21859. PostProcess = 1,
  21860. /** For particle system */
  21861. Particle = 2,
  21862. /** For procedural texture */
  21863. ProceduralTexture = 3
  21864. }
  21865. }
  21866. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21869. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21870. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21871. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21872. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21873. import { Effect } from "babylonjs/Materials/effect";
  21874. import { Mesh } from "babylonjs/Meshes/mesh";
  21875. import { Nullable } from "babylonjs/types";
  21876. import { Texture } from "babylonjs/Materials/Textures/texture";
  21877. import { Scene } from "babylonjs/scene";
  21878. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21879. /**
  21880. * Block used to read a texture from a sampler
  21881. */
  21882. export class TextureBlock extends NodeMaterialBlock {
  21883. private _defineName;
  21884. private _linearDefineName;
  21885. private _gammaDefineName;
  21886. private _tempTextureRead;
  21887. private _samplerName;
  21888. private _transformedUVName;
  21889. private _textureTransformName;
  21890. private _textureInfoName;
  21891. private _mainUVName;
  21892. private _mainUVDefineName;
  21893. private _fragmentOnly;
  21894. /**
  21895. * Gets or sets the texture associated with the node
  21896. */
  21897. texture: Nullable<Texture>;
  21898. /**
  21899. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21900. */
  21901. convertToGammaSpace: boolean;
  21902. /**
  21903. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21904. */
  21905. convertToLinearSpace: boolean;
  21906. /**
  21907. * Create a new TextureBlock
  21908. * @param name defines the block name
  21909. */
  21910. constructor(name: string, fragmentOnly?: boolean);
  21911. /**
  21912. * Gets the current class name
  21913. * @returns the class name
  21914. */
  21915. getClassName(): string;
  21916. /**
  21917. * Gets the uv input component
  21918. */
  21919. get uv(): NodeMaterialConnectionPoint;
  21920. /**
  21921. * Gets the rgba output component
  21922. */
  21923. get rgba(): NodeMaterialConnectionPoint;
  21924. /**
  21925. * Gets the rgb output component
  21926. */
  21927. get rgb(): NodeMaterialConnectionPoint;
  21928. /**
  21929. * Gets the r output component
  21930. */
  21931. get r(): NodeMaterialConnectionPoint;
  21932. /**
  21933. * Gets the g output component
  21934. */
  21935. get g(): NodeMaterialConnectionPoint;
  21936. /**
  21937. * Gets the b output component
  21938. */
  21939. get b(): NodeMaterialConnectionPoint;
  21940. /**
  21941. * Gets the a output component
  21942. */
  21943. get a(): NodeMaterialConnectionPoint;
  21944. get target(): NodeMaterialBlockTargets;
  21945. autoConfigure(material: NodeMaterial): void;
  21946. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21947. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21948. isReady(): boolean;
  21949. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21950. private get _isMixed();
  21951. private _injectVertexCode;
  21952. private _writeTextureRead;
  21953. private _writeOutput;
  21954. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21955. protected _dumpPropertiesCode(): string;
  21956. serialize(): any;
  21957. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21958. }
  21959. }
  21960. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21961. /** @hidden */
  21962. export var reflectionFunction: {
  21963. name: string;
  21964. shader: string;
  21965. };
  21966. }
  21967. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21971. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21972. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21973. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21974. import { Effect } from "babylonjs/Materials/effect";
  21975. import { Mesh } from "babylonjs/Meshes/mesh";
  21976. import { Nullable } from "babylonjs/types";
  21977. import { Scene } from "babylonjs/scene";
  21978. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21979. /**
  21980. * Base block used to read a reflection texture from a sampler
  21981. */
  21982. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21983. /** @hidden */
  21984. _define3DName: string;
  21985. /** @hidden */
  21986. _defineCubicName: string;
  21987. /** @hidden */
  21988. _defineExplicitName: string;
  21989. /** @hidden */
  21990. _defineProjectionName: string;
  21991. /** @hidden */
  21992. _defineLocalCubicName: string;
  21993. /** @hidden */
  21994. _defineSphericalName: string;
  21995. /** @hidden */
  21996. _definePlanarName: string;
  21997. /** @hidden */
  21998. _defineEquirectangularName: string;
  21999. /** @hidden */
  22000. _defineMirroredEquirectangularFixedName: string;
  22001. /** @hidden */
  22002. _defineEquirectangularFixedName: string;
  22003. /** @hidden */
  22004. _defineSkyboxName: string;
  22005. /** @hidden */
  22006. _defineOppositeZ: string;
  22007. /** @hidden */
  22008. _cubeSamplerName: string;
  22009. /** @hidden */
  22010. _2DSamplerName: string;
  22011. protected _positionUVWName: string;
  22012. protected _directionWName: string;
  22013. protected _reflectionVectorName: string;
  22014. /** @hidden */
  22015. _reflectionCoordsName: string;
  22016. /** @hidden */
  22017. _reflectionMatrixName: string;
  22018. protected _reflectionColorName: string;
  22019. /**
  22020. * Gets or sets the texture associated with the node
  22021. */
  22022. texture: Nullable<BaseTexture>;
  22023. /**
  22024. * Create a new ReflectionTextureBaseBlock
  22025. * @param name defines the block name
  22026. */
  22027. constructor(name: string);
  22028. /**
  22029. * Gets the current class name
  22030. * @returns the class name
  22031. */
  22032. getClassName(): string;
  22033. /**
  22034. * Gets the world position input component
  22035. */
  22036. abstract get position(): NodeMaterialConnectionPoint;
  22037. /**
  22038. * Gets the world position input component
  22039. */
  22040. abstract get worldPosition(): NodeMaterialConnectionPoint;
  22041. /**
  22042. * Gets the world normal input component
  22043. */
  22044. abstract get worldNormal(): NodeMaterialConnectionPoint;
  22045. /**
  22046. * Gets the world input component
  22047. */
  22048. abstract get world(): NodeMaterialConnectionPoint;
  22049. /**
  22050. * Gets the camera (or eye) position component
  22051. */
  22052. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  22053. /**
  22054. * Gets the view input component
  22055. */
  22056. abstract get view(): NodeMaterialConnectionPoint;
  22057. protected _getTexture(): Nullable<BaseTexture>;
  22058. autoConfigure(material: NodeMaterial): void;
  22059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22060. isReady(): boolean;
  22061. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  22062. /**
  22063. * Gets the code to inject in the vertex shader
  22064. * @param state current state of the node material building
  22065. * @returns the shader code
  22066. */
  22067. handleVertexSide(state: NodeMaterialBuildState): string;
  22068. /**
  22069. * Handles the inits for the fragment code path
  22070. * @param state node material build state
  22071. */
  22072. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  22073. /**
  22074. * Generates the reflection coords code for the fragment code path
  22075. * @param worldNormalVarName name of the world normal variable
  22076. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  22077. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  22078. * @returns the shader code
  22079. */
  22080. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  22081. /**
  22082. * Generates the reflection color code for the fragment code path
  22083. * @param lodVarName name of the lod variable
  22084. * @param swizzleLookupTexture swizzle to use for the final color variable
  22085. * @returns the shader code
  22086. */
  22087. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  22088. /**
  22089. * Generates the code corresponding to the connected output points
  22090. * @param state node material build state
  22091. * @param varName name of the variable to output
  22092. * @returns the shader code
  22093. */
  22094. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  22095. protected _buildBlock(state: NodeMaterialBuildState): this;
  22096. protected _dumpPropertiesCode(): string;
  22097. serialize(): any;
  22098. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22099. }
  22100. }
  22101. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  22102. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22103. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22104. import { Nullable } from "babylonjs/types";
  22105. /**
  22106. * Defines a connection point to be used for points with a custom object type
  22107. */
  22108. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  22109. private _blockType;
  22110. private _blockName;
  22111. private _nameForCheking?;
  22112. /**
  22113. * Creates a new connection point
  22114. * @param name defines the connection point name
  22115. * @param ownerBlock defines the block hosting this connection point
  22116. * @param direction defines the direction of the connection point
  22117. */
  22118. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  22119. /**
  22120. * Gets a number indicating if the current point can be connected to another point
  22121. * @param connectionPoint defines the other connection point
  22122. * @returns a number defining the compatibility state
  22123. */
  22124. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  22125. /**
  22126. * Creates a block suitable to be used as an input for this input point.
  22127. * If null is returned, a block based on the point type will be created.
  22128. * @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
  22129. */
  22130. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  22131. }
  22132. }
  22133. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  22134. /**
  22135. * Enum defining the type of properties that can be edited in the property pages in the NME
  22136. */
  22137. export enum PropertyTypeForEdition {
  22138. /** property is a boolean */
  22139. Boolean = 0,
  22140. /** property is a float */
  22141. Float = 1,
  22142. /** property is a Vector2 */
  22143. Vector2 = 2,
  22144. /** property is a list of values */
  22145. List = 3
  22146. }
  22147. /**
  22148. * Interface that defines an option in a variable of type list
  22149. */
  22150. export interface IEditablePropertyListOption {
  22151. /** label of the option */
  22152. "label": string;
  22153. /** value of the option */
  22154. "value": number;
  22155. }
  22156. /**
  22157. * Interface that defines the options available for an editable property
  22158. */
  22159. export interface IEditablePropertyOption {
  22160. /** min value */
  22161. "min"?: number;
  22162. /** max value */
  22163. "max"?: number;
  22164. /** notifiers: indicates which actions to take when the property is changed */
  22165. "notifiers"?: {
  22166. /** the material should be rebuilt */
  22167. "rebuild"?: boolean;
  22168. /** the preview should be updated */
  22169. "update"?: boolean;
  22170. };
  22171. /** list of the options for a variable of type list */
  22172. "options"?: IEditablePropertyListOption[];
  22173. }
  22174. /**
  22175. * Interface that describes an editable property
  22176. */
  22177. export interface IPropertyDescriptionForEdition {
  22178. /** name of the property */
  22179. "propertyName": string;
  22180. /** display name of the property */
  22181. "displayName": string;
  22182. /** type of the property */
  22183. "type": PropertyTypeForEdition;
  22184. /** group of the property - all properties with the same group value will be displayed in a specific section */
  22185. "groupName": string;
  22186. /** options for the property */
  22187. "options": IEditablePropertyOption;
  22188. }
  22189. /**
  22190. * Decorator that flags a property in a node material block as being editable
  22191. */
  22192. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  22193. }
  22194. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  22195. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22196. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22197. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22199. import { Nullable } from "babylonjs/types";
  22200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22201. import { Mesh } from "babylonjs/Meshes/mesh";
  22202. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22203. import { Effect } from "babylonjs/Materials/effect";
  22204. import { Scene } from "babylonjs/scene";
  22205. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22206. /**
  22207. * Block used to implement the refraction part of the sub surface module of the PBR material
  22208. */
  22209. export class RefractionBlock extends NodeMaterialBlock {
  22210. /** @hidden */
  22211. _define3DName: string;
  22212. /** @hidden */
  22213. _refractionMatrixName: string;
  22214. /** @hidden */
  22215. _defineLODRefractionAlpha: string;
  22216. /** @hidden */
  22217. _defineLinearSpecularRefraction: string;
  22218. /** @hidden */
  22219. _defineOppositeZ: string;
  22220. /** @hidden */
  22221. _cubeSamplerName: string;
  22222. /** @hidden */
  22223. _2DSamplerName: string;
  22224. /** @hidden */
  22225. _vRefractionMicrosurfaceInfosName: string;
  22226. /** @hidden */
  22227. _vRefractionInfosName: string;
  22228. private _scene;
  22229. /**
  22230. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  22231. * Materials half opaque for instance using refraction could benefit from this control.
  22232. */
  22233. linkRefractionWithTransparency: boolean;
  22234. /**
  22235. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  22236. */
  22237. invertRefractionY: boolean;
  22238. /**
  22239. * Gets or sets the texture associated with the node
  22240. */
  22241. texture: Nullable<BaseTexture>;
  22242. /**
  22243. * Create a new RefractionBlock
  22244. * @param name defines the block name
  22245. */
  22246. constructor(name: string);
  22247. /**
  22248. * Gets the current class name
  22249. * @returns the class name
  22250. */
  22251. getClassName(): string;
  22252. /**
  22253. * Gets the intensity input component
  22254. */
  22255. get intensity(): NodeMaterialConnectionPoint;
  22256. /**
  22257. * Gets the index of refraction input component
  22258. */
  22259. get indexOfRefraction(): NodeMaterialConnectionPoint;
  22260. /**
  22261. * Gets the tint at distance input component
  22262. */
  22263. get tintAtDistance(): NodeMaterialConnectionPoint;
  22264. /**
  22265. * Gets the view input component
  22266. */
  22267. get view(): NodeMaterialConnectionPoint;
  22268. /**
  22269. * Gets the refraction object output component
  22270. */
  22271. get refraction(): NodeMaterialConnectionPoint;
  22272. /**
  22273. * Returns true if the block has a texture
  22274. */
  22275. get hasTexture(): boolean;
  22276. protected _getTexture(): Nullable<BaseTexture>;
  22277. autoConfigure(material: NodeMaterial): void;
  22278. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22279. isReady(): boolean;
  22280. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22281. /**
  22282. * Gets the main code of the block (fragment side)
  22283. * @param state current state of the node material building
  22284. * @returns the shader code
  22285. */
  22286. getCode(state: NodeMaterialBuildState): string;
  22287. protected _buildBlock(state: NodeMaterialBuildState): this;
  22288. protected _dumpPropertiesCode(): string;
  22289. serialize(): any;
  22290. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22291. }
  22292. }
  22293. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  22294. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22295. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22296. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22297. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22298. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22299. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22300. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22301. import { Nullable } from "babylonjs/types";
  22302. import { Scene } from "babylonjs/scene";
  22303. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22304. /**
  22305. * Base block used as input for post process
  22306. */
  22307. export class CurrentScreenBlock extends NodeMaterialBlock {
  22308. private _samplerName;
  22309. private _linearDefineName;
  22310. private _gammaDefineName;
  22311. private _mainUVName;
  22312. private _tempTextureRead;
  22313. /**
  22314. * Gets or sets the texture associated with the node
  22315. */
  22316. texture: Nullable<BaseTexture>;
  22317. /**
  22318. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22319. */
  22320. convertToGammaSpace: boolean;
  22321. /**
  22322. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22323. */
  22324. convertToLinearSpace: boolean;
  22325. /**
  22326. * Create a new CurrentScreenBlock
  22327. * @param name defines the block name
  22328. */
  22329. constructor(name: string);
  22330. /**
  22331. * Gets the current class name
  22332. * @returns the class name
  22333. */
  22334. getClassName(): string;
  22335. /**
  22336. * Gets the uv input component
  22337. */
  22338. get uv(): NodeMaterialConnectionPoint;
  22339. /**
  22340. * Gets the rgba output component
  22341. */
  22342. get rgba(): NodeMaterialConnectionPoint;
  22343. /**
  22344. * Gets the rgb output component
  22345. */
  22346. get rgb(): NodeMaterialConnectionPoint;
  22347. /**
  22348. * Gets the r output component
  22349. */
  22350. get r(): NodeMaterialConnectionPoint;
  22351. /**
  22352. * Gets the g output component
  22353. */
  22354. get g(): NodeMaterialConnectionPoint;
  22355. /**
  22356. * Gets the b output component
  22357. */
  22358. get b(): NodeMaterialConnectionPoint;
  22359. /**
  22360. * Gets the a output component
  22361. */
  22362. get a(): NodeMaterialConnectionPoint;
  22363. /**
  22364. * Initialize the block and prepare the context for build
  22365. * @param state defines the state that will be used for the build
  22366. */
  22367. initialize(state: NodeMaterialBuildState): void;
  22368. get target(): NodeMaterialBlockTargets;
  22369. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22370. isReady(): boolean;
  22371. private _injectVertexCode;
  22372. private _writeTextureRead;
  22373. private _writeOutput;
  22374. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22375. serialize(): any;
  22376. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22377. }
  22378. }
  22379. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22380. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22381. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22382. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22384. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22385. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22386. import { Nullable } from "babylonjs/types";
  22387. import { Scene } from "babylonjs/scene";
  22388. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22389. /**
  22390. * Base block used for the particle texture
  22391. */
  22392. export class ParticleTextureBlock extends NodeMaterialBlock {
  22393. private _samplerName;
  22394. private _linearDefineName;
  22395. private _gammaDefineName;
  22396. private _tempTextureRead;
  22397. /**
  22398. * Gets or sets the texture associated with the node
  22399. */
  22400. texture: Nullable<BaseTexture>;
  22401. /**
  22402. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22403. */
  22404. convertToGammaSpace: boolean;
  22405. /**
  22406. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22407. */
  22408. convertToLinearSpace: boolean;
  22409. /**
  22410. * Create a new ParticleTextureBlock
  22411. * @param name defines the block name
  22412. */
  22413. constructor(name: string);
  22414. /**
  22415. * Gets the current class name
  22416. * @returns the class name
  22417. */
  22418. getClassName(): string;
  22419. /**
  22420. * Gets the uv input component
  22421. */
  22422. get uv(): NodeMaterialConnectionPoint;
  22423. /**
  22424. * Gets the rgba output component
  22425. */
  22426. get rgba(): NodeMaterialConnectionPoint;
  22427. /**
  22428. * Gets the rgb output component
  22429. */
  22430. get rgb(): NodeMaterialConnectionPoint;
  22431. /**
  22432. * Gets the r output component
  22433. */
  22434. get r(): NodeMaterialConnectionPoint;
  22435. /**
  22436. * Gets the g output component
  22437. */
  22438. get g(): NodeMaterialConnectionPoint;
  22439. /**
  22440. * Gets the b output component
  22441. */
  22442. get b(): NodeMaterialConnectionPoint;
  22443. /**
  22444. * Gets the a output component
  22445. */
  22446. get a(): NodeMaterialConnectionPoint;
  22447. /**
  22448. * Initialize the block and prepare the context for build
  22449. * @param state defines the state that will be used for the build
  22450. */
  22451. initialize(state: NodeMaterialBuildState): void;
  22452. autoConfigure(material: NodeMaterial): void;
  22453. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22454. isReady(): boolean;
  22455. private _writeOutput;
  22456. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22457. serialize(): any;
  22458. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22459. }
  22460. }
  22461. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22462. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22463. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22464. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22465. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22466. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22467. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22468. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22469. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22470. import { Scene } from "babylonjs/scene";
  22471. /**
  22472. * Class used to store shared data between 2 NodeMaterialBuildState
  22473. */
  22474. export class NodeMaterialBuildStateSharedData {
  22475. /**
  22476. * Gets the list of emitted varyings
  22477. */
  22478. temps: string[];
  22479. /**
  22480. * Gets the list of emitted varyings
  22481. */
  22482. varyings: string[];
  22483. /**
  22484. * Gets the varying declaration string
  22485. */
  22486. varyingDeclaration: string;
  22487. /**
  22488. * Input blocks
  22489. */
  22490. inputBlocks: InputBlock[];
  22491. /**
  22492. * Input blocks
  22493. */
  22494. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22495. /**
  22496. * Bindable blocks (Blocks that need to set data to the effect)
  22497. */
  22498. bindableBlocks: NodeMaterialBlock[];
  22499. /**
  22500. * List of blocks that can provide a compilation fallback
  22501. */
  22502. blocksWithFallbacks: NodeMaterialBlock[];
  22503. /**
  22504. * List of blocks that can provide a define update
  22505. */
  22506. blocksWithDefines: NodeMaterialBlock[];
  22507. /**
  22508. * List of blocks that can provide a repeatable content
  22509. */
  22510. repeatableContentBlocks: NodeMaterialBlock[];
  22511. /**
  22512. * List of blocks that can provide a dynamic list of uniforms
  22513. */
  22514. dynamicUniformBlocks: NodeMaterialBlock[];
  22515. /**
  22516. * List of blocks that can block the isReady function for the material
  22517. */
  22518. blockingBlocks: NodeMaterialBlock[];
  22519. /**
  22520. * Gets the list of animated inputs
  22521. */
  22522. animatedInputs: InputBlock[];
  22523. /**
  22524. * Build Id used to avoid multiple recompilations
  22525. */
  22526. buildId: number;
  22527. /** List of emitted variables */
  22528. variableNames: {
  22529. [key: string]: number;
  22530. };
  22531. /** List of emitted defines */
  22532. defineNames: {
  22533. [key: string]: number;
  22534. };
  22535. /** Should emit comments? */
  22536. emitComments: boolean;
  22537. /** Emit build activity */
  22538. verbose: boolean;
  22539. /** Gets or sets the hosting scene */
  22540. scene: Scene;
  22541. /**
  22542. * Gets the compilation hints emitted at compilation time
  22543. */
  22544. hints: {
  22545. needWorldViewMatrix: boolean;
  22546. needWorldViewProjectionMatrix: boolean;
  22547. needAlphaBlending: boolean;
  22548. needAlphaTesting: boolean;
  22549. };
  22550. /**
  22551. * List of compilation checks
  22552. */
  22553. checks: {
  22554. emitVertex: boolean;
  22555. emitFragment: boolean;
  22556. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22557. };
  22558. /**
  22559. * Is vertex program allowed to be empty?
  22560. */
  22561. allowEmptyVertexProgram: boolean;
  22562. /** Creates a new shared data */
  22563. constructor();
  22564. /**
  22565. * Emits console errors and exceptions if there is a failing check
  22566. */
  22567. emitErrors(): void;
  22568. }
  22569. }
  22570. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22571. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22572. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22573. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22574. /**
  22575. * Class used to store node based material build state
  22576. */
  22577. export class NodeMaterialBuildState {
  22578. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22579. supportUniformBuffers: boolean;
  22580. /**
  22581. * Gets the list of emitted attributes
  22582. */
  22583. attributes: string[];
  22584. /**
  22585. * Gets the list of emitted uniforms
  22586. */
  22587. uniforms: string[];
  22588. /**
  22589. * Gets the list of emitted constants
  22590. */
  22591. constants: string[];
  22592. /**
  22593. * Gets the list of emitted samplers
  22594. */
  22595. samplers: string[];
  22596. /**
  22597. * Gets the list of emitted functions
  22598. */
  22599. functions: {
  22600. [key: string]: string;
  22601. };
  22602. /**
  22603. * Gets the list of emitted extensions
  22604. */
  22605. extensions: {
  22606. [key: string]: string;
  22607. };
  22608. /**
  22609. * Gets the target of the compilation state
  22610. */
  22611. target: NodeMaterialBlockTargets;
  22612. /**
  22613. * Gets the list of emitted counters
  22614. */
  22615. counters: {
  22616. [key: string]: number;
  22617. };
  22618. /**
  22619. * Shared data between multiple NodeMaterialBuildState instances
  22620. */
  22621. sharedData: NodeMaterialBuildStateSharedData;
  22622. /** @hidden */
  22623. _vertexState: NodeMaterialBuildState;
  22624. /** @hidden */
  22625. _attributeDeclaration: string;
  22626. /** @hidden */
  22627. _uniformDeclaration: string;
  22628. /** @hidden */
  22629. _constantDeclaration: string;
  22630. /** @hidden */
  22631. _samplerDeclaration: string;
  22632. /** @hidden */
  22633. _varyingTransfer: string;
  22634. /** @hidden */
  22635. _injectAtEnd: string;
  22636. private _repeatableContentAnchorIndex;
  22637. /** @hidden */
  22638. _builtCompilationString: string;
  22639. /**
  22640. * Gets the emitted compilation strings
  22641. */
  22642. compilationString: string;
  22643. /**
  22644. * Finalize the compilation strings
  22645. * @param state defines the current compilation state
  22646. */
  22647. finalize(state: NodeMaterialBuildState): void;
  22648. /** @hidden */
  22649. get _repeatableContentAnchor(): string;
  22650. /** @hidden */
  22651. _getFreeVariableName(prefix: string): string;
  22652. /** @hidden */
  22653. _getFreeDefineName(prefix: string): string;
  22654. /** @hidden */
  22655. _excludeVariableName(name: string): void;
  22656. /** @hidden */
  22657. _emit2DSampler(name: string): void;
  22658. /** @hidden */
  22659. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22660. /** @hidden */
  22661. _emitExtension(name: string, extension: string, define?: string): void;
  22662. /** @hidden */
  22663. _emitFunction(name: string, code: string, comments: string): void;
  22664. /** @hidden */
  22665. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22666. replaceStrings?: {
  22667. search: RegExp;
  22668. replace: string;
  22669. }[];
  22670. repeatKey?: string;
  22671. }): string;
  22672. /** @hidden */
  22673. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22674. repeatKey?: string;
  22675. removeAttributes?: boolean;
  22676. removeUniforms?: boolean;
  22677. removeVaryings?: boolean;
  22678. removeIfDef?: boolean;
  22679. replaceStrings?: {
  22680. search: RegExp;
  22681. replace: string;
  22682. }[];
  22683. }, storeKey?: string): void;
  22684. /** @hidden */
  22685. _registerTempVariable(name: string): boolean;
  22686. /** @hidden */
  22687. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22688. /** @hidden */
  22689. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22690. /** @hidden */
  22691. _emitFloat(value: number): string;
  22692. }
  22693. }
  22694. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22695. /**
  22696. * Helper class used to generate session unique ID
  22697. */
  22698. export class UniqueIdGenerator {
  22699. private static _UniqueIdCounter;
  22700. /**
  22701. * Gets an unique (relatively to the current scene) Id
  22702. */
  22703. static get UniqueId(): number;
  22704. }
  22705. }
  22706. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22707. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22708. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22709. import { Nullable } from "babylonjs/types";
  22710. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22711. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22712. import { Effect } from "babylonjs/Materials/effect";
  22713. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22714. import { Mesh } from "babylonjs/Meshes/mesh";
  22715. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22716. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22717. import { Scene } from "babylonjs/scene";
  22718. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22719. /**
  22720. * Defines a block that can be used inside a node based material
  22721. */
  22722. export class NodeMaterialBlock {
  22723. private _buildId;
  22724. private _buildTarget;
  22725. private _target;
  22726. private _isFinalMerger;
  22727. private _isInput;
  22728. private _name;
  22729. protected _isUnique: boolean;
  22730. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22731. inputsAreExclusive: boolean;
  22732. /** @hidden */
  22733. _codeVariableName: string;
  22734. /** @hidden */
  22735. _inputs: NodeMaterialConnectionPoint[];
  22736. /** @hidden */
  22737. _outputs: NodeMaterialConnectionPoint[];
  22738. /** @hidden */
  22739. _preparationId: number;
  22740. /**
  22741. * Gets the name of the block
  22742. */
  22743. get name(): string;
  22744. /**
  22745. * Sets the name of the block. Will check if the name is valid.
  22746. */
  22747. set name(newName: string);
  22748. /**
  22749. * Gets or sets the unique id of the node
  22750. */
  22751. uniqueId: number;
  22752. /**
  22753. * Gets or sets the comments associated with this block
  22754. */
  22755. comments: string;
  22756. /**
  22757. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22758. */
  22759. get isUnique(): boolean;
  22760. /**
  22761. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22762. */
  22763. get isFinalMerger(): boolean;
  22764. /**
  22765. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22766. */
  22767. get isInput(): boolean;
  22768. /**
  22769. * Gets or sets the build Id
  22770. */
  22771. get buildId(): number;
  22772. set buildId(value: number);
  22773. /**
  22774. * Gets or sets the target of the block
  22775. */
  22776. get target(): NodeMaterialBlockTargets;
  22777. set target(value: NodeMaterialBlockTargets);
  22778. /**
  22779. * Gets the list of input points
  22780. */
  22781. get inputs(): NodeMaterialConnectionPoint[];
  22782. /** Gets the list of output points */
  22783. get outputs(): NodeMaterialConnectionPoint[];
  22784. /**
  22785. * Find an input by its name
  22786. * @param name defines the name of the input to look for
  22787. * @returns the input or null if not found
  22788. */
  22789. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22790. /**
  22791. * Find an output by its name
  22792. * @param name defines the name of the outputto look for
  22793. * @returns the output or null if not found
  22794. */
  22795. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22796. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22797. visibleInInspector: boolean;
  22798. /**
  22799. * Creates a new NodeMaterialBlock
  22800. * @param name defines the block name
  22801. * @param target defines the target of that block (Vertex by default)
  22802. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22803. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22804. */
  22805. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22806. /**
  22807. * Initialize the block and prepare the context for build
  22808. * @param state defines the state that will be used for the build
  22809. */
  22810. initialize(state: NodeMaterialBuildState): void;
  22811. /**
  22812. * Bind data to effect. Will only be called for blocks with isBindable === true
  22813. * @param effect defines the effect to bind data to
  22814. * @param nodeMaterial defines the hosting NodeMaterial
  22815. * @param mesh defines the mesh that will be rendered
  22816. * @param subMesh defines the submesh that will be rendered
  22817. */
  22818. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22819. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22820. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22821. protected _writeFloat(value: number): string;
  22822. /**
  22823. * Gets the current class name e.g. "NodeMaterialBlock"
  22824. * @returns the class name
  22825. */
  22826. getClassName(): string;
  22827. /**
  22828. * Register a new input. Must be called inside a block constructor
  22829. * @param name defines the connection point name
  22830. * @param type defines the connection point type
  22831. * @param isOptional defines a boolean indicating that this input can be omitted
  22832. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22833. * @param point an already created connection point. If not provided, create a new one
  22834. * @returns the current block
  22835. */
  22836. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22837. /**
  22838. * Register a new output. Must be called inside a block constructor
  22839. * @param name defines the connection point name
  22840. * @param type defines the connection point type
  22841. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22842. * @param point an already created connection point. If not provided, create a new one
  22843. * @returns the current block
  22844. */
  22845. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22846. /**
  22847. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22848. * @param forOutput defines an optional connection point to check compatibility with
  22849. * @returns the first available input or null
  22850. */
  22851. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22852. /**
  22853. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22854. * @param forBlock defines an optional block to check compatibility with
  22855. * @returns the first available input or null
  22856. */
  22857. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22858. /**
  22859. * Gets the sibling of the given output
  22860. * @param current defines the current output
  22861. * @returns the next output in the list or null
  22862. */
  22863. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22864. /**
  22865. * Connect current block with another block
  22866. * @param other defines the block to connect with
  22867. * @param options define the various options to help pick the right connections
  22868. * @returns the current block
  22869. */
  22870. connectTo(other: NodeMaterialBlock, options?: {
  22871. input?: string;
  22872. output?: string;
  22873. outputSwizzle?: string;
  22874. }): this | undefined;
  22875. protected _buildBlock(state: NodeMaterialBuildState): void;
  22876. /**
  22877. * Add uniforms, samplers and uniform buffers at compilation time
  22878. * @param state defines the state to update
  22879. * @param nodeMaterial defines the node material requesting the update
  22880. * @param defines defines the material defines to update
  22881. * @param uniformBuffers defines the list of uniform buffer names
  22882. */
  22883. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22884. /**
  22885. * Add potential fallbacks if shader compilation fails
  22886. * @param mesh defines the mesh to be rendered
  22887. * @param fallbacks defines the current prioritized list of fallbacks
  22888. */
  22889. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22890. /**
  22891. * Initialize defines for shader compilation
  22892. * @param mesh defines the mesh to be rendered
  22893. * @param nodeMaterial defines the node material requesting the update
  22894. * @param defines defines the material defines to update
  22895. * @param useInstances specifies that instances should be used
  22896. */
  22897. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22898. /**
  22899. * Update defines for shader compilation
  22900. * @param mesh defines the mesh to be rendered
  22901. * @param nodeMaterial defines the node material requesting the update
  22902. * @param defines defines the material defines to update
  22903. * @param useInstances specifies that instances should be used
  22904. * @param subMesh defines which submesh to render
  22905. */
  22906. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22907. /**
  22908. * Lets the block try to connect some inputs automatically
  22909. * @param material defines the hosting NodeMaterial
  22910. */
  22911. autoConfigure(material: NodeMaterial): void;
  22912. /**
  22913. * Function called when a block is declared as repeatable content generator
  22914. * @param vertexShaderState defines the current compilation state for the vertex shader
  22915. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22916. * @param mesh defines the mesh to be rendered
  22917. * @param defines defines the material defines to update
  22918. */
  22919. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22920. /**
  22921. * Checks if the block is ready
  22922. * @param mesh defines the mesh to be rendered
  22923. * @param nodeMaterial defines the node material requesting the update
  22924. * @param defines defines the material defines to update
  22925. * @param useInstances specifies that instances should be used
  22926. * @returns true if the block is ready
  22927. */
  22928. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22929. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22930. private _processBuild;
  22931. /**
  22932. * Validates the new name for the block node.
  22933. * @param newName the new name to be given to the node.
  22934. * @returns false if the name is a reserve word, else true.
  22935. */
  22936. validateBlockName(newName: string): boolean;
  22937. /**
  22938. * Compile the current node and generate the shader code
  22939. * @param state defines the current compilation state (uniforms, samplers, current string)
  22940. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22941. * @returns true if already built
  22942. */
  22943. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22944. protected _inputRename(name: string): string;
  22945. protected _outputRename(name: string): string;
  22946. protected _dumpPropertiesCode(): string;
  22947. /** @hidden */
  22948. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22949. /** @hidden */
  22950. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22951. /**
  22952. * Clone the current block to a new identical block
  22953. * @param scene defines the hosting scene
  22954. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22955. * @returns a copy of the current block
  22956. */
  22957. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22958. /**
  22959. * Serializes this block in a JSON representation
  22960. * @returns the serialized block object
  22961. */
  22962. serialize(): any;
  22963. /** @hidden */
  22964. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22965. private _deserializePortDisplayNamesAndExposedOnFrame;
  22966. /**
  22967. * Release resources
  22968. */
  22969. dispose(): void;
  22970. }
  22971. }
  22972. declare module "babylonjs/Materials/pushMaterial" {
  22973. import { Nullable } from "babylonjs/types";
  22974. import { Scene } from "babylonjs/scene";
  22975. import { Matrix } from "babylonjs/Maths/math.vector";
  22976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22977. import { Mesh } from "babylonjs/Meshes/mesh";
  22978. import { Material } from "babylonjs/Materials/material";
  22979. import { Effect } from "babylonjs/Materials/effect";
  22980. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22981. /**
  22982. * Base class of materials working in push mode in babylon JS
  22983. * @hidden
  22984. */
  22985. export class PushMaterial extends Material {
  22986. protected _activeEffect: Effect;
  22987. protected _normalMatrix: Matrix;
  22988. constructor(name: string, scene: Scene);
  22989. getEffect(): Effect;
  22990. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22991. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22992. /**
  22993. * Binds the given world matrix to the active effect
  22994. *
  22995. * @param world the matrix to bind
  22996. */
  22997. bindOnlyWorldMatrix(world: Matrix): void;
  22998. /**
  22999. * Binds the given normal matrix to the active effect
  23000. *
  23001. * @param normalMatrix the matrix to bind
  23002. */
  23003. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  23004. bind(world: Matrix, mesh?: Mesh): void;
  23005. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  23006. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  23007. }
  23008. }
  23009. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  23010. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23011. /**
  23012. * Root class for all node material optimizers
  23013. */
  23014. export class NodeMaterialOptimizer {
  23015. /**
  23016. * Function used to optimize a NodeMaterial graph
  23017. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  23018. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  23019. */
  23020. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  23021. }
  23022. }
  23023. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  23024. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23025. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23026. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23027. import { Scene } from "babylonjs/scene";
  23028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23029. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  23030. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23031. /**
  23032. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  23033. */
  23034. export class TransformBlock extends NodeMaterialBlock {
  23035. /**
  23036. * Defines the value to use to complement W value to transform it to a Vector4
  23037. */
  23038. complementW: number;
  23039. /**
  23040. * Defines the value to use to complement z value to transform it to a Vector4
  23041. */
  23042. complementZ: number;
  23043. /**
  23044. * Creates a new TransformBlock
  23045. * @param name defines the block name
  23046. */
  23047. constructor(name: string);
  23048. /**
  23049. * Gets the current class name
  23050. * @returns the class name
  23051. */
  23052. getClassName(): string;
  23053. /**
  23054. * Gets the vector input
  23055. */
  23056. get vector(): NodeMaterialConnectionPoint;
  23057. /**
  23058. * Gets the output component
  23059. */
  23060. get output(): NodeMaterialConnectionPoint;
  23061. /**
  23062. * Gets the xyz output component
  23063. */
  23064. get xyz(): NodeMaterialConnectionPoint;
  23065. /**
  23066. * Gets the matrix transform input
  23067. */
  23068. get transform(): NodeMaterialConnectionPoint;
  23069. protected _buildBlock(state: NodeMaterialBuildState): this;
  23070. /**
  23071. * Update defines for shader compilation
  23072. * @param mesh defines the mesh to be rendered
  23073. * @param nodeMaterial defines the node material requesting the update
  23074. * @param defines defines the material defines to update
  23075. * @param useInstances specifies that instances should be used
  23076. * @param subMesh defines which submesh to render
  23077. */
  23078. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  23079. serialize(): any;
  23080. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23081. protected _dumpPropertiesCode(): string;
  23082. }
  23083. }
  23084. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  23085. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23086. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23087. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23088. /**
  23089. * Block used to output the vertex position
  23090. */
  23091. export class VertexOutputBlock extends NodeMaterialBlock {
  23092. /**
  23093. * Creates a new VertexOutputBlock
  23094. * @param name defines the block name
  23095. */
  23096. constructor(name: string);
  23097. /**
  23098. * Gets the current class name
  23099. * @returns the class name
  23100. */
  23101. getClassName(): string;
  23102. /**
  23103. * Gets the vector input component
  23104. */
  23105. get vector(): NodeMaterialConnectionPoint;
  23106. protected _buildBlock(state: NodeMaterialBuildState): this;
  23107. }
  23108. }
  23109. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  23110. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23111. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23112. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23113. /**
  23114. * Block used to output the final color
  23115. */
  23116. export class FragmentOutputBlock extends NodeMaterialBlock {
  23117. /**
  23118. * Create a new FragmentOutputBlock
  23119. * @param name defines the block name
  23120. */
  23121. constructor(name: string);
  23122. /**
  23123. * Gets the current class name
  23124. * @returns the class name
  23125. */
  23126. getClassName(): string;
  23127. /**
  23128. * Gets the rgba input component
  23129. */
  23130. get rgba(): NodeMaterialConnectionPoint;
  23131. /**
  23132. * Gets the rgb input component
  23133. */
  23134. get rgb(): NodeMaterialConnectionPoint;
  23135. /**
  23136. * Gets the a input component
  23137. */
  23138. get a(): NodeMaterialConnectionPoint;
  23139. protected _buildBlock(state: NodeMaterialBuildState): this;
  23140. }
  23141. }
  23142. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  23143. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23144. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23145. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23146. /**
  23147. * Block used for the particle ramp gradient section
  23148. */
  23149. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  23150. /**
  23151. * Create a new ParticleRampGradientBlock
  23152. * @param name defines the block name
  23153. */
  23154. constructor(name: string);
  23155. /**
  23156. * Gets the current class name
  23157. * @returns the class name
  23158. */
  23159. getClassName(): string;
  23160. /**
  23161. * Gets the color input component
  23162. */
  23163. get color(): NodeMaterialConnectionPoint;
  23164. /**
  23165. * Gets the rampColor output component
  23166. */
  23167. get rampColor(): NodeMaterialConnectionPoint;
  23168. /**
  23169. * Initialize the block and prepare the context for build
  23170. * @param state defines the state that will be used for the build
  23171. */
  23172. initialize(state: NodeMaterialBuildState): void;
  23173. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23174. }
  23175. }
  23176. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  23177. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23178. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23179. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23180. /**
  23181. * Block used for the particle blend multiply section
  23182. */
  23183. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  23184. /**
  23185. * Create a new ParticleBlendMultiplyBlock
  23186. * @param name defines the block name
  23187. */
  23188. constructor(name: string);
  23189. /**
  23190. * Gets the current class name
  23191. * @returns the class name
  23192. */
  23193. getClassName(): string;
  23194. /**
  23195. * Gets the color input component
  23196. */
  23197. get color(): NodeMaterialConnectionPoint;
  23198. /**
  23199. * Gets the alphaTexture input component
  23200. */
  23201. get alphaTexture(): NodeMaterialConnectionPoint;
  23202. /**
  23203. * Gets the alphaColor input component
  23204. */
  23205. get alphaColor(): NodeMaterialConnectionPoint;
  23206. /**
  23207. * Gets the blendColor output component
  23208. */
  23209. get blendColor(): NodeMaterialConnectionPoint;
  23210. /**
  23211. * Initialize the block and prepare the context for build
  23212. * @param state defines the state that will be used for the build
  23213. */
  23214. initialize(state: NodeMaterialBuildState): void;
  23215. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23216. }
  23217. }
  23218. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  23219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23221. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23222. /**
  23223. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  23224. */
  23225. export class VectorMergerBlock extends NodeMaterialBlock {
  23226. /**
  23227. * Create a new VectorMergerBlock
  23228. * @param name defines the block name
  23229. */
  23230. constructor(name: string);
  23231. /**
  23232. * Gets the current class name
  23233. * @returns the class name
  23234. */
  23235. getClassName(): string;
  23236. /**
  23237. * Gets the xyz component (input)
  23238. */
  23239. get xyzIn(): NodeMaterialConnectionPoint;
  23240. /**
  23241. * Gets the xy component (input)
  23242. */
  23243. get xyIn(): NodeMaterialConnectionPoint;
  23244. /**
  23245. * Gets the x component (input)
  23246. */
  23247. get x(): NodeMaterialConnectionPoint;
  23248. /**
  23249. * Gets the y component (input)
  23250. */
  23251. get y(): NodeMaterialConnectionPoint;
  23252. /**
  23253. * Gets the z component (input)
  23254. */
  23255. get z(): NodeMaterialConnectionPoint;
  23256. /**
  23257. * Gets the w component (input)
  23258. */
  23259. get w(): NodeMaterialConnectionPoint;
  23260. /**
  23261. * Gets the xyzw component (output)
  23262. */
  23263. get xyzw(): NodeMaterialConnectionPoint;
  23264. /**
  23265. * Gets the xyz component (output)
  23266. */
  23267. get xyzOut(): NodeMaterialConnectionPoint;
  23268. /**
  23269. * Gets the xy component (output)
  23270. */
  23271. get xyOut(): NodeMaterialConnectionPoint;
  23272. /**
  23273. * Gets the xy component (output)
  23274. * @deprecated Please use xyOut instead.
  23275. */
  23276. get xy(): NodeMaterialConnectionPoint;
  23277. /**
  23278. * Gets the xyz component (output)
  23279. * @deprecated Please use xyzOut instead.
  23280. */
  23281. get xyz(): NodeMaterialConnectionPoint;
  23282. protected _buildBlock(state: NodeMaterialBuildState): this;
  23283. }
  23284. }
  23285. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  23286. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23287. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23288. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23289. import { Vector2 } from "babylonjs/Maths/math.vector";
  23290. import { Scene } from "babylonjs/scene";
  23291. /**
  23292. * Block used to remap a float from a range to a new one
  23293. */
  23294. export class RemapBlock extends NodeMaterialBlock {
  23295. /**
  23296. * Gets or sets the source range
  23297. */
  23298. sourceRange: Vector2;
  23299. /**
  23300. * Gets or sets the target range
  23301. */
  23302. targetRange: Vector2;
  23303. /**
  23304. * Creates a new RemapBlock
  23305. * @param name defines the block name
  23306. */
  23307. constructor(name: string);
  23308. /**
  23309. * Gets the current class name
  23310. * @returns the class name
  23311. */
  23312. getClassName(): string;
  23313. /**
  23314. * Gets the input component
  23315. */
  23316. get input(): NodeMaterialConnectionPoint;
  23317. /**
  23318. * Gets the source min input component
  23319. */
  23320. get sourceMin(): NodeMaterialConnectionPoint;
  23321. /**
  23322. * Gets the source max input component
  23323. */
  23324. get sourceMax(): NodeMaterialConnectionPoint;
  23325. /**
  23326. * Gets the target min input component
  23327. */
  23328. get targetMin(): NodeMaterialConnectionPoint;
  23329. /**
  23330. * Gets the target max input component
  23331. */
  23332. get targetMax(): NodeMaterialConnectionPoint;
  23333. /**
  23334. * Gets the output component
  23335. */
  23336. get output(): NodeMaterialConnectionPoint;
  23337. protected _buildBlock(state: NodeMaterialBuildState): this;
  23338. protected _dumpPropertiesCode(): string;
  23339. serialize(): any;
  23340. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23341. }
  23342. }
  23343. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23344. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23345. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23346. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23347. /**
  23348. * Block used to multiply 2 values
  23349. */
  23350. export class MultiplyBlock extends NodeMaterialBlock {
  23351. /**
  23352. * Creates a new MultiplyBlock
  23353. * @param name defines the block name
  23354. */
  23355. constructor(name: string);
  23356. /**
  23357. * Gets the current class name
  23358. * @returns the class name
  23359. */
  23360. getClassName(): string;
  23361. /**
  23362. * Gets the left operand input component
  23363. */
  23364. get left(): NodeMaterialConnectionPoint;
  23365. /**
  23366. * Gets the right operand input component
  23367. */
  23368. get right(): NodeMaterialConnectionPoint;
  23369. /**
  23370. * Gets the output component
  23371. */
  23372. get output(): NodeMaterialConnectionPoint;
  23373. protected _buildBlock(state: NodeMaterialBuildState): this;
  23374. }
  23375. }
  23376. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23377. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23378. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23379. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23380. /**
  23381. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23382. */
  23383. export class ColorSplitterBlock extends NodeMaterialBlock {
  23384. /**
  23385. * Create a new ColorSplitterBlock
  23386. * @param name defines the block name
  23387. */
  23388. constructor(name: string);
  23389. /**
  23390. * Gets the current class name
  23391. * @returns the class name
  23392. */
  23393. getClassName(): string;
  23394. /**
  23395. * Gets the rgba component (input)
  23396. */
  23397. get rgba(): NodeMaterialConnectionPoint;
  23398. /**
  23399. * Gets the rgb component (input)
  23400. */
  23401. get rgbIn(): NodeMaterialConnectionPoint;
  23402. /**
  23403. * Gets the rgb component (output)
  23404. */
  23405. get rgbOut(): NodeMaterialConnectionPoint;
  23406. /**
  23407. * Gets the r component (output)
  23408. */
  23409. get r(): NodeMaterialConnectionPoint;
  23410. /**
  23411. * Gets the g component (output)
  23412. */
  23413. get g(): NodeMaterialConnectionPoint;
  23414. /**
  23415. * Gets the b component (output)
  23416. */
  23417. get b(): NodeMaterialConnectionPoint;
  23418. /**
  23419. * Gets the a component (output)
  23420. */
  23421. get a(): NodeMaterialConnectionPoint;
  23422. protected _inputRename(name: string): string;
  23423. protected _outputRename(name: string): string;
  23424. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23425. }
  23426. }
  23427. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23428. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23429. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23430. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23431. import { Scene } from "babylonjs/scene";
  23432. /**
  23433. * Operations supported by the Trigonometry block
  23434. */
  23435. export enum TrigonometryBlockOperations {
  23436. /** Cos */
  23437. Cos = 0,
  23438. /** Sin */
  23439. Sin = 1,
  23440. /** Abs */
  23441. Abs = 2,
  23442. /** Exp */
  23443. Exp = 3,
  23444. /** Exp2 */
  23445. Exp2 = 4,
  23446. /** Round */
  23447. Round = 5,
  23448. /** Floor */
  23449. Floor = 6,
  23450. /** Ceiling */
  23451. Ceiling = 7,
  23452. /** Square root */
  23453. Sqrt = 8,
  23454. /** Log */
  23455. Log = 9,
  23456. /** Tangent */
  23457. Tan = 10,
  23458. /** Arc tangent */
  23459. ArcTan = 11,
  23460. /** Arc cosinus */
  23461. ArcCos = 12,
  23462. /** Arc sinus */
  23463. ArcSin = 13,
  23464. /** Fraction */
  23465. Fract = 14,
  23466. /** Sign */
  23467. Sign = 15,
  23468. /** To radians (from degrees) */
  23469. Radians = 16,
  23470. /** To degrees (from radians) */
  23471. Degrees = 17
  23472. }
  23473. /**
  23474. * Block used to apply trigonometry operation to floats
  23475. */
  23476. export class TrigonometryBlock extends NodeMaterialBlock {
  23477. /**
  23478. * Gets or sets the operation applied by the block
  23479. */
  23480. operation: TrigonometryBlockOperations;
  23481. /**
  23482. * Creates a new TrigonometryBlock
  23483. * @param name defines the block name
  23484. */
  23485. constructor(name: string);
  23486. /**
  23487. * Gets the current class name
  23488. * @returns the class name
  23489. */
  23490. getClassName(): string;
  23491. /**
  23492. * Gets the input component
  23493. */
  23494. get input(): NodeMaterialConnectionPoint;
  23495. /**
  23496. * Gets the output component
  23497. */
  23498. get output(): NodeMaterialConnectionPoint;
  23499. protected _buildBlock(state: NodeMaterialBuildState): this;
  23500. serialize(): any;
  23501. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23502. protected _dumpPropertiesCode(): string;
  23503. }
  23504. }
  23505. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23506. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23507. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23508. import { Scene } from "babylonjs/scene";
  23509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23510. import { Matrix } from "babylonjs/Maths/math.vector";
  23511. import { Mesh } from "babylonjs/Meshes/mesh";
  23512. import { Engine } from "babylonjs/Engines/engine";
  23513. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23514. import { Observable } from "babylonjs/Misc/observable";
  23515. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23516. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23517. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23518. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23519. import { Nullable } from "babylonjs/types";
  23520. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23521. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23522. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23523. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23524. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23525. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23526. import { Effect } from "babylonjs/Materials/effect";
  23527. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23528. import { Camera } from "babylonjs/Cameras/camera";
  23529. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23530. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23531. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23532. /**
  23533. * Interface used to configure the node material editor
  23534. */
  23535. export interface INodeMaterialEditorOptions {
  23536. /** Define the URl to load node editor script */
  23537. editorURL?: string;
  23538. }
  23539. /** @hidden */
  23540. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23541. NORMAL: boolean;
  23542. TANGENT: boolean;
  23543. UV1: boolean;
  23544. /** BONES */
  23545. NUM_BONE_INFLUENCERS: number;
  23546. BonesPerMesh: number;
  23547. BONETEXTURE: boolean;
  23548. /** MORPH TARGETS */
  23549. MORPHTARGETS: boolean;
  23550. MORPHTARGETS_NORMAL: boolean;
  23551. MORPHTARGETS_TANGENT: boolean;
  23552. MORPHTARGETS_UV: boolean;
  23553. NUM_MORPH_INFLUENCERS: number;
  23554. /** IMAGE PROCESSING */
  23555. IMAGEPROCESSING: boolean;
  23556. VIGNETTE: boolean;
  23557. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23558. VIGNETTEBLENDMODEOPAQUE: boolean;
  23559. TONEMAPPING: boolean;
  23560. TONEMAPPING_ACES: boolean;
  23561. CONTRAST: boolean;
  23562. EXPOSURE: boolean;
  23563. COLORCURVES: boolean;
  23564. COLORGRADING: boolean;
  23565. COLORGRADING3D: boolean;
  23566. SAMPLER3DGREENDEPTH: boolean;
  23567. SAMPLER3DBGRMAP: boolean;
  23568. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23569. /** MISC. */
  23570. BUMPDIRECTUV: number;
  23571. constructor();
  23572. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23573. }
  23574. /**
  23575. * Class used to configure NodeMaterial
  23576. */
  23577. export interface INodeMaterialOptions {
  23578. /**
  23579. * Defines if blocks should emit comments
  23580. */
  23581. emitComments: boolean;
  23582. }
  23583. /**
  23584. * Class used to create a node based material built by assembling shader blocks
  23585. */
  23586. export class NodeMaterial extends PushMaterial {
  23587. private static _BuildIdGenerator;
  23588. private _options;
  23589. private _vertexCompilationState;
  23590. private _fragmentCompilationState;
  23591. private _sharedData;
  23592. private _buildId;
  23593. private _buildWasSuccessful;
  23594. private _cachedWorldViewMatrix;
  23595. private _cachedWorldViewProjectionMatrix;
  23596. private _optimizers;
  23597. private _animationFrame;
  23598. /** Define the Url to load node editor script */
  23599. static EditorURL: string;
  23600. /** Define the Url to load snippets */
  23601. static SnippetUrl: string;
  23602. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23603. static IgnoreTexturesAtLoadTime: boolean;
  23604. private BJSNODEMATERIALEDITOR;
  23605. /** Get the inspector from bundle or global */
  23606. private _getGlobalNodeMaterialEditor;
  23607. /**
  23608. * Snippet ID if the material was created from the snippet server
  23609. */
  23610. snippetId: string;
  23611. /**
  23612. * Gets or sets data used by visual editor
  23613. * @see https://nme.babylonjs.com
  23614. */
  23615. editorData: any;
  23616. /**
  23617. * 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)
  23618. */
  23619. ignoreAlpha: boolean;
  23620. /**
  23621. * Defines the maximum number of lights that can be used in the material
  23622. */
  23623. maxSimultaneousLights: number;
  23624. /**
  23625. * Observable raised when the material is built
  23626. */
  23627. onBuildObservable: Observable<NodeMaterial>;
  23628. /**
  23629. * Gets or sets the root nodes of the material vertex shader
  23630. */
  23631. _vertexOutputNodes: NodeMaterialBlock[];
  23632. /**
  23633. * Gets or sets the root nodes of the material fragment (pixel) shader
  23634. */
  23635. _fragmentOutputNodes: NodeMaterialBlock[];
  23636. /** Gets or sets options to control the node material overall behavior */
  23637. get options(): INodeMaterialOptions;
  23638. set options(options: INodeMaterialOptions);
  23639. /**
  23640. * Default configuration related to image processing available in the standard Material.
  23641. */
  23642. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23643. /**
  23644. * Gets the image processing configuration used either in this material.
  23645. */
  23646. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23647. /**
  23648. * Sets the Default image processing configuration used either in the this material.
  23649. *
  23650. * If sets to null, the scene one is in use.
  23651. */
  23652. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23653. /**
  23654. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23655. */
  23656. attachedBlocks: NodeMaterialBlock[];
  23657. /**
  23658. * Specifies the mode of the node material
  23659. * @hidden
  23660. */
  23661. _mode: NodeMaterialModes;
  23662. /**
  23663. * Gets the mode property
  23664. */
  23665. get mode(): NodeMaterialModes;
  23666. /**
  23667. * A free comment about the material
  23668. */
  23669. comment: string;
  23670. /**
  23671. * Create a new node based material
  23672. * @param name defines the material name
  23673. * @param scene defines the hosting scene
  23674. * @param options defines creation option
  23675. */
  23676. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23677. /**
  23678. * Gets the current class name of the material e.g. "NodeMaterial"
  23679. * @returns the class name
  23680. */
  23681. getClassName(): string;
  23682. /**
  23683. * Keep track of the image processing observer to allow dispose and replace.
  23684. */
  23685. private _imageProcessingObserver;
  23686. /**
  23687. * Attaches a new image processing configuration to the Standard Material.
  23688. * @param configuration
  23689. */
  23690. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23691. /**
  23692. * Get a block by its name
  23693. * @param name defines the name of the block to retrieve
  23694. * @returns the required block or null if not found
  23695. */
  23696. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23697. /**
  23698. * Get a block by its name
  23699. * @param predicate defines the predicate used to find the good candidate
  23700. * @returns the required block or null if not found
  23701. */
  23702. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23703. /**
  23704. * Get an input block by its name
  23705. * @param predicate defines the predicate used to find the good candidate
  23706. * @returns the required input block or null if not found
  23707. */
  23708. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23709. /**
  23710. * Gets the list of input blocks attached to this material
  23711. * @returns an array of InputBlocks
  23712. */
  23713. getInputBlocks(): InputBlock[];
  23714. /**
  23715. * Adds a new optimizer to the list of optimizers
  23716. * @param optimizer defines the optimizers to add
  23717. * @returns the current material
  23718. */
  23719. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23720. /**
  23721. * Remove an optimizer from the list of optimizers
  23722. * @param optimizer defines the optimizers to remove
  23723. * @returns the current material
  23724. */
  23725. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23726. /**
  23727. * Add a new block to the list of output nodes
  23728. * @param node defines the node to add
  23729. * @returns the current material
  23730. */
  23731. addOutputNode(node: NodeMaterialBlock): this;
  23732. /**
  23733. * Remove a block from the list of root nodes
  23734. * @param node defines the node to remove
  23735. * @returns the current material
  23736. */
  23737. removeOutputNode(node: NodeMaterialBlock): this;
  23738. private _addVertexOutputNode;
  23739. private _removeVertexOutputNode;
  23740. private _addFragmentOutputNode;
  23741. private _removeFragmentOutputNode;
  23742. /**
  23743. * Specifies if the material will require alpha blending
  23744. * @returns a boolean specifying if alpha blending is needed
  23745. */
  23746. needAlphaBlending(): boolean;
  23747. /**
  23748. * Specifies if this material should be rendered in alpha test mode
  23749. * @returns a boolean specifying if an alpha test is needed.
  23750. */
  23751. needAlphaTesting(): boolean;
  23752. private _initializeBlock;
  23753. private _resetDualBlocks;
  23754. /**
  23755. * Remove a block from the current node material
  23756. * @param block defines the block to remove
  23757. */
  23758. removeBlock(block: NodeMaterialBlock): void;
  23759. /**
  23760. * Build the material and generates the inner effect
  23761. * @param verbose defines if the build should log activity
  23762. */
  23763. build(verbose?: boolean): void;
  23764. /**
  23765. * Runs an otpimization phase to try to improve the shader code
  23766. */
  23767. optimize(): void;
  23768. private _prepareDefinesForAttributes;
  23769. /**
  23770. * Create a post process from the material
  23771. * @param camera The camera to apply the render pass to.
  23772. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23773. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23774. * @param engine The engine which the post process will be applied. (default: current engine)
  23775. * @param reusable If the post process can be reused on the same frame. (default: false)
  23776. * @param textureType Type of textures used when performing the post process. (default: 0)
  23777. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23778. * @returns the post process created
  23779. */
  23780. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23781. /**
  23782. * Create the post process effect from the material
  23783. * @param postProcess The post process to create the effect for
  23784. */
  23785. createEffectForPostProcess(postProcess: PostProcess): void;
  23786. private _createEffectForPostProcess;
  23787. /**
  23788. * Create a new procedural texture based on this node material
  23789. * @param size defines the size of the texture
  23790. * @param scene defines the hosting scene
  23791. * @returns the new procedural texture attached to this node material
  23792. */
  23793. createProceduralTexture(size: number | {
  23794. width: number;
  23795. height: number;
  23796. layers?: number;
  23797. }, scene: Scene): Nullable<ProceduralTexture>;
  23798. private _createEffectForParticles;
  23799. private _checkInternals;
  23800. /**
  23801. * Create the effect to be used as the custom effect for a particle system
  23802. * @param particleSystem Particle system to create the effect for
  23803. * @param onCompiled defines a function to call when the effect creation is successful
  23804. * @param onError defines a function to call when the effect creation has failed
  23805. */
  23806. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23807. private _processDefines;
  23808. /**
  23809. * Get if the submesh is ready to be used and all its information available.
  23810. * Child classes can use it to update shaders
  23811. * @param mesh defines the mesh to check
  23812. * @param subMesh defines which submesh to check
  23813. * @param useInstances specifies that instances should be used
  23814. * @returns a boolean indicating that the submesh is ready or not
  23815. */
  23816. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23817. /**
  23818. * Get a string representing the shaders built by the current node graph
  23819. */
  23820. get compiledShaders(): string;
  23821. /**
  23822. * Binds the world matrix to the material
  23823. * @param world defines the world transformation matrix
  23824. */
  23825. bindOnlyWorldMatrix(world: Matrix): void;
  23826. /**
  23827. * Binds the submesh to this material by preparing the effect and shader to draw
  23828. * @param world defines the world transformation matrix
  23829. * @param mesh defines the mesh containing the submesh
  23830. * @param subMesh defines the submesh to bind the material to
  23831. */
  23832. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23833. /**
  23834. * Gets the active textures from the material
  23835. * @returns an array of textures
  23836. */
  23837. getActiveTextures(): BaseTexture[];
  23838. /**
  23839. * Gets the list of texture blocks
  23840. * @returns an array of texture blocks
  23841. */
  23842. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23843. /**
  23844. * Specifies if the material uses a texture
  23845. * @param texture defines the texture to check against the material
  23846. * @returns a boolean specifying if the material uses the texture
  23847. */
  23848. hasTexture(texture: BaseTexture): boolean;
  23849. /**
  23850. * Disposes the material
  23851. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23852. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23853. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23854. */
  23855. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23856. /** Creates the node editor window. */
  23857. private _createNodeEditor;
  23858. /**
  23859. * Launch the node material editor
  23860. * @param config Define the configuration of the editor
  23861. * @return a promise fulfilled when the node editor is visible
  23862. */
  23863. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23864. /**
  23865. * Clear the current material
  23866. */
  23867. clear(): void;
  23868. /**
  23869. * Clear the current material and set it to a default state
  23870. */
  23871. setToDefault(): void;
  23872. /**
  23873. * Clear the current material and set it to a default state for post process
  23874. */
  23875. setToDefaultPostProcess(): void;
  23876. /**
  23877. * Clear the current material and set it to a default state for procedural texture
  23878. */
  23879. setToDefaultProceduralTexture(): void;
  23880. /**
  23881. * Clear the current material and set it to a default state for particle
  23882. */
  23883. setToDefaultParticle(): void;
  23884. /**
  23885. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23886. * @param url defines the url to load from
  23887. * @returns a promise that will fullfil when the material is fully loaded
  23888. */
  23889. loadAsync(url: string): Promise<void>;
  23890. private _gatherBlocks;
  23891. /**
  23892. * Generate a string containing the code declaration required to create an equivalent of this material
  23893. * @returns a string
  23894. */
  23895. generateCode(): string;
  23896. /**
  23897. * Serializes this material in a JSON representation
  23898. * @returns the serialized material object
  23899. */
  23900. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23901. private _restoreConnections;
  23902. /**
  23903. * Clear the current graph and load a new one from a serialization object
  23904. * @param source defines the JSON representation of the material
  23905. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23906. * @param merge defines whether or not the source must be merged or replace the current content
  23907. */
  23908. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23909. /**
  23910. * Makes a duplicate of the current material.
  23911. * @param name - name to use for the new material.
  23912. */
  23913. clone(name: string): NodeMaterial;
  23914. /**
  23915. * Creates a node material from parsed material data
  23916. * @param source defines the JSON representation of the material
  23917. * @param scene defines the hosting scene
  23918. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23919. * @returns a new node material
  23920. */
  23921. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23922. /**
  23923. * Creates a node material from a snippet saved in a remote file
  23924. * @param name defines the name of the material to create
  23925. * @param url defines the url to load from
  23926. * @param scene defines the hosting scene
  23927. * @returns a promise that will resolve to the new node material
  23928. */
  23929. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23930. /**
  23931. * Creates a node material from a snippet saved by the node material editor
  23932. * @param snippetId defines the snippet to load
  23933. * @param scene defines the hosting scene
  23934. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23935. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23936. * @returns a promise that will resolve to the new node material
  23937. */
  23938. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23939. /**
  23940. * Creates a new node material set to default basic configuration
  23941. * @param name defines the name of the material
  23942. * @param scene defines the hosting scene
  23943. * @returns a new NodeMaterial
  23944. */
  23945. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23946. }
  23947. }
  23948. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23949. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23950. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23951. import { Nullable } from "babylonjs/types";
  23952. module "babylonjs/Engines/thinEngine" {
  23953. interface ThinEngine {
  23954. /**
  23955. * Unbind a list of render target textures from the webGL context
  23956. * This is used only when drawBuffer extension or webGL2 are active
  23957. * @param textures defines the render target textures to unbind
  23958. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23959. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23960. */
  23961. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23962. /**
  23963. * Create a multi render target texture
  23964. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23965. * @param size defines the size of the texture
  23966. * @param options defines the creation options
  23967. * @returns the cube texture as an InternalTexture
  23968. */
  23969. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23970. /**
  23971. * Update the sample count for a given multiple render target texture
  23972. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23973. * @param textures defines the textures to update
  23974. * @param samples defines the sample count to set
  23975. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23976. */
  23977. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23978. /**
  23979. * Select a subsets of attachments to draw to.
  23980. * @param attachments gl attachments
  23981. */
  23982. bindAttachments(attachments: number[]): void;
  23983. /**
  23984. * Creates a layout object to draw/clear on specific textures in a MRT
  23985. * @param textureStatus textureStatus[i] indicates if the i-th is active
  23986. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  23987. */
  23988. buildTextureLayout(textureStatus: boolean[]): number[];
  23989. /**
  23990. * Restores the webgl state to only draw on the main color attachment
  23991. */
  23992. restoreSingleAttachment(): void;
  23993. }
  23994. }
  23995. }
  23996. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  23997. import { Scene } from "babylonjs/scene";
  23998. import { Engine } from "babylonjs/Engines/engine";
  23999. import { Texture } from "babylonjs/Materials/Textures/texture";
  24000. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24001. import "babylonjs/Engines/Extensions/engine.multiRender";
  24002. /**
  24003. * Creation options of the multi render target texture.
  24004. */
  24005. export interface IMultiRenderTargetOptions {
  24006. /**
  24007. * Define if the texture needs to create mip maps after render.
  24008. */
  24009. generateMipMaps?: boolean;
  24010. /**
  24011. * Define the types of all the draw buffers we want to create
  24012. */
  24013. types?: number[];
  24014. /**
  24015. * Define the sampling modes of all the draw buffers we want to create
  24016. */
  24017. samplingModes?: number[];
  24018. /**
  24019. * Define if a depth buffer is required
  24020. */
  24021. generateDepthBuffer?: boolean;
  24022. /**
  24023. * Define if a stencil buffer is required
  24024. */
  24025. generateStencilBuffer?: boolean;
  24026. /**
  24027. * Define if a depth texture is required instead of a depth buffer
  24028. */
  24029. generateDepthTexture?: boolean;
  24030. /**
  24031. * Define the number of desired draw buffers
  24032. */
  24033. textureCount?: number;
  24034. /**
  24035. * Define if aspect ratio should be adapted to the texture or stay the scene one
  24036. */
  24037. doNotChangeAspectRatio?: boolean;
  24038. /**
  24039. * Define the default type of the buffers we are creating
  24040. */
  24041. defaultType?: number;
  24042. }
  24043. /**
  24044. * A multi render target, like a render target provides the ability to render to a texture.
  24045. * Unlike the render target, it can render to several draw buffers in one draw.
  24046. * This is specially interesting in deferred rendering or for any effects requiring more than
  24047. * just one color from a single pass.
  24048. */
  24049. export class MultiRenderTarget extends RenderTargetTexture {
  24050. private _internalTextures;
  24051. private _textures;
  24052. private _multiRenderTargetOptions;
  24053. private _count;
  24054. /**
  24055. * Get if draw buffers are currently supported by the used hardware and browser.
  24056. */
  24057. get isSupported(): boolean;
  24058. /**
  24059. * Get the list of textures generated by the multi render target.
  24060. */
  24061. get textures(): Texture[];
  24062. /**
  24063. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  24064. */
  24065. get count(): number;
  24066. /**
  24067. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  24068. */
  24069. get depthTexture(): Texture;
  24070. /**
  24071. * Set the wrapping mode on U of all the textures we are rendering to.
  24072. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24073. */
  24074. set wrapU(wrap: number);
  24075. /**
  24076. * Set the wrapping mode on V of all the textures we are rendering to.
  24077. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  24078. */
  24079. set wrapV(wrap: number);
  24080. /**
  24081. * Instantiate a new multi render target texture.
  24082. * A multi render target, like a render target provides the ability to render to a texture.
  24083. * Unlike the render target, it can render to several draw buffers in one draw.
  24084. * This is specially interesting in deferred rendering or for any effects requiring more than
  24085. * just one color from a single pass.
  24086. * @param name Define the name of the texture
  24087. * @param size Define the size of the buffers to render to
  24088. * @param count Define the number of target we are rendering into
  24089. * @param scene Define the scene the texture belongs to
  24090. * @param options Define the options used to create the multi render target
  24091. */
  24092. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  24093. private _initTypes;
  24094. /** @hidden */
  24095. _rebuild(forceFullRebuild?: boolean): void;
  24096. private _createInternalTextures;
  24097. private _createTextures;
  24098. /**
  24099. * Replaces a texture within the MRT.
  24100. * @param texture The new texture to insert in the MRT
  24101. * @param index The index of the texture to replace
  24102. */
  24103. replaceTexture(texture: Texture, index: number): void;
  24104. /**
  24105. * Define the number of samples used if MSAA is enabled.
  24106. */
  24107. get samples(): number;
  24108. set samples(value: number);
  24109. /**
  24110. * Resize all the textures in the multi render target.
  24111. * Be careful as it will recreate all the data in the new texture.
  24112. * @param size Define the new size
  24113. */
  24114. resize(size: any): void;
  24115. /**
  24116. * Changes the number of render targets in this MRT
  24117. * Be careful as it will recreate all the data in the new texture.
  24118. * @param count new texture count
  24119. * @param options Specifies texture types and sampling modes for new textures
  24120. */
  24121. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  24122. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24123. /**
  24124. * Dispose the render targets and their associated resources
  24125. */
  24126. dispose(): void;
  24127. /**
  24128. * Release all the underlying texture used as draw buffers.
  24129. */
  24130. releaseInternalTextures(): void;
  24131. }
  24132. }
  24133. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  24134. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24135. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24136. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24137. /** @hidden */
  24138. export var imageProcessingPixelShader: {
  24139. name: string;
  24140. shader: string;
  24141. };
  24142. }
  24143. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  24144. import { Nullable } from "babylonjs/types";
  24145. import { Color4 } from "babylonjs/Maths/math.color";
  24146. import { Camera } from "babylonjs/Cameras/camera";
  24147. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24148. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24149. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  24150. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24151. import { Engine } from "babylonjs/Engines/engine";
  24152. import "babylonjs/Shaders/imageProcessing.fragment";
  24153. import "babylonjs/Shaders/postprocess.vertex";
  24154. /**
  24155. * ImageProcessingPostProcess
  24156. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  24157. */
  24158. export class ImageProcessingPostProcess extends PostProcess {
  24159. /**
  24160. * Default configuration related to image processing available in the PBR Material.
  24161. */
  24162. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24163. /**
  24164. * Gets the image processing configuration used either in this material.
  24165. */
  24166. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24167. /**
  24168. * Sets the Default image processing configuration used either in the this material.
  24169. *
  24170. * If sets to null, the scene one is in use.
  24171. */
  24172. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24173. /**
  24174. * Keep track of the image processing observer to allow dispose and replace.
  24175. */
  24176. private _imageProcessingObserver;
  24177. /**
  24178. * Attaches a new image processing configuration to the PBR Material.
  24179. * @param configuration
  24180. */
  24181. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  24182. /**
  24183. * If the post process is supported.
  24184. */
  24185. get isSupported(): boolean;
  24186. /**
  24187. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24188. */
  24189. get colorCurves(): Nullable<ColorCurves>;
  24190. /**
  24191. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  24192. */
  24193. set colorCurves(value: Nullable<ColorCurves>);
  24194. /**
  24195. * Gets wether the color curves effect is enabled.
  24196. */
  24197. get colorCurvesEnabled(): boolean;
  24198. /**
  24199. * Sets wether the color curves effect is enabled.
  24200. */
  24201. set colorCurvesEnabled(value: boolean);
  24202. /**
  24203. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24204. */
  24205. get colorGradingTexture(): Nullable<BaseTexture>;
  24206. /**
  24207. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  24208. */
  24209. set colorGradingTexture(value: Nullable<BaseTexture>);
  24210. /**
  24211. * Gets wether the color grading effect is enabled.
  24212. */
  24213. get colorGradingEnabled(): boolean;
  24214. /**
  24215. * Gets wether the color grading effect is enabled.
  24216. */
  24217. set colorGradingEnabled(value: boolean);
  24218. /**
  24219. * Gets exposure used in the effect.
  24220. */
  24221. get exposure(): number;
  24222. /**
  24223. * Sets exposure used in the effect.
  24224. */
  24225. set exposure(value: number);
  24226. /**
  24227. * Gets wether tonemapping is enabled or not.
  24228. */
  24229. get toneMappingEnabled(): boolean;
  24230. /**
  24231. * Sets wether tonemapping is enabled or not
  24232. */
  24233. set toneMappingEnabled(value: boolean);
  24234. /**
  24235. * Gets the type of tone mapping effect.
  24236. */
  24237. get toneMappingType(): number;
  24238. /**
  24239. * Sets the type of tone mapping effect.
  24240. */
  24241. set toneMappingType(value: number);
  24242. /**
  24243. * Gets contrast used in the effect.
  24244. */
  24245. get contrast(): number;
  24246. /**
  24247. * Sets contrast used in the effect.
  24248. */
  24249. set contrast(value: number);
  24250. /**
  24251. * Gets Vignette stretch size.
  24252. */
  24253. get vignetteStretch(): number;
  24254. /**
  24255. * Sets Vignette stretch size.
  24256. */
  24257. set vignetteStretch(value: number);
  24258. /**
  24259. * Gets Vignette centre X Offset.
  24260. */
  24261. get vignetteCentreX(): number;
  24262. /**
  24263. * Sets Vignette centre X Offset.
  24264. */
  24265. set vignetteCentreX(value: number);
  24266. /**
  24267. * Gets Vignette centre Y Offset.
  24268. */
  24269. get vignetteCentreY(): number;
  24270. /**
  24271. * Sets Vignette centre Y Offset.
  24272. */
  24273. set vignetteCentreY(value: number);
  24274. /**
  24275. * Gets Vignette weight or intensity of the vignette effect.
  24276. */
  24277. get vignetteWeight(): number;
  24278. /**
  24279. * Sets Vignette weight or intensity of the vignette effect.
  24280. */
  24281. set vignetteWeight(value: number);
  24282. /**
  24283. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24284. * if vignetteEnabled is set to true.
  24285. */
  24286. get vignetteColor(): Color4;
  24287. /**
  24288. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  24289. * if vignetteEnabled is set to true.
  24290. */
  24291. set vignetteColor(value: Color4);
  24292. /**
  24293. * Gets Camera field of view used by the Vignette effect.
  24294. */
  24295. get vignetteCameraFov(): number;
  24296. /**
  24297. * Sets Camera field of view used by the Vignette effect.
  24298. */
  24299. set vignetteCameraFov(value: number);
  24300. /**
  24301. * Gets the vignette blend mode allowing different kind of effect.
  24302. */
  24303. get vignetteBlendMode(): number;
  24304. /**
  24305. * Sets the vignette blend mode allowing different kind of effect.
  24306. */
  24307. set vignetteBlendMode(value: number);
  24308. /**
  24309. * Gets wether the vignette effect is enabled.
  24310. */
  24311. get vignetteEnabled(): boolean;
  24312. /**
  24313. * Sets wether the vignette effect is enabled.
  24314. */
  24315. set vignetteEnabled(value: boolean);
  24316. private _fromLinearSpace;
  24317. /**
  24318. * Gets wether the input of the processing is in Gamma or Linear Space.
  24319. */
  24320. get fromLinearSpace(): boolean;
  24321. /**
  24322. * Sets wether the input of the processing is in Gamma or Linear Space.
  24323. */
  24324. set fromLinearSpace(value: boolean);
  24325. /**
  24326. * Defines cache preventing GC.
  24327. */
  24328. private _defines;
  24329. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  24330. /**
  24331. * "ImageProcessingPostProcess"
  24332. * @returns "ImageProcessingPostProcess"
  24333. */
  24334. getClassName(): string;
  24335. /**
  24336. * @hidden
  24337. */
  24338. _updateParameters(): void;
  24339. dispose(camera?: Camera): void;
  24340. }
  24341. }
  24342. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24343. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24344. /**
  24345. * Interface for defining prepass effects in the prepass post-process pipeline
  24346. */
  24347. export interface PrePassEffectConfiguration {
  24348. /**
  24349. * Name of the effect
  24350. */
  24351. name: string;
  24352. /**
  24353. * Post process to attach for this effect
  24354. */
  24355. postProcess?: PostProcess;
  24356. /**
  24357. * Textures required in the MRT
  24358. */
  24359. texturesRequired: number[];
  24360. /**
  24361. * Is the effect enabled
  24362. */
  24363. enabled: boolean;
  24364. /**
  24365. * Disposes the effect configuration
  24366. */
  24367. dispose?: () => void;
  24368. /**
  24369. * Creates the associated post process
  24370. */
  24371. createPostProcess?: () => PostProcess;
  24372. }
  24373. }
  24374. declare module "babylonjs/Materials/fresnelParameters" {
  24375. import { DeepImmutable } from "babylonjs/types";
  24376. import { Color3 } from "babylonjs/Maths/math.color";
  24377. /**
  24378. * Options to be used when creating a FresnelParameters.
  24379. */
  24380. export type IFresnelParametersCreationOptions = {
  24381. /**
  24382. * Define the color used on edges (grazing angle)
  24383. */
  24384. leftColor?: Color3;
  24385. /**
  24386. * Define the color used on center
  24387. */
  24388. rightColor?: Color3;
  24389. /**
  24390. * Define bias applied to computed fresnel term
  24391. */
  24392. bias?: number;
  24393. /**
  24394. * Defined the power exponent applied to fresnel term
  24395. */
  24396. power?: number;
  24397. /**
  24398. * Define if the fresnel effect is enable or not.
  24399. */
  24400. isEnabled?: boolean;
  24401. };
  24402. /**
  24403. * Serialized format for FresnelParameters.
  24404. */
  24405. export type IFresnelParametersSerialized = {
  24406. /**
  24407. * Define the color used on edges (grazing angle) [as an array]
  24408. */
  24409. leftColor: number[];
  24410. /**
  24411. * Define the color used on center [as an array]
  24412. */
  24413. rightColor: number[];
  24414. /**
  24415. * Define bias applied to computed fresnel term
  24416. */
  24417. bias: number;
  24418. /**
  24419. * Defined the power exponent applied to fresnel term
  24420. */
  24421. power?: number;
  24422. /**
  24423. * Define if the fresnel effect is enable or not.
  24424. */
  24425. isEnabled: boolean;
  24426. };
  24427. /**
  24428. * This represents all the required information to add a fresnel effect on a material:
  24429. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24430. */
  24431. export class FresnelParameters {
  24432. private _isEnabled;
  24433. /**
  24434. * Define if the fresnel effect is enable or not.
  24435. */
  24436. get isEnabled(): boolean;
  24437. set isEnabled(value: boolean);
  24438. /**
  24439. * Define the color used on edges (grazing angle)
  24440. */
  24441. leftColor: Color3;
  24442. /**
  24443. * Define the color used on center
  24444. */
  24445. rightColor: Color3;
  24446. /**
  24447. * Define bias applied to computed fresnel term
  24448. */
  24449. bias: number;
  24450. /**
  24451. * Defined the power exponent applied to fresnel term
  24452. */
  24453. power: number;
  24454. /**
  24455. * Creates a new FresnelParameters object.
  24456. *
  24457. * @param options provide your own settings to optionally to override defaults
  24458. */
  24459. constructor(options?: IFresnelParametersCreationOptions);
  24460. /**
  24461. * Clones the current fresnel and its valuues
  24462. * @returns a clone fresnel configuration
  24463. */
  24464. clone(): FresnelParameters;
  24465. /**
  24466. * Determines equality between FresnelParameters objects
  24467. * @param otherFresnelParameters defines the second operand
  24468. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  24469. */
  24470. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  24471. /**
  24472. * Serializes the current fresnel parameters to a JSON representation.
  24473. * @return the JSON serialization
  24474. */
  24475. serialize(): IFresnelParametersSerialized;
  24476. /**
  24477. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  24478. * @param parsedFresnelParameters Define the JSON representation
  24479. * @returns the parsed parameters
  24480. */
  24481. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  24482. }
  24483. }
  24484. declare module "babylonjs/Materials/materialFlags" {
  24485. /**
  24486. * This groups all the flags used to control the materials channel.
  24487. */
  24488. export class MaterialFlags {
  24489. private static _DiffuseTextureEnabled;
  24490. /**
  24491. * Are diffuse textures enabled in the application.
  24492. */
  24493. static get DiffuseTextureEnabled(): boolean;
  24494. static set DiffuseTextureEnabled(value: boolean);
  24495. private static _DetailTextureEnabled;
  24496. /**
  24497. * Are detail textures enabled in the application.
  24498. */
  24499. static get DetailTextureEnabled(): boolean;
  24500. static set DetailTextureEnabled(value: boolean);
  24501. private static _AmbientTextureEnabled;
  24502. /**
  24503. * Are ambient textures enabled in the application.
  24504. */
  24505. static get AmbientTextureEnabled(): boolean;
  24506. static set AmbientTextureEnabled(value: boolean);
  24507. private static _OpacityTextureEnabled;
  24508. /**
  24509. * Are opacity textures enabled in the application.
  24510. */
  24511. static get OpacityTextureEnabled(): boolean;
  24512. static set OpacityTextureEnabled(value: boolean);
  24513. private static _ReflectionTextureEnabled;
  24514. /**
  24515. * Are reflection textures enabled in the application.
  24516. */
  24517. static get ReflectionTextureEnabled(): boolean;
  24518. static set ReflectionTextureEnabled(value: boolean);
  24519. private static _EmissiveTextureEnabled;
  24520. /**
  24521. * Are emissive textures enabled in the application.
  24522. */
  24523. static get EmissiveTextureEnabled(): boolean;
  24524. static set EmissiveTextureEnabled(value: boolean);
  24525. private static _SpecularTextureEnabled;
  24526. /**
  24527. * Are specular textures enabled in the application.
  24528. */
  24529. static get SpecularTextureEnabled(): boolean;
  24530. static set SpecularTextureEnabled(value: boolean);
  24531. private static _BumpTextureEnabled;
  24532. /**
  24533. * Are bump textures enabled in the application.
  24534. */
  24535. static get BumpTextureEnabled(): boolean;
  24536. static set BumpTextureEnabled(value: boolean);
  24537. private static _LightmapTextureEnabled;
  24538. /**
  24539. * Are lightmap textures enabled in the application.
  24540. */
  24541. static get LightmapTextureEnabled(): boolean;
  24542. static set LightmapTextureEnabled(value: boolean);
  24543. private static _RefractionTextureEnabled;
  24544. /**
  24545. * Are refraction textures enabled in the application.
  24546. */
  24547. static get RefractionTextureEnabled(): boolean;
  24548. static set RefractionTextureEnabled(value: boolean);
  24549. private static _ColorGradingTextureEnabled;
  24550. /**
  24551. * Are color grading textures enabled in the application.
  24552. */
  24553. static get ColorGradingTextureEnabled(): boolean;
  24554. static set ColorGradingTextureEnabled(value: boolean);
  24555. private static _FresnelEnabled;
  24556. /**
  24557. * Are fresnels enabled in the application.
  24558. */
  24559. static get FresnelEnabled(): boolean;
  24560. static set FresnelEnabled(value: boolean);
  24561. private static _ClearCoatTextureEnabled;
  24562. /**
  24563. * Are clear coat textures enabled in the application.
  24564. */
  24565. static get ClearCoatTextureEnabled(): boolean;
  24566. static set ClearCoatTextureEnabled(value: boolean);
  24567. private static _ClearCoatBumpTextureEnabled;
  24568. /**
  24569. * Are clear coat bump textures enabled in the application.
  24570. */
  24571. static get ClearCoatBumpTextureEnabled(): boolean;
  24572. static set ClearCoatBumpTextureEnabled(value: boolean);
  24573. private static _ClearCoatTintTextureEnabled;
  24574. /**
  24575. * Are clear coat tint textures enabled in the application.
  24576. */
  24577. static get ClearCoatTintTextureEnabled(): boolean;
  24578. static set ClearCoatTintTextureEnabled(value: boolean);
  24579. private static _SheenTextureEnabled;
  24580. /**
  24581. * Are sheen textures enabled in the application.
  24582. */
  24583. static get SheenTextureEnabled(): boolean;
  24584. static set SheenTextureEnabled(value: boolean);
  24585. private static _AnisotropicTextureEnabled;
  24586. /**
  24587. * Are anisotropic textures enabled in the application.
  24588. */
  24589. static get AnisotropicTextureEnabled(): boolean;
  24590. static set AnisotropicTextureEnabled(value: boolean);
  24591. private static _ThicknessTextureEnabled;
  24592. /**
  24593. * Are thickness textures enabled in the application.
  24594. */
  24595. static get ThicknessTextureEnabled(): boolean;
  24596. static set ThicknessTextureEnabled(value: boolean);
  24597. }
  24598. }
  24599. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  24600. /** @hidden */
  24601. export var defaultFragmentDeclaration: {
  24602. name: string;
  24603. shader: string;
  24604. };
  24605. }
  24606. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  24607. /** @hidden */
  24608. export var defaultUboDeclaration: {
  24609. name: string;
  24610. shader: string;
  24611. };
  24612. }
  24613. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  24614. /** @hidden */
  24615. export var prePassDeclaration: {
  24616. name: string;
  24617. shader: string;
  24618. };
  24619. }
  24620. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  24621. /** @hidden */
  24622. export var lightFragmentDeclaration: {
  24623. name: string;
  24624. shader: string;
  24625. };
  24626. }
  24627. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  24628. /** @hidden */
  24629. export var lightUboDeclaration: {
  24630. name: string;
  24631. shader: string;
  24632. };
  24633. }
  24634. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  24635. /** @hidden */
  24636. export var lightsFragmentFunctions: {
  24637. name: string;
  24638. shader: string;
  24639. };
  24640. }
  24641. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  24642. /** @hidden */
  24643. export var shadowsFragmentFunctions: {
  24644. name: string;
  24645. shader: string;
  24646. };
  24647. }
  24648. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  24649. /** @hidden */
  24650. export var fresnelFunction: {
  24651. name: string;
  24652. shader: string;
  24653. };
  24654. }
  24655. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  24656. /** @hidden */
  24657. export var bumpFragmentMainFunctions: {
  24658. name: string;
  24659. shader: string;
  24660. };
  24661. }
  24662. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  24663. /** @hidden */
  24664. export var bumpFragmentFunctions: {
  24665. name: string;
  24666. shader: string;
  24667. };
  24668. }
  24669. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  24670. /** @hidden */
  24671. export var logDepthDeclaration: {
  24672. name: string;
  24673. shader: string;
  24674. };
  24675. }
  24676. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  24677. /** @hidden */
  24678. export var bumpFragment: {
  24679. name: string;
  24680. shader: string;
  24681. };
  24682. }
  24683. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  24684. /** @hidden */
  24685. export var depthPrePass: {
  24686. name: string;
  24687. shader: string;
  24688. };
  24689. }
  24690. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  24691. /** @hidden */
  24692. export var lightFragment: {
  24693. name: string;
  24694. shader: string;
  24695. };
  24696. }
  24697. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  24698. /** @hidden */
  24699. export var logDepthFragment: {
  24700. name: string;
  24701. shader: string;
  24702. };
  24703. }
  24704. declare module "babylonjs/Shaders/default.fragment" {
  24705. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  24706. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24707. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  24708. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24709. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24710. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24711. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  24712. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  24713. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  24714. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  24715. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  24716. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  24717. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  24718. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  24719. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  24720. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24721. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  24722. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  24723. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  24724. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  24725. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  24726. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  24727. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  24728. /** @hidden */
  24729. export var defaultPixelShader: {
  24730. name: string;
  24731. shader: string;
  24732. };
  24733. }
  24734. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  24735. /** @hidden */
  24736. export var defaultVertexDeclaration: {
  24737. name: string;
  24738. shader: string;
  24739. };
  24740. }
  24741. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  24742. /** @hidden */
  24743. export var prePassVertexDeclaration: {
  24744. name: string;
  24745. shader: string;
  24746. };
  24747. }
  24748. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  24749. /** @hidden */
  24750. export var bumpVertexDeclaration: {
  24751. name: string;
  24752. shader: string;
  24753. };
  24754. }
  24755. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  24756. /** @hidden */
  24757. export var prePassVertex: {
  24758. name: string;
  24759. shader: string;
  24760. };
  24761. }
  24762. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  24763. /** @hidden */
  24764. export var bumpVertex: {
  24765. name: string;
  24766. shader: string;
  24767. };
  24768. }
  24769. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  24770. /** @hidden */
  24771. export var fogVertex: {
  24772. name: string;
  24773. shader: string;
  24774. };
  24775. }
  24776. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  24777. /** @hidden */
  24778. export var shadowsVertex: {
  24779. name: string;
  24780. shader: string;
  24781. };
  24782. }
  24783. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  24784. /** @hidden */
  24785. export var pointCloudVertex: {
  24786. name: string;
  24787. shader: string;
  24788. };
  24789. }
  24790. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  24791. /** @hidden */
  24792. export var logDepthVertex: {
  24793. name: string;
  24794. shader: string;
  24795. };
  24796. }
  24797. declare module "babylonjs/Shaders/default.vertex" {
  24798. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  24799. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  24800. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  24801. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  24802. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  24803. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  24804. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  24805. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  24806. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  24807. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  24808. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  24809. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  24810. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  24811. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  24812. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  24813. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  24814. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  24815. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  24816. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  24817. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  24818. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  24819. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  24820. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  24821. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  24822. /** @hidden */
  24823. export var defaultVertexShader: {
  24824. name: string;
  24825. shader: string;
  24826. };
  24827. }
  24828. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  24829. import { Nullable } from "babylonjs/types";
  24830. import { Scene } from "babylonjs/scene";
  24831. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24832. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24833. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24834. /**
  24835. * @hidden
  24836. */
  24837. export interface IMaterialDetailMapDefines {
  24838. DETAIL: boolean;
  24839. DETAILDIRECTUV: number;
  24840. DETAIL_NORMALBLENDMETHOD: number;
  24841. /** @hidden */
  24842. _areTexturesDirty: boolean;
  24843. }
  24844. /**
  24845. * Define the code related to the detail map parameters of a material
  24846. *
  24847. * Inspired from:
  24848. * 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
  24849. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  24850. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  24851. */
  24852. export class DetailMapConfiguration {
  24853. private _texture;
  24854. /**
  24855. * The detail texture of the material.
  24856. */
  24857. texture: Nullable<BaseTexture>;
  24858. /**
  24859. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  24860. * Bigger values mean stronger blending
  24861. */
  24862. diffuseBlendLevel: number;
  24863. /**
  24864. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  24865. * Bigger values mean stronger blending. Only used with PBR materials
  24866. */
  24867. roughnessBlendLevel: number;
  24868. /**
  24869. * Defines how strong the bump effect from the detail map is
  24870. * Bigger values mean stronger effect
  24871. */
  24872. bumpLevel: number;
  24873. private _normalBlendMethod;
  24874. /**
  24875. * The method used to blend the bump and detail normals together
  24876. */
  24877. normalBlendMethod: number;
  24878. private _isEnabled;
  24879. /**
  24880. * Enable or disable the detail map on this material
  24881. */
  24882. isEnabled: boolean;
  24883. /** @hidden */
  24884. private _internalMarkAllSubMeshesAsTexturesDirty;
  24885. /** @hidden */
  24886. _markAllSubMeshesAsTexturesDirty(): void;
  24887. /**
  24888. * Instantiate a new detail map
  24889. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24890. */
  24891. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24892. /**
  24893. * Gets whether the submesh is ready to be used or not.
  24894. * @param defines the list of "defines" to update.
  24895. * @param scene defines the scene the material belongs to.
  24896. * @returns - boolean indicating that the submesh is ready or not.
  24897. */
  24898. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  24899. /**
  24900. * Update the defines for detail map usage
  24901. * @param defines the list of "defines" to update.
  24902. * @param scene defines the scene the material belongs to.
  24903. */
  24904. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  24905. /**
  24906. * Binds the material data.
  24907. * @param uniformBuffer defines the Uniform buffer to fill in.
  24908. * @param scene defines the scene the material belongs to.
  24909. * @param isFrozen defines whether the material is frozen or not.
  24910. */
  24911. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24912. /**
  24913. * Checks to see if a texture is used in the material.
  24914. * @param texture - Base texture to use.
  24915. * @returns - Boolean specifying if a texture is used in the material.
  24916. */
  24917. hasTexture(texture: BaseTexture): boolean;
  24918. /**
  24919. * Returns an array of the actively used textures.
  24920. * @param activeTextures Array of BaseTextures
  24921. */
  24922. getActiveTextures(activeTextures: BaseTexture[]): void;
  24923. /**
  24924. * Returns the animatable textures.
  24925. * @param animatables Array of animatable textures.
  24926. */
  24927. getAnimatables(animatables: IAnimatable[]): void;
  24928. /**
  24929. * Disposes the resources of the material.
  24930. * @param forceDisposeTextures - Forces the disposal of all textures.
  24931. */
  24932. dispose(forceDisposeTextures?: boolean): void;
  24933. /**
  24934. * Get the current class name useful for serialization or dynamic coding.
  24935. * @returns "DetailMap"
  24936. */
  24937. getClassName(): string;
  24938. /**
  24939. * Add the required uniforms to the current list.
  24940. * @param uniforms defines the current uniform list.
  24941. */
  24942. static AddUniforms(uniforms: string[]): void;
  24943. /**
  24944. * Add the required samplers to the current list.
  24945. * @param samplers defines the current sampler list.
  24946. */
  24947. static AddSamplers(samplers: string[]): void;
  24948. /**
  24949. * Add the required uniforms to the current buffer.
  24950. * @param uniformBuffer defines the current uniform buffer.
  24951. */
  24952. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24953. /**
  24954. * Makes a duplicate of the current instance into another one.
  24955. * @param detailMap define the instance where to copy the info
  24956. */
  24957. copyTo(detailMap: DetailMapConfiguration): void;
  24958. /**
  24959. * Serializes this detail map instance
  24960. * @returns - An object with the serialized instance.
  24961. */
  24962. serialize(): any;
  24963. /**
  24964. * Parses a detail map setting from a serialized object.
  24965. * @param source - Serialized object.
  24966. * @param scene Defines the scene we are parsing for
  24967. * @param rootUrl Defines the rootUrl to load from
  24968. */
  24969. parse(source: any, scene: Scene, rootUrl: string): void;
  24970. }
  24971. }
  24972. declare module "babylonjs/Materials/standardMaterial" {
  24973. import { SmartArray } from "babylonjs/Misc/smartArray";
  24974. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24975. import { Nullable } from "babylonjs/types";
  24976. import { Scene } from "babylonjs/scene";
  24977. import { Matrix } from "babylonjs/Maths/math.vector";
  24978. import { Color3 } from "babylonjs/Maths/math.color";
  24979. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24981. import { Mesh } from "babylonjs/Meshes/mesh";
  24982. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  24983. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  24984. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  24985. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  24986. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24987. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  24988. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24989. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24990. import "babylonjs/Shaders/default.fragment";
  24991. import "babylonjs/Shaders/default.vertex";
  24992. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  24993. /** @hidden */
  24994. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  24995. MAINUV1: boolean;
  24996. MAINUV2: boolean;
  24997. DIFFUSE: boolean;
  24998. DIFFUSEDIRECTUV: number;
  24999. DETAIL: boolean;
  25000. DETAILDIRECTUV: number;
  25001. DETAIL_NORMALBLENDMETHOD: number;
  25002. AMBIENT: boolean;
  25003. AMBIENTDIRECTUV: number;
  25004. OPACITY: boolean;
  25005. OPACITYDIRECTUV: number;
  25006. OPACITYRGB: boolean;
  25007. REFLECTION: boolean;
  25008. EMISSIVE: boolean;
  25009. EMISSIVEDIRECTUV: number;
  25010. SPECULAR: boolean;
  25011. SPECULARDIRECTUV: number;
  25012. BUMP: boolean;
  25013. BUMPDIRECTUV: number;
  25014. PARALLAX: boolean;
  25015. PARALLAXOCCLUSION: boolean;
  25016. SPECULAROVERALPHA: boolean;
  25017. CLIPPLANE: boolean;
  25018. CLIPPLANE2: boolean;
  25019. CLIPPLANE3: boolean;
  25020. CLIPPLANE4: boolean;
  25021. CLIPPLANE5: boolean;
  25022. CLIPPLANE6: boolean;
  25023. ALPHATEST: boolean;
  25024. DEPTHPREPASS: boolean;
  25025. ALPHAFROMDIFFUSE: boolean;
  25026. POINTSIZE: boolean;
  25027. FOG: boolean;
  25028. SPECULARTERM: boolean;
  25029. DIFFUSEFRESNEL: boolean;
  25030. OPACITYFRESNEL: boolean;
  25031. REFLECTIONFRESNEL: boolean;
  25032. REFRACTIONFRESNEL: boolean;
  25033. EMISSIVEFRESNEL: boolean;
  25034. FRESNEL: boolean;
  25035. NORMAL: boolean;
  25036. UV1: boolean;
  25037. UV2: boolean;
  25038. VERTEXCOLOR: boolean;
  25039. VERTEXALPHA: boolean;
  25040. NUM_BONE_INFLUENCERS: number;
  25041. BonesPerMesh: number;
  25042. BONETEXTURE: boolean;
  25043. BONES_VELOCITY_ENABLED: boolean;
  25044. INSTANCES: boolean;
  25045. THIN_INSTANCES: boolean;
  25046. GLOSSINESS: boolean;
  25047. ROUGHNESS: boolean;
  25048. EMISSIVEASILLUMINATION: boolean;
  25049. LINKEMISSIVEWITHDIFFUSE: boolean;
  25050. REFLECTIONFRESNELFROMSPECULAR: boolean;
  25051. LIGHTMAP: boolean;
  25052. LIGHTMAPDIRECTUV: number;
  25053. OBJECTSPACE_NORMALMAP: boolean;
  25054. USELIGHTMAPASSHADOWMAP: boolean;
  25055. REFLECTIONMAP_3D: boolean;
  25056. REFLECTIONMAP_SPHERICAL: boolean;
  25057. REFLECTIONMAP_PLANAR: boolean;
  25058. REFLECTIONMAP_CUBIC: boolean;
  25059. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  25060. REFLECTIONMAP_PROJECTION: boolean;
  25061. REFLECTIONMAP_SKYBOX: boolean;
  25062. REFLECTIONMAP_EXPLICIT: boolean;
  25063. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  25064. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  25065. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  25066. INVERTCUBICMAP: boolean;
  25067. LOGARITHMICDEPTH: boolean;
  25068. REFRACTION: boolean;
  25069. REFRACTIONMAP_3D: boolean;
  25070. REFLECTIONOVERALPHA: boolean;
  25071. TWOSIDEDLIGHTING: boolean;
  25072. SHADOWFLOAT: boolean;
  25073. MORPHTARGETS: boolean;
  25074. MORPHTARGETS_NORMAL: boolean;
  25075. MORPHTARGETS_TANGENT: boolean;
  25076. MORPHTARGETS_UV: boolean;
  25077. NUM_MORPH_INFLUENCERS: number;
  25078. NONUNIFORMSCALING: boolean;
  25079. PREMULTIPLYALPHA: boolean;
  25080. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  25081. ALPHABLEND: boolean;
  25082. PREPASS: boolean;
  25083. PREPASS_IRRADIANCE: boolean;
  25084. PREPASS_IRRADIANCE_INDEX: number;
  25085. PREPASS_ALBEDO: boolean;
  25086. PREPASS_ALBEDO_INDEX: number;
  25087. PREPASS_DEPTHNORMAL: boolean;
  25088. PREPASS_DEPTHNORMAL_INDEX: number;
  25089. PREPASS_POSITION: boolean;
  25090. PREPASS_POSITION_INDEX: number;
  25091. PREPASS_VELOCITY: boolean;
  25092. PREPASS_VELOCITY_INDEX: number;
  25093. PREPASS_REFLECTIVITY: boolean;
  25094. PREPASS_REFLECTIVITY_INDEX: number;
  25095. SCENE_MRT_COUNT: number;
  25096. RGBDLIGHTMAP: boolean;
  25097. RGBDREFLECTION: boolean;
  25098. RGBDREFRACTION: boolean;
  25099. IMAGEPROCESSING: boolean;
  25100. VIGNETTE: boolean;
  25101. VIGNETTEBLENDMODEMULTIPLY: boolean;
  25102. VIGNETTEBLENDMODEOPAQUE: boolean;
  25103. TONEMAPPING: boolean;
  25104. TONEMAPPING_ACES: boolean;
  25105. CONTRAST: boolean;
  25106. COLORCURVES: boolean;
  25107. COLORGRADING: boolean;
  25108. COLORGRADING3D: boolean;
  25109. SAMPLER3DGREENDEPTH: boolean;
  25110. SAMPLER3DBGRMAP: boolean;
  25111. IMAGEPROCESSINGPOSTPROCESS: boolean;
  25112. MULTIVIEW: boolean;
  25113. /**
  25114. * If the reflection texture on this material is in linear color space
  25115. * @hidden
  25116. */
  25117. IS_REFLECTION_LINEAR: boolean;
  25118. /**
  25119. * If the refraction texture on this material is in linear color space
  25120. * @hidden
  25121. */
  25122. IS_REFRACTION_LINEAR: boolean;
  25123. EXPOSURE: boolean;
  25124. constructor();
  25125. setReflectionMode(modeToEnable: string): void;
  25126. }
  25127. /**
  25128. * This is the default material used in Babylon. It is the best trade off between quality
  25129. * and performances.
  25130. * @see https://doc.babylonjs.com/babylon101/materials
  25131. */
  25132. export class StandardMaterial extends PushMaterial {
  25133. private _diffuseTexture;
  25134. /**
  25135. * The basic texture of the material as viewed under a light.
  25136. */
  25137. diffuseTexture: Nullable<BaseTexture>;
  25138. private _ambientTexture;
  25139. /**
  25140. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  25141. */
  25142. ambientTexture: Nullable<BaseTexture>;
  25143. private _opacityTexture;
  25144. /**
  25145. * Define the transparency of the material from a texture.
  25146. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  25147. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  25148. */
  25149. opacityTexture: Nullable<BaseTexture>;
  25150. private _reflectionTexture;
  25151. /**
  25152. * Define the texture used to display the reflection.
  25153. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25154. */
  25155. reflectionTexture: Nullable<BaseTexture>;
  25156. private _emissiveTexture;
  25157. /**
  25158. * Define texture of the material as if self lit.
  25159. * This will be mixed in the final result even in the absence of light.
  25160. */
  25161. emissiveTexture: Nullable<BaseTexture>;
  25162. private _specularTexture;
  25163. /**
  25164. * Define how the color and intensity of the highlight given by the light in the material.
  25165. */
  25166. specularTexture: Nullable<BaseTexture>;
  25167. private _bumpTexture;
  25168. /**
  25169. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  25170. * 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.
  25171. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  25172. */
  25173. bumpTexture: Nullable<BaseTexture>;
  25174. private _lightmapTexture;
  25175. /**
  25176. * Complex lighting can be computationally expensive to compute at runtime.
  25177. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  25178. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  25179. */
  25180. lightmapTexture: Nullable<BaseTexture>;
  25181. private _refractionTexture;
  25182. /**
  25183. * Define the texture used to display the refraction.
  25184. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25185. */
  25186. refractionTexture: Nullable<BaseTexture>;
  25187. /**
  25188. * The color of the material lit by the environmental background lighting.
  25189. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  25190. */
  25191. ambientColor: Color3;
  25192. /**
  25193. * The basic color of the material as viewed under a light.
  25194. */
  25195. diffuseColor: Color3;
  25196. /**
  25197. * Define how the color and intensity of the highlight given by the light in the material.
  25198. */
  25199. specularColor: Color3;
  25200. /**
  25201. * Define the color of the material as if self lit.
  25202. * This will be mixed in the final result even in the absence of light.
  25203. */
  25204. emissiveColor: Color3;
  25205. /**
  25206. * Defines how sharp are the highlights in the material.
  25207. * The bigger the value the sharper giving a more glossy feeling to the result.
  25208. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  25209. */
  25210. specularPower: number;
  25211. private _useAlphaFromDiffuseTexture;
  25212. /**
  25213. * Does the transparency come from the diffuse texture alpha channel.
  25214. */
  25215. useAlphaFromDiffuseTexture: boolean;
  25216. private _useEmissiveAsIllumination;
  25217. /**
  25218. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  25219. */
  25220. useEmissiveAsIllumination: boolean;
  25221. private _linkEmissiveWithDiffuse;
  25222. /**
  25223. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  25224. * the emissive level when the final color is close to one.
  25225. */
  25226. linkEmissiveWithDiffuse: boolean;
  25227. private _useSpecularOverAlpha;
  25228. /**
  25229. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  25230. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  25231. */
  25232. useSpecularOverAlpha: boolean;
  25233. private _useReflectionOverAlpha;
  25234. /**
  25235. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  25236. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  25237. */
  25238. useReflectionOverAlpha: boolean;
  25239. private _disableLighting;
  25240. /**
  25241. * Does lights from the scene impacts this material.
  25242. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  25243. */
  25244. disableLighting: boolean;
  25245. private _useObjectSpaceNormalMap;
  25246. /**
  25247. * Allows using an object space normal map (instead of tangent space).
  25248. */
  25249. useObjectSpaceNormalMap: boolean;
  25250. private _useParallax;
  25251. /**
  25252. * Is parallax enabled or not.
  25253. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  25254. */
  25255. useParallax: boolean;
  25256. private _useParallaxOcclusion;
  25257. /**
  25258. * Is parallax occlusion enabled or not.
  25259. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  25260. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  25261. */
  25262. useParallaxOcclusion: boolean;
  25263. /**
  25264. * 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.
  25265. */
  25266. parallaxScaleBias: number;
  25267. private _roughness;
  25268. /**
  25269. * Helps to define how blurry the reflections should appears in the material.
  25270. */
  25271. roughness: number;
  25272. /**
  25273. * In case of refraction, define the value of the index of refraction.
  25274. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25275. */
  25276. indexOfRefraction: number;
  25277. /**
  25278. * Invert the refraction texture alongside the y axis.
  25279. * It can be useful with procedural textures or probe for instance.
  25280. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  25281. */
  25282. invertRefractionY: boolean;
  25283. /**
  25284. * Defines the alpha limits in alpha test mode.
  25285. */
  25286. alphaCutOff: number;
  25287. private _useLightmapAsShadowmap;
  25288. /**
  25289. * In case of light mapping, define whether the map contains light or shadow informations.
  25290. */
  25291. useLightmapAsShadowmap: boolean;
  25292. private _diffuseFresnelParameters;
  25293. /**
  25294. * Define the diffuse fresnel parameters of the material.
  25295. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25296. */
  25297. diffuseFresnelParameters: FresnelParameters;
  25298. private _opacityFresnelParameters;
  25299. /**
  25300. * Define the opacity fresnel parameters of the material.
  25301. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25302. */
  25303. opacityFresnelParameters: FresnelParameters;
  25304. private _reflectionFresnelParameters;
  25305. /**
  25306. * Define the reflection fresnel parameters of the material.
  25307. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25308. */
  25309. reflectionFresnelParameters: FresnelParameters;
  25310. private _refractionFresnelParameters;
  25311. /**
  25312. * Define the refraction fresnel parameters of the material.
  25313. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25314. */
  25315. refractionFresnelParameters: FresnelParameters;
  25316. private _emissiveFresnelParameters;
  25317. /**
  25318. * Define the emissive fresnel parameters of the material.
  25319. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25320. */
  25321. emissiveFresnelParameters: FresnelParameters;
  25322. private _useReflectionFresnelFromSpecular;
  25323. /**
  25324. * If true automatically deducts the fresnels values from the material specularity.
  25325. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  25326. */
  25327. useReflectionFresnelFromSpecular: boolean;
  25328. private _useGlossinessFromSpecularMapAlpha;
  25329. /**
  25330. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  25331. */
  25332. useGlossinessFromSpecularMapAlpha: boolean;
  25333. private _maxSimultaneousLights;
  25334. /**
  25335. * Defines the maximum number of lights that can be used in the material
  25336. */
  25337. maxSimultaneousLights: number;
  25338. private _invertNormalMapX;
  25339. /**
  25340. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  25341. */
  25342. invertNormalMapX: boolean;
  25343. private _invertNormalMapY;
  25344. /**
  25345. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  25346. */
  25347. invertNormalMapY: boolean;
  25348. private _twoSidedLighting;
  25349. /**
  25350. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  25351. */
  25352. twoSidedLighting: boolean;
  25353. /**
  25354. * Default configuration related to image processing available in the standard Material.
  25355. */
  25356. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25357. /**
  25358. * Gets the image processing configuration used either in this material.
  25359. */
  25360. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25361. /**
  25362. * Sets the Default image processing configuration used either in the this material.
  25363. *
  25364. * If sets to null, the scene one is in use.
  25365. */
  25366. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25367. /**
  25368. * Keep track of the image processing observer to allow dispose and replace.
  25369. */
  25370. private _imageProcessingObserver;
  25371. /**
  25372. * Attaches a new image processing configuration to the Standard Material.
  25373. * @param configuration
  25374. */
  25375. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  25376. /**
  25377. * Defines additionnal PrePass parameters for the material.
  25378. */
  25379. readonly prePassConfiguration: PrePassConfiguration;
  25380. /**
  25381. * Gets wether the color curves effect is enabled.
  25382. */
  25383. get cameraColorCurvesEnabled(): boolean;
  25384. /**
  25385. * Sets wether the color curves effect is enabled.
  25386. */
  25387. set cameraColorCurvesEnabled(value: boolean);
  25388. /**
  25389. * Gets wether the color grading effect is enabled.
  25390. */
  25391. get cameraColorGradingEnabled(): boolean;
  25392. /**
  25393. * Gets wether the color grading effect is enabled.
  25394. */
  25395. set cameraColorGradingEnabled(value: boolean);
  25396. /**
  25397. * Gets wether tonemapping is enabled or not.
  25398. */
  25399. get cameraToneMappingEnabled(): boolean;
  25400. /**
  25401. * Sets wether tonemapping is enabled or not
  25402. */
  25403. set cameraToneMappingEnabled(value: boolean);
  25404. /**
  25405. * The camera exposure used on this material.
  25406. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25407. * This corresponds to a photographic exposure.
  25408. */
  25409. get cameraExposure(): number;
  25410. /**
  25411. * The camera exposure used on this material.
  25412. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  25413. * This corresponds to a photographic exposure.
  25414. */
  25415. set cameraExposure(value: number);
  25416. /**
  25417. * Gets The camera contrast used on this material.
  25418. */
  25419. get cameraContrast(): number;
  25420. /**
  25421. * Sets The camera contrast used on this material.
  25422. */
  25423. set cameraContrast(value: number);
  25424. /**
  25425. * Gets the Color Grading 2D Lookup Texture.
  25426. */
  25427. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  25428. /**
  25429. * Sets the Color Grading 2D Lookup Texture.
  25430. */
  25431. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  25432. /**
  25433. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25434. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25435. * 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;
  25436. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25437. */
  25438. get cameraColorCurves(): Nullable<ColorCurves>;
  25439. /**
  25440. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  25441. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  25442. * 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;
  25443. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  25444. */
  25445. set cameraColorCurves(value: Nullable<ColorCurves>);
  25446. /**
  25447. * Can this material render to several textures at once
  25448. */
  25449. get canRenderToMRT(): boolean;
  25450. /**
  25451. * Defines the detail map parameters for the material.
  25452. */
  25453. readonly detailMap: DetailMapConfiguration;
  25454. protected _renderTargets: SmartArray<RenderTargetTexture>;
  25455. protected _worldViewProjectionMatrix: Matrix;
  25456. protected _globalAmbientColor: Color3;
  25457. protected _useLogarithmicDepth: boolean;
  25458. protected _rebuildInParallel: boolean;
  25459. /**
  25460. * Instantiates a new standard material.
  25461. * This is the default material used in Babylon. It is the best trade off between quality
  25462. * and performances.
  25463. * @see https://doc.babylonjs.com/babylon101/materials
  25464. * @param name Define the name of the material in the scene
  25465. * @param scene Define the scene the material belong to
  25466. */
  25467. constructor(name: string, scene: Scene);
  25468. /**
  25469. * Gets a boolean indicating that current material needs to register RTT
  25470. */
  25471. get hasRenderTargetTextures(): boolean;
  25472. /**
  25473. * Gets the current class name of the material e.g. "StandardMaterial"
  25474. * Mainly use in serialization.
  25475. * @returns the class name
  25476. */
  25477. getClassName(): string;
  25478. /**
  25479. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  25480. * You can try switching to logarithmic depth.
  25481. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  25482. */
  25483. get useLogarithmicDepth(): boolean;
  25484. set useLogarithmicDepth(value: boolean);
  25485. /**
  25486. * Specifies if the material will require alpha blending
  25487. * @returns a boolean specifying if alpha blending is needed
  25488. */
  25489. needAlphaBlending(): boolean;
  25490. /**
  25491. * Specifies if this material should be rendered in alpha test mode
  25492. * @returns a boolean specifying if an alpha test is needed.
  25493. */
  25494. needAlphaTesting(): boolean;
  25495. /**
  25496. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  25497. */
  25498. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  25499. /**
  25500. * Specifies whether or not there is a usable alpha channel for transparency.
  25501. */
  25502. protected _hasAlphaChannel(): boolean;
  25503. /**
  25504. * Get the texture used for alpha test purpose.
  25505. * @returns the diffuse texture in case of the standard material.
  25506. */
  25507. getAlphaTestTexture(): Nullable<BaseTexture>;
  25508. /**
  25509. * Get if the submesh is ready to be used and all its information available.
  25510. * Child classes can use it to update shaders
  25511. * @param mesh defines the mesh to check
  25512. * @param subMesh defines which submesh to check
  25513. * @param useInstances specifies that instances should be used
  25514. * @returns a boolean indicating that the submesh is ready or not
  25515. */
  25516. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25517. /**
  25518. * Builds the material UBO layouts.
  25519. * Used internally during the effect preparation.
  25520. */
  25521. buildUniformLayout(): void;
  25522. /**
  25523. * Unbinds the material from the mesh
  25524. */
  25525. unbind(): void;
  25526. /**
  25527. * Binds the submesh to this material by preparing the effect and shader to draw
  25528. * @param world defines the world transformation matrix
  25529. * @param mesh defines the mesh containing the submesh
  25530. * @param subMesh defines the submesh to bind the material to
  25531. */
  25532. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25533. /**
  25534. * Get the list of animatables in the material.
  25535. * @returns the list of animatables object used in the material
  25536. */
  25537. getAnimatables(): IAnimatable[];
  25538. /**
  25539. * Gets the active textures from the material
  25540. * @returns an array of textures
  25541. */
  25542. getActiveTextures(): BaseTexture[];
  25543. /**
  25544. * Specifies if the material uses a texture
  25545. * @param texture defines the texture to check against the material
  25546. * @returns a boolean specifying if the material uses the texture
  25547. */
  25548. hasTexture(texture: BaseTexture): boolean;
  25549. /**
  25550. * Disposes the material
  25551. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25552. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25553. */
  25554. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  25555. /**
  25556. * Makes a duplicate of the material, and gives it a new name
  25557. * @param name defines the new name for the duplicated material
  25558. * @returns the cloned material
  25559. */
  25560. clone(name: string): StandardMaterial;
  25561. /**
  25562. * Serializes this material in a JSON representation
  25563. * @returns the serialized material object
  25564. */
  25565. serialize(): any;
  25566. /**
  25567. * Creates a standard material from parsed material data
  25568. * @param source defines the JSON representation of the material
  25569. * @param scene defines the hosting scene
  25570. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  25571. * @returns a new standard material
  25572. */
  25573. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  25574. /**
  25575. * Are diffuse textures enabled in the application.
  25576. */
  25577. static get DiffuseTextureEnabled(): boolean;
  25578. static set DiffuseTextureEnabled(value: boolean);
  25579. /**
  25580. * Are detail textures enabled in the application.
  25581. */
  25582. static get DetailTextureEnabled(): boolean;
  25583. static set DetailTextureEnabled(value: boolean);
  25584. /**
  25585. * Are ambient textures enabled in the application.
  25586. */
  25587. static get AmbientTextureEnabled(): boolean;
  25588. static set AmbientTextureEnabled(value: boolean);
  25589. /**
  25590. * Are opacity textures enabled in the application.
  25591. */
  25592. static get OpacityTextureEnabled(): boolean;
  25593. static set OpacityTextureEnabled(value: boolean);
  25594. /**
  25595. * Are reflection textures enabled in the application.
  25596. */
  25597. static get ReflectionTextureEnabled(): boolean;
  25598. static set ReflectionTextureEnabled(value: boolean);
  25599. /**
  25600. * Are emissive textures enabled in the application.
  25601. */
  25602. static get EmissiveTextureEnabled(): boolean;
  25603. static set EmissiveTextureEnabled(value: boolean);
  25604. /**
  25605. * Are specular textures enabled in the application.
  25606. */
  25607. static get SpecularTextureEnabled(): boolean;
  25608. static set SpecularTextureEnabled(value: boolean);
  25609. /**
  25610. * Are bump textures enabled in the application.
  25611. */
  25612. static get BumpTextureEnabled(): boolean;
  25613. static set BumpTextureEnabled(value: boolean);
  25614. /**
  25615. * Are lightmap textures enabled in the application.
  25616. */
  25617. static get LightmapTextureEnabled(): boolean;
  25618. static set LightmapTextureEnabled(value: boolean);
  25619. /**
  25620. * Are refraction textures enabled in the application.
  25621. */
  25622. static get RefractionTextureEnabled(): boolean;
  25623. static set RefractionTextureEnabled(value: boolean);
  25624. /**
  25625. * Are color grading textures enabled in the application.
  25626. */
  25627. static get ColorGradingTextureEnabled(): boolean;
  25628. static set ColorGradingTextureEnabled(value: boolean);
  25629. /**
  25630. * Are fresnels enabled in the application.
  25631. */
  25632. static get FresnelEnabled(): boolean;
  25633. static set FresnelEnabled(value: boolean);
  25634. }
  25635. }
  25636. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  25637. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25638. /** @hidden */
  25639. export var rgbdDecodePixelShader: {
  25640. name: string;
  25641. shader: string;
  25642. };
  25643. }
  25644. declare module "babylonjs/Misc/rgbdTextureTools" {
  25645. import "babylonjs/Shaders/rgbdDecode.fragment";
  25646. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25647. import { Texture } from "babylonjs/Materials/Textures/texture";
  25648. /**
  25649. * Class used to host RGBD texture specific utilities
  25650. */
  25651. export class RGBDTextureTools {
  25652. /**
  25653. * Expand the RGBD Texture from RGBD to Half Float if possible.
  25654. * @param texture the texture to expand.
  25655. */
  25656. static ExpandRGBDTexture(texture: Texture): void;
  25657. }
  25658. }
  25659. declare module "babylonjs/Misc/brdfTextureTools" {
  25660. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25661. import { Scene } from "babylonjs/scene";
  25662. /**
  25663. * Class used to host texture specific utilities
  25664. */
  25665. export class BRDFTextureTools {
  25666. /**
  25667. * Prevents texture cache collision
  25668. */
  25669. private static _instanceNumber;
  25670. /**
  25671. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  25672. * @param scene defines the hosting scene
  25673. * @returns the environment BRDF texture
  25674. */
  25675. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  25676. private static _environmentBRDFBase64Texture;
  25677. }
  25678. }
  25679. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  25680. import { Nullable } from "babylonjs/types";
  25681. import { Color3 } from "babylonjs/Maths/math.color";
  25682. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25683. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25684. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25685. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25686. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25687. import { Engine } from "babylonjs/Engines/engine";
  25688. import { Scene } from "babylonjs/scene";
  25689. /**
  25690. * @hidden
  25691. */
  25692. export interface IMaterialClearCoatDefines {
  25693. CLEARCOAT: boolean;
  25694. CLEARCOAT_DEFAULTIOR: boolean;
  25695. CLEARCOAT_TEXTURE: boolean;
  25696. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  25697. CLEARCOAT_TEXTUREDIRECTUV: number;
  25698. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  25699. CLEARCOAT_BUMP: boolean;
  25700. CLEARCOAT_BUMPDIRECTUV: number;
  25701. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  25702. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  25703. CLEARCOAT_REMAP_F0: boolean;
  25704. CLEARCOAT_TINT: boolean;
  25705. CLEARCOAT_TINT_TEXTURE: boolean;
  25706. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  25707. /** @hidden */
  25708. _areTexturesDirty: boolean;
  25709. }
  25710. /**
  25711. * Define the code related to the clear coat parameters of the pbr material.
  25712. */
  25713. export class PBRClearCoatConfiguration {
  25714. /**
  25715. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25716. * The default fits with a polyurethane material.
  25717. */
  25718. private static readonly _DefaultIndexOfRefraction;
  25719. private _isEnabled;
  25720. /**
  25721. * Defines if the clear coat is enabled in the material.
  25722. */
  25723. isEnabled: boolean;
  25724. /**
  25725. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  25726. */
  25727. intensity: number;
  25728. /**
  25729. * Defines the clear coat layer roughness.
  25730. */
  25731. roughness: number;
  25732. private _indexOfRefraction;
  25733. /**
  25734. * Defines the index of refraction of the clear coat.
  25735. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  25736. * The default fits with a polyurethane material.
  25737. * Changing the default value is more performance intensive.
  25738. */
  25739. indexOfRefraction: number;
  25740. private _texture;
  25741. /**
  25742. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  25743. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  25744. * if textureRoughness is not empty, else no texture roughness is used
  25745. */
  25746. texture: Nullable<BaseTexture>;
  25747. private _useRoughnessFromMainTexture;
  25748. /**
  25749. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  25750. * If false, the green channel from textureRoughness is used for roughness
  25751. */
  25752. useRoughnessFromMainTexture: boolean;
  25753. private _textureRoughness;
  25754. /**
  25755. * Stores the clear coat roughness in a texture (green channel)
  25756. * Not used if useRoughnessFromMainTexture is true
  25757. */
  25758. textureRoughness: Nullable<BaseTexture>;
  25759. private _remapF0OnInterfaceChange;
  25760. /**
  25761. * Defines if the F0 value should be remapped to account for the interface change in the material.
  25762. */
  25763. remapF0OnInterfaceChange: boolean;
  25764. private _bumpTexture;
  25765. /**
  25766. * Define the clear coat specific bump texture.
  25767. */
  25768. bumpTexture: Nullable<BaseTexture>;
  25769. private _isTintEnabled;
  25770. /**
  25771. * Defines if the clear coat tint is enabled in the material.
  25772. */
  25773. isTintEnabled: boolean;
  25774. /**
  25775. * Defines the clear coat tint of the material.
  25776. * This is only use if tint is enabled
  25777. */
  25778. tintColor: Color3;
  25779. /**
  25780. * Defines the distance at which the tint color should be found in the
  25781. * clear coat media.
  25782. * This is only use if tint is enabled
  25783. */
  25784. tintColorAtDistance: number;
  25785. /**
  25786. * Defines the clear coat layer thickness.
  25787. * This is only use if tint is enabled
  25788. */
  25789. tintThickness: number;
  25790. private _tintTexture;
  25791. /**
  25792. * Stores the clear tint values in a texture.
  25793. * rgb is tint
  25794. * a is a thickness factor
  25795. */
  25796. tintTexture: Nullable<BaseTexture>;
  25797. /** @hidden */
  25798. private _internalMarkAllSubMeshesAsTexturesDirty;
  25799. /** @hidden */
  25800. _markAllSubMeshesAsTexturesDirty(): void;
  25801. /**
  25802. * Instantiate a new istance of clear coat configuration.
  25803. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25804. */
  25805. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25806. /**
  25807. * Gets wehter the submesh is ready to be used or not.
  25808. * @param defines the list of "defines" to update.
  25809. * @param scene defines the scene the material belongs to.
  25810. * @param engine defines the engine the material belongs to.
  25811. * @param disableBumpMap defines wether the material disables bump or not.
  25812. * @returns - boolean indicating that the submesh is ready or not.
  25813. */
  25814. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  25815. /**
  25816. * Checks to see if a texture is used in the material.
  25817. * @param defines the list of "defines" to update.
  25818. * @param scene defines the scene to the material belongs to.
  25819. */
  25820. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  25821. /**
  25822. * Binds the material data.
  25823. * @param uniformBuffer defines the Uniform buffer to fill in.
  25824. * @param scene defines the scene the material belongs to.
  25825. * @param engine defines the engine the material belongs to.
  25826. * @param disableBumpMap defines wether the material disables bump or not.
  25827. * @param isFrozen defines wether the material is frozen or not.
  25828. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  25829. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  25830. * @param subMesh the submesh to bind data for
  25831. */
  25832. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  25833. /**
  25834. * Checks to see if a texture is used in the material.
  25835. * @param texture - Base texture to use.
  25836. * @returns - Boolean specifying if a texture is used in the material.
  25837. */
  25838. hasTexture(texture: BaseTexture): boolean;
  25839. /**
  25840. * Returns an array of the actively used textures.
  25841. * @param activeTextures Array of BaseTextures
  25842. */
  25843. getActiveTextures(activeTextures: BaseTexture[]): void;
  25844. /**
  25845. * Returns the animatable textures.
  25846. * @param animatables Array of animatable textures.
  25847. */
  25848. getAnimatables(animatables: IAnimatable[]): void;
  25849. /**
  25850. * Disposes the resources of the material.
  25851. * @param forceDisposeTextures - Forces the disposal of all textures.
  25852. */
  25853. dispose(forceDisposeTextures?: boolean): void;
  25854. /**
  25855. * Get the current class name of the texture useful for serialization or dynamic coding.
  25856. * @returns "PBRClearCoatConfiguration"
  25857. */
  25858. getClassName(): string;
  25859. /**
  25860. * Add fallbacks to the effect fallbacks list.
  25861. * @param defines defines the Base texture to use.
  25862. * @param fallbacks defines the current fallback list.
  25863. * @param currentRank defines the current fallback rank.
  25864. * @returns the new fallback rank.
  25865. */
  25866. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25867. /**
  25868. * Add the required uniforms to the current list.
  25869. * @param uniforms defines the current uniform list.
  25870. */
  25871. static AddUniforms(uniforms: string[]): void;
  25872. /**
  25873. * Add the required samplers to the current list.
  25874. * @param samplers defines the current sampler list.
  25875. */
  25876. static AddSamplers(samplers: string[]): void;
  25877. /**
  25878. * Add the required uniforms to the current buffer.
  25879. * @param uniformBuffer defines the current uniform buffer.
  25880. */
  25881. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25882. /**
  25883. * Makes a duplicate of the current configuration into another one.
  25884. * @param clearCoatConfiguration define the config where to copy the info
  25885. */
  25886. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  25887. /**
  25888. * Serializes this clear coat configuration.
  25889. * @returns - An object with the serialized config.
  25890. */
  25891. serialize(): any;
  25892. /**
  25893. * Parses a anisotropy Configuration from a serialized object.
  25894. * @param source - Serialized object.
  25895. * @param scene Defines the scene we are parsing for
  25896. * @param rootUrl Defines the rootUrl to load from
  25897. */
  25898. parse(source: any, scene: Scene, rootUrl: string): void;
  25899. }
  25900. }
  25901. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  25902. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25904. import { Vector2 } from "babylonjs/Maths/math.vector";
  25905. import { Scene } from "babylonjs/scene";
  25906. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25907. import { Nullable } from "babylonjs/types";
  25908. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25909. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  25910. /**
  25911. * @hidden
  25912. */
  25913. export interface IMaterialAnisotropicDefines {
  25914. ANISOTROPIC: boolean;
  25915. ANISOTROPIC_TEXTURE: boolean;
  25916. ANISOTROPIC_TEXTUREDIRECTUV: number;
  25917. MAINUV1: boolean;
  25918. _areTexturesDirty: boolean;
  25919. _needUVs: boolean;
  25920. }
  25921. /**
  25922. * Define the code related to the anisotropic parameters of the pbr material.
  25923. */
  25924. export class PBRAnisotropicConfiguration {
  25925. private _isEnabled;
  25926. /**
  25927. * Defines if the anisotropy is enabled in the material.
  25928. */
  25929. isEnabled: boolean;
  25930. /**
  25931. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  25932. */
  25933. intensity: number;
  25934. /**
  25935. * Defines if the effect is along the tangents, bitangents or in between.
  25936. * By default, the effect is "strectching" the highlights along the tangents.
  25937. */
  25938. direction: Vector2;
  25939. private _texture;
  25940. /**
  25941. * Stores the anisotropy values in a texture.
  25942. * rg is direction (like normal from -1 to 1)
  25943. * b is a intensity
  25944. */
  25945. texture: Nullable<BaseTexture>;
  25946. /** @hidden */
  25947. private _internalMarkAllSubMeshesAsTexturesDirty;
  25948. /** @hidden */
  25949. _markAllSubMeshesAsTexturesDirty(): void;
  25950. /**
  25951. * Instantiate a new istance of anisotropy configuration.
  25952. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25953. */
  25954. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  25955. /**
  25956. * Specifies that the submesh is ready to be used.
  25957. * @param defines the list of "defines" to update.
  25958. * @param scene defines the scene the material belongs to.
  25959. * @returns - boolean indicating that the submesh is ready or not.
  25960. */
  25961. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  25962. /**
  25963. * Checks to see if a texture is used in the material.
  25964. * @param defines the list of "defines" to update.
  25965. * @param mesh the mesh we are preparing the defines for.
  25966. * @param scene defines the scene the material belongs to.
  25967. */
  25968. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  25969. /**
  25970. * Binds the material data.
  25971. * @param uniformBuffer defines the Uniform buffer to fill in.
  25972. * @param scene defines the scene the material belongs to.
  25973. * @param isFrozen defines wether the material is frozen or not.
  25974. */
  25975. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  25976. /**
  25977. * Checks to see if a texture is used in the material.
  25978. * @param texture - Base texture to use.
  25979. * @returns - Boolean specifying if a texture is used in the material.
  25980. */
  25981. hasTexture(texture: BaseTexture): boolean;
  25982. /**
  25983. * Returns an array of the actively used textures.
  25984. * @param activeTextures Array of BaseTextures
  25985. */
  25986. getActiveTextures(activeTextures: BaseTexture[]): void;
  25987. /**
  25988. * Returns the animatable textures.
  25989. * @param animatables Array of animatable textures.
  25990. */
  25991. getAnimatables(animatables: IAnimatable[]): void;
  25992. /**
  25993. * Disposes the resources of the material.
  25994. * @param forceDisposeTextures - Forces the disposal of all textures.
  25995. */
  25996. dispose(forceDisposeTextures?: boolean): void;
  25997. /**
  25998. * Get the current class name of the texture useful for serialization or dynamic coding.
  25999. * @returns "PBRAnisotropicConfiguration"
  26000. */
  26001. getClassName(): string;
  26002. /**
  26003. * Add fallbacks to the effect fallbacks list.
  26004. * @param defines defines the Base texture to use.
  26005. * @param fallbacks defines the current fallback list.
  26006. * @param currentRank defines the current fallback rank.
  26007. * @returns the new fallback rank.
  26008. */
  26009. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26010. /**
  26011. * Add the required uniforms to the current list.
  26012. * @param uniforms defines the current uniform list.
  26013. */
  26014. static AddUniforms(uniforms: string[]): void;
  26015. /**
  26016. * Add the required uniforms to the current buffer.
  26017. * @param uniformBuffer defines the current uniform buffer.
  26018. */
  26019. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26020. /**
  26021. * Add the required samplers to the current list.
  26022. * @param samplers defines the current sampler list.
  26023. */
  26024. static AddSamplers(samplers: string[]): void;
  26025. /**
  26026. * Makes a duplicate of the current configuration into another one.
  26027. * @param anisotropicConfiguration define the config where to copy the info
  26028. */
  26029. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  26030. /**
  26031. * Serializes this anisotropy configuration.
  26032. * @returns - An object with the serialized config.
  26033. */
  26034. serialize(): any;
  26035. /**
  26036. * Parses a anisotropy Configuration from a serialized object.
  26037. * @param source - Serialized object.
  26038. * @param scene Defines the scene we are parsing for
  26039. * @param rootUrl Defines the rootUrl to load from
  26040. */
  26041. parse(source: any, scene: Scene, rootUrl: string): void;
  26042. }
  26043. }
  26044. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  26045. import { Scene } from "babylonjs/scene";
  26046. /**
  26047. * @hidden
  26048. */
  26049. export interface IMaterialBRDFDefines {
  26050. BRDF_V_HEIGHT_CORRELATED: boolean;
  26051. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26052. SPHERICAL_HARMONICS: boolean;
  26053. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26054. /** @hidden */
  26055. _areMiscDirty: boolean;
  26056. }
  26057. /**
  26058. * Define the code related to the BRDF parameters of the pbr material.
  26059. */
  26060. export class PBRBRDFConfiguration {
  26061. /**
  26062. * Default value used for the energy conservation.
  26063. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  26064. */
  26065. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  26066. /**
  26067. * Default value used for the Smith Visibility Height Correlated mode.
  26068. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  26069. */
  26070. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  26071. /**
  26072. * Default value used for the IBL diffuse part.
  26073. * This can help switching back to the polynomials mode globally which is a tiny bit
  26074. * less GPU intensive at the drawback of a lower quality.
  26075. */
  26076. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  26077. /**
  26078. * Default value used for activating energy conservation for the specular workflow.
  26079. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  26080. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  26081. */
  26082. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  26083. private _useEnergyConservation;
  26084. /**
  26085. * Defines if the material uses energy conservation.
  26086. */
  26087. useEnergyConservation: boolean;
  26088. private _useSmithVisibilityHeightCorrelated;
  26089. /**
  26090. * LEGACY Mode set to false
  26091. * Defines if the material uses height smith correlated visibility term.
  26092. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  26093. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  26094. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  26095. * Not relying on height correlated will also disable energy conservation.
  26096. */
  26097. useSmithVisibilityHeightCorrelated: boolean;
  26098. private _useSphericalHarmonics;
  26099. /**
  26100. * LEGACY Mode set to false
  26101. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  26102. * diffuse part of the IBL.
  26103. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  26104. * to the ground truth.
  26105. */
  26106. useSphericalHarmonics: boolean;
  26107. private _useSpecularGlossinessInputEnergyConservation;
  26108. /**
  26109. * Defines if the material uses energy conservation, when the specular workflow is active.
  26110. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  26111. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  26112. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  26113. */
  26114. useSpecularGlossinessInputEnergyConservation: boolean;
  26115. /** @hidden */
  26116. private _internalMarkAllSubMeshesAsMiscDirty;
  26117. /** @hidden */
  26118. _markAllSubMeshesAsMiscDirty(): void;
  26119. /**
  26120. * Instantiate a new istance of clear coat configuration.
  26121. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  26122. */
  26123. constructor(markAllSubMeshesAsMiscDirty: () => void);
  26124. /**
  26125. * Checks to see if a texture is used in the material.
  26126. * @param defines the list of "defines" to update.
  26127. */
  26128. prepareDefines(defines: IMaterialBRDFDefines): void;
  26129. /**
  26130. * Get the current class name of the texture useful for serialization or dynamic coding.
  26131. * @returns "PBRClearCoatConfiguration"
  26132. */
  26133. getClassName(): string;
  26134. /**
  26135. * Makes a duplicate of the current configuration into another one.
  26136. * @param brdfConfiguration define the config where to copy the info
  26137. */
  26138. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  26139. /**
  26140. * Serializes this BRDF configuration.
  26141. * @returns - An object with the serialized config.
  26142. */
  26143. serialize(): any;
  26144. /**
  26145. * Parses a anisotropy Configuration from a serialized object.
  26146. * @param source - Serialized object.
  26147. * @param scene Defines the scene we are parsing for
  26148. * @param rootUrl Defines the rootUrl to load from
  26149. */
  26150. parse(source: any, scene: Scene, rootUrl: string): void;
  26151. }
  26152. }
  26153. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  26154. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26155. import { Color3 } from "babylonjs/Maths/math.color";
  26156. import { Scene } from "babylonjs/scene";
  26157. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26158. import { Nullable } from "babylonjs/types";
  26159. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26160. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  26161. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26162. /**
  26163. * @hidden
  26164. */
  26165. export interface IMaterialSheenDefines {
  26166. SHEEN: boolean;
  26167. SHEEN_TEXTURE: boolean;
  26168. SHEEN_TEXTURE_ROUGHNESS: boolean;
  26169. SHEEN_TEXTUREDIRECTUV: number;
  26170. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  26171. SHEEN_LINKWITHALBEDO: boolean;
  26172. SHEEN_ROUGHNESS: boolean;
  26173. SHEEN_ALBEDOSCALING: boolean;
  26174. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  26175. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  26176. /** @hidden */
  26177. _areTexturesDirty: boolean;
  26178. }
  26179. /**
  26180. * Define the code related to the Sheen parameters of the pbr material.
  26181. */
  26182. export class PBRSheenConfiguration {
  26183. private _isEnabled;
  26184. /**
  26185. * Defines if the material uses sheen.
  26186. */
  26187. isEnabled: boolean;
  26188. private _linkSheenWithAlbedo;
  26189. /**
  26190. * Defines if the sheen is linked to the sheen color.
  26191. */
  26192. linkSheenWithAlbedo: boolean;
  26193. /**
  26194. * Defines the sheen intensity.
  26195. */
  26196. intensity: number;
  26197. /**
  26198. * Defines the sheen color.
  26199. */
  26200. color: Color3;
  26201. private _texture;
  26202. /**
  26203. * Stores the sheen tint values in a texture.
  26204. * rgb is tint
  26205. * 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)
  26206. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  26207. */
  26208. texture: Nullable<BaseTexture>;
  26209. private _useRoughnessFromMainTexture;
  26210. /**
  26211. * Indicates that the alpha channel of the texture property will be used for roughness.
  26212. * Has no effect if the roughness (and texture!) property is not defined
  26213. */
  26214. useRoughnessFromMainTexture: boolean;
  26215. private _roughness;
  26216. /**
  26217. * Defines the sheen roughness.
  26218. * It is not taken into account if linkSheenWithAlbedo is true.
  26219. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  26220. */
  26221. roughness: Nullable<number>;
  26222. private _textureRoughness;
  26223. /**
  26224. * Stores the sheen roughness in a texture.
  26225. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  26226. */
  26227. textureRoughness: Nullable<BaseTexture>;
  26228. private _albedoScaling;
  26229. /**
  26230. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  26231. * It allows the strength of the sheen effect to not depend on the base color of the material,
  26232. * making it easier to setup and tweak the effect
  26233. */
  26234. albedoScaling: boolean;
  26235. /** @hidden */
  26236. private _internalMarkAllSubMeshesAsTexturesDirty;
  26237. /** @hidden */
  26238. _markAllSubMeshesAsTexturesDirty(): void;
  26239. /**
  26240. * Instantiate a new istance of clear coat configuration.
  26241. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26242. */
  26243. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  26244. /**
  26245. * Specifies that the submesh is ready to be used.
  26246. * @param defines the list of "defines" to update.
  26247. * @param scene defines the scene the material belongs to.
  26248. * @returns - boolean indicating that the submesh is ready or not.
  26249. */
  26250. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  26251. /**
  26252. * Checks to see if a texture is used in the material.
  26253. * @param defines the list of "defines" to update.
  26254. * @param scene defines the scene the material belongs to.
  26255. */
  26256. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  26257. /**
  26258. * Binds the material data.
  26259. * @param uniformBuffer defines the Uniform buffer to fill in.
  26260. * @param scene defines the scene the material belongs to.
  26261. * @param isFrozen defines wether the material is frozen or not.
  26262. * @param subMesh the submesh to bind data for
  26263. */
  26264. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  26265. /**
  26266. * Checks to see if a texture is used in the material.
  26267. * @param texture - Base texture to use.
  26268. * @returns - Boolean specifying if a texture is used in the material.
  26269. */
  26270. hasTexture(texture: BaseTexture): boolean;
  26271. /**
  26272. * Returns an array of the actively used textures.
  26273. * @param activeTextures Array of BaseTextures
  26274. */
  26275. getActiveTextures(activeTextures: BaseTexture[]): void;
  26276. /**
  26277. * Returns the animatable textures.
  26278. * @param animatables Array of animatable textures.
  26279. */
  26280. getAnimatables(animatables: IAnimatable[]): void;
  26281. /**
  26282. * Disposes the resources of the material.
  26283. * @param forceDisposeTextures - Forces the disposal of all textures.
  26284. */
  26285. dispose(forceDisposeTextures?: boolean): void;
  26286. /**
  26287. * Get the current class name of the texture useful for serialization or dynamic coding.
  26288. * @returns "PBRSheenConfiguration"
  26289. */
  26290. getClassName(): string;
  26291. /**
  26292. * Add fallbacks to the effect fallbacks list.
  26293. * @param defines defines the Base texture to use.
  26294. * @param fallbacks defines the current fallback list.
  26295. * @param currentRank defines the current fallback rank.
  26296. * @returns the new fallback rank.
  26297. */
  26298. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26299. /**
  26300. * Add the required uniforms to the current list.
  26301. * @param uniforms defines the current uniform list.
  26302. */
  26303. static AddUniforms(uniforms: string[]): void;
  26304. /**
  26305. * Add the required uniforms to the current buffer.
  26306. * @param uniformBuffer defines the current uniform buffer.
  26307. */
  26308. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26309. /**
  26310. * Add the required samplers to the current list.
  26311. * @param samplers defines the current sampler list.
  26312. */
  26313. static AddSamplers(samplers: string[]): void;
  26314. /**
  26315. * Makes a duplicate of the current configuration into another one.
  26316. * @param sheenConfiguration define the config where to copy the info
  26317. */
  26318. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  26319. /**
  26320. * Serializes this BRDF configuration.
  26321. * @returns - An object with the serialized config.
  26322. */
  26323. serialize(): any;
  26324. /**
  26325. * Parses a anisotropy Configuration from a serialized object.
  26326. * @param source - Serialized object.
  26327. * @param scene Defines the scene we are parsing for
  26328. * @param rootUrl Defines the rootUrl to load from
  26329. */
  26330. parse(source: any, scene: Scene, rootUrl: string): void;
  26331. }
  26332. }
  26333. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  26334. import { Nullable } from "babylonjs/types";
  26335. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26336. import { Color3 } from "babylonjs/Maths/math.color";
  26337. import { SmartArray } from "babylonjs/Misc/smartArray";
  26338. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26339. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26340. import { Effect } from "babylonjs/Materials/effect";
  26341. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  26342. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  26343. import { Engine } from "babylonjs/Engines/engine";
  26344. import { Scene } from "babylonjs/scene";
  26345. /**
  26346. * @hidden
  26347. */
  26348. export interface IMaterialSubSurfaceDefines {
  26349. SUBSURFACE: boolean;
  26350. SS_REFRACTION: boolean;
  26351. SS_TRANSLUCENCY: boolean;
  26352. SS_SCATTERING: boolean;
  26353. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26354. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26355. SS_REFRACTIONMAP_3D: boolean;
  26356. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26357. SS_LODINREFRACTIONALPHA: boolean;
  26358. SS_GAMMAREFRACTION: boolean;
  26359. SS_RGBDREFRACTION: boolean;
  26360. SS_LINEARSPECULARREFRACTION: boolean;
  26361. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26362. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26363. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26364. /** @hidden */
  26365. _areTexturesDirty: boolean;
  26366. }
  26367. /**
  26368. * Define the code related to the sub surface parameters of the pbr material.
  26369. */
  26370. export class PBRSubSurfaceConfiguration {
  26371. private _isRefractionEnabled;
  26372. /**
  26373. * Defines if the refraction is enabled in the material.
  26374. */
  26375. isRefractionEnabled: boolean;
  26376. private _isTranslucencyEnabled;
  26377. /**
  26378. * Defines if the translucency is enabled in the material.
  26379. */
  26380. isTranslucencyEnabled: boolean;
  26381. private _isScatteringEnabled;
  26382. /**
  26383. * Defines if the sub surface scattering is enabled in the material.
  26384. */
  26385. isScatteringEnabled: boolean;
  26386. private _scatteringDiffusionProfileIndex;
  26387. /**
  26388. * Diffusion profile for subsurface scattering.
  26389. * Useful for better scattering in the skins or foliages.
  26390. */
  26391. get scatteringDiffusionProfile(): Nullable<Color3>;
  26392. set scatteringDiffusionProfile(c: Nullable<Color3>);
  26393. /**
  26394. * Defines the refraction intensity of the material.
  26395. * The refraction when enabled replaces the Diffuse part of the material.
  26396. * The intensity helps transitionning between diffuse and refraction.
  26397. */
  26398. refractionIntensity: number;
  26399. /**
  26400. * Defines the translucency intensity of the material.
  26401. * When translucency has been enabled, this defines how much of the "translucency"
  26402. * is addded to the diffuse part of the material.
  26403. */
  26404. translucencyIntensity: number;
  26405. /**
  26406. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  26407. */
  26408. useAlbedoToTintRefraction: boolean;
  26409. private _thicknessTexture;
  26410. /**
  26411. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  26412. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  26413. * 0 would mean minimumThickness
  26414. * 1 would mean maximumThickness
  26415. * The other channels might be use as a mask to vary the different effects intensity.
  26416. */
  26417. thicknessTexture: Nullable<BaseTexture>;
  26418. private _refractionTexture;
  26419. /**
  26420. * Defines the texture to use for refraction.
  26421. */
  26422. refractionTexture: Nullable<BaseTexture>;
  26423. private _indexOfRefraction;
  26424. /**
  26425. * Index of refraction of the material base layer.
  26426. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26427. *
  26428. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26429. *
  26430. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26431. */
  26432. indexOfRefraction: number;
  26433. private _volumeIndexOfRefraction;
  26434. /**
  26435. * Index of refraction of the material's volume.
  26436. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26437. *
  26438. * This ONLY impacts refraction. If not provided or given a non-valid value,
  26439. * the volume will use the same IOR as the surface.
  26440. */
  26441. get volumeIndexOfRefraction(): number;
  26442. set volumeIndexOfRefraction(value: number);
  26443. private _invertRefractionY;
  26444. /**
  26445. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26446. */
  26447. invertRefractionY: boolean;
  26448. private _linkRefractionWithTransparency;
  26449. /**
  26450. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26451. * Materials half opaque for instance using refraction could benefit from this control.
  26452. */
  26453. linkRefractionWithTransparency: boolean;
  26454. /**
  26455. * Defines the minimum thickness stored in the thickness map.
  26456. * If no thickness map is defined, this value will be used to simulate thickness.
  26457. */
  26458. minimumThickness: number;
  26459. /**
  26460. * Defines the maximum thickness stored in the thickness map.
  26461. */
  26462. maximumThickness: number;
  26463. /**
  26464. * Defines the volume tint of the material.
  26465. * This is used for both translucency and scattering.
  26466. */
  26467. tintColor: Color3;
  26468. /**
  26469. * Defines the distance at which the tint color should be found in the media.
  26470. * This is used for refraction only.
  26471. */
  26472. tintColorAtDistance: number;
  26473. /**
  26474. * Defines how far each channel transmit through the media.
  26475. * It is defined as a color to simplify it selection.
  26476. */
  26477. diffusionDistance: Color3;
  26478. private _useMaskFromThicknessTexture;
  26479. /**
  26480. * Stores the intensity of the different subsurface effects in the thickness texture.
  26481. * * the green channel is the translucency intensity.
  26482. * * the blue channel is the scattering intensity.
  26483. * * the alpha channel is the refraction intensity.
  26484. */
  26485. useMaskFromThicknessTexture: boolean;
  26486. private _scene;
  26487. /** @hidden */
  26488. private _internalMarkAllSubMeshesAsTexturesDirty;
  26489. private _internalMarkScenePrePassDirty;
  26490. /** @hidden */
  26491. _markAllSubMeshesAsTexturesDirty(): void;
  26492. /** @hidden */
  26493. _markScenePrePassDirty(): void;
  26494. /**
  26495. * Instantiate a new istance of sub surface configuration.
  26496. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  26497. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  26498. * @param scene The scene
  26499. */
  26500. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  26501. /**
  26502. * Gets wehter the submesh is ready to be used or not.
  26503. * @param defines the list of "defines" to update.
  26504. * @param scene defines the scene the material belongs to.
  26505. * @returns - boolean indicating that the submesh is ready or not.
  26506. */
  26507. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  26508. /**
  26509. * Checks to see if a texture is used in the material.
  26510. * @param defines the list of "defines" to update.
  26511. * @param scene defines the scene to the material belongs to.
  26512. */
  26513. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  26514. /**
  26515. * Binds the material data.
  26516. * @param uniformBuffer defines the Uniform buffer to fill in.
  26517. * @param scene defines the scene the material belongs to.
  26518. * @param engine defines the engine the material belongs to.
  26519. * @param isFrozen defines whether the material is frozen or not.
  26520. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  26521. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  26522. */
  26523. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  26524. /**
  26525. * Unbinds the material from the mesh.
  26526. * @param activeEffect defines the effect that should be unbound from.
  26527. * @returns true if unbound, otherwise false
  26528. */
  26529. unbind(activeEffect: Effect): boolean;
  26530. /**
  26531. * Returns the texture used for refraction or null if none is used.
  26532. * @param scene defines the scene the material belongs to.
  26533. * @returns - Refraction texture if present. If no refraction texture and refraction
  26534. * is linked with transparency, returns environment texture. Otherwise, returns null.
  26535. */
  26536. private _getRefractionTexture;
  26537. /**
  26538. * Returns true if alpha blending should be disabled.
  26539. */
  26540. get disableAlphaBlending(): boolean;
  26541. /**
  26542. * Fills the list of render target textures.
  26543. * @param renderTargets the list of render targets to update
  26544. */
  26545. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  26546. /**
  26547. * Checks to see if a texture is used in the material.
  26548. * @param texture - Base texture to use.
  26549. * @returns - Boolean specifying if a texture is used in the material.
  26550. */
  26551. hasTexture(texture: BaseTexture): boolean;
  26552. /**
  26553. * Gets a boolean indicating that current material needs to register RTT
  26554. * @returns true if this uses a render target otherwise false.
  26555. */
  26556. hasRenderTargetTextures(): boolean;
  26557. /**
  26558. * Returns an array of the actively used textures.
  26559. * @param activeTextures Array of BaseTextures
  26560. */
  26561. getActiveTextures(activeTextures: BaseTexture[]): void;
  26562. /**
  26563. * Returns the animatable textures.
  26564. * @param animatables Array of animatable textures.
  26565. */
  26566. getAnimatables(animatables: IAnimatable[]): void;
  26567. /**
  26568. * Disposes the resources of the material.
  26569. * @param forceDisposeTextures - Forces the disposal of all textures.
  26570. */
  26571. dispose(forceDisposeTextures?: boolean): void;
  26572. /**
  26573. * Get the current class name of the texture useful for serialization or dynamic coding.
  26574. * @returns "PBRSubSurfaceConfiguration"
  26575. */
  26576. getClassName(): string;
  26577. /**
  26578. * Add fallbacks to the effect fallbacks list.
  26579. * @param defines defines the Base texture to use.
  26580. * @param fallbacks defines the current fallback list.
  26581. * @param currentRank defines the current fallback rank.
  26582. * @returns the new fallback rank.
  26583. */
  26584. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  26585. /**
  26586. * Add the required uniforms to the current list.
  26587. * @param uniforms defines the current uniform list.
  26588. */
  26589. static AddUniforms(uniforms: string[]): void;
  26590. /**
  26591. * Add the required samplers to the current list.
  26592. * @param samplers defines the current sampler list.
  26593. */
  26594. static AddSamplers(samplers: string[]): void;
  26595. /**
  26596. * Add the required uniforms to the current buffer.
  26597. * @param uniformBuffer defines the current uniform buffer.
  26598. */
  26599. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  26600. /**
  26601. * Makes a duplicate of the current configuration into another one.
  26602. * @param configuration define the config where to copy the info
  26603. */
  26604. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  26605. /**
  26606. * Serializes this Sub Surface configuration.
  26607. * @returns - An object with the serialized config.
  26608. */
  26609. serialize(): any;
  26610. /**
  26611. * Parses a anisotropy Configuration from a serialized object.
  26612. * @param source - Serialized object.
  26613. * @param scene Defines the scene we are parsing for
  26614. * @param rootUrl Defines the rootUrl to load from
  26615. */
  26616. parse(source: any, scene: Scene, rootUrl: string): void;
  26617. }
  26618. }
  26619. declare module "babylonjs/Maths/sphericalPolynomial" {
  26620. import { Vector3 } from "babylonjs/Maths/math.vector";
  26621. import { Color3 } from "babylonjs/Maths/math.color";
  26622. /**
  26623. * Class representing spherical harmonics coefficients to the 3rd degree
  26624. */
  26625. export class SphericalHarmonics {
  26626. /**
  26627. * Defines whether or not the harmonics have been prescaled for rendering.
  26628. */
  26629. preScaled: boolean;
  26630. /**
  26631. * The l0,0 coefficients of the spherical harmonics
  26632. */
  26633. l00: Vector3;
  26634. /**
  26635. * The l1,-1 coefficients of the spherical harmonics
  26636. */
  26637. l1_1: Vector3;
  26638. /**
  26639. * The l1,0 coefficients of the spherical harmonics
  26640. */
  26641. l10: Vector3;
  26642. /**
  26643. * The l1,1 coefficients of the spherical harmonics
  26644. */
  26645. l11: Vector3;
  26646. /**
  26647. * The l2,-2 coefficients of the spherical harmonics
  26648. */
  26649. l2_2: Vector3;
  26650. /**
  26651. * The l2,-1 coefficients of the spherical harmonics
  26652. */
  26653. l2_1: Vector3;
  26654. /**
  26655. * The l2,0 coefficients of the spherical harmonics
  26656. */
  26657. l20: Vector3;
  26658. /**
  26659. * The l2,1 coefficients of the spherical harmonics
  26660. */
  26661. l21: Vector3;
  26662. /**
  26663. * The l2,2 coefficients of the spherical harmonics
  26664. */
  26665. l22: Vector3;
  26666. /**
  26667. * Adds a light to the spherical harmonics
  26668. * @param direction the direction of the light
  26669. * @param color the color of the light
  26670. * @param deltaSolidAngle the delta solid angle of the light
  26671. */
  26672. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  26673. /**
  26674. * Scales the spherical harmonics by the given amount
  26675. * @param scale the amount to scale
  26676. */
  26677. scaleInPlace(scale: number): void;
  26678. /**
  26679. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  26680. *
  26681. * ```
  26682. * E_lm = A_l * L_lm
  26683. * ```
  26684. *
  26685. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  26686. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  26687. * the scaling factors are given in equation 9.
  26688. */
  26689. convertIncidentRadianceToIrradiance(): void;
  26690. /**
  26691. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  26692. *
  26693. * ```
  26694. * L = (1/pi) * E * rho
  26695. * ```
  26696. *
  26697. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  26698. */
  26699. convertIrradianceToLambertianRadiance(): void;
  26700. /**
  26701. * Integrates the reconstruction coefficients directly in to the SH preventing further
  26702. * required operations at run time.
  26703. *
  26704. * This is simply done by scaling back the SH with Ylm constants parameter.
  26705. * The trigonometric part being applied by the shader at run time.
  26706. */
  26707. preScaleForRendering(): void;
  26708. /**
  26709. * Constructs a spherical harmonics from an array.
  26710. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  26711. * @returns the spherical harmonics
  26712. */
  26713. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  26714. /**
  26715. * Gets the spherical harmonics from polynomial
  26716. * @param polynomial the spherical polynomial
  26717. * @returns the spherical harmonics
  26718. */
  26719. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  26720. }
  26721. /**
  26722. * Class representing spherical polynomial coefficients to the 3rd degree
  26723. */
  26724. export class SphericalPolynomial {
  26725. private _harmonics;
  26726. /**
  26727. * The spherical harmonics used to create the polynomials.
  26728. */
  26729. get preScaledHarmonics(): SphericalHarmonics;
  26730. /**
  26731. * The x coefficients of the spherical polynomial
  26732. */
  26733. x: Vector3;
  26734. /**
  26735. * The y coefficients of the spherical polynomial
  26736. */
  26737. y: Vector3;
  26738. /**
  26739. * The z coefficients of the spherical polynomial
  26740. */
  26741. z: Vector3;
  26742. /**
  26743. * The xx coefficients of the spherical polynomial
  26744. */
  26745. xx: Vector3;
  26746. /**
  26747. * The yy coefficients of the spherical polynomial
  26748. */
  26749. yy: Vector3;
  26750. /**
  26751. * The zz coefficients of the spherical polynomial
  26752. */
  26753. zz: Vector3;
  26754. /**
  26755. * The xy coefficients of the spherical polynomial
  26756. */
  26757. xy: Vector3;
  26758. /**
  26759. * The yz coefficients of the spherical polynomial
  26760. */
  26761. yz: Vector3;
  26762. /**
  26763. * The zx coefficients of the spherical polynomial
  26764. */
  26765. zx: Vector3;
  26766. /**
  26767. * Adds an ambient color to the spherical polynomial
  26768. * @param color the color to add
  26769. */
  26770. addAmbient(color: Color3): void;
  26771. /**
  26772. * Scales the spherical polynomial by the given amount
  26773. * @param scale the amount to scale
  26774. */
  26775. scaleInPlace(scale: number): void;
  26776. /**
  26777. * Gets the spherical polynomial from harmonics
  26778. * @param harmonics the spherical harmonics
  26779. * @returns the spherical polynomial
  26780. */
  26781. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  26782. /**
  26783. * Constructs a spherical polynomial from an array.
  26784. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  26785. * @returns the spherical polynomial
  26786. */
  26787. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  26788. }
  26789. }
  26790. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  26791. import { Nullable } from "babylonjs/types";
  26792. /**
  26793. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26794. */
  26795. export interface CubeMapInfo {
  26796. /**
  26797. * The pixel array for the front face.
  26798. * This is stored in format, left to right, up to down format.
  26799. */
  26800. front: Nullable<ArrayBufferView>;
  26801. /**
  26802. * The pixel array for the back face.
  26803. * This is stored in format, left to right, up to down format.
  26804. */
  26805. back: Nullable<ArrayBufferView>;
  26806. /**
  26807. * The pixel array for the left face.
  26808. * This is stored in format, left to right, up to down format.
  26809. */
  26810. left: Nullable<ArrayBufferView>;
  26811. /**
  26812. * The pixel array for the right face.
  26813. * This is stored in format, left to right, up to down format.
  26814. */
  26815. right: Nullable<ArrayBufferView>;
  26816. /**
  26817. * The pixel array for the up face.
  26818. * This is stored in format, left to right, up to down format.
  26819. */
  26820. up: Nullable<ArrayBufferView>;
  26821. /**
  26822. * The pixel array for the down face.
  26823. * This is stored in format, left to right, up to down format.
  26824. */
  26825. down: Nullable<ArrayBufferView>;
  26826. /**
  26827. * The size of the cubemap stored.
  26828. *
  26829. * Each faces will be size * size pixels.
  26830. */
  26831. size: number;
  26832. /**
  26833. * The format of the texture.
  26834. *
  26835. * RGBA, RGB.
  26836. */
  26837. format: number;
  26838. /**
  26839. * The type of the texture data.
  26840. *
  26841. * UNSIGNED_INT, FLOAT.
  26842. */
  26843. type: number;
  26844. /**
  26845. * Specifies whether the texture is in gamma space.
  26846. */
  26847. gammaSpace: boolean;
  26848. }
  26849. /**
  26850. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26851. */
  26852. export class PanoramaToCubeMapTools {
  26853. private static FACE_LEFT;
  26854. private static FACE_RIGHT;
  26855. private static FACE_FRONT;
  26856. private static FACE_BACK;
  26857. private static FACE_DOWN;
  26858. private static FACE_UP;
  26859. /**
  26860. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26861. *
  26862. * @param float32Array The source data.
  26863. * @param inputWidth The width of the input panorama.
  26864. * @param inputHeight The height of the input panorama.
  26865. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26866. * @return The cubemap data
  26867. */
  26868. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26869. private static CreateCubemapTexture;
  26870. private static CalcProjectionSpherical;
  26871. }
  26872. }
  26873. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  26874. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26875. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26876. import { Nullable } from "babylonjs/types";
  26877. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  26878. /**
  26879. * Helper class dealing with the extraction of spherical polynomial dataArray
  26880. * from a cube map.
  26881. */
  26882. export class CubeMapToSphericalPolynomialTools {
  26883. private static FileFaces;
  26884. /**
  26885. * Converts a texture to the according Spherical Polynomial data.
  26886. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26887. *
  26888. * @param texture The texture to extract the information from.
  26889. * @return The Spherical Polynomial data.
  26890. */
  26891. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  26892. /**
  26893. * Converts a cubemap to the according Spherical Polynomial data.
  26894. * This extracts the first 3 orders only as they are the only one used in the lighting.
  26895. *
  26896. * @param cubeInfo The Cube map to extract the information from.
  26897. * @return The Spherical Polynomial data.
  26898. */
  26899. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  26900. }
  26901. }
  26902. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  26903. import { Nullable } from "babylonjs/types";
  26904. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26905. module "babylonjs/Materials/Textures/baseTexture" {
  26906. interface BaseTexture {
  26907. /**
  26908. * Get the polynomial representation of the texture data.
  26909. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26910. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26911. */
  26912. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26913. }
  26914. }
  26915. }
  26916. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  26917. /** @hidden */
  26918. export var pbrFragmentDeclaration: {
  26919. name: string;
  26920. shader: string;
  26921. };
  26922. }
  26923. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  26924. /** @hidden */
  26925. export var pbrUboDeclaration: {
  26926. name: string;
  26927. shader: string;
  26928. };
  26929. }
  26930. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  26931. /** @hidden */
  26932. export var pbrFragmentExtraDeclaration: {
  26933. name: string;
  26934. shader: string;
  26935. };
  26936. }
  26937. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  26938. /** @hidden */
  26939. export var pbrFragmentSamplersDeclaration: {
  26940. name: string;
  26941. shader: string;
  26942. };
  26943. }
  26944. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  26945. /** @hidden */
  26946. export var subSurfaceScatteringFunctions: {
  26947. name: string;
  26948. shader: string;
  26949. };
  26950. }
  26951. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  26952. /** @hidden */
  26953. export var importanceSampling: {
  26954. name: string;
  26955. shader: string;
  26956. };
  26957. }
  26958. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  26959. /** @hidden */
  26960. export var pbrHelperFunctions: {
  26961. name: string;
  26962. shader: string;
  26963. };
  26964. }
  26965. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  26966. /** @hidden */
  26967. export var harmonicsFunctions: {
  26968. name: string;
  26969. shader: string;
  26970. };
  26971. }
  26972. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  26973. /** @hidden */
  26974. export var pbrDirectLightingSetupFunctions: {
  26975. name: string;
  26976. shader: string;
  26977. };
  26978. }
  26979. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  26980. /** @hidden */
  26981. export var pbrDirectLightingFalloffFunctions: {
  26982. name: string;
  26983. shader: string;
  26984. };
  26985. }
  26986. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  26987. /** @hidden */
  26988. export var pbrBRDFFunctions: {
  26989. name: string;
  26990. shader: string;
  26991. };
  26992. }
  26993. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  26994. /** @hidden */
  26995. export var hdrFilteringFunctions: {
  26996. name: string;
  26997. shader: string;
  26998. };
  26999. }
  27000. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  27001. /** @hidden */
  27002. export var pbrDirectLightingFunctions: {
  27003. name: string;
  27004. shader: string;
  27005. };
  27006. }
  27007. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  27008. /** @hidden */
  27009. export var pbrIBLFunctions: {
  27010. name: string;
  27011. shader: string;
  27012. };
  27013. }
  27014. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  27015. /** @hidden */
  27016. export var pbrBlockAlbedoOpacity: {
  27017. name: string;
  27018. shader: string;
  27019. };
  27020. }
  27021. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  27022. /** @hidden */
  27023. export var pbrBlockReflectivity: {
  27024. name: string;
  27025. shader: string;
  27026. };
  27027. }
  27028. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  27029. /** @hidden */
  27030. export var pbrBlockAmbientOcclusion: {
  27031. name: string;
  27032. shader: string;
  27033. };
  27034. }
  27035. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  27036. /** @hidden */
  27037. export var pbrBlockAlphaFresnel: {
  27038. name: string;
  27039. shader: string;
  27040. };
  27041. }
  27042. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  27043. /** @hidden */
  27044. export var pbrBlockAnisotropic: {
  27045. name: string;
  27046. shader: string;
  27047. };
  27048. }
  27049. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  27050. /** @hidden */
  27051. export var pbrBlockReflection: {
  27052. name: string;
  27053. shader: string;
  27054. };
  27055. }
  27056. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  27057. /** @hidden */
  27058. export var pbrBlockSheen: {
  27059. name: string;
  27060. shader: string;
  27061. };
  27062. }
  27063. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  27064. /** @hidden */
  27065. export var pbrBlockClearcoat: {
  27066. name: string;
  27067. shader: string;
  27068. };
  27069. }
  27070. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  27071. /** @hidden */
  27072. export var pbrBlockSubSurface: {
  27073. name: string;
  27074. shader: string;
  27075. };
  27076. }
  27077. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  27078. /** @hidden */
  27079. export var pbrBlockNormalGeometric: {
  27080. name: string;
  27081. shader: string;
  27082. };
  27083. }
  27084. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  27085. /** @hidden */
  27086. export var pbrBlockNormalFinal: {
  27087. name: string;
  27088. shader: string;
  27089. };
  27090. }
  27091. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  27092. /** @hidden */
  27093. export var pbrBlockLightmapInit: {
  27094. name: string;
  27095. shader: string;
  27096. };
  27097. }
  27098. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  27099. /** @hidden */
  27100. export var pbrBlockGeometryInfo: {
  27101. name: string;
  27102. shader: string;
  27103. };
  27104. }
  27105. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  27106. /** @hidden */
  27107. export var pbrBlockReflectance0: {
  27108. name: string;
  27109. shader: string;
  27110. };
  27111. }
  27112. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  27113. /** @hidden */
  27114. export var pbrBlockReflectance: {
  27115. name: string;
  27116. shader: string;
  27117. };
  27118. }
  27119. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  27120. /** @hidden */
  27121. export var pbrBlockDirectLighting: {
  27122. name: string;
  27123. shader: string;
  27124. };
  27125. }
  27126. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  27127. /** @hidden */
  27128. export var pbrBlockFinalLitComponents: {
  27129. name: string;
  27130. shader: string;
  27131. };
  27132. }
  27133. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  27134. /** @hidden */
  27135. export var pbrBlockFinalUnlitComponents: {
  27136. name: string;
  27137. shader: string;
  27138. };
  27139. }
  27140. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  27141. /** @hidden */
  27142. export var pbrBlockFinalColorComposition: {
  27143. name: string;
  27144. shader: string;
  27145. };
  27146. }
  27147. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  27148. /** @hidden */
  27149. export var pbrBlockImageProcessing: {
  27150. name: string;
  27151. shader: string;
  27152. };
  27153. }
  27154. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  27155. /** @hidden */
  27156. export var pbrDebug: {
  27157. name: string;
  27158. shader: string;
  27159. };
  27160. }
  27161. declare module "babylonjs/Shaders/pbr.fragment" {
  27162. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  27163. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  27164. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  27165. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  27166. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27167. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27168. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  27169. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27170. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27171. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27172. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27173. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27174. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  27175. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  27176. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  27177. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27178. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27179. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  27180. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  27181. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  27182. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  27183. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  27184. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  27185. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  27186. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  27187. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27188. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27189. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  27190. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  27191. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  27192. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  27193. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  27194. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  27195. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  27196. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  27197. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  27198. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27199. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  27200. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27201. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  27202. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27203. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  27204. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  27205. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  27206. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  27207. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  27208. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27209. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  27210. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  27211. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  27212. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27213. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27214. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  27215. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  27216. /** @hidden */
  27217. export var pbrPixelShader: {
  27218. name: string;
  27219. shader: string;
  27220. };
  27221. }
  27222. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  27223. /** @hidden */
  27224. export var pbrVertexDeclaration: {
  27225. name: string;
  27226. shader: string;
  27227. };
  27228. }
  27229. declare module "babylonjs/Shaders/pbr.vertex" {
  27230. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  27231. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  27232. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27233. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27234. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27235. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  27236. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  27237. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27238. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27239. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27240. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27241. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27242. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27243. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27244. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27245. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27246. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27247. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27248. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  27249. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27250. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27251. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27252. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27253. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27254. /** @hidden */
  27255. export var pbrVertexShader: {
  27256. name: string;
  27257. shader: string;
  27258. };
  27259. }
  27260. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  27261. import { Nullable } from "babylonjs/types";
  27262. import { Scene } from "babylonjs/scene";
  27263. import { Matrix } from "babylonjs/Maths/math.vector";
  27264. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27266. import { Mesh } from "babylonjs/Meshes/mesh";
  27267. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  27268. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  27269. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  27270. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  27271. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  27272. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  27273. import { Color3 } from "babylonjs/Maths/math.color";
  27274. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27275. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  27276. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27277. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27278. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27279. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27280. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  27281. import "babylonjs/Shaders/pbr.fragment";
  27282. import "babylonjs/Shaders/pbr.vertex";
  27283. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  27284. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  27285. /**
  27286. * Manages the defines for the PBR Material.
  27287. * @hidden
  27288. */
  27289. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  27290. PBR: boolean;
  27291. NUM_SAMPLES: string;
  27292. REALTIME_FILTERING: boolean;
  27293. MAINUV1: boolean;
  27294. MAINUV2: boolean;
  27295. UV1: boolean;
  27296. UV2: boolean;
  27297. ALBEDO: boolean;
  27298. GAMMAALBEDO: boolean;
  27299. ALBEDODIRECTUV: number;
  27300. VERTEXCOLOR: boolean;
  27301. DETAIL: boolean;
  27302. DETAILDIRECTUV: number;
  27303. DETAIL_NORMALBLENDMETHOD: number;
  27304. AMBIENT: boolean;
  27305. AMBIENTDIRECTUV: number;
  27306. AMBIENTINGRAYSCALE: boolean;
  27307. OPACITY: boolean;
  27308. VERTEXALPHA: boolean;
  27309. OPACITYDIRECTUV: number;
  27310. OPACITYRGB: boolean;
  27311. ALPHATEST: boolean;
  27312. DEPTHPREPASS: boolean;
  27313. ALPHABLEND: boolean;
  27314. ALPHAFROMALBEDO: boolean;
  27315. ALPHATESTVALUE: string;
  27316. SPECULAROVERALPHA: boolean;
  27317. RADIANCEOVERALPHA: boolean;
  27318. ALPHAFRESNEL: boolean;
  27319. LINEARALPHAFRESNEL: boolean;
  27320. PREMULTIPLYALPHA: boolean;
  27321. EMISSIVE: boolean;
  27322. EMISSIVEDIRECTUV: number;
  27323. REFLECTIVITY: boolean;
  27324. REFLECTIVITYDIRECTUV: number;
  27325. SPECULARTERM: boolean;
  27326. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  27327. MICROSURFACEAUTOMATIC: boolean;
  27328. LODBASEDMICROSFURACE: boolean;
  27329. MICROSURFACEMAP: boolean;
  27330. MICROSURFACEMAPDIRECTUV: number;
  27331. METALLICWORKFLOW: boolean;
  27332. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  27333. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  27334. METALLNESSSTOREINMETALMAPBLUE: boolean;
  27335. AOSTOREINMETALMAPRED: boolean;
  27336. METALLIC_REFLECTANCE: boolean;
  27337. METALLIC_REFLECTANCEDIRECTUV: number;
  27338. ENVIRONMENTBRDF: boolean;
  27339. ENVIRONMENTBRDF_RGBD: boolean;
  27340. NORMAL: boolean;
  27341. TANGENT: boolean;
  27342. BUMP: boolean;
  27343. BUMPDIRECTUV: number;
  27344. OBJECTSPACE_NORMALMAP: boolean;
  27345. PARALLAX: boolean;
  27346. PARALLAXOCCLUSION: boolean;
  27347. NORMALXYSCALE: boolean;
  27348. LIGHTMAP: boolean;
  27349. LIGHTMAPDIRECTUV: number;
  27350. USELIGHTMAPASSHADOWMAP: boolean;
  27351. GAMMALIGHTMAP: boolean;
  27352. RGBDLIGHTMAP: boolean;
  27353. REFLECTION: boolean;
  27354. REFLECTIONMAP_3D: boolean;
  27355. REFLECTIONMAP_SPHERICAL: boolean;
  27356. REFLECTIONMAP_PLANAR: boolean;
  27357. REFLECTIONMAP_CUBIC: boolean;
  27358. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27359. REFLECTIONMAP_PROJECTION: boolean;
  27360. REFLECTIONMAP_SKYBOX: boolean;
  27361. REFLECTIONMAP_EXPLICIT: boolean;
  27362. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27363. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27364. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27365. INVERTCUBICMAP: boolean;
  27366. USESPHERICALFROMREFLECTIONMAP: boolean;
  27367. USEIRRADIANCEMAP: boolean;
  27368. SPHERICAL_HARMONICS: boolean;
  27369. USESPHERICALINVERTEX: boolean;
  27370. REFLECTIONMAP_OPPOSITEZ: boolean;
  27371. LODINREFLECTIONALPHA: boolean;
  27372. GAMMAREFLECTION: boolean;
  27373. RGBDREFLECTION: boolean;
  27374. LINEARSPECULARREFLECTION: boolean;
  27375. RADIANCEOCCLUSION: boolean;
  27376. HORIZONOCCLUSION: boolean;
  27377. INSTANCES: boolean;
  27378. THIN_INSTANCES: boolean;
  27379. PREPASS: boolean;
  27380. PREPASS_IRRADIANCE: boolean;
  27381. PREPASS_IRRADIANCE_INDEX: number;
  27382. PREPASS_ALBEDO: boolean;
  27383. PREPASS_ALBEDO_INDEX: number;
  27384. PREPASS_DEPTHNORMAL: boolean;
  27385. PREPASS_DEPTHNORMAL_INDEX: number;
  27386. PREPASS_POSITION: boolean;
  27387. PREPASS_POSITION_INDEX: number;
  27388. PREPASS_VELOCITY: boolean;
  27389. PREPASS_VELOCITY_INDEX: number;
  27390. PREPASS_REFLECTIVITY: boolean;
  27391. PREPASS_REFLECTIVITY_INDEX: number;
  27392. SCENE_MRT_COUNT: number;
  27393. NUM_BONE_INFLUENCERS: number;
  27394. BonesPerMesh: number;
  27395. BONETEXTURE: boolean;
  27396. BONES_VELOCITY_ENABLED: boolean;
  27397. NONUNIFORMSCALING: boolean;
  27398. MORPHTARGETS: boolean;
  27399. MORPHTARGETS_NORMAL: boolean;
  27400. MORPHTARGETS_TANGENT: boolean;
  27401. MORPHTARGETS_UV: boolean;
  27402. NUM_MORPH_INFLUENCERS: number;
  27403. IMAGEPROCESSING: boolean;
  27404. VIGNETTE: boolean;
  27405. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27406. VIGNETTEBLENDMODEOPAQUE: boolean;
  27407. TONEMAPPING: boolean;
  27408. TONEMAPPING_ACES: boolean;
  27409. CONTRAST: boolean;
  27410. COLORCURVES: boolean;
  27411. COLORGRADING: boolean;
  27412. COLORGRADING3D: boolean;
  27413. SAMPLER3DGREENDEPTH: boolean;
  27414. SAMPLER3DBGRMAP: boolean;
  27415. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27416. EXPOSURE: boolean;
  27417. MULTIVIEW: boolean;
  27418. USEPHYSICALLIGHTFALLOFF: boolean;
  27419. USEGLTFLIGHTFALLOFF: boolean;
  27420. TWOSIDEDLIGHTING: boolean;
  27421. SHADOWFLOAT: boolean;
  27422. CLIPPLANE: boolean;
  27423. CLIPPLANE2: boolean;
  27424. CLIPPLANE3: boolean;
  27425. CLIPPLANE4: boolean;
  27426. CLIPPLANE5: boolean;
  27427. CLIPPLANE6: boolean;
  27428. POINTSIZE: boolean;
  27429. FOG: boolean;
  27430. LOGARITHMICDEPTH: boolean;
  27431. FORCENORMALFORWARD: boolean;
  27432. SPECULARAA: boolean;
  27433. CLEARCOAT: boolean;
  27434. CLEARCOAT_DEFAULTIOR: boolean;
  27435. CLEARCOAT_TEXTURE: boolean;
  27436. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  27437. CLEARCOAT_TEXTUREDIRECTUV: number;
  27438. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  27439. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27440. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27441. CLEARCOAT_BUMP: boolean;
  27442. CLEARCOAT_BUMPDIRECTUV: number;
  27443. CLEARCOAT_REMAP_F0: boolean;
  27444. CLEARCOAT_TINT: boolean;
  27445. CLEARCOAT_TINT_TEXTURE: boolean;
  27446. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  27447. ANISOTROPIC: boolean;
  27448. ANISOTROPIC_TEXTURE: boolean;
  27449. ANISOTROPIC_TEXTUREDIRECTUV: number;
  27450. BRDF_V_HEIGHT_CORRELATED: boolean;
  27451. MS_BRDF_ENERGY_CONSERVATION: boolean;
  27452. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  27453. SHEEN: boolean;
  27454. SHEEN_TEXTURE: boolean;
  27455. SHEEN_TEXTURE_ROUGHNESS: boolean;
  27456. SHEEN_TEXTUREDIRECTUV: number;
  27457. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  27458. SHEEN_LINKWITHALBEDO: boolean;
  27459. SHEEN_ROUGHNESS: boolean;
  27460. SHEEN_ALBEDOSCALING: boolean;
  27461. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  27462. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  27463. SUBSURFACE: boolean;
  27464. SS_REFRACTION: boolean;
  27465. SS_TRANSLUCENCY: boolean;
  27466. SS_SCATTERING: boolean;
  27467. SS_THICKNESSANDMASK_TEXTURE: boolean;
  27468. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  27469. SS_REFRACTIONMAP_3D: boolean;
  27470. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  27471. SS_LODINREFRACTIONALPHA: boolean;
  27472. SS_GAMMAREFRACTION: boolean;
  27473. SS_RGBDREFRACTION: boolean;
  27474. SS_LINEARSPECULARREFRACTION: boolean;
  27475. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  27476. SS_ALBEDOFORREFRACTIONTINT: boolean;
  27477. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  27478. UNLIT: boolean;
  27479. DEBUGMODE: number;
  27480. /**
  27481. * Initializes the PBR Material defines.
  27482. */
  27483. constructor();
  27484. /**
  27485. * Resets the PBR Material defines.
  27486. */
  27487. reset(): void;
  27488. }
  27489. /**
  27490. * The Physically based material base class of BJS.
  27491. *
  27492. * This offers the main features of a standard PBR material.
  27493. * For more information, please refer to the documentation :
  27494. * https://doc.babylonjs.com/how_to/physically_based_rendering
  27495. */
  27496. export abstract class PBRBaseMaterial extends PushMaterial {
  27497. /**
  27498. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  27499. */
  27500. static readonly PBRMATERIAL_OPAQUE: number;
  27501. /**
  27502. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  27503. */
  27504. static readonly PBRMATERIAL_ALPHATEST: number;
  27505. /**
  27506. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27507. */
  27508. static readonly PBRMATERIAL_ALPHABLEND: number;
  27509. /**
  27510. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  27511. * They are also discarded below the alpha cutoff threshold to improve performances.
  27512. */
  27513. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  27514. /**
  27515. * Defines the default value of how much AO map is occluding the analytical lights
  27516. * (point spot...).
  27517. */
  27518. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  27519. /**
  27520. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  27521. */
  27522. static readonly LIGHTFALLOFF_PHYSICAL: number;
  27523. /**
  27524. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  27525. * to enhance interoperability with other engines.
  27526. */
  27527. static readonly LIGHTFALLOFF_GLTF: number;
  27528. /**
  27529. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  27530. * to enhance interoperability with other materials.
  27531. */
  27532. static readonly LIGHTFALLOFF_STANDARD: number;
  27533. /**
  27534. * Intensity of the direct lights e.g. the four lights available in your scene.
  27535. * This impacts both the direct diffuse and specular highlights.
  27536. */
  27537. protected _directIntensity: number;
  27538. /**
  27539. * Intensity of the emissive part of the material.
  27540. * This helps controlling the emissive effect without modifying the emissive color.
  27541. */
  27542. protected _emissiveIntensity: number;
  27543. /**
  27544. * Intensity of the environment e.g. how much the environment will light the object
  27545. * either through harmonics for rough material or through the refelction for shiny ones.
  27546. */
  27547. protected _environmentIntensity: number;
  27548. /**
  27549. * This is a special control allowing the reduction of the specular highlights coming from the
  27550. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  27551. */
  27552. protected _specularIntensity: number;
  27553. /**
  27554. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  27555. */
  27556. private _lightingInfos;
  27557. /**
  27558. * Debug Control allowing disabling the bump map on this material.
  27559. */
  27560. protected _disableBumpMap: boolean;
  27561. /**
  27562. * AKA Diffuse Texture in standard nomenclature.
  27563. */
  27564. protected _albedoTexture: Nullable<BaseTexture>;
  27565. /**
  27566. * AKA Occlusion Texture in other nomenclature.
  27567. */
  27568. protected _ambientTexture: Nullable<BaseTexture>;
  27569. /**
  27570. * AKA Occlusion Texture Intensity in other nomenclature.
  27571. */
  27572. protected _ambientTextureStrength: number;
  27573. /**
  27574. * Defines how much the AO map is occluding the analytical lights (point spot...).
  27575. * 1 means it completely occludes it
  27576. * 0 mean it has no impact
  27577. */
  27578. protected _ambientTextureImpactOnAnalyticalLights: number;
  27579. /**
  27580. * Stores the alpha values in a texture.
  27581. */
  27582. protected _opacityTexture: Nullable<BaseTexture>;
  27583. /**
  27584. * Stores the reflection values in a texture.
  27585. */
  27586. protected _reflectionTexture: Nullable<BaseTexture>;
  27587. /**
  27588. * Stores the emissive values in a texture.
  27589. */
  27590. protected _emissiveTexture: Nullable<BaseTexture>;
  27591. /**
  27592. * AKA Specular texture in other nomenclature.
  27593. */
  27594. protected _reflectivityTexture: Nullable<BaseTexture>;
  27595. /**
  27596. * Used to switch from specular/glossiness to metallic/roughness workflow.
  27597. */
  27598. protected _metallicTexture: Nullable<BaseTexture>;
  27599. /**
  27600. * Specifies the metallic scalar of the metallic/roughness workflow.
  27601. * Can also be used to scale the metalness values of the metallic texture.
  27602. */
  27603. protected _metallic: Nullable<number>;
  27604. /**
  27605. * Specifies the roughness scalar of the metallic/roughness workflow.
  27606. * Can also be used to scale the roughness values of the metallic texture.
  27607. */
  27608. protected _roughness: Nullable<number>;
  27609. /**
  27610. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  27611. * By default the indexOfrefraction is used to compute F0;
  27612. *
  27613. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  27614. *
  27615. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  27616. * F90 = metallicReflectanceColor;
  27617. */
  27618. protected _metallicF0Factor: number;
  27619. /**
  27620. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  27621. * By default the F90 is always 1;
  27622. *
  27623. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  27624. *
  27625. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  27626. * F90 = metallicReflectanceColor;
  27627. */
  27628. protected _metallicReflectanceColor: Color3;
  27629. /**
  27630. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  27631. * This is multiply against the scalar values defined in the material.
  27632. */
  27633. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  27634. /**
  27635. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  27636. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  27637. */
  27638. protected _microSurfaceTexture: Nullable<BaseTexture>;
  27639. /**
  27640. * Stores surface normal data used to displace a mesh in a texture.
  27641. */
  27642. protected _bumpTexture: Nullable<BaseTexture>;
  27643. /**
  27644. * Stores the pre-calculated light information of a mesh in a texture.
  27645. */
  27646. protected _lightmapTexture: Nullable<BaseTexture>;
  27647. /**
  27648. * The color of a material in ambient lighting.
  27649. */
  27650. protected _ambientColor: Color3;
  27651. /**
  27652. * AKA Diffuse Color in other nomenclature.
  27653. */
  27654. protected _albedoColor: Color3;
  27655. /**
  27656. * AKA Specular Color in other nomenclature.
  27657. */
  27658. protected _reflectivityColor: Color3;
  27659. /**
  27660. * The color applied when light is reflected from a material.
  27661. */
  27662. protected _reflectionColor: Color3;
  27663. /**
  27664. * The color applied when light is emitted from a material.
  27665. */
  27666. protected _emissiveColor: Color3;
  27667. /**
  27668. * AKA Glossiness in other nomenclature.
  27669. */
  27670. protected _microSurface: number;
  27671. /**
  27672. * Specifies that the material will use the light map as a show map.
  27673. */
  27674. protected _useLightmapAsShadowmap: boolean;
  27675. /**
  27676. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  27677. * makes the reflect vector face the model (under horizon).
  27678. */
  27679. protected _useHorizonOcclusion: boolean;
  27680. /**
  27681. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  27682. * too much the area relying on ambient texture to define their ambient occlusion.
  27683. */
  27684. protected _useRadianceOcclusion: boolean;
  27685. /**
  27686. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  27687. */
  27688. protected _useAlphaFromAlbedoTexture: boolean;
  27689. /**
  27690. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  27691. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27692. */
  27693. protected _useSpecularOverAlpha: boolean;
  27694. /**
  27695. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  27696. */
  27697. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  27698. /**
  27699. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  27700. */
  27701. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  27702. /**
  27703. * Specifies if the metallic texture contains the roughness information in its green channel.
  27704. */
  27705. protected _useRoughnessFromMetallicTextureGreen: boolean;
  27706. /**
  27707. * Specifies if the metallic texture contains the metallness information in its blue channel.
  27708. */
  27709. protected _useMetallnessFromMetallicTextureBlue: boolean;
  27710. /**
  27711. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  27712. */
  27713. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  27714. /**
  27715. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  27716. */
  27717. protected _useAmbientInGrayScale: boolean;
  27718. /**
  27719. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  27720. * The material will try to infer what glossiness each pixel should be.
  27721. */
  27722. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  27723. /**
  27724. * Defines the falloff type used in this material.
  27725. * It by default is Physical.
  27726. */
  27727. protected _lightFalloff: number;
  27728. /**
  27729. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27730. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27731. */
  27732. protected _useRadianceOverAlpha: boolean;
  27733. /**
  27734. * Allows using an object space normal map (instead of tangent space).
  27735. */
  27736. protected _useObjectSpaceNormalMap: boolean;
  27737. /**
  27738. * Allows using the bump map in parallax mode.
  27739. */
  27740. protected _useParallax: boolean;
  27741. /**
  27742. * Allows using the bump map in parallax occlusion mode.
  27743. */
  27744. protected _useParallaxOcclusion: boolean;
  27745. /**
  27746. * Controls the scale bias of the parallax mode.
  27747. */
  27748. protected _parallaxScaleBias: number;
  27749. /**
  27750. * If sets to true, disables all the lights affecting the material.
  27751. */
  27752. protected _disableLighting: boolean;
  27753. /**
  27754. * Number of Simultaneous lights allowed on the material.
  27755. */
  27756. protected _maxSimultaneousLights: number;
  27757. /**
  27758. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  27759. */
  27760. protected _invertNormalMapX: boolean;
  27761. /**
  27762. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  27763. */
  27764. protected _invertNormalMapY: boolean;
  27765. /**
  27766. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27767. */
  27768. protected _twoSidedLighting: boolean;
  27769. /**
  27770. * Defines the alpha limits in alpha test mode.
  27771. */
  27772. protected _alphaCutOff: number;
  27773. /**
  27774. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  27775. */
  27776. protected _forceAlphaTest: boolean;
  27777. /**
  27778. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27779. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  27780. */
  27781. protected _useAlphaFresnel: boolean;
  27782. /**
  27783. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  27784. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  27785. */
  27786. protected _useLinearAlphaFresnel: boolean;
  27787. /**
  27788. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  27789. * from cos thetav and roughness:
  27790. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  27791. */
  27792. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  27793. /**
  27794. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  27795. */
  27796. protected _forceIrradianceInFragment: boolean;
  27797. private _realTimeFiltering;
  27798. /**
  27799. * Enables realtime filtering on the texture.
  27800. */
  27801. get realTimeFiltering(): boolean;
  27802. set realTimeFiltering(b: boolean);
  27803. private _realTimeFilteringQuality;
  27804. /**
  27805. * Quality switch for realtime filtering
  27806. */
  27807. get realTimeFilteringQuality(): number;
  27808. set realTimeFilteringQuality(n: number);
  27809. /**
  27810. * Can this material render to several textures at once
  27811. */
  27812. get canRenderToMRT(): boolean;
  27813. /**
  27814. * Force normal to face away from face.
  27815. */
  27816. protected _forceNormalForward: boolean;
  27817. /**
  27818. * Enables specular anti aliasing in the PBR shader.
  27819. * It will both interacts on the Geometry for analytical and IBL lighting.
  27820. * It also prefilter the roughness map based on the bump values.
  27821. */
  27822. protected _enableSpecularAntiAliasing: boolean;
  27823. /**
  27824. * Default configuration related to image processing available in the PBR Material.
  27825. */
  27826. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27827. /**
  27828. * Keep track of the image processing observer to allow dispose and replace.
  27829. */
  27830. private _imageProcessingObserver;
  27831. /**
  27832. * Attaches a new image processing configuration to the PBR Material.
  27833. * @param configuration
  27834. */
  27835. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27836. /**
  27837. * Stores the available render targets.
  27838. */
  27839. private _renderTargets;
  27840. /**
  27841. * Sets the global ambient color for the material used in lighting calculations.
  27842. */
  27843. private _globalAmbientColor;
  27844. /**
  27845. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  27846. */
  27847. private _useLogarithmicDepth;
  27848. /**
  27849. * If set to true, no lighting calculations will be applied.
  27850. */
  27851. private _unlit;
  27852. private _debugMode;
  27853. /**
  27854. * @hidden
  27855. * This is reserved for the inspector.
  27856. * Defines the material debug mode.
  27857. * It helps seeing only some components of the material while troubleshooting.
  27858. */
  27859. debugMode: number;
  27860. /**
  27861. * @hidden
  27862. * This is reserved for the inspector.
  27863. * Specify from where on screen the debug mode should start.
  27864. * The value goes from -1 (full screen) to 1 (not visible)
  27865. * It helps with side by side comparison against the final render
  27866. * This defaults to -1
  27867. */
  27868. private debugLimit;
  27869. /**
  27870. * @hidden
  27871. * This is reserved for the inspector.
  27872. * As the default viewing range might not be enough (if the ambient is really small for instance)
  27873. * You can use the factor to better multiply the final value.
  27874. */
  27875. private debugFactor;
  27876. /**
  27877. * Defines the clear coat layer parameters for the material.
  27878. */
  27879. readonly clearCoat: PBRClearCoatConfiguration;
  27880. /**
  27881. * Defines the anisotropic parameters for the material.
  27882. */
  27883. readonly anisotropy: PBRAnisotropicConfiguration;
  27884. /**
  27885. * Defines the BRDF parameters for the material.
  27886. */
  27887. readonly brdf: PBRBRDFConfiguration;
  27888. /**
  27889. * Defines the Sheen parameters for the material.
  27890. */
  27891. readonly sheen: PBRSheenConfiguration;
  27892. /**
  27893. * Defines the SubSurface parameters for the material.
  27894. */
  27895. readonly subSurface: PBRSubSurfaceConfiguration;
  27896. /**
  27897. * Defines additionnal PrePass parameters for the material.
  27898. */
  27899. readonly prePassConfiguration: PrePassConfiguration;
  27900. /**
  27901. * Defines the detail map parameters for the material.
  27902. */
  27903. readonly detailMap: DetailMapConfiguration;
  27904. protected _rebuildInParallel: boolean;
  27905. /**
  27906. * Instantiates a new PBRMaterial instance.
  27907. *
  27908. * @param name The material name
  27909. * @param scene The scene the material will be use in.
  27910. */
  27911. constructor(name: string, scene: Scene);
  27912. /**
  27913. * Gets a boolean indicating that current material needs to register RTT
  27914. */
  27915. get hasRenderTargetTextures(): boolean;
  27916. /**
  27917. * Gets the name of the material class.
  27918. */
  27919. getClassName(): string;
  27920. /**
  27921. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27922. */
  27923. get useLogarithmicDepth(): boolean;
  27924. /**
  27925. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  27926. */
  27927. set useLogarithmicDepth(value: boolean);
  27928. /**
  27929. * Returns true if alpha blending should be disabled.
  27930. */
  27931. protected get _disableAlphaBlending(): boolean;
  27932. /**
  27933. * Specifies whether or not this material should be rendered in alpha blend mode.
  27934. */
  27935. needAlphaBlending(): boolean;
  27936. /**
  27937. * Specifies whether or not this material should be rendered in alpha test mode.
  27938. */
  27939. needAlphaTesting(): boolean;
  27940. /**
  27941. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  27942. */
  27943. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  27944. /**
  27945. * Specifies whether or not there is a usable alpha channel for transparency.
  27946. */
  27947. protected _hasAlphaChannel(): boolean;
  27948. /**
  27949. * Gets the texture used for the alpha test.
  27950. */
  27951. getAlphaTestTexture(): Nullable<BaseTexture>;
  27952. /**
  27953. * Specifies that the submesh is ready to be used.
  27954. * @param mesh - BJS mesh.
  27955. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  27956. * @param useInstances - Specifies that instances should be used.
  27957. * @returns - boolean indicating that the submesh is ready or not.
  27958. */
  27959. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27960. /**
  27961. * Specifies if the material uses metallic roughness workflow.
  27962. * @returns boolean specifiying if the material uses metallic roughness workflow.
  27963. */
  27964. isMetallicWorkflow(): boolean;
  27965. private _prepareEffect;
  27966. private _prepareDefines;
  27967. /**
  27968. * Force shader compilation
  27969. */
  27970. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  27971. /**
  27972. * Initializes the uniform buffer layout for the shader.
  27973. */
  27974. buildUniformLayout(): void;
  27975. /**
  27976. * Unbinds the material from the mesh
  27977. */
  27978. unbind(): void;
  27979. /**
  27980. * Binds the submesh data.
  27981. * @param world - The world matrix.
  27982. * @param mesh - The BJS mesh.
  27983. * @param subMesh - A submesh of the BJS mesh.
  27984. */
  27985. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27986. /**
  27987. * Returns the animatable textures.
  27988. * @returns - Array of animatable textures.
  27989. */
  27990. getAnimatables(): IAnimatable[];
  27991. /**
  27992. * Returns the texture used for reflections.
  27993. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  27994. */
  27995. private _getReflectionTexture;
  27996. /**
  27997. * Returns an array of the actively used textures.
  27998. * @returns - Array of BaseTextures
  27999. */
  28000. getActiveTextures(): BaseTexture[];
  28001. /**
  28002. * Checks to see if a texture is used in the material.
  28003. * @param texture - Base texture to use.
  28004. * @returns - Boolean specifying if a texture is used in the material.
  28005. */
  28006. hasTexture(texture: BaseTexture): boolean;
  28007. /**
  28008. * Sets the required values to the prepass renderer.
  28009. * @param prePassRenderer defines the prepass renderer to setup
  28010. */
  28011. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  28012. /**
  28013. * Disposes the resources of the material.
  28014. * @param forceDisposeEffect - Forces the disposal of effects.
  28015. * @param forceDisposeTextures - Forces the disposal of all textures.
  28016. */
  28017. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  28018. }
  28019. }
  28020. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  28021. import { Nullable } from "babylonjs/types";
  28022. import { Scene } from "babylonjs/scene";
  28023. import { Color3 } from "babylonjs/Maths/math.color";
  28024. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  28025. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  28026. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28027. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  28028. /**
  28029. * The Physically based material of BJS.
  28030. *
  28031. * This offers the main features of a standard PBR material.
  28032. * For more information, please refer to the documentation :
  28033. * https://doc.babylonjs.com/how_to/physically_based_rendering
  28034. */
  28035. export class PBRMaterial extends PBRBaseMaterial {
  28036. /**
  28037. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  28038. */
  28039. static readonly PBRMATERIAL_OPAQUE: number;
  28040. /**
  28041. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  28042. */
  28043. static readonly PBRMATERIAL_ALPHATEST: number;
  28044. /**
  28045. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28046. */
  28047. static readonly PBRMATERIAL_ALPHABLEND: number;
  28048. /**
  28049. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28050. * They are also discarded below the alpha cutoff threshold to improve performances.
  28051. */
  28052. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  28053. /**
  28054. * Defines the default value of how much AO map is occluding the analytical lights
  28055. * (point spot...).
  28056. */
  28057. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  28058. /**
  28059. * Intensity of the direct lights e.g. the four lights available in your scene.
  28060. * This impacts both the direct diffuse and specular highlights.
  28061. */
  28062. directIntensity: number;
  28063. /**
  28064. * Intensity of the emissive part of the material.
  28065. * This helps controlling the emissive effect without modifying the emissive color.
  28066. */
  28067. emissiveIntensity: number;
  28068. /**
  28069. * Intensity of the environment e.g. how much the environment will light the object
  28070. * either through harmonics for rough material or through the refelction for shiny ones.
  28071. */
  28072. environmentIntensity: number;
  28073. /**
  28074. * This is a special control allowing the reduction of the specular highlights coming from the
  28075. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  28076. */
  28077. specularIntensity: number;
  28078. /**
  28079. * Debug Control allowing disabling the bump map on this material.
  28080. */
  28081. disableBumpMap: boolean;
  28082. /**
  28083. * AKA Diffuse Texture in standard nomenclature.
  28084. */
  28085. albedoTexture: BaseTexture;
  28086. /**
  28087. * AKA Occlusion Texture in other nomenclature.
  28088. */
  28089. ambientTexture: BaseTexture;
  28090. /**
  28091. * AKA Occlusion Texture Intensity in other nomenclature.
  28092. */
  28093. ambientTextureStrength: number;
  28094. /**
  28095. * Defines how much the AO map is occluding the analytical lights (point spot...).
  28096. * 1 means it completely occludes it
  28097. * 0 mean it has no impact
  28098. */
  28099. ambientTextureImpactOnAnalyticalLights: number;
  28100. /**
  28101. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  28102. */
  28103. opacityTexture: BaseTexture;
  28104. /**
  28105. * Stores the reflection values in a texture.
  28106. */
  28107. reflectionTexture: Nullable<BaseTexture>;
  28108. /**
  28109. * Stores the emissive values in a texture.
  28110. */
  28111. emissiveTexture: BaseTexture;
  28112. /**
  28113. * AKA Specular texture in other nomenclature.
  28114. */
  28115. reflectivityTexture: BaseTexture;
  28116. /**
  28117. * Used to switch from specular/glossiness to metallic/roughness workflow.
  28118. */
  28119. metallicTexture: BaseTexture;
  28120. /**
  28121. * Specifies the metallic scalar of the metallic/roughness workflow.
  28122. * Can also be used to scale the metalness values of the metallic texture.
  28123. */
  28124. metallic: Nullable<number>;
  28125. /**
  28126. * Specifies the roughness scalar of the metallic/roughness workflow.
  28127. * Can also be used to scale the roughness values of the metallic texture.
  28128. */
  28129. roughness: Nullable<number>;
  28130. /**
  28131. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  28132. * By default the indexOfrefraction is used to compute F0;
  28133. *
  28134. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  28135. *
  28136. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  28137. * F90 = metallicReflectanceColor;
  28138. */
  28139. metallicF0Factor: number;
  28140. /**
  28141. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  28142. * By default the F90 is always 1;
  28143. *
  28144. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  28145. *
  28146. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  28147. * F90 = metallicReflectanceColor;
  28148. */
  28149. metallicReflectanceColor: Color3;
  28150. /**
  28151. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  28152. * This is multiply against the scalar values defined in the material.
  28153. */
  28154. metallicReflectanceTexture: Nullable<BaseTexture>;
  28155. /**
  28156. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  28157. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  28158. */
  28159. microSurfaceTexture: BaseTexture;
  28160. /**
  28161. * Stores surface normal data used to displace a mesh in a texture.
  28162. */
  28163. bumpTexture: BaseTexture;
  28164. /**
  28165. * Stores the pre-calculated light information of a mesh in a texture.
  28166. */
  28167. lightmapTexture: BaseTexture;
  28168. /**
  28169. * Stores the refracted light information in a texture.
  28170. */
  28171. get refractionTexture(): Nullable<BaseTexture>;
  28172. set refractionTexture(value: Nullable<BaseTexture>);
  28173. /**
  28174. * The color of a material in ambient lighting.
  28175. */
  28176. ambientColor: Color3;
  28177. /**
  28178. * AKA Diffuse Color in other nomenclature.
  28179. */
  28180. albedoColor: Color3;
  28181. /**
  28182. * AKA Specular Color in other nomenclature.
  28183. */
  28184. reflectivityColor: Color3;
  28185. /**
  28186. * The color reflected from the material.
  28187. */
  28188. reflectionColor: Color3;
  28189. /**
  28190. * The color emitted from the material.
  28191. */
  28192. emissiveColor: Color3;
  28193. /**
  28194. * AKA Glossiness in other nomenclature.
  28195. */
  28196. microSurface: number;
  28197. /**
  28198. * Index of refraction of the material base layer.
  28199. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  28200. *
  28201. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  28202. *
  28203. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  28204. */
  28205. get indexOfRefraction(): number;
  28206. set indexOfRefraction(value: number);
  28207. /**
  28208. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  28209. */
  28210. get invertRefractionY(): boolean;
  28211. set invertRefractionY(value: boolean);
  28212. /**
  28213. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  28214. * Materials half opaque for instance using refraction could benefit from this control.
  28215. */
  28216. get linkRefractionWithTransparency(): boolean;
  28217. set linkRefractionWithTransparency(value: boolean);
  28218. /**
  28219. * If true, the light map contains occlusion information instead of lighting info.
  28220. */
  28221. useLightmapAsShadowmap: boolean;
  28222. /**
  28223. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  28224. */
  28225. useAlphaFromAlbedoTexture: boolean;
  28226. /**
  28227. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  28228. */
  28229. forceAlphaTest: boolean;
  28230. /**
  28231. * Defines the alpha limits in alpha test mode.
  28232. */
  28233. alphaCutOff: number;
  28234. /**
  28235. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  28236. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  28237. */
  28238. useSpecularOverAlpha: boolean;
  28239. /**
  28240. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  28241. */
  28242. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  28243. /**
  28244. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  28245. */
  28246. useRoughnessFromMetallicTextureAlpha: boolean;
  28247. /**
  28248. * Specifies if the metallic texture contains the roughness information in its green channel.
  28249. */
  28250. useRoughnessFromMetallicTextureGreen: boolean;
  28251. /**
  28252. * Specifies if the metallic texture contains the metallness information in its blue channel.
  28253. */
  28254. useMetallnessFromMetallicTextureBlue: boolean;
  28255. /**
  28256. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  28257. */
  28258. useAmbientOcclusionFromMetallicTextureRed: boolean;
  28259. /**
  28260. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  28261. */
  28262. useAmbientInGrayScale: boolean;
  28263. /**
  28264. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  28265. * The material will try to infer what glossiness each pixel should be.
  28266. */
  28267. useAutoMicroSurfaceFromReflectivityMap: boolean;
  28268. /**
  28269. * BJS is using an harcoded light falloff based on a manually sets up range.
  28270. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  28271. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  28272. */
  28273. get usePhysicalLightFalloff(): boolean;
  28274. /**
  28275. * BJS is using an harcoded light falloff based on a manually sets up range.
  28276. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  28277. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  28278. */
  28279. set usePhysicalLightFalloff(value: boolean);
  28280. /**
  28281. * In order to support the falloff compatibility with gltf, a special mode has been added
  28282. * to reproduce the gltf light falloff.
  28283. */
  28284. get useGLTFLightFalloff(): boolean;
  28285. /**
  28286. * In order to support the falloff compatibility with gltf, a special mode has been added
  28287. * to reproduce the gltf light falloff.
  28288. */
  28289. set useGLTFLightFalloff(value: boolean);
  28290. /**
  28291. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  28292. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  28293. */
  28294. useRadianceOverAlpha: boolean;
  28295. /**
  28296. * Allows using an object space normal map (instead of tangent space).
  28297. */
  28298. useObjectSpaceNormalMap: boolean;
  28299. /**
  28300. * Allows using the bump map in parallax mode.
  28301. */
  28302. useParallax: boolean;
  28303. /**
  28304. * Allows using the bump map in parallax occlusion mode.
  28305. */
  28306. useParallaxOcclusion: boolean;
  28307. /**
  28308. * Controls the scale bias of the parallax mode.
  28309. */
  28310. parallaxScaleBias: number;
  28311. /**
  28312. * If sets to true, disables all the lights affecting the material.
  28313. */
  28314. disableLighting: boolean;
  28315. /**
  28316. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  28317. */
  28318. forceIrradianceInFragment: boolean;
  28319. /**
  28320. * Number of Simultaneous lights allowed on the material.
  28321. */
  28322. maxSimultaneousLights: number;
  28323. /**
  28324. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  28325. */
  28326. invertNormalMapX: boolean;
  28327. /**
  28328. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  28329. */
  28330. invertNormalMapY: boolean;
  28331. /**
  28332. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  28333. */
  28334. twoSidedLighting: boolean;
  28335. /**
  28336. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28337. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  28338. */
  28339. useAlphaFresnel: boolean;
  28340. /**
  28341. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  28342. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  28343. */
  28344. useLinearAlphaFresnel: boolean;
  28345. /**
  28346. * Let user defines the brdf lookup texture used for IBL.
  28347. * A default 8bit version is embedded but you could point at :
  28348. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  28349. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  28350. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  28351. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  28352. */
  28353. environmentBRDFTexture: Nullable<BaseTexture>;
  28354. /**
  28355. * Force normal to face away from face.
  28356. */
  28357. forceNormalForward: boolean;
  28358. /**
  28359. * Enables specular anti aliasing in the PBR shader.
  28360. * It will both interacts on the Geometry for analytical and IBL lighting.
  28361. * It also prefilter the roughness map based on the bump values.
  28362. */
  28363. enableSpecularAntiAliasing: boolean;
  28364. /**
  28365. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  28366. * makes the reflect vector face the model (under horizon).
  28367. */
  28368. useHorizonOcclusion: boolean;
  28369. /**
  28370. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  28371. * too much the area relying on ambient texture to define their ambient occlusion.
  28372. */
  28373. useRadianceOcclusion: boolean;
  28374. /**
  28375. * If set to true, no lighting calculations will be applied.
  28376. */
  28377. unlit: boolean;
  28378. /**
  28379. * Gets the image processing configuration used either in this material.
  28380. */
  28381. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  28382. /**
  28383. * Sets the Default image processing configuration used either in the this material.
  28384. *
  28385. * If sets to null, the scene one is in use.
  28386. */
  28387. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  28388. /**
  28389. * Gets wether the color curves effect is enabled.
  28390. */
  28391. get cameraColorCurvesEnabled(): boolean;
  28392. /**
  28393. * Sets wether the color curves effect is enabled.
  28394. */
  28395. set cameraColorCurvesEnabled(value: boolean);
  28396. /**
  28397. * Gets wether the color grading effect is enabled.
  28398. */
  28399. get cameraColorGradingEnabled(): boolean;
  28400. /**
  28401. * Gets wether the color grading effect is enabled.
  28402. */
  28403. set cameraColorGradingEnabled(value: boolean);
  28404. /**
  28405. * Gets wether tonemapping is enabled or not.
  28406. */
  28407. get cameraToneMappingEnabled(): boolean;
  28408. /**
  28409. * Sets wether tonemapping is enabled or not
  28410. */
  28411. set cameraToneMappingEnabled(value: boolean);
  28412. /**
  28413. * The camera exposure used on this material.
  28414. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28415. * This corresponds to a photographic exposure.
  28416. */
  28417. get cameraExposure(): number;
  28418. /**
  28419. * The camera exposure used on this material.
  28420. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  28421. * This corresponds to a photographic exposure.
  28422. */
  28423. set cameraExposure(value: number);
  28424. /**
  28425. * Gets The camera contrast used on this material.
  28426. */
  28427. get cameraContrast(): number;
  28428. /**
  28429. * Sets The camera contrast used on this material.
  28430. */
  28431. set cameraContrast(value: number);
  28432. /**
  28433. * Gets the Color Grading 2D Lookup Texture.
  28434. */
  28435. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  28436. /**
  28437. * Sets the Color Grading 2D Lookup Texture.
  28438. */
  28439. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  28440. /**
  28441. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28442. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28443. * 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;
  28444. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28445. */
  28446. get cameraColorCurves(): Nullable<ColorCurves>;
  28447. /**
  28448. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  28449. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  28450. * 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;
  28451. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  28452. */
  28453. set cameraColorCurves(value: Nullable<ColorCurves>);
  28454. /**
  28455. * Instantiates a new PBRMaterial instance.
  28456. *
  28457. * @param name The material name
  28458. * @param scene The scene the material will be use in.
  28459. */
  28460. constructor(name: string, scene: Scene);
  28461. /**
  28462. * Returns the name of this material class.
  28463. */
  28464. getClassName(): string;
  28465. /**
  28466. * Makes a duplicate of the current material.
  28467. * @param name - name to use for the new material.
  28468. */
  28469. clone(name: string): PBRMaterial;
  28470. /**
  28471. * Serializes this PBR Material.
  28472. * @returns - An object with the serialized material.
  28473. */
  28474. serialize(): any;
  28475. /**
  28476. * Parses a PBR Material from a serialized object.
  28477. * @param source - Serialized object.
  28478. * @param scene - BJS scene instance.
  28479. * @param rootUrl - url for the scene object
  28480. * @returns - PBRMaterial
  28481. */
  28482. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  28483. }
  28484. }
  28485. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  28486. /** @hidden */
  28487. export var mrtFragmentDeclaration: {
  28488. name: string;
  28489. shader: string;
  28490. };
  28491. }
  28492. declare module "babylonjs/Shaders/geometry.fragment" {
  28493. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  28494. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  28495. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  28496. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  28497. /** @hidden */
  28498. export var geometryPixelShader: {
  28499. name: string;
  28500. shader: string;
  28501. };
  28502. }
  28503. declare module "babylonjs/Shaders/geometry.vertex" {
  28504. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  28505. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  28506. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  28507. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  28508. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  28509. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  28510. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  28511. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  28512. /** @hidden */
  28513. export var geometryVertexShader: {
  28514. name: string;
  28515. shader: string;
  28516. };
  28517. }
  28518. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  28519. import { Matrix } from "babylonjs/Maths/math.vector";
  28520. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28521. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28522. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28523. import { Effect } from "babylonjs/Materials/effect";
  28524. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28525. import { Scene } from "babylonjs/scene";
  28526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28527. import { Nullable } from "babylonjs/types";
  28528. import "babylonjs/Shaders/geometry.fragment";
  28529. import "babylonjs/Shaders/geometry.vertex";
  28530. /** @hidden */
  28531. interface ISavedTransformationMatrix {
  28532. world: Matrix;
  28533. viewProjection: Matrix;
  28534. }
  28535. /**
  28536. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  28537. */
  28538. export class GeometryBufferRenderer {
  28539. /**
  28540. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  28541. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  28542. */
  28543. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  28544. /**
  28545. * Constant used to retrieve the position texture index in the G-Buffer textures array
  28546. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  28547. */
  28548. static readonly POSITION_TEXTURE_TYPE: number;
  28549. /**
  28550. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  28551. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  28552. */
  28553. static readonly VELOCITY_TEXTURE_TYPE: number;
  28554. /**
  28555. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  28556. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  28557. */
  28558. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  28559. /**
  28560. * Dictionary used to store the previous transformation matrices of each rendered mesh
  28561. * in order to compute objects velocities when enableVelocity is set to "true"
  28562. * @hidden
  28563. */
  28564. _previousTransformationMatrices: {
  28565. [index: number]: ISavedTransformationMatrix;
  28566. };
  28567. /**
  28568. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  28569. * in order to compute objects velocities when enableVelocity is set to "true"
  28570. * @hidden
  28571. */
  28572. _previousBonesTransformationMatrices: {
  28573. [index: number]: Float32Array;
  28574. };
  28575. /**
  28576. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  28577. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  28578. */
  28579. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  28580. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  28581. renderTransparentMeshes: boolean;
  28582. private _scene;
  28583. private _resizeObserver;
  28584. private _multiRenderTarget;
  28585. private _ratio;
  28586. private _enablePosition;
  28587. private _enableVelocity;
  28588. private _enableReflectivity;
  28589. private _positionIndex;
  28590. private _velocityIndex;
  28591. private _reflectivityIndex;
  28592. private _depthNormalIndex;
  28593. private _linkedWithPrePass;
  28594. private _prePassRenderer;
  28595. private _attachments;
  28596. protected _effect: Effect;
  28597. protected _cachedDefines: string;
  28598. /**
  28599. * @hidden
  28600. * Sets up internal structures to share outputs with PrePassRenderer
  28601. * This method should only be called by the PrePassRenderer itself
  28602. */
  28603. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  28604. /**
  28605. * @hidden
  28606. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  28607. * This method should only be called by the PrePassRenderer itself
  28608. */
  28609. _unlinkPrePassRenderer(): void;
  28610. /**
  28611. * @hidden
  28612. * Resets the geometry buffer layout
  28613. */
  28614. _resetLayout(): void;
  28615. /**
  28616. * @hidden
  28617. * Replaces a texture in the geometry buffer renderer
  28618. * Useful when linking textures of the prepass renderer
  28619. */
  28620. _forceTextureType(geometryBufferType: number, index: number): void;
  28621. /**
  28622. * @hidden
  28623. * Sets texture attachments
  28624. * Useful when linking textures of the prepass renderer
  28625. */
  28626. _setAttachments(attachments: number[]): void;
  28627. /**
  28628. * @hidden
  28629. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  28630. * Useful when linking textures of the prepass renderer
  28631. */
  28632. _linkInternalTexture(internalTexture: InternalTexture): void;
  28633. /**
  28634. * Gets the render list (meshes to be rendered) used in the G buffer.
  28635. */
  28636. get renderList(): Nullable<AbstractMesh[]>;
  28637. /**
  28638. * Set the render list (meshes to be rendered) used in the G buffer.
  28639. */
  28640. set renderList(meshes: Nullable<AbstractMesh[]>);
  28641. /**
  28642. * Gets wether or not G buffer are supported by the running hardware.
  28643. * This requires draw buffer supports
  28644. */
  28645. get isSupported(): boolean;
  28646. /**
  28647. * Returns the index of the given texture type in the G-Buffer textures array
  28648. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  28649. * @returns the index of the given texture type in the G-Buffer textures array
  28650. */
  28651. getTextureIndex(textureType: number): number;
  28652. /**
  28653. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  28654. */
  28655. get enablePosition(): boolean;
  28656. /**
  28657. * Sets whether or not objects positions are enabled for the G buffer.
  28658. */
  28659. set enablePosition(enable: boolean);
  28660. /**
  28661. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  28662. */
  28663. get enableVelocity(): boolean;
  28664. /**
  28665. * Sets wether or not objects velocities are enabled for the G buffer.
  28666. */
  28667. set enableVelocity(enable: boolean);
  28668. /**
  28669. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  28670. */
  28671. get enableReflectivity(): boolean;
  28672. /**
  28673. * Sets wether or not objects roughness are enabled for the G buffer.
  28674. */
  28675. set enableReflectivity(enable: boolean);
  28676. /**
  28677. * Gets the scene associated with the buffer.
  28678. */
  28679. get scene(): Scene;
  28680. /**
  28681. * Gets the ratio used by the buffer during its creation.
  28682. * How big is the buffer related to the main canvas.
  28683. */
  28684. get ratio(): number;
  28685. /** @hidden */
  28686. static _SceneComponentInitialization: (scene: Scene) => void;
  28687. /**
  28688. * Creates a new G Buffer for the scene
  28689. * @param scene The scene the buffer belongs to
  28690. * @param ratio How big is the buffer related to the main canvas.
  28691. */
  28692. constructor(scene: Scene, ratio?: number);
  28693. /**
  28694. * Checks wether everything is ready to render a submesh to the G buffer.
  28695. * @param subMesh the submesh to check readiness for
  28696. * @param useInstances is the mesh drawn using instance or not
  28697. * @returns true if ready otherwise false
  28698. */
  28699. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  28700. /**
  28701. * Gets the current underlying G Buffer.
  28702. * @returns the buffer
  28703. */
  28704. getGBuffer(): MultiRenderTarget;
  28705. /**
  28706. * Gets the number of samples used to render the buffer (anti aliasing).
  28707. */
  28708. get samples(): number;
  28709. /**
  28710. * Sets the number of samples used to render the buffer (anti aliasing).
  28711. */
  28712. set samples(value: number);
  28713. /**
  28714. * Disposes the renderer and frees up associated resources.
  28715. */
  28716. dispose(): void;
  28717. private _assignRenderTargetIndices;
  28718. protected _createRenderTargets(): void;
  28719. private _copyBonesTransformationMatrices;
  28720. }
  28721. }
  28722. declare module "babylonjs/Rendering/prePassRenderer" {
  28723. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  28724. import { Scene } from "babylonjs/scene";
  28725. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  28726. import { Effect } from "babylonjs/Materials/effect";
  28727. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28728. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28729. import { Material } from "babylonjs/Materials/material";
  28730. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28731. /**
  28732. * Renders a pre pass of the scene
  28733. * This means every mesh in the scene will be rendered to a render target texture
  28734. * And then this texture will be composited to the rendering canvas with post processes
  28735. * It is necessary for effects like subsurface scattering or deferred shading
  28736. */
  28737. export class PrePassRenderer {
  28738. /** @hidden */
  28739. static _SceneComponentInitialization: (scene: Scene) => void;
  28740. private _textureFormats;
  28741. /**
  28742. * To save performance, we can excluded skinned meshes from the prepass
  28743. */
  28744. excludedSkinnedMesh: AbstractMesh[];
  28745. /**
  28746. * Force material to be excluded from the prepass
  28747. * Can be useful when `useGeometryBufferFallback` is set to `true`
  28748. * and you don't want a material to show in the effect.
  28749. */
  28750. excludedMaterials: Material[];
  28751. private _textureIndices;
  28752. private _scene;
  28753. private _engine;
  28754. private _isDirty;
  28755. /**
  28756. * Number of textures in the multi render target texture where the scene is directly rendered
  28757. */
  28758. mrtCount: number;
  28759. /**
  28760. * The render target where the scene is directly rendered
  28761. */
  28762. prePassRT: MultiRenderTarget;
  28763. private _multiRenderAttachments;
  28764. private _defaultAttachments;
  28765. private _clearAttachments;
  28766. private _postProcesses;
  28767. private readonly _clearColor;
  28768. /**
  28769. * Image processing post process for composition
  28770. */
  28771. imageProcessingPostProcess: ImageProcessingPostProcess;
  28772. /**
  28773. * Configuration for prepass effects
  28774. */
  28775. private _effectConfigurations;
  28776. private _mrtFormats;
  28777. private _mrtLayout;
  28778. private _enabled;
  28779. /**
  28780. * Indicates if the prepass is enabled
  28781. */
  28782. get enabled(): boolean;
  28783. /**
  28784. * How many samples are used for MSAA of the scene render target
  28785. */
  28786. get samples(): number;
  28787. set samples(n: number);
  28788. private _geometryBuffer;
  28789. private _useGeometryBufferFallback;
  28790. /**
  28791. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  28792. */
  28793. get useGeometryBufferFallback(): boolean;
  28794. set useGeometryBufferFallback(value: boolean);
  28795. /**
  28796. * Instanciates a prepass renderer
  28797. * @param scene The scene
  28798. */
  28799. constructor(scene: Scene);
  28800. private _initializeAttachments;
  28801. private _createCompositionEffect;
  28802. /**
  28803. * Indicates if rendering a prepass is supported
  28804. */
  28805. get isSupported(): boolean;
  28806. /**
  28807. * Sets the proper output textures to draw in the engine.
  28808. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  28809. * @param subMesh Submesh on which the effect is applied
  28810. */
  28811. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  28812. /**
  28813. * @hidden
  28814. */
  28815. _beforeCameraDraw(): void;
  28816. /**
  28817. * @hidden
  28818. */
  28819. _afterCameraDraw(): void;
  28820. private _checkRTSize;
  28821. private _bindFrameBuffer;
  28822. /**
  28823. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  28824. */
  28825. clear(): void;
  28826. private _setState;
  28827. private _updateGeometryBufferLayout;
  28828. /**
  28829. * Adds an effect configuration to the prepass.
  28830. * If an effect has already been added, it won't add it twice and will return the configuration
  28831. * already present.
  28832. * @param cfg the effect configuration
  28833. * @return the effect configuration now used by the prepass
  28834. */
  28835. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  28836. /**
  28837. * Returns the index of a texture in the multi render target texture array.
  28838. * @param type Texture type
  28839. * @return The index
  28840. */
  28841. getIndex(type: number): number;
  28842. private _enable;
  28843. private _disable;
  28844. private _resetLayout;
  28845. private _resetPostProcessChain;
  28846. private _bindPostProcessChain;
  28847. /**
  28848. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  28849. */
  28850. markAsDirty(): void;
  28851. /**
  28852. * Enables a texture on the MultiRenderTarget for prepass
  28853. */
  28854. private _enableTextures;
  28855. private _update;
  28856. private _markAllMaterialsAsPrePassDirty;
  28857. /**
  28858. * Disposes the prepass renderer.
  28859. */
  28860. dispose(): void;
  28861. }
  28862. }
  28863. declare module "babylonjs/PostProcesses/postProcess" {
  28864. import { Nullable } from "babylonjs/types";
  28865. import { SmartArray } from "babylonjs/Misc/smartArray";
  28866. import { Observable } from "babylonjs/Misc/observable";
  28867. import { Vector2 } from "babylonjs/Maths/math.vector";
  28868. import { Camera } from "babylonjs/Cameras/camera";
  28869. import { Effect } from "babylonjs/Materials/effect";
  28870. import "babylonjs/Shaders/postprocess.vertex";
  28871. import { IInspectable } from "babylonjs/Misc/iInspectable";
  28872. import { Engine } from "babylonjs/Engines/engine";
  28873. import { Color4 } from "babylonjs/Maths/math.color";
  28874. import "babylonjs/Engines/Extensions/engine.renderTarget";
  28875. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  28876. import { Scene } from "babylonjs/scene";
  28877. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28878. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  28879. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  28880. /**
  28881. * Size options for a post process
  28882. */
  28883. export type PostProcessOptions = {
  28884. width: number;
  28885. height: number;
  28886. };
  28887. /**
  28888. * PostProcess can be used to apply a shader to a texture after it has been rendered
  28889. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28890. */
  28891. export class PostProcess {
  28892. /**
  28893. * Gets or sets the unique id of the post process
  28894. */
  28895. uniqueId: number;
  28896. /** Name of the PostProcess. */
  28897. name: string;
  28898. /**
  28899. * Width of the texture to apply the post process on
  28900. */
  28901. width: number;
  28902. /**
  28903. * Height of the texture to apply the post process on
  28904. */
  28905. height: number;
  28906. /**
  28907. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  28908. */
  28909. nodeMaterialSource: Nullable<NodeMaterial>;
  28910. /**
  28911. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  28912. * @hidden
  28913. */
  28914. _outputTexture: Nullable<InternalTexture>;
  28915. /**
  28916. * Sampling mode used by the shader
  28917. * See https://doc.babylonjs.com/classes/3.1/texture
  28918. */
  28919. renderTargetSamplingMode: number;
  28920. /**
  28921. * Clear color to use when screen clearing
  28922. */
  28923. clearColor: Color4;
  28924. /**
  28925. * If the buffer needs to be cleared before applying the post process. (default: true)
  28926. * Should be set to false if shader will overwrite all previous pixels.
  28927. */
  28928. autoClear: boolean;
  28929. /**
  28930. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  28931. */
  28932. alphaMode: number;
  28933. /**
  28934. * Sets the setAlphaBlendConstants of the babylon engine
  28935. */
  28936. alphaConstants: Color4;
  28937. /**
  28938. * Animations to be used for the post processing
  28939. */
  28940. animations: import("babylonjs/Animations/animation").Animation[];
  28941. /**
  28942. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  28943. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  28944. */
  28945. enablePixelPerfectMode: boolean;
  28946. /**
  28947. * Force the postprocess to be applied without taking in account viewport
  28948. */
  28949. forceFullscreenViewport: boolean;
  28950. /**
  28951. * List of inspectable custom properties (used by the Inspector)
  28952. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28953. */
  28954. inspectableCustomProperties: IInspectable[];
  28955. /**
  28956. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  28957. *
  28958. * | Value | Type | Description |
  28959. * | ----- | ----------------------------------- | ----------- |
  28960. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  28961. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  28962. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  28963. *
  28964. */
  28965. scaleMode: number;
  28966. /**
  28967. * Force textures to be a power of two (default: false)
  28968. */
  28969. alwaysForcePOT: boolean;
  28970. private _samples;
  28971. /**
  28972. * Number of sample textures (default: 1)
  28973. */
  28974. get samples(): number;
  28975. set samples(n: number);
  28976. /**
  28977. * Modify the scale of the post process to be the same as the viewport (default: false)
  28978. */
  28979. adaptScaleToCurrentViewport: boolean;
  28980. private _camera;
  28981. protected _scene: Scene;
  28982. private _engine;
  28983. private _options;
  28984. private _reusable;
  28985. private _textureType;
  28986. private _textureFormat;
  28987. /**
  28988. * Smart array of input and output textures for the post process.
  28989. * @hidden
  28990. */
  28991. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  28992. /**
  28993. * The index in _textures that corresponds to the output texture.
  28994. * @hidden
  28995. */
  28996. _currentRenderTextureInd: number;
  28997. private _effect;
  28998. private _samplers;
  28999. private _fragmentUrl;
  29000. private _vertexUrl;
  29001. private _parameters;
  29002. private _scaleRatio;
  29003. protected _indexParameters: any;
  29004. private _shareOutputWithPostProcess;
  29005. private _texelSize;
  29006. private _forcedOutputTexture;
  29007. /**
  29008. * Prepass configuration in case this post process needs a texture from prepass
  29009. * @hidden
  29010. */
  29011. _prePassEffectConfiguration: PrePassEffectConfiguration;
  29012. /**
  29013. * Returns the fragment url or shader name used in the post process.
  29014. * @returns the fragment url or name in the shader store.
  29015. */
  29016. getEffectName(): string;
  29017. /**
  29018. * An event triggered when the postprocess is activated.
  29019. */
  29020. onActivateObservable: Observable<Camera>;
  29021. private _onActivateObserver;
  29022. /**
  29023. * A function that is added to the onActivateObservable
  29024. */
  29025. set onActivate(callback: Nullable<(camera: Camera) => void>);
  29026. /**
  29027. * An event triggered when the postprocess changes its size.
  29028. */
  29029. onSizeChangedObservable: Observable<PostProcess>;
  29030. private _onSizeChangedObserver;
  29031. /**
  29032. * A function that is added to the onSizeChangedObservable
  29033. */
  29034. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  29035. /**
  29036. * An event triggered when the postprocess applies its effect.
  29037. */
  29038. onApplyObservable: Observable<Effect>;
  29039. private _onApplyObserver;
  29040. /**
  29041. * A function that is added to the onApplyObservable
  29042. */
  29043. set onApply(callback: (effect: Effect) => void);
  29044. /**
  29045. * An event triggered before rendering the postprocess
  29046. */
  29047. onBeforeRenderObservable: Observable<Effect>;
  29048. private _onBeforeRenderObserver;
  29049. /**
  29050. * A function that is added to the onBeforeRenderObservable
  29051. */
  29052. set onBeforeRender(callback: (effect: Effect) => void);
  29053. /**
  29054. * An event triggered after rendering the postprocess
  29055. */
  29056. onAfterRenderObservable: Observable<Effect>;
  29057. private _onAfterRenderObserver;
  29058. /**
  29059. * A function that is added to the onAfterRenderObservable
  29060. */
  29061. set onAfterRender(callback: (efect: Effect) => void);
  29062. /**
  29063. * 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
  29064. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  29065. */
  29066. get inputTexture(): InternalTexture;
  29067. set inputTexture(value: InternalTexture);
  29068. /**
  29069. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  29070. * the only way to unset it is to use this function to restore its internal state
  29071. */
  29072. restoreDefaultInputTexture(): void;
  29073. /**
  29074. * Gets the camera which post process is applied to.
  29075. * @returns The camera the post process is applied to.
  29076. */
  29077. getCamera(): Camera;
  29078. /**
  29079. * Gets the texel size of the postprocess.
  29080. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  29081. */
  29082. get texelSize(): Vector2;
  29083. /**
  29084. * Creates a new instance PostProcess
  29085. * @param name The name of the PostProcess.
  29086. * @param fragmentUrl The url of the fragment shader to be used.
  29087. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  29088. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  29089. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  29090. * @param camera The camera to apply the render pass to.
  29091. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  29092. * @param engine The engine which the post process will be applied. (default: current engine)
  29093. * @param reusable If the post process can be reused on the same frame. (default: false)
  29094. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  29095. * @param textureType Type of textures used when performing the post process. (default: 0)
  29096. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  29097. * @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
  29098. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  29099. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  29100. */
  29101. 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);
  29102. /**
  29103. * Gets a string identifying the name of the class
  29104. * @returns "PostProcess" string
  29105. */
  29106. getClassName(): string;
  29107. /**
  29108. * Gets the engine which this post process belongs to.
  29109. * @returns The engine the post process was enabled with.
  29110. */
  29111. getEngine(): Engine;
  29112. /**
  29113. * The effect that is created when initializing the post process.
  29114. * @returns The created effect corresponding the the postprocess.
  29115. */
  29116. getEffect(): Effect;
  29117. /**
  29118. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  29119. * @param postProcess The post process to share the output with.
  29120. * @returns This post process.
  29121. */
  29122. shareOutputWith(postProcess: PostProcess): PostProcess;
  29123. /**
  29124. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  29125. * This should be called if the post process that shares output with this post process is disabled/disposed.
  29126. */
  29127. useOwnOutput(): void;
  29128. /**
  29129. * Updates the effect with the current post process compile time values and recompiles the shader.
  29130. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  29131. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  29132. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  29133. * @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
  29134. * @param onCompiled Called when the shader has been compiled.
  29135. * @param onError Called if there is an error when compiling a shader.
  29136. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  29137. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  29138. */
  29139. 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;
  29140. /**
  29141. * The post process is reusable if it can be used multiple times within one frame.
  29142. * @returns If the post process is reusable
  29143. */
  29144. isReusable(): boolean;
  29145. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  29146. markTextureDirty(): void;
  29147. /**
  29148. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  29149. * 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.
  29150. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  29151. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  29152. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  29153. * @returns The target texture that was bound to be written to.
  29154. */
  29155. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  29156. /**
  29157. * If the post process is supported.
  29158. */
  29159. get isSupported(): boolean;
  29160. /**
  29161. * The aspect ratio of the output texture.
  29162. */
  29163. get aspectRatio(): number;
  29164. /**
  29165. * Get a value indicating if the post-process is ready to be used
  29166. * @returns true if the post-process is ready (shader is compiled)
  29167. */
  29168. isReady(): boolean;
  29169. /**
  29170. * Binds all textures and uniforms to the shader, this will be run on every pass.
  29171. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  29172. */
  29173. apply(): Nullable<Effect>;
  29174. private _disposeTextures;
  29175. /**
  29176. * Sets the required values to the prepass renderer.
  29177. * @param prePassRenderer defines the prepass renderer to setup.
  29178. * @returns true if the pre pass is needed.
  29179. */
  29180. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29181. /**
  29182. * Disposes the post process.
  29183. * @param camera The camera to dispose the post process on.
  29184. */
  29185. dispose(camera?: Camera): void;
  29186. /**
  29187. * Serializes the particle system to a JSON object
  29188. * @returns the JSON object
  29189. */
  29190. serialize(): any;
  29191. /**
  29192. * Creates a material from parsed material data
  29193. * @param parsedPostProcess defines parsed post process data
  29194. * @param scene defines the hosting scene
  29195. * @param rootUrl defines the root URL to use to load textures
  29196. * @returns a new post process
  29197. */
  29198. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  29199. }
  29200. }
  29201. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  29202. /** @hidden */
  29203. export var kernelBlurVaryingDeclaration: {
  29204. name: string;
  29205. shader: string;
  29206. };
  29207. }
  29208. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  29209. /** @hidden */
  29210. export var kernelBlurFragment: {
  29211. name: string;
  29212. shader: string;
  29213. };
  29214. }
  29215. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  29216. /** @hidden */
  29217. export var kernelBlurFragment2: {
  29218. name: string;
  29219. shader: string;
  29220. };
  29221. }
  29222. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  29223. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  29224. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  29225. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  29226. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  29227. /** @hidden */
  29228. export var kernelBlurPixelShader: {
  29229. name: string;
  29230. shader: string;
  29231. };
  29232. }
  29233. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  29234. /** @hidden */
  29235. export var kernelBlurVertex: {
  29236. name: string;
  29237. shader: string;
  29238. };
  29239. }
  29240. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  29241. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  29242. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  29243. /** @hidden */
  29244. export var kernelBlurVertexShader: {
  29245. name: string;
  29246. shader: string;
  29247. };
  29248. }
  29249. declare module "babylonjs/PostProcesses/blurPostProcess" {
  29250. import { Vector2 } from "babylonjs/Maths/math.vector";
  29251. import { Nullable } from "babylonjs/types";
  29252. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  29253. import { Camera } from "babylonjs/Cameras/camera";
  29254. import { Effect } from "babylonjs/Materials/effect";
  29255. import { Engine } from "babylonjs/Engines/engine";
  29256. import "babylonjs/Shaders/kernelBlur.fragment";
  29257. import "babylonjs/Shaders/kernelBlur.vertex";
  29258. import { Scene } from "babylonjs/scene";
  29259. /**
  29260. * The Blur Post Process which blurs an image based on a kernel and direction.
  29261. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  29262. */
  29263. export class BlurPostProcess extends PostProcess {
  29264. private blockCompilation;
  29265. protected _kernel: number;
  29266. protected _idealKernel: number;
  29267. protected _packedFloat: boolean;
  29268. private _staticDefines;
  29269. /** The direction in which to blur the image. */
  29270. direction: Vector2;
  29271. /**
  29272. * Sets the length in pixels of the blur sample region
  29273. */
  29274. set kernel(v: number);
  29275. /**
  29276. * Gets the length in pixels of the blur sample region
  29277. */
  29278. get kernel(): number;
  29279. /**
  29280. * Sets wether or not the blur needs to unpack/repack floats
  29281. */
  29282. set packedFloat(v: boolean);
  29283. /**
  29284. * Gets wether or not the blur is unpacking/repacking floats
  29285. */
  29286. get packedFloat(): boolean;
  29287. /**
  29288. * Gets a string identifying the name of the class
  29289. * @returns "BlurPostProcess" string
  29290. */
  29291. getClassName(): string;
  29292. /**
  29293. * Creates a new instance BlurPostProcess
  29294. * @param name The name of the effect.
  29295. * @param direction The direction in which to blur the image.
  29296. * @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.
  29297. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  29298. * @param camera The camera to apply the render pass to.
  29299. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  29300. * @param engine The engine which the post process will be applied. (default: current engine)
  29301. * @param reusable If the post process can be reused on the same frame. (default: false)
  29302. * @param textureType Type of textures used when performing the post process. (default: 0)
  29303. * @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)
  29304. */
  29305. 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);
  29306. /**
  29307. * Updates the effect with the current post process compile time values and recompiles the shader.
  29308. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  29309. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  29310. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  29311. * @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
  29312. * @param onCompiled Called when the shader has been compiled.
  29313. * @param onError Called if there is an error when compiling a shader.
  29314. */
  29315. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29316. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  29317. /**
  29318. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  29319. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  29320. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  29321. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  29322. * The gaps between physical kernels are compensated for in the weighting of the samples
  29323. * @param idealKernel Ideal blur kernel.
  29324. * @return Nearest best kernel.
  29325. */
  29326. protected _nearestBestKernel(idealKernel: number): number;
  29327. /**
  29328. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  29329. * @param x The point on the Gaussian distribution to sample.
  29330. * @return the value of the Gaussian function at x.
  29331. */
  29332. protected _gaussianWeight(x: number): number;
  29333. /**
  29334. * Generates a string that can be used as a floating point number in GLSL.
  29335. * @param x Value to print.
  29336. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  29337. * @return GLSL float string.
  29338. */
  29339. protected _glslFloat(x: number, decimalFigures?: number): string;
  29340. /** @hidden */
  29341. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  29342. }
  29343. }
  29344. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  29345. import { Scene } from "babylonjs/scene";
  29346. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29347. import { Plane } from "babylonjs/Maths/math.plane";
  29348. /**
  29349. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29350. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29351. * You can then easily use it as a reflectionTexture on a flat surface.
  29352. * In case the surface is not a plane, please consider relying on reflection probes.
  29353. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29354. */
  29355. export class MirrorTexture extends RenderTargetTexture {
  29356. private scene;
  29357. /**
  29358. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  29359. * 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.
  29360. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29361. */
  29362. mirrorPlane: Plane;
  29363. /**
  29364. * Define the blur ratio used to blur the reflection if needed.
  29365. */
  29366. set blurRatio(value: number);
  29367. get blurRatio(): number;
  29368. /**
  29369. * Define the adaptive blur kernel used to blur the reflection if needed.
  29370. * This will autocompute the closest best match for the `blurKernel`
  29371. */
  29372. set adaptiveBlurKernel(value: number);
  29373. /**
  29374. * Define the blur kernel used to blur the reflection if needed.
  29375. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29376. */
  29377. set blurKernel(value: number);
  29378. /**
  29379. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  29380. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29381. */
  29382. set blurKernelX(value: number);
  29383. get blurKernelX(): number;
  29384. /**
  29385. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  29386. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  29387. */
  29388. set blurKernelY(value: number);
  29389. get blurKernelY(): number;
  29390. private _autoComputeBlurKernel;
  29391. protected _onRatioRescale(): void;
  29392. private _updateGammaSpace;
  29393. private _imageProcessingConfigChangeObserver;
  29394. private _transformMatrix;
  29395. private _mirrorMatrix;
  29396. private _savedViewMatrix;
  29397. private _blurX;
  29398. private _blurY;
  29399. private _adaptiveBlurKernel;
  29400. private _blurKernelX;
  29401. private _blurKernelY;
  29402. private _blurRatio;
  29403. /**
  29404. * Instantiates a Mirror Texture.
  29405. * Mirror texture can be used to simulate the view from a mirror in a scene.
  29406. * It will dynamically be rendered every frame to adapt to the camera point of view.
  29407. * You can then easily use it as a reflectionTexture on a flat surface.
  29408. * In case the surface is not a plane, please consider relying on reflection probes.
  29409. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  29410. * @param name
  29411. * @param size
  29412. * @param scene
  29413. * @param generateMipMaps
  29414. * @param type
  29415. * @param samplingMode
  29416. * @param generateDepthBuffer
  29417. */
  29418. constructor(name: string, size: number | {
  29419. width: number;
  29420. height: number;
  29421. } | {
  29422. ratio: number;
  29423. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  29424. private _preparePostProcesses;
  29425. /**
  29426. * Clone the mirror texture.
  29427. * @returns the cloned texture
  29428. */
  29429. clone(): MirrorTexture;
  29430. /**
  29431. * Serialize the texture to a JSON representation you could use in Parse later on
  29432. * @returns the serialized JSON representation
  29433. */
  29434. serialize(): any;
  29435. /**
  29436. * Dispose the texture and release its associated resources.
  29437. */
  29438. dispose(): void;
  29439. }
  29440. }
  29441. declare module "babylonjs/Materials/Textures/texture" {
  29442. import { Observable } from "babylonjs/Misc/observable";
  29443. import { Nullable } from "babylonjs/types";
  29444. import { Matrix } from "babylonjs/Maths/math.vector";
  29445. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29446. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29447. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29448. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  29449. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  29450. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29451. import { Scene } from "babylonjs/scene";
  29452. /**
  29453. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29454. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29455. */
  29456. export class Texture extends BaseTexture {
  29457. /**
  29458. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  29459. */
  29460. static SerializeBuffers: boolean;
  29461. /** @hidden */
  29462. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  29463. /** @hidden */
  29464. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  29465. /** @hidden */
  29466. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  29467. /** nearest is mag = nearest and min = nearest and mip = linear */
  29468. static readonly NEAREST_SAMPLINGMODE: number;
  29469. /** nearest is mag = nearest and min = nearest and mip = linear */
  29470. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  29471. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29472. static readonly BILINEAR_SAMPLINGMODE: number;
  29473. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29474. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  29475. /** Trilinear is mag = linear and min = linear and mip = linear */
  29476. static readonly TRILINEAR_SAMPLINGMODE: number;
  29477. /** Trilinear is mag = linear and min = linear and mip = linear */
  29478. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  29479. /** mag = nearest and min = nearest and mip = nearest */
  29480. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  29481. /** mag = nearest and min = linear and mip = nearest */
  29482. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  29483. /** mag = nearest and min = linear and mip = linear */
  29484. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  29485. /** mag = nearest and min = linear and mip = none */
  29486. static readonly NEAREST_LINEAR: number;
  29487. /** mag = nearest and min = nearest and mip = none */
  29488. static readonly NEAREST_NEAREST: number;
  29489. /** mag = linear and min = nearest and mip = nearest */
  29490. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  29491. /** mag = linear and min = nearest and mip = linear */
  29492. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  29493. /** mag = linear and min = linear and mip = none */
  29494. static readonly LINEAR_LINEAR: number;
  29495. /** mag = linear and min = nearest and mip = none */
  29496. static readonly LINEAR_NEAREST: number;
  29497. /** Explicit coordinates mode */
  29498. static readonly EXPLICIT_MODE: number;
  29499. /** Spherical coordinates mode */
  29500. static readonly SPHERICAL_MODE: number;
  29501. /** Planar coordinates mode */
  29502. static readonly PLANAR_MODE: number;
  29503. /** Cubic coordinates mode */
  29504. static readonly CUBIC_MODE: number;
  29505. /** Projection coordinates mode */
  29506. static readonly PROJECTION_MODE: number;
  29507. /** Inverse Cubic coordinates mode */
  29508. static readonly SKYBOX_MODE: number;
  29509. /** Inverse Cubic coordinates mode */
  29510. static readonly INVCUBIC_MODE: number;
  29511. /** Equirectangular coordinates mode */
  29512. static readonly EQUIRECTANGULAR_MODE: number;
  29513. /** Equirectangular Fixed coordinates mode */
  29514. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  29515. /** Equirectangular Fixed Mirrored coordinates mode */
  29516. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29517. /** Texture is not repeating outside of 0..1 UVs */
  29518. static readonly CLAMP_ADDRESSMODE: number;
  29519. /** Texture is repeating outside of 0..1 UVs */
  29520. static readonly WRAP_ADDRESSMODE: number;
  29521. /** Texture is repeating and mirrored */
  29522. static readonly MIRROR_ADDRESSMODE: number;
  29523. /**
  29524. * 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
  29525. */
  29526. static UseSerializedUrlIfAny: boolean;
  29527. /**
  29528. * Define the url of the texture.
  29529. */
  29530. url: Nullable<string>;
  29531. /**
  29532. * Define an offset on the texture to offset the u coordinates of the UVs
  29533. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29534. */
  29535. uOffset: number;
  29536. /**
  29537. * Define an offset on the texture to offset the v coordinates of the UVs
  29538. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  29539. */
  29540. vOffset: number;
  29541. /**
  29542. * Define an offset on the texture to scale the u coordinates of the UVs
  29543. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29544. */
  29545. uScale: number;
  29546. /**
  29547. * Define an offset on the texture to scale the v coordinates of the UVs
  29548. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  29549. */
  29550. vScale: number;
  29551. /**
  29552. * Define an offset on the texture to rotate around the u coordinates of the UVs
  29553. * @see https://doc.babylonjs.com/how_to/more_materials
  29554. */
  29555. uAng: number;
  29556. /**
  29557. * Define an offset on the texture to rotate around the v coordinates of the UVs
  29558. * @see https://doc.babylonjs.com/how_to/more_materials
  29559. */
  29560. vAng: number;
  29561. /**
  29562. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  29563. * @see https://doc.babylonjs.com/how_to/more_materials
  29564. */
  29565. wAng: number;
  29566. /**
  29567. * Defines the center of rotation (U)
  29568. */
  29569. uRotationCenter: number;
  29570. /**
  29571. * Defines the center of rotation (V)
  29572. */
  29573. vRotationCenter: number;
  29574. /**
  29575. * Defines the center of rotation (W)
  29576. */
  29577. wRotationCenter: number;
  29578. /**
  29579. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  29580. */
  29581. homogeneousRotationInUVTransform: boolean;
  29582. /**
  29583. * Are mip maps generated for this texture or not.
  29584. */
  29585. get noMipmap(): boolean;
  29586. /**
  29587. * List of inspectable custom properties (used by the Inspector)
  29588. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29589. */
  29590. inspectableCustomProperties: Nullable<IInspectable[]>;
  29591. private _noMipmap;
  29592. /** @hidden */
  29593. _invertY: boolean;
  29594. private _rowGenerationMatrix;
  29595. private _cachedTextureMatrix;
  29596. private _projectionModeMatrix;
  29597. private _t0;
  29598. private _t1;
  29599. private _t2;
  29600. private _cachedUOffset;
  29601. private _cachedVOffset;
  29602. private _cachedUScale;
  29603. private _cachedVScale;
  29604. private _cachedUAng;
  29605. private _cachedVAng;
  29606. private _cachedWAng;
  29607. private _cachedProjectionMatrixId;
  29608. private _cachedURotationCenter;
  29609. private _cachedVRotationCenter;
  29610. private _cachedWRotationCenter;
  29611. private _cachedHomogeneousRotationInUVTransform;
  29612. private _cachedCoordinatesMode;
  29613. /** @hidden */
  29614. protected _initialSamplingMode: number;
  29615. /** @hidden */
  29616. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  29617. private _deleteBuffer;
  29618. protected _format: Nullable<number>;
  29619. private _delayedOnLoad;
  29620. private _delayedOnError;
  29621. private _mimeType?;
  29622. private _loaderOptions?;
  29623. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  29624. get mimeType(): string | undefined;
  29625. /**
  29626. * Observable triggered once the texture has been loaded.
  29627. */
  29628. onLoadObservable: Observable<Texture>;
  29629. protected _isBlocking: boolean;
  29630. /**
  29631. * Is the texture preventing material to render while loading.
  29632. * If false, a default texture will be used instead of the loading one during the preparation step.
  29633. */
  29634. set isBlocking(value: boolean);
  29635. get isBlocking(): boolean;
  29636. /**
  29637. * Get the current sampling mode associated with the texture.
  29638. */
  29639. get samplingMode(): number;
  29640. /**
  29641. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  29642. */
  29643. get invertY(): boolean;
  29644. /**
  29645. * Instantiates a new texture.
  29646. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  29647. * @see https://doc.babylonjs.com/babylon101/materials#texture
  29648. * @param url defines the url of the picture to load as a texture
  29649. * @param sceneOrEngine defines the scene or engine the texture will belong to
  29650. * @param noMipmap defines if the texture will require mip maps or not
  29651. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  29652. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29653. * @param onLoad defines a callback triggered when the texture has been loaded
  29654. * @param onError defines a callback triggered when an error occurred during the loading session
  29655. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  29656. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  29657. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29658. * @param mimeType defines an optional mime type information
  29659. * @param loaderOptions options to be passed to the loader
  29660. */
  29661. 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);
  29662. /**
  29663. * Update the url (and optional buffer) of this texture if url was null during construction.
  29664. * @param url the url of the texture
  29665. * @param buffer the buffer of the texture (defaults to null)
  29666. * @param onLoad callback called when the texture is loaded (defaults to null)
  29667. */
  29668. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  29669. /**
  29670. * Finish the loading sequence of a texture flagged as delayed load.
  29671. * @hidden
  29672. */
  29673. delayLoad(): void;
  29674. private _prepareRowForTextureGeneration;
  29675. /**
  29676. * Checks if the texture has the same transform matrix than another texture
  29677. * @param texture texture to check against
  29678. * @returns true if the transforms are the same, else false
  29679. */
  29680. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  29681. /**
  29682. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  29683. * @returns the transform matrix of the texture.
  29684. */
  29685. getTextureMatrix(uBase?: number): Matrix;
  29686. /**
  29687. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  29688. * @returns The reflection texture transform
  29689. */
  29690. getReflectionTextureMatrix(): Matrix;
  29691. /**
  29692. * Clones the texture.
  29693. * @returns the cloned texture
  29694. */
  29695. clone(): Texture;
  29696. /**
  29697. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  29698. * @returns The JSON representation of the texture
  29699. */
  29700. serialize(): any;
  29701. /**
  29702. * Get the current class name of the texture useful for serialization or dynamic coding.
  29703. * @returns "Texture"
  29704. */
  29705. getClassName(): string;
  29706. /**
  29707. * Dispose the texture and release its associated resources.
  29708. */
  29709. dispose(): void;
  29710. /**
  29711. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  29712. * @param parsedTexture Define the JSON representation of the texture
  29713. * @param scene Define the scene the parsed texture should be instantiated in
  29714. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  29715. * @returns The parsed texture if successful
  29716. */
  29717. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  29718. /**
  29719. * Creates a texture from its base 64 representation.
  29720. * @param data Define the base64 payload without the data: prefix
  29721. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29722. * @param scene Define the scene the texture should belong to
  29723. * @param noMipmap Forces the texture to not create mip map information if true
  29724. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29725. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29726. * @param onLoad define a callback triggered when the texture has been loaded
  29727. * @param onError define a callback triggered when an error occurred during the loading session
  29728. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29729. * @returns the created texture
  29730. */
  29731. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  29732. /**
  29733. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  29734. * @param data Define the base64 payload without the data: prefix
  29735. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  29736. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  29737. * @param scene Define the scene the texture should belong to
  29738. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  29739. * @param noMipmap Forces the texture to not create mip map information if true
  29740. * @param invertY define if the texture needs to be inverted on the y axis during loading
  29741. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  29742. * @param onLoad define a callback triggered when the texture has been loaded
  29743. * @param onError define a callback triggered when an error occurred during the loading session
  29744. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  29745. * @returns the created texture
  29746. */
  29747. 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;
  29748. }
  29749. }
  29750. declare module "babylonjs/PostProcesses/postProcessManager" {
  29751. import { Nullable } from "babylonjs/types";
  29752. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29753. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29754. import { Scene } from "babylonjs/scene";
  29755. /**
  29756. * PostProcessManager is used to manage one or more post processes or post process pipelines
  29757. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  29758. */
  29759. export class PostProcessManager {
  29760. private _scene;
  29761. private _indexBuffer;
  29762. private _vertexBuffers;
  29763. /**
  29764. * Creates a new instance PostProcess
  29765. * @param scene The scene that the post process is associated with.
  29766. */
  29767. constructor(scene: Scene);
  29768. private _prepareBuffers;
  29769. private _buildIndexBuffer;
  29770. /**
  29771. * Rebuilds the vertex buffers of the manager.
  29772. * @hidden
  29773. */
  29774. _rebuild(): void;
  29775. /**
  29776. * Prepares a frame to be run through a post process.
  29777. * @param sourceTexture The input texture to the post procesess. (default: null)
  29778. * @param postProcesses An array of post processes to be run. (default: null)
  29779. * @returns True if the post processes were able to be run.
  29780. * @hidden
  29781. */
  29782. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  29783. /**
  29784. * Manually render a set of post processes to a texture.
  29785. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  29786. * @param postProcesses An array of post processes to be run.
  29787. * @param targetTexture The target texture to render to.
  29788. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  29789. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  29790. * @param lodLevel defines which lod of the texture to render to
  29791. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  29792. */
  29793. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  29794. /**
  29795. * Finalize the result of the output of the postprocesses.
  29796. * @param doNotPresent If true the result will not be displayed to the screen.
  29797. * @param targetTexture The target texture to render to.
  29798. * @param faceIndex The index of the face to bind the target texture to.
  29799. * @param postProcesses The array of post processes to render.
  29800. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  29801. * @hidden
  29802. */
  29803. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  29804. /**
  29805. * Disposes of the post process manager.
  29806. */
  29807. dispose(): void;
  29808. }
  29809. }
  29810. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  29811. import { Observable } from "babylonjs/Misc/observable";
  29812. import { SmartArray } from "babylonjs/Misc/smartArray";
  29813. import { Nullable, Immutable } from "babylonjs/types";
  29814. import { Camera } from "babylonjs/Cameras/camera";
  29815. import { Scene } from "babylonjs/scene";
  29816. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29817. import { Color4 } from "babylonjs/Maths/math.color";
  29818. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  29819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29820. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29821. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29822. import { Texture } from "babylonjs/Materials/Textures/texture";
  29823. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29824. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  29825. import "babylonjs/Engines/Extensions/engine.renderTarget";
  29826. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  29827. import { Engine } from "babylonjs/Engines/engine";
  29828. /**
  29829. * This Helps creating a texture that will be created from a camera in your scene.
  29830. * It is basically a dynamic texture that could be used to create special effects for instance.
  29831. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  29832. */
  29833. export class RenderTargetTexture extends Texture {
  29834. /**
  29835. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  29836. */
  29837. static readonly REFRESHRATE_RENDER_ONCE: number;
  29838. /**
  29839. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  29840. */
  29841. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  29842. /**
  29843. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  29844. * the central point of your effect and can save a lot of performances.
  29845. */
  29846. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  29847. /**
  29848. * Use this predicate to dynamically define the list of mesh you want to render.
  29849. * If set, the renderList property will be overwritten.
  29850. */
  29851. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  29852. private _renderList;
  29853. /**
  29854. * Use this list to define the list of mesh you want to render.
  29855. */
  29856. get renderList(): Nullable<Array<AbstractMesh>>;
  29857. set renderList(value: Nullable<Array<AbstractMesh>>);
  29858. /**
  29859. * Use this function to overload the renderList array at rendering time.
  29860. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  29861. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  29862. * the cube (if the RTT is a cube, else layerOrFace=0).
  29863. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  29864. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  29865. * hold dummy elements!
  29866. */
  29867. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  29868. private _hookArray;
  29869. /**
  29870. * Define if particles should be rendered in your texture.
  29871. */
  29872. renderParticles: boolean;
  29873. /**
  29874. * Define if sprites should be rendered in your texture.
  29875. */
  29876. renderSprites: boolean;
  29877. /**
  29878. * Define the camera used to render the texture.
  29879. */
  29880. activeCamera: Nullable<Camera>;
  29881. /**
  29882. * Override the mesh isReady function with your own one.
  29883. */
  29884. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  29885. /**
  29886. * Override the render function of the texture with your own one.
  29887. */
  29888. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  29889. /**
  29890. * Define if camera post processes should be use while rendering the texture.
  29891. */
  29892. useCameraPostProcesses: boolean;
  29893. /**
  29894. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  29895. */
  29896. ignoreCameraViewport: boolean;
  29897. private _postProcessManager;
  29898. private _postProcesses;
  29899. private _resizeObserver;
  29900. /**
  29901. * An event triggered when the texture is unbind.
  29902. */
  29903. onBeforeBindObservable: Observable<RenderTargetTexture>;
  29904. /**
  29905. * An event triggered when the texture is unbind.
  29906. */
  29907. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  29908. private _onAfterUnbindObserver;
  29909. /**
  29910. * Set a after unbind callback in the texture.
  29911. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  29912. */
  29913. set onAfterUnbind(callback: () => void);
  29914. /**
  29915. * An event triggered before rendering the texture
  29916. */
  29917. onBeforeRenderObservable: Observable<number>;
  29918. private _onBeforeRenderObserver;
  29919. /**
  29920. * Set a before render callback in the texture.
  29921. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  29922. */
  29923. set onBeforeRender(callback: (faceIndex: number) => void);
  29924. /**
  29925. * An event triggered after rendering the texture
  29926. */
  29927. onAfterRenderObservable: Observable<number>;
  29928. private _onAfterRenderObserver;
  29929. /**
  29930. * Set a after render callback in the texture.
  29931. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  29932. */
  29933. set onAfterRender(callback: (faceIndex: number) => void);
  29934. /**
  29935. * An event triggered after the texture clear
  29936. */
  29937. onClearObservable: Observable<Engine>;
  29938. private _onClearObserver;
  29939. /**
  29940. * Set a clear callback in the texture.
  29941. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  29942. */
  29943. set onClear(callback: (Engine: Engine) => void);
  29944. /**
  29945. * An event triggered when the texture is resized.
  29946. */
  29947. onResizeObservable: Observable<RenderTargetTexture>;
  29948. /**
  29949. * Define the clear color of the Render Target if it should be different from the scene.
  29950. */
  29951. clearColor: Color4;
  29952. protected _size: number | {
  29953. width: number;
  29954. height: number;
  29955. layers?: number;
  29956. };
  29957. protected _initialSizeParameter: number | {
  29958. width: number;
  29959. height: number;
  29960. } | {
  29961. ratio: number;
  29962. };
  29963. protected _sizeRatio: Nullable<number>;
  29964. /** @hidden */
  29965. _generateMipMaps: boolean;
  29966. protected _renderingManager: RenderingManager;
  29967. /** @hidden */
  29968. _waitingRenderList?: string[];
  29969. protected _doNotChangeAspectRatio: boolean;
  29970. protected _currentRefreshId: number;
  29971. protected _refreshRate: number;
  29972. protected _textureMatrix: Matrix;
  29973. protected _samples: number;
  29974. protected _renderTargetOptions: RenderTargetCreationOptions;
  29975. /**
  29976. * Gets render target creation options that were used.
  29977. */
  29978. get renderTargetOptions(): RenderTargetCreationOptions;
  29979. protected _onRatioRescale(): void;
  29980. /**
  29981. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  29982. * It must define where the camera used to render the texture is set
  29983. */
  29984. boundingBoxPosition: Vector3;
  29985. private _boundingBoxSize;
  29986. /**
  29987. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  29988. * When defined, the cubemap will switch to local mode
  29989. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  29990. * @example https://www.babylonjs-playground.com/#RNASML
  29991. */
  29992. set boundingBoxSize(value: Vector3);
  29993. get boundingBoxSize(): Vector3;
  29994. /**
  29995. * In case the RTT has been created with a depth texture, get the associated
  29996. * depth texture.
  29997. * Otherwise, return null.
  29998. */
  29999. get depthStencilTexture(): Nullable<InternalTexture>;
  30000. /**
  30001. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  30002. * or used a shadow, depth texture...
  30003. * @param name The friendly name of the texture
  30004. * @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)
  30005. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  30006. * @param generateMipMaps True if mip maps need to be generated after render.
  30007. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  30008. * @param type The type of the buffer in the RTT (int, half float, float...)
  30009. * @param isCube True if a cube texture needs to be created
  30010. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  30011. * @param generateDepthBuffer True to generate a depth buffer
  30012. * @param generateStencilBuffer True to generate a stencil buffer
  30013. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  30014. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  30015. * @param delayAllocation if the texture allocation should be delayed (default: false)
  30016. */
  30017. constructor(name: string, size: number | {
  30018. width: number;
  30019. height: number;
  30020. layers?: number;
  30021. } | {
  30022. ratio: number;
  30023. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  30024. /**
  30025. * Creates a depth stencil texture.
  30026. * This is only available in WebGL 2 or with the depth texture extension available.
  30027. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  30028. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  30029. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  30030. */
  30031. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  30032. private _processSizeParameter;
  30033. /**
  30034. * Define the number of samples to use in case of MSAA.
  30035. * It defaults to one meaning no MSAA has been enabled.
  30036. */
  30037. get samples(): number;
  30038. set samples(value: number);
  30039. /**
  30040. * Resets the refresh counter of the texture and start bak from scratch.
  30041. * Could be useful to regenerate the texture if it is setup to render only once.
  30042. */
  30043. resetRefreshCounter(): void;
  30044. /**
  30045. * Define the refresh rate of the texture or the rendering frequency.
  30046. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  30047. */
  30048. get refreshRate(): number;
  30049. set refreshRate(value: number);
  30050. /**
  30051. * Adds a post process to the render target rendering passes.
  30052. * @param postProcess define the post process to add
  30053. */
  30054. addPostProcess(postProcess: PostProcess): void;
  30055. /**
  30056. * Clear all the post processes attached to the render target
  30057. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  30058. */
  30059. clearPostProcesses(dispose?: boolean): void;
  30060. /**
  30061. * Remove one of the post process from the list of attached post processes to the texture
  30062. * @param postProcess define the post process to remove from the list
  30063. */
  30064. removePostProcess(postProcess: PostProcess): void;
  30065. /** @hidden */
  30066. _shouldRender(): boolean;
  30067. /**
  30068. * Gets the actual render size of the texture.
  30069. * @returns the width of the render size
  30070. */
  30071. getRenderSize(): number;
  30072. /**
  30073. * Gets the actual render width of the texture.
  30074. * @returns the width of the render size
  30075. */
  30076. getRenderWidth(): number;
  30077. /**
  30078. * Gets the actual render height of the texture.
  30079. * @returns the height of the render size
  30080. */
  30081. getRenderHeight(): number;
  30082. /**
  30083. * Gets the actual number of layers of the texture.
  30084. * @returns the number of layers
  30085. */
  30086. getRenderLayers(): number;
  30087. /**
  30088. * Get if the texture can be rescaled or not.
  30089. */
  30090. get canRescale(): boolean;
  30091. /**
  30092. * Resize the texture using a ratio.
  30093. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  30094. */
  30095. scale(ratio: number): void;
  30096. /**
  30097. * Get the texture reflection matrix used to rotate/transform the reflection.
  30098. * @returns the reflection matrix
  30099. */
  30100. getReflectionTextureMatrix(): Matrix;
  30101. /**
  30102. * Resize the texture to a new desired size.
  30103. * Be carrefull as it will recreate all the data in the new texture.
  30104. * @param size Define the new size. It can be:
  30105. * - a number for squared texture,
  30106. * - an object containing { width: number, height: number }
  30107. * - or an object containing a ratio { ratio: number }
  30108. */
  30109. resize(size: number | {
  30110. width: number;
  30111. height: number;
  30112. } | {
  30113. ratio: number;
  30114. }): void;
  30115. private _defaultRenderListPrepared;
  30116. /**
  30117. * Renders all the objects from the render list into the texture.
  30118. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  30119. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  30120. */
  30121. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  30122. private _bestReflectionRenderTargetDimension;
  30123. private _prepareRenderingManager;
  30124. /**
  30125. * @hidden
  30126. * @param faceIndex face index to bind to if this is a cubetexture
  30127. * @param layer defines the index of the texture to bind in the array
  30128. */
  30129. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  30130. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  30131. private renderToTarget;
  30132. /**
  30133. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  30134. * This allowed control for front to back rendering or reversly depending of the special needs.
  30135. *
  30136. * @param renderingGroupId The rendering group id corresponding to its index
  30137. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  30138. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  30139. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  30140. */
  30141. 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;
  30142. /**
  30143. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  30144. *
  30145. * @param renderingGroupId The rendering group id corresponding to its index
  30146. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  30147. */
  30148. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  30149. /**
  30150. * Clones the texture.
  30151. * @returns the cloned texture
  30152. */
  30153. clone(): RenderTargetTexture;
  30154. /**
  30155. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  30156. * @returns The JSON representation of the texture
  30157. */
  30158. serialize(): any;
  30159. /**
  30160. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  30161. */
  30162. disposeFramebufferObjects(): void;
  30163. /**
  30164. * Dispose the texture and release its associated resources.
  30165. */
  30166. dispose(): void;
  30167. /** @hidden */
  30168. _rebuild(): void;
  30169. /**
  30170. * Clear the info related to rendering groups preventing retention point in material dispose.
  30171. */
  30172. freeRenderingGroups(): void;
  30173. /**
  30174. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  30175. * @returns the view count
  30176. */
  30177. getViewCount(): number;
  30178. }
  30179. }
  30180. declare module "babylonjs/Misc/guid" {
  30181. /**
  30182. * Class used to manipulate GUIDs
  30183. */
  30184. export class GUID {
  30185. /**
  30186. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30187. * Be aware Math.random() could cause collisions, but:
  30188. * "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"
  30189. * @returns a pseudo random id
  30190. */
  30191. static RandomId(): string;
  30192. }
  30193. }
  30194. declare module "babylonjs/Materials/shadowDepthWrapper" {
  30195. import { Nullable } from "babylonjs/types";
  30196. import { Scene } from "babylonjs/scene";
  30197. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30198. import { Material } from "babylonjs/Materials/material";
  30199. import { Effect } from "babylonjs/Materials/effect";
  30200. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  30201. /**
  30202. * Options to be used when creating a shadow depth material
  30203. */
  30204. export interface IIOptionShadowDepthMaterial {
  30205. /** Variables in the vertex shader code that need to have their names remapped.
  30206. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  30207. * "var_name" should be either: worldPos or vNormalW
  30208. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  30209. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  30210. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  30211. */
  30212. remappedVariables?: string[];
  30213. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  30214. standalone?: boolean;
  30215. }
  30216. /**
  30217. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  30218. */
  30219. export class ShadowDepthWrapper {
  30220. private _scene;
  30221. private _options?;
  30222. private _baseMaterial;
  30223. private _onEffectCreatedObserver;
  30224. private _subMeshToEffect;
  30225. private _subMeshToDepthEffect;
  30226. private _meshes;
  30227. /** @hidden */
  30228. _matriceNames: any;
  30229. /** Gets the standalone status of the wrapper */
  30230. get standalone(): boolean;
  30231. /** Gets the base material the wrapper is built upon */
  30232. get baseMaterial(): Material;
  30233. /**
  30234. * Instantiate a new shadow depth wrapper.
  30235. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  30236. * generate the shadow depth map. For more information, please refer to the documentation:
  30237. * https://doc.babylonjs.com/babylon101/shadows
  30238. * @param baseMaterial Material to wrap
  30239. * @param scene Define the scene the material belongs to
  30240. * @param options Options used to create the wrapper
  30241. */
  30242. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  30243. /**
  30244. * Gets the effect to use to generate the depth map
  30245. * @param subMesh subMesh to get the effect for
  30246. * @param shadowGenerator shadow generator to get the effect for
  30247. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  30248. */
  30249. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  30250. /**
  30251. * Specifies that the submesh is ready to be used for depth rendering
  30252. * @param subMesh submesh to check
  30253. * @param defines the list of defines to take into account when checking the effect
  30254. * @param shadowGenerator combined with subMesh, it defines the effect to check
  30255. * @param useInstances specifies that instances should be used
  30256. * @returns a boolean indicating that the submesh is ready or not
  30257. */
  30258. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  30259. /**
  30260. * Disposes the resources
  30261. */
  30262. dispose(): void;
  30263. private _makeEffect;
  30264. }
  30265. }
  30266. declare module "babylonjs/Materials/material" {
  30267. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30268. import { SmartArray } from "babylonjs/Misc/smartArray";
  30269. import { Observable } from "babylonjs/Misc/observable";
  30270. import { Nullable } from "babylonjs/types";
  30271. import { Scene } from "babylonjs/scene";
  30272. import { Matrix } from "babylonjs/Maths/math.vector";
  30273. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30275. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30276. import { Effect } from "babylonjs/Materials/effect";
  30277. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30278. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30279. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30280. import { IInspectable } from "babylonjs/Misc/iInspectable";
  30281. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  30282. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  30283. import { Mesh } from "babylonjs/Meshes/mesh";
  30284. import { Animation } from "babylonjs/Animations/animation";
  30285. /**
  30286. * Options for compiling materials.
  30287. */
  30288. export interface IMaterialCompilationOptions {
  30289. /**
  30290. * Defines whether clip planes are enabled.
  30291. */
  30292. clipPlane: boolean;
  30293. /**
  30294. * Defines whether instances are enabled.
  30295. */
  30296. useInstances: boolean;
  30297. }
  30298. /**
  30299. * Options passed when calling customShaderNameResolve
  30300. */
  30301. export interface ICustomShaderNameResolveOptions {
  30302. /**
  30303. * 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
  30304. */
  30305. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  30306. }
  30307. /**
  30308. * Base class for the main features of a material in Babylon.js
  30309. */
  30310. export class Material implements IAnimatable {
  30311. /**
  30312. * Returns the triangle fill mode
  30313. */
  30314. static readonly TriangleFillMode: number;
  30315. /**
  30316. * Returns the wireframe mode
  30317. */
  30318. static readonly WireFrameFillMode: number;
  30319. /**
  30320. * Returns the point fill mode
  30321. */
  30322. static readonly PointFillMode: number;
  30323. /**
  30324. * Returns the point list draw mode
  30325. */
  30326. static readonly PointListDrawMode: number;
  30327. /**
  30328. * Returns the line list draw mode
  30329. */
  30330. static readonly LineListDrawMode: number;
  30331. /**
  30332. * Returns the line loop draw mode
  30333. */
  30334. static readonly LineLoopDrawMode: number;
  30335. /**
  30336. * Returns the line strip draw mode
  30337. */
  30338. static readonly LineStripDrawMode: number;
  30339. /**
  30340. * Returns the triangle strip draw mode
  30341. */
  30342. static readonly TriangleStripDrawMode: number;
  30343. /**
  30344. * Returns the triangle fan draw mode
  30345. */
  30346. static readonly TriangleFanDrawMode: number;
  30347. /**
  30348. * Stores the clock-wise side orientation
  30349. */
  30350. static readonly ClockWiseSideOrientation: number;
  30351. /**
  30352. * Stores the counter clock-wise side orientation
  30353. */
  30354. static readonly CounterClockWiseSideOrientation: number;
  30355. /**
  30356. * The dirty texture flag value
  30357. */
  30358. static readonly TextureDirtyFlag: number;
  30359. /**
  30360. * The dirty light flag value
  30361. */
  30362. static readonly LightDirtyFlag: number;
  30363. /**
  30364. * The dirty fresnel flag value
  30365. */
  30366. static readonly FresnelDirtyFlag: number;
  30367. /**
  30368. * The dirty attribute flag value
  30369. */
  30370. static readonly AttributesDirtyFlag: number;
  30371. /**
  30372. * The dirty misc flag value
  30373. */
  30374. static readonly MiscDirtyFlag: number;
  30375. /**
  30376. * The dirty prepass flag value
  30377. */
  30378. static readonly PrePassDirtyFlag: number;
  30379. /**
  30380. * The all dirty flag value
  30381. */
  30382. static readonly AllDirtyFlag: number;
  30383. /**
  30384. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  30385. */
  30386. static readonly MATERIAL_OPAQUE: number;
  30387. /**
  30388. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  30389. */
  30390. static readonly MATERIAL_ALPHATEST: number;
  30391. /**
  30392. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30393. */
  30394. static readonly MATERIAL_ALPHABLEND: number;
  30395. /**
  30396. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  30397. * They are also discarded below the alpha cutoff threshold to improve performances.
  30398. */
  30399. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  30400. /**
  30401. * The Whiteout method is used to blend normals.
  30402. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30403. */
  30404. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  30405. /**
  30406. * The Reoriented Normal Mapping method is used to blend normals.
  30407. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  30408. */
  30409. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  30410. /**
  30411. * Custom callback helping to override the default shader used in the material.
  30412. */
  30413. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  30414. /**
  30415. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  30416. */
  30417. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  30418. /**
  30419. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  30420. * This means that the material can keep using a previous shader while a new one is being compiled.
  30421. * This is mostly used when shader parallel compilation is supported (true by default)
  30422. */
  30423. allowShaderHotSwapping: boolean;
  30424. /**
  30425. * The ID of the material
  30426. */
  30427. id: string;
  30428. /**
  30429. * Gets or sets the unique id of the material
  30430. */
  30431. uniqueId: number;
  30432. /**
  30433. * The name of the material
  30434. */
  30435. name: string;
  30436. /**
  30437. * Gets or sets user defined metadata
  30438. */
  30439. metadata: any;
  30440. /**
  30441. * For internal use only. Please do not use.
  30442. */
  30443. reservedDataStore: any;
  30444. /**
  30445. * Specifies if the ready state should be checked on each call
  30446. */
  30447. checkReadyOnEveryCall: boolean;
  30448. /**
  30449. * Specifies if the ready state should be checked once
  30450. */
  30451. checkReadyOnlyOnce: boolean;
  30452. /**
  30453. * The state of the material
  30454. */
  30455. state: string;
  30456. /**
  30457. * If the material can be rendered to several textures with MRT extension
  30458. */
  30459. get canRenderToMRT(): boolean;
  30460. /**
  30461. * The alpha value of the material
  30462. */
  30463. protected _alpha: number;
  30464. /**
  30465. * List of inspectable custom properties (used by the Inspector)
  30466. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30467. */
  30468. inspectableCustomProperties: IInspectable[];
  30469. /**
  30470. * Sets the alpha value of the material
  30471. */
  30472. set alpha(value: number);
  30473. /**
  30474. * Gets the alpha value of the material
  30475. */
  30476. get alpha(): number;
  30477. /**
  30478. * Specifies if back face culling is enabled
  30479. */
  30480. protected _backFaceCulling: boolean;
  30481. /**
  30482. * Sets the back-face culling state
  30483. */
  30484. set backFaceCulling(value: boolean);
  30485. /**
  30486. * Gets the back-face culling state
  30487. */
  30488. get backFaceCulling(): boolean;
  30489. /**
  30490. * Stores the value for side orientation
  30491. */
  30492. sideOrientation: number;
  30493. /**
  30494. * Callback triggered when the material is compiled
  30495. */
  30496. onCompiled: Nullable<(effect: Effect) => void>;
  30497. /**
  30498. * Callback triggered when an error occurs
  30499. */
  30500. onError: Nullable<(effect: Effect, errors: string) => void>;
  30501. /**
  30502. * Callback triggered to get the render target textures
  30503. */
  30504. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  30505. /**
  30506. * Gets a boolean indicating that current material needs to register RTT
  30507. */
  30508. get hasRenderTargetTextures(): boolean;
  30509. /**
  30510. * Specifies if the material should be serialized
  30511. */
  30512. doNotSerialize: boolean;
  30513. /**
  30514. * @hidden
  30515. */
  30516. _storeEffectOnSubMeshes: boolean;
  30517. /**
  30518. * Stores the animations for the material
  30519. */
  30520. animations: Nullable<Array<Animation>>;
  30521. /**
  30522. * An event triggered when the material is disposed
  30523. */
  30524. onDisposeObservable: Observable<Material>;
  30525. /**
  30526. * An observer which watches for dispose events
  30527. */
  30528. private _onDisposeObserver;
  30529. private _onUnBindObservable;
  30530. /**
  30531. * Called during a dispose event
  30532. */
  30533. set onDispose(callback: () => void);
  30534. private _onBindObservable;
  30535. /**
  30536. * An event triggered when the material is bound
  30537. */
  30538. get onBindObservable(): Observable<AbstractMesh>;
  30539. /**
  30540. * An observer which watches for bind events
  30541. */
  30542. private _onBindObserver;
  30543. /**
  30544. * Called during a bind event
  30545. */
  30546. set onBind(callback: (Mesh: AbstractMesh) => void);
  30547. /**
  30548. * An event triggered when the material is unbound
  30549. */
  30550. get onUnBindObservable(): Observable<Material>;
  30551. protected _onEffectCreatedObservable: Nullable<Observable<{
  30552. effect: Effect;
  30553. subMesh: Nullable<SubMesh>;
  30554. }>>;
  30555. /**
  30556. * An event triggered when the effect is (re)created
  30557. */
  30558. get onEffectCreatedObservable(): Observable<{
  30559. effect: Effect;
  30560. subMesh: Nullable<SubMesh>;
  30561. }>;
  30562. /**
  30563. * Stores the value of the alpha mode
  30564. */
  30565. private _alphaMode;
  30566. /**
  30567. * Sets the value of the alpha mode.
  30568. *
  30569. * | Value | Type | Description |
  30570. * | --- | --- | --- |
  30571. * | 0 | ALPHA_DISABLE | |
  30572. * | 1 | ALPHA_ADD | |
  30573. * | 2 | ALPHA_COMBINE | |
  30574. * | 3 | ALPHA_SUBTRACT | |
  30575. * | 4 | ALPHA_MULTIPLY | |
  30576. * | 5 | ALPHA_MAXIMIZED | |
  30577. * | 6 | ALPHA_ONEONE | |
  30578. * | 7 | ALPHA_PREMULTIPLIED | |
  30579. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  30580. * | 9 | ALPHA_INTERPOLATE | |
  30581. * | 10 | ALPHA_SCREENMODE | |
  30582. *
  30583. */
  30584. set alphaMode(value: number);
  30585. /**
  30586. * Gets the value of the alpha mode
  30587. */
  30588. get alphaMode(): number;
  30589. /**
  30590. * Stores the state of the need depth pre-pass value
  30591. */
  30592. private _needDepthPrePass;
  30593. /**
  30594. * Sets the need depth pre-pass value
  30595. */
  30596. set needDepthPrePass(value: boolean);
  30597. /**
  30598. * Gets the depth pre-pass value
  30599. */
  30600. get needDepthPrePass(): boolean;
  30601. /**
  30602. * Specifies if depth writing should be disabled
  30603. */
  30604. disableDepthWrite: boolean;
  30605. /**
  30606. * Specifies if color writing should be disabled
  30607. */
  30608. disableColorWrite: boolean;
  30609. /**
  30610. * Specifies if depth writing should be forced
  30611. */
  30612. forceDepthWrite: boolean;
  30613. /**
  30614. * Specifies the depth function that should be used. 0 means the default engine function
  30615. */
  30616. depthFunction: number;
  30617. /**
  30618. * Specifies if there should be a separate pass for culling
  30619. */
  30620. separateCullingPass: boolean;
  30621. /**
  30622. * Stores the state specifing if fog should be enabled
  30623. */
  30624. private _fogEnabled;
  30625. /**
  30626. * Sets the state for enabling fog
  30627. */
  30628. set fogEnabled(value: boolean);
  30629. /**
  30630. * Gets the value of the fog enabled state
  30631. */
  30632. get fogEnabled(): boolean;
  30633. /**
  30634. * Stores the size of points
  30635. */
  30636. pointSize: number;
  30637. /**
  30638. * Stores the z offset value
  30639. */
  30640. zOffset: number;
  30641. get wireframe(): boolean;
  30642. /**
  30643. * Sets the state of wireframe mode
  30644. */
  30645. set wireframe(value: boolean);
  30646. /**
  30647. * Gets the value specifying if point clouds are enabled
  30648. */
  30649. get pointsCloud(): boolean;
  30650. /**
  30651. * Sets the state of point cloud mode
  30652. */
  30653. set pointsCloud(value: boolean);
  30654. /**
  30655. * Gets the material fill mode
  30656. */
  30657. get fillMode(): number;
  30658. /**
  30659. * Sets the material fill mode
  30660. */
  30661. set fillMode(value: number);
  30662. /**
  30663. * @hidden
  30664. * Stores the effects for the material
  30665. */
  30666. _effect: Nullable<Effect>;
  30667. /**
  30668. * Specifies if uniform buffers should be used
  30669. */
  30670. private _useUBO;
  30671. /**
  30672. * Stores a reference to the scene
  30673. */
  30674. private _scene;
  30675. /**
  30676. * Stores the fill mode state
  30677. */
  30678. private _fillMode;
  30679. /**
  30680. * Specifies if the depth write state should be cached
  30681. */
  30682. private _cachedDepthWriteState;
  30683. /**
  30684. * Specifies if the color write state should be cached
  30685. */
  30686. private _cachedColorWriteState;
  30687. /**
  30688. * Specifies if the depth function state should be cached
  30689. */
  30690. private _cachedDepthFunctionState;
  30691. /**
  30692. * Stores the uniform buffer
  30693. */
  30694. protected _uniformBuffer: UniformBuffer;
  30695. /** @hidden */
  30696. _indexInSceneMaterialArray: number;
  30697. /** @hidden */
  30698. meshMap: Nullable<{
  30699. [id: string]: AbstractMesh | undefined;
  30700. }>;
  30701. /**
  30702. * Creates a material instance
  30703. * @param name defines the name of the material
  30704. * @param scene defines the scene to reference
  30705. * @param doNotAdd specifies if the material should be added to the scene
  30706. */
  30707. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  30708. /**
  30709. * Returns a string representation of the current material
  30710. * @param fullDetails defines a boolean indicating which levels of logging is desired
  30711. * @returns a string with material information
  30712. */
  30713. toString(fullDetails?: boolean): string;
  30714. /**
  30715. * Gets the class name of the material
  30716. * @returns a string with the class name of the material
  30717. */
  30718. getClassName(): string;
  30719. /**
  30720. * Specifies if updates for the material been locked
  30721. */
  30722. get isFrozen(): boolean;
  30723. /**
  30724. * Locks updates for the material
  30725. */
  30726. freeze(): void;
  30727. /**
  30728. * Unlocks updates for the material
  30729. */
  30730. unfreeze(): void;
  30731. /**
  30732. * Specifies if the material is ready to be used
  30733. * @param mesh defines the mesh to check
  30734. * @param useInstances specifies if instances should be used
  30735. * @returns a boolean indicating if the material is ready to be used
  30736. */
  30737. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  30738. /**
  30739. * Specifies that the submesh is ready to be used
  30740. * @param mesh defines the mesh to check
  30741. * @param subMesh defines which submesh to check
  30742. * @param useInstances specifies that instances should be used
  30743. * @returns a boolean indicating that the submesh is ready or not
  30744. */
  30745. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  30746. /**
  30747. * Returns the material effect
  30748. * @returns the effect associated with the material
  30749. */
  30750. getEffect(): Nullable<Effect>;
  30751. /**
  30752. * Returns the current scene
  30753. * @returns a Scene
  30754. */
  30755. getScene(): Scene;
  30756. /**
  30757. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  30758. */
  30759. protected _forceAlphaTest: boolean;
  30760. /**
  30761. * The transparency mode of the material.
  30762. */
  30763. protected _transparencyMode: Nullable<number>;
  30764. /**
  30765. * Gets the current transparency mode.
  30766. */
  30767. get transparencyMode(): Nullable<number>;
  30768. /**
  30769. * Sets the transparency mode of the material.
  30770. *
  30771. * | Value | Type | Description |
  30772. * | ----- | ----------------------------------- | ----------- |
  30773. * | 0 | OPAQUE | |
  30774. * | 1 | ALPHATEST | |
  30775. * | 2 | ALPHABLEND | |
  30776. * | 3 | ALPHATESTANDBLEND | |
  30777. *
  30778. */
  30779. set transparencyMode(value: Nullable<number>);
  30780. /**
  30781. * Returns true if alpha blending should be disabled.
  30782. */
  30783. protected get _disableAlphaBlending(): boolean;
  30784. /**
  30785. * Specifies whether or not this material should be rendered in alpha blend mode.
  30786. * @returns a boolean specifying if alpha blending is needed
  30787. */
  30788. needAlphaBlending(): boolean;
  30789. /**
  30790. * Specifies if the mesh will require alpha blending
  30791. * @param mesh defines the mesh to check
  30792. * @returns a boolean specifying if alpha blending is needed for the mesh
  30793. */
  30794. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  30795. /**
  30796. * Specifies whether or not this material should be rendered in alpha test mode.
  30797. * @returns a boolean specifying if an alpha test is needed.
  30798. */
  30799. needAlphaTesting(): boolean;
  30800. /**
  30801. * Specifies if material alpha testing should be turned on for the mesh
  30802. * @param mesh defines the mesh to check
  30803. */
  30804. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  30805. /**
  30806. * Gets the texture used for the alpha test
  30807. * @returns the texture to use for alpha testing
  30808. */
  30809. getAlphaTestTexture(): Nullable<BaseTexture>;
  30810. /**
  30811. * Marks the material to indicate that it needs to be re-calculated
  30812. */
  30813. markDirty(): void;
  30814. /** @hidden */
  30815. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  30816. /**
  30817. * Binds the material to the mesh
  30818. * @param world defines the world transformation matrix
  30819. * @param mesh defines the mesh to bind the material to
  30820. */
  30821. bind(world: Matrix, mesh?: Mesh): void;
  30822. /**
  30823. * Binds the submesh to the material
  30824. * @param world defines the world transformation matrix
  30825. * @param mesh defines the mesh containing the submesh
  30826. * @param subMesh defines the submesh to bind the material to
  30827. */
  30828. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  30829. /**
  30830. * Binds the world matrix to the material
  30831. * @param world defines the world transformation matrix
  30832. */
  30833. bindOnlyWorldMatrix(world: Matrix): void;
  30834. /**
  30835. * Binds the scene's uniform buffer to the effect.
  30836. * @param effect defines the effect to bind to the scene uniform buffer
  30837. * @param sceneUbo defines the uniform buffer storing scene data
  30838. */
  30839. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  30840. /**
  30841. * Binds the view matrix to the effect
  30842. * @param effect defines the effect to bind the view matrix to
  30843. */
  30844. bindView(effect: Effect): void;
  30845. /**
  30846. * Binds the view projection matrix to the effect
  30847. * @param effect defines the effect to bind the view projection matrix to
  30848. */
  30849. bindViewProjection(effect: Effect): void;
  30850. /**
  30851. * Processes to execute after binding the material to a mesh
  30852. * @param mesh defines the rendered mesh
  30853. */
  30854. protected _afterBind(mesh?: Mesh): void;
  30855. /**
  30856. * Unbinds the material from the mesh
  30857. */
  30858. unbind(): void;
  30859. /**
  30860. * Gets the active textures from the material
  30861. * @returns an array of textures
  30862. */
  30863. getActiveTextures(): BaseTexture[];
  30864. /**
  30865. * Specifies if the material uses a texture
  30866. * @param texture defines the texture to check against the material
  30867. * @returns a boolean specifying if the material uses the texture
  30868. */
  30869. hasTexture(texture: BaseTexture): boolean;
  30870. /**
  30871. * Makes a duplicate of the material, and gives it a new name
  30872. * @param name defines the new name for the duplicated material
  30873. * @returns the cloned material
  30874. */
  30875. clone(name: string): Nullable<Material>;
  30876. /**
  30877. * Gets the meshes bound to the material
  30878. * @returns an array of meshes bound to the material
  30879. */
  30880. getBindedMeshes(): AbstractMesh[];
  30881. /**
  30882. * Force shader compilation
  30883. * @param mesh defines the mesh associated with this material
  30884. * @param onCompiled defines a function to execute once the material is compiled
  30885. * @param options defines the options to configure the compilation
  30886. * @param onError defines a function to execute if the material fails compiling
  30887. */
  30888. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  30889. /**
  30890. * Force shader compilation
  30891. * @param mesh defines the mesh that will use this material
  30892. * @param options defines additional options for compiling the shaders
  30893. * @returns a promise that resolves when the compilation completes
  30894. */
  30895. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  30896. private static readonly _AllDirtyCallBack;
  30897. private static readonly _ImageProcessingDirtyCallBack;
  30898. private static readonly _TextureDirtyCallBack;
  30899. private static readonly _FresnelDirtyCallBack;
  30900. private static readonly _MiscDirtyCallBack;
  30901. private static readonly _PrePassDirtyCallBack;
  30902. private static readonly _LightsDirtyCallBack;
  30903. private static readonly _AttributeDirtyCallBack;
  30904. private static _FresnelAndMiscDirtyCallBack;
  30905. private static _TextureAndMiscDirtyCallBack;
  30906. private static readonly _DirtyCallbackArray;
  30907. private static readonly _RunDirtyCallBacks;
  30908. /**
  30909. * Marks a define in the material to indicate that it needs to be re-computed
  30910. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  30911. */
  30912. markAsDirty(flag: number): void;
  30913. /**
  30914. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  30915. * @param func defines a function which checks material defines against the submeshes
  30916. */
  30917. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  30918. /**
  30919. * Indicates that the scene should check if the rendering now needs a prepass
  30920. */
  30921. protected _markScenePrePassDirty(): void;
  30922. /**
  30923. * Indicates that we need to re-calculated for all submeshes
  30924. */
  30925. protected _markAllSubMeshesAsAllDirty(): void;
  30926. /**
  30927. * Indicates that image processing needs to be re-calculated for all submeshes
  30928. */
  30929. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  30930. /**
  30931. * Indicates that textures need to be re-calculated for all submeshes
  30932. */
  30933. protected _markAllSubMeshesAsTexturesDirty(): void;
  30934. /**
  30935. * Indicates that fresnel needs to be re-calculated for all submeshes
  30936. */
  30937. protected _markAllSubMeshesAsFresnelDirty(): void;
  30938. /**
  30939. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  30940. */
  30941. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  30942. /**
  30943. * Indicates that lights need to be re-calculated for all submeshes
  30944. */
  30945. protected _markAllSubMeshesAsLightsDirty(): void;
  30946. /**
  30947. * Indicates that attributes need to be re-calculated for all submeshes
  30948. */
  30949. protected _markAllSubMeshesAsAttributesDirty(): void;
  30950. /**
  30951. * Indicates that misc needs to be re-calculated for all submeshes
  30952. */
  30953. protected _markAllSubMeshesAsMiscDirty(): void;
  30954. /**
  30955. * Indicates that prepass needs to be re-calculated for all submeshes
  30956. */
  30957. protected _markAllSubMeshesAsPrePassDirty(): void;
  30958. /**
  30959. * Indicates that textures and misc need to be re-calculated for all submeshes
  30960. */
  30961. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  30962. /**
  30963. * Sets the required values to the prepass renderer.
  30964. * @param prePassRenderer defines the prepass renderer to setup.
  30965. * @returns true if the pre pass is needed.
  30966. */
  30967. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  30968. /**
  30969. * Disposes the material
  30970. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  30971. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  30972. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  30973. */
  30974. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  30975. /** @hidden */
  30976. private releaseVertexArrayObject;
  30977. /**
  30978. * Serializes this material
  30979. * @returns the serialized material object
  30980. */
  30981. serialize(): any;
  30982. /**
  30983. * Creates a material from parsed material data
  30984. * @param parsedMaterial defines parsed material data
  30985. * @param scene defines the hosting scene
  30986. * @param rootUrl defines the root URL to use to load textures
  30987. * @returns a new material
  30988. */
  30989. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  30990. }
  30991. }
  30992. declare module "babylonjs/Materials/multiMaterial" {
  30993. import { Nullable } from "babylonjs/types";
  30994. import { Scene } from "babylonjs/scene";
  30995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30996. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30997. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30998. import { Material } from "babylonjs/Materials/material";
  30999. /**
  31000. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31001. * separate meshes. This can be use to improve performances.
  31002. * @see https://doc.babylonjs.com/how_to/multi_materials
  31003. */
  31004. export class MultiMaterial extends Material {
  31005. private _subMaterials;
  31006. /**
  31007. * Gets or Sets the list of Materials used within the multi material.
  31008. * They need to be ordered according to the submeshes order in the associated mesh
  31009. */
  31010. get subMaterials(): Nullable<Material>[];
  31011. set subMaterials(value: Nullable<Material>[]);
  31012. /**
  31013. * Function used to align with Node.getChildren()
  31014. * @returns the list of Materials used within the multi material
  31015. */
  31016. getChildren(): Nullable<Material>[];
  31017. /**
  31018. * Instantiates a new Multi Material
  31019. * A multi-material is used to apply different materials to different parts of the same object without the need of
  31020. * separate meshes. This can be use to improve performances.
  31021. * @see https://doc.babylonjs.com/how_to/multi_materials
  31022. * @param name Define the name in the scene
  31023. * @param scene Define the scene the material belongs to
  31024. */
  31025. constructor(name: string, scene: Scene);
  31026. private _hookArray;
  31027. /**
  31028. * Get one of the submaterial by its index in the submaterials array
  31029. * @param index The index to look the sub material at
  31030. * @returns The Material if the index has been defined
  31031. */
  31032. getSubMaterial(index: number): Nullable<Material>;
  31033. /**
  31034. * Get the list of active textures for the whole sub materials list.
  31035. * @returns All the textures that will be used during the rendering
  31036. */
  31037. getActiveTextures(): BaseTexture[];
  31038. /**
  31039. * Gets the current class name of the material e.g. "MultiMaterial"
  31040. * Mainly use in serialization.
  31041. * @returns the class name
  31042. */
  31043. getClassName(): string;
  31044. /**
  31045. * Checks if the material is ready to render the requested sub mesh
  31046. * @param mesh Define the mesh the submesh belongs to
  31047. * @param subMesh Define the sub mesh to look readyness for
  31048. * @param useInstances Define whether or not the material is used with instances
  31049. * @returns true if ready, otherwise false
  31050. */
  31051. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31052. /**
  31053. * Clones the current material and its related sub materials
  31054. * @param name Define the name of the newly cloned material
  31055. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  31056. * @returns the cloned material
  31057. */
  31058. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  31059. /**
  31060. * Serializes the materials into a JSON representation.
  31061. * @returns the JSON representation
  31062. */
  31063. serialize(): any;
  31064. /**
  31065. * Dispose the material and release its associated resources
  31066. * @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)
  31067. * @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)
  31068. * @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)
  31069. */
  31070. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  31071. /**
  31072. * Creates a MultiMaterial from parsed MultiMaterial data.
  31073. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  31074. * @param scene defines the hosting scene
  31075. * @returns a new MultiMaterial
  31076. */
  31077. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  31078. }
  31079. }
  31080. declare module "babylonjs/Meshes/subMesh" {
  31081. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  31082. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  31083. import { Engine } from "babylonjs/Engines/engine";
  31084. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  31085. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31086. import { Effect } from "babylonjs/Materials/effect";
  31087. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31088. import { Plane } from "babylonjs/Maths/math.plane";
  31089. import { Collider } from "babylonjs/Collisions/collider";
  31090. import { Material } from "babylonjs/Materials/material";
  31091. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31093. import { Mesh } from "babylonjs/Meshes/mesh";
  31094. import { Ray } from "babylonjs/Culling/ray";
  31095. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  31096. /**
  31097. * Defines a subdivision inside a mesh
  31098. */
  31099. export class SubMesh implements ICullable {
  31100. /** the material index to use */
  31101. materialIndex: number;
  31102. /** vertex index start */
  31103. verticesStart: number;
  31104. /** vertices count */
  31105. verticesCount: number;
  31106. /** index start */
  31107. indexStart: number;
  31108. /** indices count */
  31109. indexCount: number;
  31110. /** @hidden */
  31111. _materialDefines: Nullable<MaterialDefines>;
  31112. /** @hidden */
  31113. _materialEffect: Nullable<Effect>;
  31114. /** @hidden */
  31115. _effectOverride: Nullable<Effect>;
  31116. /**
  31117. * Gets material defines used by the effect associated to the sub mesh
  31118. */
  31119. get materialDefines(): Nullable<MaterialDefines>;
  31120. /**
  31121. * Sets material defines used by the effect associated to the sub mesh
  31122. */
  31123. set materialDefines(defines: Nullable<MaterialDefines>);
  31124. /**
  31125. * Gets associated effect
  31126. */
  31127. get effect(): Nullable<Effect>;
  31128. /**
  31129. * Sets associated effect (effect used to render this submesh)
  31130. * @param effect defines the effect to associate with
  31131. * @param defines defines the set of defines used to compile this effect
  31132. */
  31133. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  31134. /** @hidden */
  31135. _linesIndexCount: number;
  31136. private _mesh;
  31137. private _renderingMesh;
  31138. private _boundingInfo;
  31139. private _linesIndexBuffer;
  31140. /** @hidden */
  31141. _lastColliderWorldVertices: Nullable<Vector3[]>;
  31142. /** @hidden */
  31143. _trianglePlanes: Plane[];
  31144. /** @hidden */
  31145. _lastColliderTransformMatrix: Nullable<Matrix>;
  31146. /** @hidden */
  31147. _renderId: number;
  31148. /** @hidden */
  31149. _alphaIndex: number;
  31150. /** @hidden */
  31151. _distanceToCamera: number;
  31152. /** @hidden */
  31153. _id: number;
  31154. private _currentMaterial;
  31155. /**
  31156. * Add a new submesh to a mesh
  31157. * @param materialIndex defines the material index to use
  31158. * @param verticesStart defines vertex index start
  31159. * @param verticesCount defines vertices count
  31160. * @param indexStart defines index start
  31161. * @param indexCount defines indices count
  31162. * @param mesh defines the parent mesh
  31163. * @param renderingMesh defines an optional rendering mesh
  31164. * @param createBoundingBox defines if bounding box should be created for this submesh
  31165. * @returns the new submesh
  31166. */
  31167. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  31168. /**
  31169. * Creates a new submesh
  31170. * @param materialIndex defines the material index to use
  31171. * @param verticesStart defines vertex index start
  31172. * @param verticesCount defines vertices count
  31173. * @param indexStart defines index start
  31174. * @param indexCount defines indices count
  31175. * @param mesh defines the parent mesh
  31176. * @param renderingMesh defines an optional rendering mesh
  31177. * @param createBoundingBox defines if bounding box should be created for this submesh
  31178. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  31179. */
  31180. constructor(
  31181. /** the material index to use */
  31182. materialIndex: number,
  31183. /** vertex index start */
  31184. verticesStart: number,
  31185. /** vertices count */
  31186. verticesCount: number,
  31187. /** index start */
  31188. indexStart: number,
  31189. /** indices count */
  31190. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  31191. /**
  31192. * Returns true if this submesh covers the entire parent mesh
  31193. * @ignorenaming
  31194. */
  31195. get IsGlobal(): boolean;
  31196. /**
  31197. * Returns the submesh BoudingInfo object
  31198. * @returns current bounding info (or mesh's one if the submesh is global)
  31199. */
  31200. getBoundingInfo(): BoundingInfo;
  31201. /**
  31202. * Sets the submesh BoundingInfo
  31203. * @param boundingInfo defines the new bounding info to use
  31204. * @returns the SubMesh
  31205. */
  31206. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  31207. /**
  31208. * Returns the mesh of the current submesh
  31209. * @return the parent mesh
  31210. */
  31211. getMesh(): AbstractMesh;
  31212. /**
  31213. * Returns the rendering mesh of the submesh
  31214. * @returns the rendering mesh (could be different from parent mesh)
  31215. */
  31216. getRenderingMesh(): Mesh;
  31217. /**
  31218. * Returns the replacement mesh of the submesh
  31219. * @returns the replacement mesh (could be different from parent mesh)
  31220. */
  31221. getReplacementMesh(): Nullable<AbstractMesh>;
  31222. /**
  31223. * Returns the effective mesh of the submesh
  31224. * @returns the effective mesh (could be different from parent mesh)
  31225. */
  31226. getEffectiveMesh(): AbstractMesh;
  31227. /**
  31228. * Returns the submesh material
  31229. * @returns null or the current material
  31230. */
  31231. getMaterial(): Nullable<Material>;
  31232. private _IsMultiMaterial;
  31233. /**
  31234. * Sets a new updated BoundingInfo object to the submesh
  31235. * @param data defines an optional position array to use to determine the bounding info
  31236. * @returns the SubMesh
  31237. */
  31238. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  31239. /** @hidden */
  31240. _checkCollision(collider: Collider): boolean;
  31241. /**
  31242. * Updates the submesh BoundingInfo
  31243. * @param world defines the world matrix to use to update the bounding info
  31244. * @returns the submesh
  31245. */
  31246. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  31247. /**
  31248. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  31249. * @param frustumPlanes defines the frustum planes
  31250. * @returns true if the submesh is intersecting with the frustum
  31251. */
  31252. isInFrustum(frustumPlanes: Plane[]): boolean;
  31253. /**
  31254. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  31255. * @param frustumPlanes defines the frustum planes
  31256. * @returns true if the submesh is inside the frustum
  31257. */
  31258. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  31259. /**
  31260. * Renders the submesh
  31261. * @param enableAlphaMode defines if alpha needs to be used
  31262. * @returns the submesh
  31263. */
  31264. render(enableAlphaMode: boolean): SubMesh;
  31265. /**
  31266. * @hidden
  31267. */
  31268. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  31269. /**
  31270. * Checks if the submesh intersects with a ray
  31271. * @param ray defines the ray to test
  31272. * @returns true is the passed ray intersects the submesh bounding box
  31273. */
  31274. canIntersects(ray: Ray): boolean;
  31275. /**
  31276. * Intersects current submesh with a ray
  31277. * @param ray defines the ray to test
  31278. * @param positions defines mesh's positions array
  31279. * @param indices defines mesh's indices array
  31280. * @param fastCheck defines if the first intersection will be used (and not the closest)
  31281. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  31282. * @returns intersection info or null if no intersection
  31283. */
  31284. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  31285. /** @hidden */
  31286. private _intersectLines;
  31287. /** @hidden */
  31288. private _intersectUnIndexedLines;
  31289. /** @hidden */
  31290. private _intersectTriangles;
  31291. /** @hidden */
  31292. private _intersectUnIndexedTriangles;
  31293. /** @hidden */
  31294. _rebuild(): void;
  31295. /**
  31296. * Creates a new submesh from the passed mesh
  31297. * @param newMesh defines the new hosting mesh
  31298. * @param newRenderingMesh defines an optional rendering mesh
  31299. * @returns the new submesh
  31300. */
  31301. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  31302. /**
  31303. * Release associated resources
  31304. */
  31305. dispose(): void;
  31306. /**
  31307. * Gets the class name
  31308. * @returns the string "SubMesh".
  31309. */
  31310. getClassName(): string;
  31311. /**
  31312. * Creates a new submesh from indices data
  31313. * @param materialIndex the index of the main mesh material
  31314. * @param startIndex the index where to start the copy in the mesh indices array
  31315. * @param indexCount the number of indices to copy then from the startIndex
  31316. * @param mesh the main mesh to create the submesh from
  31317. * @param renderingMesh the optional rendering mesh
  31318. * @returns a new submesh
  31319. */
  31320. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  31321. }
  31322. }
  31323. declare module "babylonjs/Loading/sceneLoaderFlags" {
  31324. /**
  31325. * Class used to represent data loading progression
  31326. */
  31327. export class SceneLoaderFlags {
  31328. private static _ForceFullSceneLoadingForIncremental;
  31329. private static _ShowLoadingScreen;
  31330. private static _CleanBoneMatrixWeights;
  31331. private static _loggingLevel;
  31332. /**
  31333. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  31334. */
  31335. static get ForceFullSceneLoadingForIncremental(): boolean;
  31336. static set ForceFullSceneLoadingForIncremental(value: boolean);
  31337. /**
  31338. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  31339. */
  31340. static get ShowLoadingScreen(): boolean;
  31341. static set ShowLoadingScreen(value: boolean);
  31342. /**
  31343. * Defines the current logging level (while loading the scene)
  31344. * @ignorenaming
  31345. */
  31346. static get loggingLevel(): number;
  31347. static set loggingLevel(value: number);
  31348. /**
  31349. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  31350. */
  31351. static get CleanBoneMatrixWeights(): boolean;
  31352. static set CleanBoneMatrixWeights(value: boolean);
  31353. }
  31354. }
  31355. declare module "babylonjs/Meshes/geometry" {
  31356. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  31357. import { Scene } from "babylonjs/scene";
  31358. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  31359. import { Engine } from "babylonjs/Engines/engine";
  31360. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  31361. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31362. import { Effect } from "babylonjs/Materials/effect";
  31363. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31364. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31365. import { Mesh } from "babylonjs/Meshes/mesh";
  31366. /**
  31367. * Class used to store geometry data (vertex buffers + index buffer)
  31368. */
  31369. export class Geometry implements IGetSetVerticesData {
  31370. /**
  31371. * Gets or sets the ID of the geometry
  31372. */
  31373. id: string;
  31374. /**
  31375. * Gets or sets the unique ID of the geometry
  31376. */
  31377. uniqueId: number;
  31378. /**
  31379. * Gets the delay loading state of the geometry (none by default which means not delayed)
  31380. */
  31381. delayLoadState: number;
  31382. /**
  31383. * Gets the file containing the data to load when running in delay load state
  31384. */
  31385. delayLoadingFile: Nullable<string>;
  31386. /**
  31387. * Callback called when the geometry is updated
  31388. */
  31389. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  31390. private _scene;
  31391. private _engine;
  31392. private _meshes;
  31393. private _totalVertices;
  31394. /** @hidden */
  31395. _indices: IndicesArray;
  31396. /** @hidden */
  31397. _vertexBuffers: {
  31398. [key: string]: VertexBuffer;
  31399. };
  31400. private _isDisposed;
  31401. private _extend;
  31402. private _boundingBias;
  31403. /** @hidden */
  31404. _delayInfo: Array<string>;
  31405. private _indexBuffer;
  31406. private _indexBufferIsUpdatable;
  31407. /** @hidden */
  31408. _boundingInfo: Nullable<BoundingInfo>;
  31409. /** @hidden */
  31410. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  31411. /** @hidden */
  31412. _softwareSkinningFrameId: number;
  31413. private _vertexArrayObjects;
  31414. private _updatable;
  31415. /** @hidden */
  31416. _positions: Nullable<Vector3[]>;
  31417. private _positionsCache;
  31418. /**
  31419. * 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
  31420. */
  31421. get boundingBias(): Vector2;
  31422. /**
  31423. * 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
  31424. */
  31425. set boundingBias(value: Vector2);
  31426. /**
  31427. * Static function used to attach a new empty geometry to a mesh
  31428. * @param mesh defines the mesh to attach the geometry to
  31429. * @returns the new Geometry
  31430. */
  31431. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  31432. /** Get the list of meshes using this geometry */
  31433. get meshes(): Mesh[];
  31434. /**
  31435. * 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
  31436. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  31437. */
  31438. useBoundingInfoFromGeometry: boolean;
  31439. /**
  31440. * Creates a new geometry
  31441. * @param id defines the unique ID
  31442. * @param scene defines the hosting scene
  31443. * @param vertexData defines the VertexData used to get geometry data
  31444. * @param updatable defines if geometry must be updatable (false by default)
  31445. * @param mesh defines the mesh that will be associated with the geometry
  31446. */
  31447. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  31448. /**
  31449. * Gets the current extend of the geometry
  31450. */
  31451. get extend(): {
  31452. minimum: Vector3;
  31453. maximum: Vector3;
  31454. };
  31455. /**
  31456. * Gets the hosting scene
  31457. * @returns the hosting Scene
  31458. */
  31459. getScene(): Scene;
  31460. /**
  31461. * Gets the hosting engine
  31462. * @returns the hosting Engine
  31463. */
  31464. getEngine(): Engine;
  31465. /**
  31466. * Defines if the geometry is ready to use
  31467. * @returns true if the geometry is ready to be used
  31468. */
  31469. isReady(): boolean;
  31470. /**
  31471. * Gets a value indicating that the geometry should not be serialized
  31472. */
  31473. get doNotSerialize(): boolean;
  31474. /** @hidden */
  31475. _rebuild(): void;
  31476. /**
  31477. * Affects all geometry data in one call
  31478. * @param vertexData defines the geometry data
  31479. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  31480. */
  31481. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  31482. /**
  31483. * Set specific vertex data
  31484. * @param kind defines the data kind (Position, normal, etc...)
  31485. * @param data defines the vertex data to use
  31486. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31487. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31488. */
  31489. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  31490. /**
  31491. * Removes a specific vertex data
  31492. * @param kind defines the data kind (Position, normal, etc...)
  31493. */
  31494. removeVerticesData(kind: string): void;
  31495. /**
  31496. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  31497. * @param buffer defines the vertex buffer to use
  31498. * @param totalVertices defines the total number of vertices for position kind (could be null)
  31499. */
  31500. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  31501. /**
  31502. * Update a specific vertex buffer
  31503. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  31504. * It will do nothing if the buffer is not updatable
  31505. * @param kind defines the data kind (Position, normal, etc...)
  31506. * @param data defines the data to use
  31507. * @param offset defines the offset in the target buffer where to store the data
  31508. * @param useBytes set to true if the offset is in bytes
  31509. */
  31510. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  31511. /**
  31512. * Update a specific vertex buffer
  31513. * This function will create a new buffer if the current one is not updatable
  31514. * @param kind defines the data kind (Position, normal, etc...)
  31515. * @param data defines the data to use
  31516. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  31517. */
  31518. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  31519. private _updateBoundingInfo;
  31520. /** @hidden */
  31521. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  31522. /**
  31523. * Gets total number of vertices
  31524. * @returns the total number of vertices
  31525. */
  31526. getTotalVertices(): number;
  31527. /**
  31528. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31529. * @param kind defines the data kind (Position, normal, etc...)
  31530. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31531. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31532. * @returns a float array containing vertex data
  31533. */
  31534. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31535. /**
  31536. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  31537. * @param kind defines the data kind (Position, normal, etc...)
  31538. * @returns true if the vertex buffer with the specified kind is updatable
  31539. */
  31540. isVertexBufferUpdatable(kind: string): boolean;
  31541. /**
  31542. * Gets a specific vertex buffer
  31543. * @param kind defines the data kind (Position, normal, etc...)
  31544. * @returns a VertexBuffer
  31545. */
  31546. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  31547. /**
  31548. * Returns all vertex buffers
  31549. * @return an object holding all vertex buffers indexed by kind
  31550. */
  31551. getVertexBuffers(): Nullable<{
  31552. [key: string]: VertexBuffer;
  31553. }>;
  31554. /**
  31555. * Gets a boolean indicating if specific vertex buffer is present
  31556. * @param kind defines the data kind (Position, normal, etc...)
  31557. * @returns true if data is present
  31558. */
  31559. isVerticesDataPresent(kind: string): boolean;
  31560. /**
  31561. * Gets a list of all attached data kinds (Position, normal, etc...)
  31562. * @returns a list of string containing all kinds
  31563. */
  31564. getVerticesDataKinds(): string[];
  31565. /**
  31566. * Update index buffer
  31567. * @param indices defines the indices to store in the index buffer
  31568. * @param offset defines the offset in the target buffer where to store the data
  31569. * @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)
  31570. */
  31571. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  31572. /**
  31573. * Creates a new index buffer
  31574. * @param indices defines the indices to store in the index buffer
  31575. * @param totalVertices defines the total number of vertices (could be null)
  31576. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31577. */
  31578. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  31579. /**
  31580. * Return the total number of indices
  31581. * @returns the total number of indices
  31582. */
  31583. getTotalIndices(): number;
  31584. /**
  31585. * Gets the index buffer array
  31586. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31587. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31588. * @returns the index buffer array
  31589. */
  31590. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31591. /**
  31592. * Gets the index buffer
  31593. * @return the index buffer
  31594. */
  31595. getIndexBuffer(): Nullable<DataBuffer>;
  31596. /** @hidden */
  31597. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  31598. /**
  31599. * Release the associated resources for a specific mesh
  31600. * @param mesh defines the source mesh
  31601. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  31602. */
  31603. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  31604. /**
  31605. * Apply current geometry to a given mesh
  31606. * @param mesh defines the mesh to apply geometry to
  31607. */
  31608. applyToMesh(mesh: Mesh): void;
  31609. private _updateExtend;
  31610. private _applyToMesh;
  31611. private notifyUpdate;
  31612. /**
  31613. * Load the geometry if it was flagged as delay loaded
  31614. * @param scene defines the hosting scene
  31615. * @param onLoaded defines a callback called when the geometry is loaded
  31616. */
  31617. load(scene: Scene, onLoaded?: () => void): void;
  31618. private _queueLoad;
  31619. /**
  31620. * Invert the geometry to move from a right handed system to a left handed one.
  31621. */
  31622. toLeftHanded(): void;
  31623. /** @hidden */
  31624. _resetPointsArrayCache(): void;
  31625. /** @hidden */
  31626. _generatePointsArray(): boolean;
  31627. /**
  31628. * Gets a value indicating if the geometry is disposed
  31629. * @returns true if the geometry was disposed
  31630. */
  31631. isDisposed(): boolean;
  31632. private _disposeVertexArrayObjects;
  31633. /**
  31634. * Free all associated resources
  31635. */
  31636. dispose(): void;
  31637. /**
  31638. * Clone the current geometry into a new geometry
  31639. * @param id defines the unique ID of the new geometry
  31640. * @returns a new geometry object
  31641. */
  31642. copy(id: string): Geometry;
  31643. /**
  31644. * Serialize the current geometry info (and not the vertices data) into a JSON object
  31645. * @return a JSON representation of the current geometry data (without the vertices data)
  31646. */
  31647. serialize(): any;
  31648. private toNumberArray;
  31649. /**
  31650. * Serialize all vertices data into a JSON oject
  31651. * @returns a JSON representation of the current geometry data
  31652. */
  31653. serializeVerticeData(): any;
  31654. /**
  31655. * Extracts a clone of a mesh geometry
  31656. * @param mesh defines the source mesh
  31657. * @param id defines the unique ID of the new geometry object
  31658. * @returns the new geometry object
  31659. */
  31660. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  31661. /**
  31662. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  31663. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31664. * Be aware Math.random() could cause collisions, but:
  31665. * "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"
  31666. * @returns a string containing a new GUID
  31667. */
  31668. static RandomId(): string;
  31669. /** @hidden */
  31670. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  31671. private static _CleanMatricesWeights;
  31672. /**
  31673. * Create a new geometry from persisted data (Using .babylon file format)
  31674. * @param parsedVertexData defines the persisted data
  31675. * @param scene defines the hosting scene
  31676. * @param rootUrl defines the root url to use to load assets (like delayed data)
  31677. * @returns the new geometry object
  31678. */
  31679. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  31680. }
  31681. }
  31682. declare module "babylonjs/Meshes/mesh.vertexData" {
  31683. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  31684. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  31685. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  31686. import { Geometry } from "babylonjs/Meshes/geometry";
  31687. import { Mesh } from "babylonjs/Meshes/mesh";
  31688. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  31689. /**
  31690. * Define an interface for all classes that will get and set the data on vertices
  31691. */
  31692. export interface IGetSetVerticesData {
  31693. /**
  31694. * Gets a boolean indicating if specific vertex data is present
  31695. * @param kind defines the vertex data kind to use
  31696. * @returns true is data kind is present
  31697. */
  31698. isVerticesDataPresent(kind: string): boolean;
  31699. /**
  31700. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  31701. * @param kind defines the data kind (Position, normal, etc...)
  31702. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  31703. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31704. * @returns a float array containing vertex data
  31705. */
  31706. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  31707. /**
  31708. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  31709. * @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.
  31710. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  31711. * @returns the indices array or an empty array if the mesh has no geometry
  31712. */
  31713. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  31714. /**
  31715. * Set specific vertex data
  31716. * @param kind defines the data kind (Position, normal, etc...)
  31717. * @param data defines the vertex data to use
  31718. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  31719. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  31720. */
  31721. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  31722. /**
  31723. * Update a specific associated vertex buffer
  31724. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  31725. * - VertexBuffer.PositionKind
  31726. * - VertexBuffer.UVKind
  31727. * - VertexBuffer.UV2Kind
  31728. * - VertexBuffer.UV3Kind
  31729. * - VertexBuffer.UV4Kind
  31730. * - VertexBuffer.UV5Kind
  31731. * - VertexBuffer.UV6Kind
  31732. * - VertexBuffer.ColorKind
  31733. * - VertexBuffer.MatricesIndicesKind
  31734. * - VertexBuffer.MatricesIndicesExtraKind
  31735. * - VertexBuffer.MatricesWeightsKind
  31736. * - VertexBuffer.MatricesWeightsExtraKind
  31737. * @param data defines the data source
  31738. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  31739. * @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)
  31740. */
  31741. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  31742. /**
  31743. * Creates a new index buffer
  31744. * @param indices defines the indices to store in the index buffer
  31745. * @param totalVertices defines the total number of vertices (could be null)
  31746. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  31747. */
  31748. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  31749. }
  31750. /**
  31751. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  31752. */
  31753. export class VertexData {
  31754. /**
  31755. * Mesh side orientation : usually the external or front surface
  31756. */
  31757. static readonly FRONTSIDE: number;
  31758. /**
  31759. * Mesh side orientation : usually the internal or back surface
  31760. */
  31761. static readonly BACKSIDE: number;
  31762. /**
  31763. * Mesh side orientation : both internal and external or front and back surfaces
  31764. */
  31765. static readonly DOUBLESIDE: number;
  31766. /**
  31767. * Mesh side orientation : by default, `FRONTSIDE`
  31768. */
  31769. static readonly DEFAULTSIDE: number;
  31770. /**
  31771. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  31772. */
  31773. positions: Nullable<FloatArray>;
  31774. /**
  31775. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  31776. */
  31777. normals: Nullable<FloatArray>;
  31778. /**
  31779. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  31780. */
  31781. tangents: Nullable<FloatArray>;
  31782. /**
  31783. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31784. */
  31785. uvs: Nullable<FloatArray>;
  31786. /**
  31787. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31788. */
  31789. uvs2: Nullable<FloatArray>;
  31790. /**
  31791. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31792. */
  31793. uvs3: Nullable<FloatArray>;
  31794. /**
  31795. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31796. */
  31797. uvs4: Nullable<FloatArray>;
  31798. /**
  31799. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31800. */
  31801. uvs5: Nullable<FloatArray>;
  31802. /**
  31803. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  31804. */
  31805. uvs6: Nullable<FloatArray>;
  31806. /**
  31807. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  31808. */
  31809. colors: Nullable<FloatArray>;
  31810. /**
  31811. * 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).
  31812. */
  31813. matricesIndices: Nullable<FloatArray>;
  31814. /**
  31815. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  31816. */
  31817. matricesWeights: Nullable<FloatArray>;
  31818. /**
  31819. * An array extending the number of possible indices
  31820. */
  31821. matricesIndicesExtra: Nullable<FloatArray>;
  31822. /**
  31823. * An array extending the number of possible weights when the number of indices is extended
  31824. */
  31825. matricesWeightsExtra: Nullable<FloatArray>;
  31826. /**
  31827. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  31828. */
  31829. indices: Nullable<IndicesArray>;
  31830. /**
  31831. * Uses the passed data array to set the set the values for the specified kind of data
  31832. * @param data a linear array of floating numbers
  31833. * @param kind the type of data that is being set, eg positions, colors etc
  31834. */
  31835. set(data: FloatArray, kind: string): void;
  31836. /**
  31837. * Associates the vertexData to the passed Mesh.
  31838. * Sets it as updatable or not (default `false`)
  31839. * @param mesh the mesh the vertexData is applied to
  31840. * @param updatable when used and having the value true allows new data to update the vertexData
  31841. * @returns the VertexData
  31842. */
  31843. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  31844. /**
  31845. * Associates the vertexData to the passed Geometry.
  31846. * Sets it as updatable or not (default `false`)
  31847. * @param geometry the geometry the vertexData is applied to
  31848. * @param updatable when used and having the value true allows new data to update the vertexData
  31849. * @returns VertexData
  31850. */
  31851. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  31852. /**
  31853. * Updates the associated mesh
  31854. * @param mesh the mesh to be updated
  31855. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31856. * @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
  31857. * @returns VertexData
  31858. */
  31859. updateMesh(mesh: Mesh): VertexData;
  31860. /**
  31861. * Updates the associated geometry
  31862. * @param geometry the geometry to be updated
  31863. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  31864. * @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
  31865. * @returns VertexData.
  31866. */
  31867. updateGeometry(geometry: Geometry): VertexData;
  31868. private _applyTo;
  31869. private _update;
  31870. /**
  31871. * Transforms each position and each normal of the vertexData according to the passed Matrix
  31872. * @param matrix the transforming matrix
  31873. * @returns the VertexData
  31874. */
  31875. transform(matrix: Matrix): VertexData;
  31876. /**
  31877. * Merges the passed VertexData into the current one
  31878. * @param other the VertexData to be merged into the current one
  31879. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  31880. * @returns the modified VertexData
  31881. */
  31882. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  31883. private _mergeElement;
  31884. private _validate;
  31885. /**
  31886. * Serializes the VertexData
  31887. * @returns a serialized object
  31888. */
  31889. serialize(): any;
  31890. /**
  31891. * Extracts the vertexData from a mesh
  31892. * @param mesh the mesh from which to extract the VertexData
  31893. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  31894. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31895. * @returns the object VertexData associated to the passed mesh
  31896. */
  31897. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31898. /**
  31899. * Extracts the vertexData from the geometry
  31900. * @param geometry the geometry from which to extract the VertexData
  31901. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  31902. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  31903. * @returns the object VertexData associated to the passed mesh
  31904. */
  31905. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  31906. private static _ExtractFrom;
  31907. /**
  31908. * Creates the VertexData for a Ribbon
  31909. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  31910. * * pathArray array of paths, each of which an array of successive Vector3
  31911. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  31912. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  31913. * * 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
  31914. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31915. * * 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)
  31916. * * 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)
  31917. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  31918. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  31919. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  31920. * @returns the VertexData of the ribbon
  31921. */
  31922. static CreateRibbon(options: {
  31923. pathArray: Vector3[][];
  31924. closeArray?: boolean;
  31925. closePath?: boolean;
  31926. offset?: number;
  31927. sideOrientation?: number;
  31928. frontUVs?: Vector4;
  31929. backUVs?: Vector4;
  31930. invertUV?: boolean;
  31931. uvs?: Vector2[];
  31932. colors?: Color4[];
  31933. }): VertexData;
  31934. /**
  31935. * Creates the VertexData for a box
  31936. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31937. * * size sets the width, height and depth of the box to the value of size, optional default 1
  31938. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  31939. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  31940. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  31941. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31942. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31943. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31944. * * 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)
  31945. * * 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)
  31946. * @returns the VertexData of the box
  31947. */
  31948. static CreateBox(options: {
  31949. size?: number;
  31950. width?: number;
  31951. height?: number;
  31952. depth?: number;
  31953. faceUV?: Vector4[];
  31954. faceColors?: Color4[];
  31955. sideOrientation?: number;
  31956. frontUVs?: Vector4;
  31957. backUVs?: Vector4;
  31958. }): VertexData;
  31959. /**
  31960. * Creates the VertexData for a tiled box
  31961. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31962. * * faceTiles sets the pattern, tile size and number of tiles for a face
  31963. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  31964. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  31965. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31966. * @returns the VertexData of the box
  31967. */
  31968. static CreateTiledBox(options: {
  31969. pattern?: number;
  31970. width?: number;
  31971. height?: number;
  31972. depth?: number;
  31973. tileSize?: number;
  31974. tileWidth?: number;
  31975. tileHeight?: number;
  31976. alignHorizontal?: number;
  31977. alignVertical?: number;
  31978. faceUV?: Vector4[];
  31979. faceColors?: Color4[];
  31980. sideOrientation?: number;
  31981. }): VertexData;
  31982. /**
  31983. * Creates the VertexData for a tiled plane
  31984. * @param options an object used to set the following optional parameters for the box, required but can be empty
  31985. * * pattern a limited pattern arrangement depending on the number
  31986. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  31987. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  31988. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  31989. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  31990. * * 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)
  31991. * * 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)
  31992. * @returns the VertexData of the tiled plane
  31993. */
  31994. static CreateTiledPlane(options: {
  31995. pattern?: number;
  31996. tileSize?: number;
  31997. tileWidth?: number;
  31998. tileHeight?: number;
  31999. size?: number;
  32000. width?: number;
  32001. height?: number;
  32002. alignHorizontal?: number;
  32003. alignVertical?: number;
  32004. sideOrientation?: number;
  32005. frontUVs?: Vector4;
  32006. backUVs?: Vector4;
  32007. }): VertexData;
  32008. /**
  32009. * Creates the VertexData for an ellipsoid, defaults to a sphere
  32010. * @param options an object used to set the following optional parameters for the box, required but can be empty
  32011. * * segments sets the number of horizontal strips optional, default 32
  32012. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  32013. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  32014. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  32015. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  32016. * * 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
  32017. * * 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
  32018. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32019. * * 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)
  32020. * * 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)
  32021. * @returns the VertexData of the ellipsoid
  32022. */
  32023. static CreateSphere(options: {
  32024. segments?: number;
  32025. diameter?: number;
  32026. diameterX?: number;
  32027. diameterY?: number;
  32028. diameterZ?: number;
  32029. arc?: number;
  32030. slice?: number;
  32031. sideOrientation?: number;
  32032. frontUVs?: Vector4;
  32033. backUVs?: Vector4;
  32034. }): VertexData;
  32035. /**
  32036. * Creates the VertexData for a cylinder, cone or prism
  32037. * @param options an object used to set the following optional parameters for the box, required but can be empty
  32038. * * height sets the height (y direction) of the cylinder, optional, default 2
  32039. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  32040. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  32041. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  32042. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  32043. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  32044. * * 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
  32045. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  32046. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  32047. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  32048. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  32049. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32050. * * 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)
  32051. * * 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)
  32052. * @returns the VertexData of the cylinder, cone or prism
  32053. */
  32054. static CreateCylinder(options: {
  32055. height?: number;
  32056. diameterTop?: number;
  32057. diameterBottom?: number;
  32058. diameter?: number;
  32059. tessellation?: number;
  32060. subdivisions?: number;
  32061. arc?: number;
  32062. faceColors?: Color4[];
  32063. faceUV?: Vector4[];
  32064. hasRings?: boolean;
  32065. enclose?: boolean;
  32066. sideOrientation?: number;
  32067. frontUVs?: Vector4;
  32068. backUVs?: Vector4;
  32069. }): VertexData;
  32070. /**
  32071. * Creates the VertexData for a torus
  32072. * @param options an object used to set the following optional parameters for the box, required but can be empty
  32073. * * diameter the diameter of the torus, optional default 1
  32074. * * thickness the diameter of the tube forming the torus, optional default 0.5
  32075. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  32076. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32077. * * 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)
  32078. * * 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)
  32079. * @returns the VertexData of the torus
  32080. */
  32081. static CreateTorus(options: {
  32082. diameter?: number;
  32083. thickness?: number;
  32084. tessellation?: number;
  32085. sideOrientation?: number;
  32086. frontUVs?: Vector4;
  32087. backUVs?: Vector4;
  32088. }): VertexData;
  32089. /**
  32090. * Creates the VertexData of the LineSystem
  32091. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  32092. * - lines an array of lines, each line being an array of successive Vector3
  32093. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  32094. * @returns the VertexData of the LineSystem
  32095. */
  32096. static CreateLineSystem(options: {
  32097. lines: Vector3[][];
  32098. colors?: Nullable<Color4[][]>;
  32099. }): VertexData;
  32100. /**
  32101. * Create the VertexData for a DashedLines
  32102. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  32103. * - points an array successive Vector3
  32104. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  32105. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  32106. * - dashNb the intended total number of dashes, optional, default 200
  32107. * @returns the VertexData for the DashedLines
  32108. */
  32109. static CreateDashedLines(options: {
  32110. points: Vector3[];
  32111. dashSize?: number;
  32112. gapSize?: number;
  32113. dashNb?: number;
  32114. }): VertexData;
  32115. /**
  32116. * Creates the VertexData for a Ground
  32117. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  32118. * - width the width (x direction) of the ground, optional, default 1
  32119. * - height the height (z direction) of the ground, optional, default 1
  32120. * - subdivisions the number of subdivisions per side, optional, default 1
  32121. * @returns the VertexData of the Ground
  32122. */
  32123. static CreateGround(options: {
  32124. width?: number;
  32125. height?: number;
  32126. subdivisions?: number;
  32127. subdivisionsX?: number;
  32128. subdivisionsY?: number;
  32129. }): VertexData;
  32130. /**
  32131. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  32132. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  32133. * * xmin the ground minimum X coordinate, optional, default -1
  32134. * * zmin the ground minimum Z coordinate, optional, default -1
  32135. * * xmax the ground maximum X coordinate, optional, default 1
  32136. * * zmax the ground maximum Z coordinate, optional, default 1
  32137. * * 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}
  32138. * * 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}
  32139. * @returns the VertexData of the TiledGround
  32140. */
  32141. static CreateTiledGround(options: {
  32142. xmin: number;
  32143. zmin: number;
  32144. xmax: number;
  32145. zmax: number;
  32146. subdivisions?: {
  32147. w: number;
  32148. h: number;
  32149. };
  32150. precision?: {
  32151. w: number;
  32152. h: number;
  32153. };
  32154. }): VertexData;
  32155. /**
  32156. * Creates the VertexData of the Ground designed from a heightmap
  32157. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  32158. * * width the width (x direction) of the ground
  32159. * * height the height (z direction) of the ground
  32160. * * subdivisions the number of subdivisions per side
  32161. * * minHeight the minimum altitude on the ground, optional, default 0
  32162. * * maxHeight the maximum altitude on the ground, optional default 1
  32163. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  32164. * * buffer the array holding the image color data
  32165. * * bufferWidth the width of image
  32166. * * bufferHeight the height of image
  32167. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  32168. * @returns the VertexData of the Ground designed from a heightmap
  32169. */
  32170. static CreateGroundFromHeightMap(options: {
  32171. width: number;
  32172. height: number;
  32173. subdivisions: number;
  32174. minHeight: number;
  32175. maxHeight: number;
  32176. colorFilter: Color3;
  32177. buffer: Uint8Array;
  32178. bufferWidth: number;
  32179. bufferHeight: number;
  32180. alphaFilter: number;
  32181. }): VertexData;
  32182. /**
  32183. * Creates the VertexData for a Plane
  32184. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  32185. * * size sets the width and height of the plane to the value of size, optional default 1
  32186. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  32187. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  32188. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32189. * * 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)
  32190. * * 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)
  32191. * @returns the VertexData of the box
  32192. */
  32193. static CreatePlane(options: {
  32194. size?: number;
  32195. width?: number;
  32196. height?: number;
  32197. sideOrientation?: number;
  32198. frontUVs?: Vector4;
  32199. backUVs?: Vector4;
  32200. }): VertexData;
  32201. /**
  32202. * Creates the VertexData of the Disc or regular Polygon
  32203. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  32204. * * radius the radius of the disc, optional default 0.5
  32205. * * tessellation the number of polygon sides, optional, default 64
  32206. * * 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
  32207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32208. * * 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)
  32209. * * 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)
  32210. * @returns the VertexData of the box
  32211. */
  32212. static CreateDisc(options: {
  32213. radius?: number;
  32214. tessellation?: number;
  32215. arc?: number;
  32216. sideOrientation?: number;
  32217. frontUVs?: Vector4;
  32218. backUVs?: Vector4;
  32219. }): VertexData;
  32220. /**
  32221. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  32222. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  32223. * @param polygon a mesh built from polygonTriangulation.build()
  32224. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32225. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  32226. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  32227. * @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)
  32228. * @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)
  32229. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  32230. * @returns the VertexData of the Polygon
  32231. */
  32232. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  32233. /**
  32234. * Creates the VertexData of the IcoSphere
  32235. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  32236. * * radius the radius of the IcoSphere, optional default 1
  32237. * * radiusX allows stretching in the x direction, optional, default radius
  32238. * * radiusY allows stretching in the y direction, optional, default radius
  32239. * * radiusZ allows stretching in the z direction, optional, default radius
  32240. * * flat when true creates a flat shaded mesh, optional, default true
  32241. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  32242. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32243. * * 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)
  32244. * * 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)
  32245. * @returns the VertexData of the IcoSphere
  32246. */
  32247. static CreateIcoSphere(options: {
  32248. radius?: number;
  32249. radiusX?: number;
  32250. radiusY?: number;
  32251. radiusZ?: number;
  32252. flat?: boolean;
  32253. subdivisions?: number;
  32254. sideOrientation?: number;
  32255. frontUVs?: Vector4;
  32256. backUVs?: Vector4;
  32257. }): VertexData;
  32258. /**
  32259. * Creates the VertexData for a Polyhedron
  32260. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  32261. * * type provided types are:
  32262. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  32263. * * 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)
  32264. * * size the size of the IcoSphere, optional default 1
  32265. * * sizeX allows stretching in the x direction, optional, default size
  32266. * * sizeY allows stretching in the y direction, optional, default size
  32267. * * sizeZ allows stretching in the z direction, optional, default size
  32268. * * 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
  32269. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  32270. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  32271. * * flat when true creates a flat shaded mesh, optional, default true
  32272. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  32273. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32274. * * 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)
  32275. * * 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)
  32276. * @returns the VertexData of the Polyhedron
  32277. */
  32278. static CreatePolyhedron(options: {
  32279. type?: number;
  32280. size?: number;
  32281. sizeX?: number;
  32282. sizeY?: number;
  32283. sizeZ?: number;
  32284. custom?: any;
  32285. faceUV?: Vector4[];
  32286. faceColors?: Color4[];
  32287. flat?: boolean;
  32288. sideOrientation?: number;
  32289. frontUVs?: Vector4;
  32290. backUVs?: Vector4;
  32291. }): VertexData;
  32292. /**
  32293. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  32294. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  32295. * @returns the VertexData of the Capsule
  32296. */
  32297. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  32298. /**
  32299. * Creates the VertexData for a TorusKnot
  32300. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  32301. * * radius the radius of the torus knot, optional, default 2
  32302. * * tube the thickness of the tube, optional, default 0.5
  32303. * * radialSegments the number of sides on each tube segments, optional, default 32
  32304. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  32305. * * p the number of windings around the z axis, optional, default 2
  32306. * * q the number of windings around the x axis, optional, default 3
  32307. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  32308. * * 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)
  32309. * * 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)
  32310. * @returns the VertexData of the Torus Knot
  32311. */
  32312. static CreateTorusKnot(options: {
  32313. radius?: number;
  32314. tube?: number;
  32315. radialSegments?: number;
  32316. tubularSegments?: number;
  32317. p?: number;
  32318. q?: number;
  32319. sideOrientation?: number;
  32320. frontUVs?: Vector4;
  32321. backUVs?: Vector4;
  32322. }): VertexData;
  32323. /**
  32324. * Compute normals for given positions and indices
  32325. * @param positions an array of vertex positions, [...., x, y, z, ......]
  32326. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  32327. * @param normals an array of vertex normals, [...., x, y, z, ......]
  32328. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  32329. * * facetNormals : optional array of facet normals (vector3)
  32330. * * facetPositions : optional array of facet positions (vector3)
  32331. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  32332. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  32333. * * bInfo : optional bounding info, required for facetPartitioning computation
  32334. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  32335. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  32336. * * useRightHandedSystem: optional boolean to for right handed system computation
  32337. * * depthSort : optional boolean to enable the facet depth sort computation
  32338. * * distanceTo : optional Vector3 to compute the facet depth from this location
  32339. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  32340. */
  32341. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  32342. facetNormals?: any;
  32343. facetPositions?: any;
  32344. facetPartitioning?: any;
  32345. ratio?: number;
  32346. bInfo?: any;
  32347. bbSize?: Vector3;
  32348. subDiv?: any;
  32349. useRightHandedSystem?: boolean;
  32350. depthSort?: boolean;
  32351. distanceTo?: Vector3;
  32352. depthSortedFacets?: any;
  32353. }): void;
  32354. /** @hidden */
  32355. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  32356. /**
  32357. * Applies VertexData created from the imported parameters to the geometry
  32358. * @param parsedVertexData the parsed data from an imported file
  32359. * @param geometry the geometry to apply the VertexData to
  32360. */
  32361. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  32362. }
  32363. }
  32364. declare module "babylonjs/Morph/morphTarget" {
  32365. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  32366. import { Observable } from "babylonjs/Misc/observable";
  32367. import { Nullable, FloatArray } from "babylonjs/types";
  32368. import { Scene } from "babylonjs/scene";
  32369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32370. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32371. /**
  32372. * Defines a target to use with MorphTargetManager
  32373. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32374. */
  32375. export class MorphTarget implements IAnimatable {
  32376. /** defines the name of the target */
  32377. name: string;
  32378. /**
  32379. * Gets or sets the list of animations
  32380. */
  32381. animations: import("babylonjs/Animations/animation").Animation[];
  32382. private _scene;
  32383. private _positions;
  32384. private _normals;
  32385. private _tangents;
  32386. private _uvs;
  32387. private _influence;
  32388. private _uniqueId;
  32389. /**
  32390. * Observable raised when the influence changes
  32391. */
  32392. onInfluenceChanged: Observable<boolean>;
  32393. /** @hidden */
  32394. _onDataLayoutChanged: Observable<void>;
  32395. /**
  32396. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  32397. */
  32398. get influence(): number;
  32399. set influence(influence: number);
  32400. /**
  32401. * Gets or sets the id of the morph Target
  32402. */
  32403. id: string;
  32404. private _animationPropertiesOverride;
  32405. /**
  32406. * Gets or sets the animation properties override
  32407. */
  32408. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  32409. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  32410. /**
  32411. * Creates a new MorphTarget
  32412. * @param name defines the name of the target
  32413. * @param influence defines the influence to use
  32414. * @param scene defines the scene the morphtarget belongs to
  32415. */
  32416. constructor(
  32417. /** defines the name of the target */
  32418. name: string, influence?: number, scene?: Nullable<Scene>);
  32419. /**
  32420. * Gets the unique ID of this manager
  32421. */
  32422. get uniqueId(): number;
  32423. /**
  32424. * Gets a boolean defining if the target contains position data
  32425. */
  32426. get hasPositions(): boolean;
  32427. /**
  32428. * Gets a boolean defining if the target contains normal data
  32429. */
  32430. get hasNormals(): boolean;
  32431. /**
  32432. * Gets a boolean defining if the target contains tangent data
  32433. */
  32434. get hasTangents(): boolean;
  32435. /**
  32436. * Gets a boolean defining if the target contains texture coordinates data
  32437. */
  32438. get hasUVs(): boolean;
  32439. /**
  32440. * Affects position data to this target
  32441. * @param data defines the position data to use
  32442. */
  32443. setPositions(data: Nullable<FloatArray>): void;
  32444. /**
  32445. * Gets the position data stored in this target
  32446. * @returns a FloatArray containing the position data (or null if not present)
  32447. */
  32448. getPositions(): Nullable<FloatArray>;
  32449. /**
  32450. * Affects normal data to this target
  32451. * @param data defines the normal data to use
  32452. */
  32453. setNormals(data: Nullable<FloatArray>): void;
  32454. /**
  32455. * Gets the normal data stored in this target
  32456. * @returns a FloatArray containing the normal data (or null if not present)
  32457. */
  32458. getNormals(): Nullable<FloatArray>;
  32459. /**
  32460. * Affects tangent data to this target
  32461. * @param data defines the tangent data to use
  32462. */
  32463. setTangents(data: Nullable<FloatArray>): void;
  32464. /**
  32465. * Gets the tangent data stored in this target
  32466. * @returns a FloatArray containing the tangent data (or null if not present)
  32467. */
  32468. getTangents(): Nullable<FloatArray>;
  32469. /**
  32470. * Affects texture coordinates data to this target
  32471. * @param data defines the texture coordinates data to use
  32472. */
  32473. setUVs(data: Nullable<FloatArray>): void;
  32474. /**
  32475. * Gets the texture coordinates data stored in this target
  32476. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  32477. */
  32478. getUVs(): Nullable<FloatArray>;
  32479. /**
  32480. * Clone the current target
  32481. * @returns a new MorphTarget
  32482. */
  32483. clone(): MorphTarget;
  32484. /**
  32485. * Serializes the current target into a Serialization object
  32486. * @returns the serialized object
  32487. */
  32488. serialize(): any;
  32489. /**
  32490. * Returns the string "MorphTarget"
  32491. * @returns "MorphTarget"
  32492. */
  32493. getClassName(): string;
  32494. /**
  32495. * Creates a new target from serialized data
  32496. * @param serializationObject defines the serialized data to use
  32497. * @returns a new MorphTarget
  32498. */
  32499. static Parse(serializationObject: any): MorphTarget;
  32500. /**
  32501. * Creates a MorphTarget from mesh data
  32502. * @param mesh defines the source mesh
  32503. * @param name defines the name to use for the new target
  32504. * @param influence defines the influence to attach to the target
  32505. * @returns a new MorphTarget
  32506. */
  32507. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  32508. }
  32509. }
  32510. declare module "babylonjs/Morph/morphTargetManager" {
  32511. import { Nullable } from "babylonjs/types";
  32512. import { Scene } from "babylonjs/scene";
  32513. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32514. /**
  32515. * This class is used to deform meshes using morphing between different targets
  32516. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32517. */
  32518. export class MorphTargetManager {
  32519. private _targets;
  32520. private _targetInfluenceChangedObservers;
  32521. private _targetDataLayoutChangedObservers;
  32522. private _activeTargets;
  32523. private _scene;
  32524. private _influences;
  32525. private _supportsNormals;
  32526. private _supportsTangents;
  32527. private _supportsUVs;
  32528. private _vertexCount;
  32529. private _uniqueId;
  32530. private _tempInfluences;
  32531. /**
  32532. * Gets or sets a boolean indicating if normals must be morphed
  32533. */
  32534. enableNormalMorphing: boolean;
  32535. /**
  32536. * Gets or sets a boolean indicating if tangents must be morphed
  32537. */
  32538. enableTangentMorphing: boolean;
  32539. /**
  32540. * Gets or sets a boolean indicating if UV must be morphed
  32541. */
  32542. enableUVMorphing: boolean;
  32543. /**
  32544. * Creates a new MorphTargetManager
  32545. * @param scene defines the current scene
  32546. */
  32547. constructor(scene?: Nullable<Scene>);
  32548. /**
  32549. * Gets the unique ID of this manager
  32550. */
  32551. get uniqueId(): number;
  32552. /**
  32553. * Gets the number of vertices handled by this manager
  32554. */
  32555. get vertexCount(): number;
  32556. /**
  32557. * Gets a boolean indicating if this manager supports morphing of normals
  32558. */
  32559. get supportsNormals(): boolean;
  32560. /**
  32561. * Gets a boolean indicating if this manager supports morphing of tangents
  32562. */
  32563. get supportsTangents(): boolean;
  32564. /**
  32565. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  32566. */
  32567. get supportsUVs(): boolean;
  32568. /**
  32569. * Gets the number of targets stored in this manager
  32570. */
  32571. get numTargets(): number;
  32572. /**
  32573. * Gets the number of influencers (ie. the number of targets with influences > 0)
  32574. */
  32575. get numInfluencers(): number;
  32576. /**
  32577. * Gets the list of influences (one per target)
  32578. */
  32579. get influences(): Float32Array;
  32580. /**
  32581. * Gets the active target at specified index. An active target is a target with an influence > 0
  32582. * @param index defines the index to check
  32583. * @returns the requested target
  32584. */
  32585. getActiveTarget(index: number): MorphTarget;
  32586. /**
  32587. * Gets the target at specified index
  32588. * @param index defines the index to check
  32589. * @returns the requested target
  32590. */
  32591. getTarget(index: number): MorphTarget;
  32592. /**
  32593. * Add a new target to this manager
  32594. * @param target defines the target to add
  32595. */
  32596. addTarget(target: MorphTarget): void;
  32597. /**
  32598. * Removes a target from the manager
  32599. * @param target defines the target to remove
  32600. */
  32601. removeTarget(target: MorphTarget): void;
  32602. /**
  32603. * Clone the current manager
  32604. * @returns a new MorphTargetManager
  32605. */
  32606. clone(): MorphTargetManager;
  32607. /**
  32608. * Serializes the current manager into a Serialization object
  32609. * @returns the serialized object
  32610. */
  32611. serialize(): any;
  32612. private _syncActiveTargets;
  32613. /**
  32614. * Syncrhonize the targets with all the meshes using this morph target manager
  32615. */
  32616. synchronize(): void;
  32617. /**
  32618. * Creates a new MorphTargetManager from serialized data
  32619. * @param serializationObject defines the serialized data
  32620. * @param scene defines the hosting scene
  32621. * @returns the new MorphTargetManager
  32622. */
  32623. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  32624. }
  32625. }
  32626. declare module "babylonjs/Meshes/meshLODLevel" {
  32627. import { Mesh } from "babylonjs/Meshes/mesh";
  32628. import { Nullable } from "babylonjs/types";
  32629. /**
  32630. * Class used to represent a specific level of detail of a mesh
  32631. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32632. */
  32633. export class MeshLODLevel {
  32634. /** Defines the distance where this level should start being displayed */
  32635. distance: number;
  32636. /** Defines the mesh to use to render this level */
  32637. mesh: Nullable<Mesh>;
  32638. /**
  32639. * Creates a new LOD level
  32640. * @param distance defines the distance where this level should star being displayed
  32641. * @param mesh defines the mesh to use to render this level
  32642. */
  32643. constructor(
  32644. /** Defines the distance where this level should start being displayed */
  32645. distance: number,
  32646. /** Defines the mesh to use to render this level */
  32647. mesh: Nullable<Mesh>);
  32648. }
  32649. }
  32650. declare module "babylonjs/Misc/canvasGenerator" {
  32651. /**
  32652. * Helper class used to generate a canvas to manipulate images
  32653. */
  32654. export class CanvasGenerator {
  32655. /**
  32656. * Create a new canvas (or offscreen canvas depending on the context)
  32657. * @param width defines the expected width
  32658. * @param height defines the expected height
  32659. * @return a new canvas or offscreen canvas
  32660. */
  32661. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  32662. }
  32663. }
  32664. declare module "babylonjs/Meshes/groundMesh" {
  32665. import { Scene } from "babylonjs/scene";
  32666. import { Vector3 } from "babylonjs/Maths/math.vector";
  32667. import { Mesh } from "babylonjs/Meshes/mesh";
  32668. /**
  32669. * Mesh representing the gorund
  32670. */
  32671. export class GroundMesh extends Mesh {
  32672. /** If octree should be generated */
  32673. generateOctree: boolean;
  32674. private _heightQuads;
  32675. /** @hidden */
  32676. _subdivisionsX: number;
  32677. /** @hidden */
  32678. _subdivisionsY: number;
  32679. /** @hidden */
  32680. _width: number;
  32681. /** @hidden */
  32682. _height: number;
  32683. /** @hidden */
  32684. _minX: number;
  32685. /** @hidden */
  32686. _maxX: number;
  32687. /** @hidden */
  32688. _minZ: number;
  32689. /** @hidden */
  32690. _maxZ: number;
  32691. constructor(name: string, scene: Scene);
  32692. /**
  32693. * "GroundMesh"
  32694. * @returns "GroundMesh"
  32695. */
  32696. getClassName(): string;
  32697. /**
  32698. * The minimum of x and y subdivisions
  32699. */
  32700. get subdivisions(): number;
  32701. /**
  32702. * X subdivisions
  32703. */
  32704. get subdivisionsX(): number;
  32705. /**
  32706. * Y subdivisions
  32707. */
  32708. get subdivisionsY(): number;
  32709. /**
  32710. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  32711. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  32712. * @param chunksCount the number of subdivisions for x and y
  32713. * @param octreeBlocksSize (Default: 32)
  32714. */
  32715. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  32716. /**
  32717. * Returns a height (y) value in the Worl system :
  32718. * the ground altitude at the coordinates (x, z) expressed in the World system.
  32719. * @param x x coordinate
  32720. * @param z z coordinate
  32721. * @returns the ground y position if (x, z) are outside the ground surface.
  32722. */
  32723. getHeightAtCoordinates(x: number, z: number): number;
  32724. /**
  32725. * Returns a normalized vector (Vector3) orthogonal to the ground
  32726. * at the ground coordinates (x, z) expressed in the World system.
  32727. * @param x x coordinate
  32728. * @param z z coordinate
  32729. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  32730. */
  32731. getNormalAtCoordinates(x: number, z: number): Vector3;
  32732. /**
  32733. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  32734. * at the ground coordinates (x, z) expressed in the World system.
  32735. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  32736. * @param x x coordinate
  32737. * @param z z coordinate
  32738. * @param ref vector to store the result
  32739. * @returns the GroundMesh.
  32740. */
  32741. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  32742. /**
  32743. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  32744. * if the ground has been updated.
  32745. * This can be used in the render loop.
  32746. * @returns the GroundMesh.
  32747. */
  32748. updateCoordinateHeights(): GroundMesh;
  32749. private _getFacetAt;
  32750. private _initHeightQuads;
  32751. private _computeHeightQuads;
  32752. /**
  32753. * Serializes this ground mesh
  32754. * @param serializationObject object to write serialization to
  32755. */
  32756. serialize(serializationObject: any): void;
  32757. /**
  32758. * Parses a serialized ground mesh
  32759. * @param parsedMesh the serialized mesh
  32760. * @param scene the scene to create the ground mesh in
  32761. * @returns the created ground mesh
  32762. */
  32763. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  32764. }
  32765. }
  32766. declare module "babylonjs/Physics/physicsJoint" {
  32767. import { Vector3 } from "babylonjs/Maths/math.vector";
  32768. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  32769. /**
  32770. * Interface for Physics-Joint data
  32771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32772. */
  32773. export interface PhysicsJointData {
  32774. /**
  32775. * The main pivot of the joint
  32776. */
  32777. mainPivot?: Vector3;
  32778. /**
  32779. * The connected pivot of the joint
  32780. */
  32781. connectedPivot?: Vector3;
  32782. /**
  32783. * The main axis of the joint
  32784. */
  32785. mainAxis?: Vector3;
  32786. /**
  32787. * The connected axis of the joint
  32788. */
  32789. connectedAxis?: Vector3;
  32790. /**
  32791. * The collision of the joint
  32792. */
  32793. collision?: boolean;
  32794. /**
  32795. * Native Oimo/Cannon/Energy data
  32796. */
  32797. nativeParams?: any;
  32798. }
  32799. /**
  32800. * This is a holder class for the physics joint created by the physics plugin
  32801. * It holds a set of functions to control the underlying joint
  32802. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32803. */
  32804. export class PhysicsJoint {
  32805. /**
  32806. * The type of the physics joint
  32807. */
  32808. type: number;
  32809. /**
  32810. * The data for the physics joint
  32811. */
  32812. jointData: PhysicsJointData;
  32813. private _physicsJoint;
  32814. protected _physicsPlugin: IPhysicsEnginePlugin;
  32815. /**
  32816. * Initializes the physics joint
  32817. * @param type The type of the physics joint
  32818. * @param jointData The data for the physics joint
  32819. */
  32820. constructor(
  32821. /**
  32822. * The type of the physics joint
  32823. */
  32824. type: number,
  32825. /**
  32826. * The data for the physics joint
  32827. */
  32828. jointData: PhysicsJointData);
  32829. /**
  32830. * Gets the physics joint
  32831. */
  32832. get physicsJoint(): any;
  32833. /**
  32834. * Sets the physics joint
  32835. */
  32836. set physicsJoint(newJoint: any);
  32837. /**
  32838. * Sets the physics plugin
  32839. */
  32840. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  32841. /**
  32842. * Execute a function that is physics-plugin specific.
  32843. * @param {Function} func the function that will be executed.
  32844. * It accepts two parameters: the physics world and the physics joint
  32845. */
  32846. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  32847. /**
  32848. * Distance-Joint type
  32849. */
  32850. static DistanceJoint: number;
  32851. /**
  32852. * Hinge-Joint type
  32853. */
  32854. static HingeJoint: number;
  32855. /**
  32856. * Ball-and-Socket joint type
  32857. */
  32858. static BallAndSocketJoint: number;
  32859. /**
  32860. * Wheel-Joint type
  32861. */
  32862. static WheelJoint: number;
  32863. /**
  32864. * Slider-Joint type
  32865. */
  32866. static SliderJoint: number;
  32867. /**
  32868. * Prismatic-Joint type
  32869. */
  32870. static PrismaticJoint: number;
  32871. /**
  32872. * Universal-Joint type
  32873. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  32874. */
  32875. static UniversalJoint: number;
  32876. /**
  32877. * Hinge-Joint 2 type
  32878. */
  32879. static Hinge2Joint: number;
  32880. /**
  32881. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  32882. */
  32883. static PointToPointJoint: number;
  32884. /**
  32885. * Spring-Joint type
  32886. */
  32887. static SpringJoint: number;
  32888. /**
  32889. * Lock-Joint type
  32890. */
  32891. static LockJoint: number;
  32892. }
  32893. /**
  32894. * A class representing a physics distance joint
  32895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32896. */
  32897. export class DistanceJoint extends PhysicsJoint {
  32898. /**
  32899. *
  32900. * @param jointData The data for the Distance-Joint
  32901. */
  32902. constructor(jointData: DistanceJointData);
  32903. /**
  32904. * Update the predefined distance.
  32905. * @param maxDistance The maximum preferred distance
  32906. * @param minDistance The minimum preferred distance
  32907. */
  32908. updateDistance(maxDistance: number, minDistance?: number): void;
  32909. }
  32910. /**
  32911. * Represents a Motor-Enabled Joint
  32912. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32913. */
  32914. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  32915. /**
  32916. * Initializes the Motor-Enabled Joint
  32917. * @param type The type of the joint
  32918. * @param jointData The physica joint data for the joint
  32919. */
  32920. constructor(type: number, jointData: PhysicsJointData);
  32921. /**
  32922. * Set the motor values.
  32923. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32924. * @param force the force to apply
  32925. * @param maxForce max force for this motor.
  32926. */
  32927. setMotor(force?: number, maxForce?: number): void;
  32928. /**
  32929. * Set the motor's limits.
  32930. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32931. * @param upperLimit The upper limit of the motor
  32932. * @param lowerLimit The lower limit of the motor
  32933. */
  32934. setLimit(upperLimit: number, lowerLimit?: number): void;
  32935. }
  32936. /**
  32937. * This class represents a single physics Hinge-Joint
  32938. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32939. */
  32940. export class HingeJoint extends MotorEnabledJoint {
  32941. /**
  32942. * Initializes the Hinge-Joint
  32943. * @param jointData The joint data for the Hinge-Joint
  32944. */
  32945. constructor(jointData: PhysicsJointData);
  32946. /**
  32947. * Set the motor values.
  32948. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32949. * @param {number} force the force to apply
  32950. * @param {number} maxForce max force for this motor.
  32951. */
  32952. setMotor(force?: number, maxForce?: number): void;
  32953. /**
  32954. * Set the motor's limits.
  32955. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32956. * @param upperLimit The upper limit of the motor
  32957. * @param lowerLimit The lower limit of the motor
  32958. */
  32959. setLimit(upperLimit: number, lowerLimit?: number): void;
  32960. }
  32961. /**
  32962. * This class represents a dual hinge physics joint (same as wheel joint)
  32963. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32964. */
  32965. export class Hinge2Joint extends MotorEnabledJoint {
  32966. /**
  32967. * Initializes the Hinge2-Joint
  32968. * @param jointData The joint data for the Hinge2-Joint
  32969. */
  32970. constructor(jointData: PhysicsJointData);
  32971. /**
  32972. * Set the motor values.
  32973. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32974. * @param {number} targetSpeed the speed the motor is to reach
  32975. * @param {number} maxForce max force for this motor.
  32976. * @param {motorIndex} the motor's index, 0 or 1.
  32977. */
  32978. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  32979. /**
  32980. * Set the motor limits.
  32981. * Attention, this function is plugin specific. Engines won't react 100% the same.
  32982. * @param {number} upperLimit the upper limit
  32983. * @param {number} lowerLimit lower limit
  32984. * @param {motorIndex} the motor's index, 0 or 1.
  32985. */
  32986. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  32987. }
  32988. /**
  32989. * Interface for a motor enabled joint
  32990. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  32991. */
  32992. export interface IMotorEnabledJoint {
  32993. /**
  32994. * Physics joint
  32995. */
  32996. physicsJoint: any;
  32997. /**
  32998. * Sets the motor of the motor-enabled joint
  32999. * @param force The force of the motor
  33000. * @param maxForce The maximum force of the motor
  33001. * @param motorIndex The index of the motor
  33002. */
  33003. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  33004. /**
  33005. * Sets the limit of the motor
  33006. * @param upperLimit The upper limit of the motor
  33007. * @param lowerLimit The lower limit of the motor
  33008. * @param motorIndex The index of the motor
  33009. */
  33010. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33011. }
  33012. /**
  33013. * Joint data for a Distance-Joint
  33014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33015. */
  33016. export interface DistanceJointData extends PhysicsJointData {
  33017. /**
  33018. * Max distance the 2 joint objects can be apart
  33019. */
  33020. maxDistance: number;
  33021. }
  33022. /**
  33023. * Joint data from a spring joint
  33024. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33025. */
  33026. export interface SpringJointData extends PhysicsJointData {
  33027. /**
  33028. * Length of the spring
  33029. */
  33030. length: number;
  33031. /**
  33032. * Stiffness of the spring
  33033. */
  33034. stiffness: number;
  33035. /**
  33036. * Damping of the spring
  33037. */
  33038. damping: number;
  33039. /** this callback will be called when applying the force to the impostors. */
  33040. forceApplicationCallback: () => void;
  33041. }
  33042. }
  33043. declare module "babylonjs/Physics/physicsRaycastResult" {
  33044. import { Vector3 } from "babylonjs/Maths/math.vector";
  33045. /**
  33046. * Holds the data for the raycast result
  33047. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33048. */
  33049. export class PhysicsRaycastResult {
  33050. private _hasHit;
  33051. private _hitDistance;
  33052. private _hitNormalWorld;
  33053. private _hitPointWorld;
  33054. private _rayFromWorld;
  33055. private _rayToWorld;
  33056. /**
  33057. * Gets if there was a hit
  33058. */
  33059. get hasHit(): boolean;
  33060. /**
  33061. * Gets the distance from the hit
  33062. */
  33063. get hitDistance(): number;
  33064. /**
  33065. * Gets the hit normal/direction in the world
  33066. */
  33067. get hitNormalWorld(): Vector3;
  33068. /**
  33069. * Gets the hit point in the world
  33070. */
  33071. get hitPointWorld(): Vector3;
  33072. /**
  33073. * Gets the ray "start point" of the ray in the world
  33074. */
  33075. get rayFromWorld(): Vector3;
  33076. /**
  33077. * Gets the ray "end point" of the ray in the world
  33078. */
  33079. get rayToWorld(): Vector3;
  33080. /**
  33081. * Sets the hit data (normal & point in world space)
  33082. * @param hitNormalWorld defines the normal in world space
  33083. * @param hitPointWorld defines the point in world space
  33084. */
  33085. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  33086. /**
  33087. * Sets the distance from the start point to the hit point
  33088. * @param distance
  33089. */
  33090. setHitDistance(distance: number): void;
  33091. /**
  33092. * Calculates the distance manually
  33093. */
  33094. calculateHitDistance(): void;
  33095. /**
  33096. * Resets all the values to default
  33097. * @param from The from point on world space
  33098. * @param to The to point on world space
  33099. */
  33100. reset(from?: Vector3, to?: Vector3): void;
  33101. }
  33102. /**
  33103. * Interface for the size containing width and height
  33104. */
  33105. interface IXYZ {
  33106. /**
  33107. * X
  33108. */
  33109. x: number;
  33110. /**
  33111. * Y
  33112. */
  33113. y: number;
  33114. /**
  33115. * Z
  33116. */
  33117. z: number;
  33118. }
  33119. }
  33120. declare module "babylonjs/Physics/IPhysicsEngine" {
  33121. import { Nullable } from "babylonjs/types";
  33122. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  33123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33124. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33125. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  33126. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  33127. /**
  33128. * Interface used to describe a physics joint
  33129. */
  33130. export interface PhysicsImpostorJoint {
  33131. /** Defines the main impostor to which the joint is linked */
  33132. mainImpostor: PhysicsImpostor;
  33133. /** Defines the impostor that is connected to the main impostor using this joint */
  33134. connectedImpostor: PhysicsImpostor;
  33135. /** Defines the joint itself */
  33136. joint: PhysicsJoint;
  33137. }
  33138. /** @hidden */
  33139. export interface IPhysicsEnginePlugin {
  33140. world: any;
  33141. name: string;
  33142. setGravity(gravity: Vector3): void;
  33143. setTimeStep(timeStep: number): void;
  33144. getTimeStep(): number;
  33145. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  33146. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33147. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  33148. generatePhysicsBody(impostor: PhysicsImpostor): void;
  33149. removePhysicsBody(impostor: PhysicsImpostor): void;
  33150. generateJoint(joint: PhysicsImpostorJoint): void;
  33151. removeJoint(joint: PhysicsImpostorJoint): void;
  33152. isSupported(): boolean;
  33153. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  33154. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  33155. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33156. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  33157. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33158. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  33159. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  33160. getBodyMass(impostor: PhysicsImpostor): number;
  33161. getBodyFriction(impostor: PhysicsImpostor): number;
  33162. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  33163. getBodyRestitution(impostor: PhysicsImpostor): number;
  33164. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  33165. getBodyPressure?(impostor: PhysicsImpostor): number;
  33166. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  33167. getBodyStiffness?(impostor: PhysicsImpostor): number;
  33168. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  33169. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  33170. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  33171. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  33172. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  33173. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33174. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  33175. sleepBody(impostor: PhysicsImpostor): void;
  33176. wakeUpBody(impostor: PhysicsImpostor): void;
  33177. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33178. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  33179. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  33180. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  33181. getRadius(impostor: PhysicsImpostor): number;
  33182. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  33183. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  33184. dispose(): void;
  33185. }
  33186. /**
  33187. * Interface used to define a physics engine
  33188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33189. */
  33190. export interface IPhysicsEngine {
  33191. /**
  33192. * Gets the gravity vector used by the simulation
  33193. */
  33194. gravity: Vector3;
  33195. /**
  33196. * Sets the gravity vector used by the simulation
  33197. * @param gravity defines the gravity vector to use
  33198. */
  33199. setGravity(gravity: Vector3): void;
  33200. /**
  33201. * Set the time step of the physics engine.
  33202. * Default is 1/60.
  33203. * To slow it down, enter 1/600 for example.
  33204. * To speed it up, 1/30
  33205. * @param newTimeStep the new timestep to apply to this world.
  33206. */
  33207. setTimeStep(newTimeStep: number): void;
  33208. /**
  33209. * Get the time step of the physics engine.
  33210. * @returns the current time step
  33211. */
  33212. getTimeStep(): number;
  33213. /**
  33214. * Set the sub time step of the physics engine.
  33215. * Default is 0 meaning there is no sub steps
  33216. * To increase physics resolution precision, set a small value (like 1 ms)
  33217. * @param subTimeStep defines the new sub timestep used for physics resolution.
  33218. */
  33219. setSubTimeStep(subTimeStep: number): void;
  33220. /**
  33221. * Get the sub time step of the physics engine.
  33222. * @returns the current sub time step
  33223. */
  33224. getSubTimeStep(): number;
  33225. /**
  33226. * Release all resources
  33227. */
  33228. dispose(): void;
  33229. /**
  33230. * Gets the name of the current physics plugin
  33231. * @returns the name of the plugin
  33232. */
  33233. getPhysicsPluginName(): string;
  33234. /**
  33235. * Adding a new impostor for the impostor tracking.
  33236. * This will be done by the impostor itself.
  33237. * @param impostor the impostor to add
  33238. */
  33239. addImpostor(impostor: PhysicsImpostor): void;
  33240. /**
  33241. * Remove an impostor from the engine.
  33242. * This impostor and its mesh will not longer be updated by the physics engine.
  33243. * @param impostor the impostor to remove
  33244. */
  33245. removeImpostor(impostor: PhysicsImpostor): void;
  33246. /**
  33247. * Add a joint to the physics engine
  33248. * @param mainImpostor defines the main impostor to which the joint is added.
  33249. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  33250. * @param joint defines the joint that will connect both impostors.
  33251. */
  33252. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33253. /**
  33254. * Removes a joint from the simulation
  33255. * @param mainImpostor defines the impostor used with the joint
  33256. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  33257. * @param joint defines the joint to remove
  33258. */
  33259. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  33260. /**
  33261. * Gets the current plugin used to run the simulation
  33262. * @returns current plugin
  33263. */
  33264. getPhysicsPlugin(): IPhysicsEnginePlugin;
  33265. /**
  33266. * Gets the list of physic impostors
  33267. * @returns an array of PhysicsImpostor
  33268. */
  33269. getImpostors(): Array<PhysicsImpostor>;
  33270. /**
  33271. * Gets the impostor for a physics enabled object
  33272. * @param object defines the object impersonated by the impostor
  33273. * @returns the PhysicsImpostor or null if not found
  33274. */
  33275. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33276. /**
  33277. * Gets the impostor for a physics body object
  33278. * @param body defines physics body used by the impostor
  33279. * @returns the PhysicsImpostor or null if not found
  33280. */
  33281. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  33282. /**
  33283. * Does a raycast in the physics world
  33284. * @param from when should the ray start?
  33285. * @param to when should the ray end?
  33286. * @returns PhysicsRaycastResult
  33287. */
  33288. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  33289. /**
  33290. * Called by the scene. No need to call it.
  33291. * @param delta defines the timespam between frames
  33292. */
  33293. _step(delta: number): void;
  33294. }
  33295. }
  33296. declare module "babylonjs/Physics/physicsImpostor" {
  33297. import { Nullable, IndicesArray } from "babylonjs/types";
  33298. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  33299. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33301. import { Scene } from "babylonjs/scene";
  33302. import { Bone } from "babylonjs/Bones/bone";
  33303. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33304. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  33305. import { Space } from "babylonjs/Maths/math.axis";
  33306. /**
  33307. * The interface for the physics imposter parameters
  33308. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33309. */
  33310. export interface PhysicsImpostorParameters {
  33311. /**
  33312. * The mass of the physics imposter
  33313. */
  33314. mass: number;
  33315. /**
  33316. * The friction of the physics imposter
  33317. */
  33318. friction?: number;
  33319. /**
  33320. * The coefficient of restitution of the physics imposter
  33321. */
  33322. restitution?: number;
  33323. /**
  33324. * The native options of the physics imposter
  33325. */
  33326. nativeOptions?: any;
  33327. /**
  33328. * Specifies if the parent should be ignored
  33329. */
  33330. ignoreParent?: boolean;
  33331. /**
  33332. * Specifies if bi-directional transformations should be disabled
  33333. */
  33334. disableBidirectionalTransformation?: boolean;
  33335. /**
  33336. * The pressure inside the physics imposter, soft object only
  33337. */
  33338. pressure?: number;
  33339. /**
  33340. * The stiffness the physics imposter, soft object only
  33341. */
  33342. stiffness?: number;
  33343. /**
  33344. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  33345. */
  33346. velocityIterations?: number;
  33347. /**
  33348. * The number of iterations used in maintaining consistent vertex positions, soft object only
  33349. */
  33350. positionIterations?: number;
  33351. /**
  33352. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  33353. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  33354. * Add to fix multiple points
  33355. */
  33356. fixedPoints?: number;
  33357. /**
  33358. * The collision margin around a soft object
  33359. */
  33360. margin?: number;
  33361. /**
  33362. * The collision margin around a soft object
  33363. */
  33364. damping?: number;
  33365. /**
  33366. * The path for a rope based on an extrusion
  33367. */
  33368. path?: any;
  33369. /**
  33370. * The shape of an extrusion used for a rope based on an extrusion
  33371. */
  33372. shape?: any;
  33373. }
  33374. /**
  33375. * Interface for a physics-enabled object
  33376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33377. */
  33378. export interface IPhysicsEnabledObject {
  33379. /**
  33380. * The position of the physics-enabled object
  33381. */
  33382. position: Vector3;
  33383. /**
  33384. * The rotation of the physics-enabled object
  33385. */
  33386. rotationQuaternion: Nullable<Quaternion>;
  33387. /**
  33388. * The scale of the physics-enabled object
  33389. */
  33390. scaling: Vector3;
  33391. /**
  33392. * The rotation of the physics-enabled object
  33393. */
  33394. rotation?: Vector3;
  33395. /**
  33396. * The parent of the physics-enabled object
  33397. */
  33398. parent?: any;
  33399. /**
  33400. * The bounding info of the physics-enabled object
  33401. * @returns The bounding info of the physics-enabled object
  33402. */
  33403. getBoundingInfo(): BoundingInfo;
  33404. /**
  33405. * Computes the world matrix
  33406. * @param force Specifies if the world matrix should be computed by force
  33407. * @returns A world matrix
  33408. */
  33409. computeWorldMatrix(force: boolean): Matrix;
  33410. /**
  33411. * Gets the world matrix
  33412. * @returns A world matrix
  33413. */
  33414. getWorldMatrix?(): Matrix;
  33415. /**
  33416. * Gets the child meshes
  33417. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  33418. * @returns An array of abstract meshes
  33419. */
  33420. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  33421. /**
  33422. * Gets the vertex data
  33423. * @param kind The type of vertex data
  33424. * @returns A nullable array of numbers, or a float32 array
  33425. */
  33426. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  33427. /**
  33428. * Gets the indices from the mesh
  33429. * @returns A nullable array of index arrays
  33430. */
  33431. getIndices?(): Nullable<IndicesArray>;
  33432. /**
  33433. * Gets the scene from the mesh
  33434. * @returns the indices array or null
  33435. */
  33436. getScene?(): Scene;
  33437. /**
  33438. * Gets the absolute position from the mesh
  33439. * @returns the absolute position
  33440. */
  33441. getAbsolutePosition(): Vector3;
  33442. /**
  33443. * Gets the absolute pivot point from the mesh
  33444. * @returns the absolute pivot point
  33445. */
  33446. getAbsolutePivotPoint(): Vector3;
  33447. /**
  33448. * Rotates the mesh
  33449. * @param axis The axis of rotation
  33450. * @param amount The amount of rotation
  33451. * @param space The space of the rotation
  33452. * @returns The rotation transform node
  33453. */
  33454. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  33455. /**
  33456. * Translates the mesh
  33457. * @param axis The axis of translation
  33458. * @param distance The distance of translation
  33459. * @param space The space of the translation
  33460. * @returns The transform node
  33461. */
  33462. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  33463. /**
  33464. * Sets the absolute position of the mesh
  33465. * @param absolutePosition The absolute position of the mesh
  33466. * @returns The transform node
  33467. */
  33468. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  33469. /**
  33470. * Gets the class name of the mesh
  33471. * @returns The class name
  33472. */
  33473. getClassName(): string;
  33474. }
  33475. /**
  33476. * Represents a physics imposter
  33477. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  33478. */
  33479. export class PhysicsImpostor {
  33480. /**
  33481. * The physics-enabled object used as the physics imposter
  33482. */
  33483. object: IPhysicsEnabledObject;
  33484. /**
  33485. * The type of the physics imposter
  33486. */
  33487. type: number;
  33488. private _options;
  33489. private _scene?;
  33490. /**
  33491. * The default object size of the imposter
  33492. */
  33493. static DEFAULT_OBJECT_SIZE: Vector3;
  33494. /**
  33495. * The identity quaternion of the imposter
  33496. */
  33497. static IDENTITY_QUATERNION: Quaternion;
  33498. /** @hidden */
  33499. _pluginData: any;
  33500. private _physicsEngine;
  33501. private _physicsBody;
  33502. private _bodyUpdateRequired;
  33503. private _onBeforePhysicsStepCallbacks;
  33504. private _onAfterPhysicsStepCallbacks;
  33505. /** @hidden */
  33506. _onPhysicsCollideCallbacks: Array<{
  33507. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  33508. otherImpostors: Array<PhysicsImpostor>;
  33509. }>;
  33510. private _deltaPosition;
  33511. private _deltaRotation;
  33512. private _deltaRotationConjugated;
  33513. /** @hidden */
  33514. _isFromLine: boolean;
  33515. private _parent;
  33516. private _isDisposed;
  33517. private static _tmpVecs;
  33518. private static _tmpQuat;
  33519. /**
  33520. * Specifies if the physics imposter is disposed
  33521. */
  33522. get isDisposed(): boolean;
  33523. /**
  33524. * Gets the mass of the physics imposter
  33525. */
  33526. get mass(): number;
  33527. set mass(value: number);
  33528. /**
  33529. * Gets the coefficient of friction
  33530. */
  33531. get friction(): number;
  33532. /**
  33533. * Sets the coefficient of friction
  33534. */
  33535. set friction(value: number);
  33536. /**
  33537. * Gets the coefficient of restitution
  33538. */
  33539. get restitution(): number;
  33540. /**
  33541. * Sets the coefficient of restitution
  33542. */
  33543. set restitution(value: number);
  33544. /**
  33545. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  33546. */
  33547. get pressure(): number;
  33548. /**
  33549. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  33550. */
  33551. set pressure(value: number);
  33552. /**
  33553. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33554. */
  33555. get stiffness(): number;
  33556. /**
  33557. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  33558. */
  33559. set stiffness(value: number);
  33560. /**
  33561. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33562. */
  33563. get velocityIterations(): number;
  33564. /**
  33565. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  33566. */
  33567. set velocityIterations(value: number);
  33568. /**
  33569. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33570. */
  33571. get positionIterations(): number;
  33572. /**
  33573. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  33574. */
  33575. set positionIterations(value: number);
  33576. /**
  33577. * The unique id of the physics imposter
  33578. * set by the physics engine when adding this impostor to the array
  33579. */
  33580. uniqueId: number;
  33581. /**
  33582. * @hidden
  33583. */
  33584. soft: boolean;
  33585. /**
  33586. * @hidden
  33587. */
  33588. segments: number;
  33589. private _joints;
  33590. /**
  33591. * Initializes the physics imposter
  33592. * @param object The physics-enabled object used as the physics imposter
  33593. * @param type The type of the physics imposter
  33594. * @param _options The options for the physics imposter
  33595. * @param _scene The Babylon scene
  33596. */
  33597. constructor(
  33598. /**
  33599. * The physics-enabled object used as the physics imposter
  33600. */
  33601. object: IPhysicsEnabledObject,
  33602. /**
  33603. * The type of the physics imposter
  33604. */
  33605. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  33606. /**
  33607. * This function will completly initialize this impostor.
  33608. * It will create a new body - but only if this mesh has no parent.
  33609. * If it has, this impostor will not be used other than to define the impostor
  33610. * of the child mesh.
  33611. * @hidden
  33612. */
  33613. _init(): void;
  33614. private _getPhysicsParent;
  33615. /**
  33616. * Should a new body be generated.
  33617. * @returns boolean specifying if body initialization is required
  33618. */
  33619. isBodyInitRequired(): boolean;
  33620. /**
  33621. * Sets the updated scaling
  33622. * @param updated Specifies if the scaling is updated
  33623. */
  33624. setScalingUpdated(): void;
  33625. /**
  33626. * Force a regeneration of this or the parent's impostor's body.
  33627. * Use under cautious - This will remove all joints already implemented.
  33628. */
  33629. forceUpdate(): void;
  33630. /**
  33631. * Gets the body that holds this impostor. Either its own, or its parent.
  33632. */
  33633. get physicsBody(): any;
  33634. /**
  33635. * Get the parent of the physics imposter
  33636. * @returns Physics imposter or null
  33637. */
  33638. get parent(): Nullable<PhysicsImpostor>;
  33639. /**
  33640. * Sets the parent of the physics imposter
  33641. */
  33642. set parent(value: Nullable<PhysicsImpostor>);
  33643. /**
  33644. * Set the physics body. Used mainly by the physics engine/plugin
  33645. */
  33646. set physicsBody(physicsBody: any);
  33647. /**
  33648. * Resets the update flags
  33649. */
  33650. resetUpdateFlags(): void;
  33651. /**
  33652. * Gets the object extend size
  33653. * @returns the object extend size
  33654. */
  33655. getObjectExtendSize(): Vector3;
  33656. /**
  33657. * Gets the object center
  33658. * @returns The object center
  33659. */
  33660. getObjectCenter(): Vector3;
  33661. /**
  33662. * Get a specific parameter from the options parameters
  33663. * @param paramName The object parameter name
  33664. * @returns The object parameter
  33665. */
  33666. getParam(paramName: string): any;
  33667. /**
  33668. * Sets a specific parameter in the options given to the physics plugin
  33669. * @param paramName The parameter name
  33670. * @param value The value of the parameter
  33671. */
  33672. setParam(paramName: string, value: number): void;
  33673. /**
  33674. * Specifically change the body's mass option. Won't recreate the physics body object
  33675. * @param mass The mass of the physics imposter
  33676. */
  33677. setMass(mass: number): void;
  33678. /**
  33679. * Gets the linear velocity
  33680. * @returns linear velocity or null
  33681. */
  33682. getLinearVelocity(): Nullable<Vector3>;
  33683. /**
  33684. * Sets the linear velocity
  33685. * @param velocity linear velocity or null
  33686. */
  33687. setLinearVelocity(velocity: Nullable<Vector3>): void;
  33688. /**
  33689. * Gets the angular velocity
  33690. * @returns angular velocity or null
  33691. */
  33692. getAngularVelocity(): Nullable<Vector3>;
  33693. /**
  33694. * Sets the angular velocity
  33695. * @param velocity The velocity or null
  33696. */
  33697. setAngularVelocity(velocity: Nullable<Vector3>): void;
  33698. /**
  33699. * Execute a function with the physics plugin native code
  33700. * Provide a function the will have two variables - the world object and the physics body object
  33701. * @param func The function to execute with the physics plugin native code
  33702. */
  33703. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  33704. /**
  33705. * Register a function that will be executed before the physics world is stepping forward
  33706. * @param func The function to execute before the physics world is stepped forward
  33707. */
  33708. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33709. /**
  33710. * Unregister a function that will be executed before the physics world is stepping forward
  33711. * @param func The function to execute before the physics world is stepped forward
  33712. */
  33713. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33714. /**
  33715. * Register a function that will be executed after the physics step
  33716. * @param func The function to execute after physics step
  33717. */
  33718. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33719. /**
  33720. * Unregisters a function that will be executed after the physics step
  33721. * @param func The function to execute after physics step
  33722. */
  33723. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  33724. /**
  33725. * register a function that will be executed when this impostor collides against a different body
  33726. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  33727. * @param func Callback that is executed on collision
  33728. */
  33729. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  33730. /**
  33731. * Unregisters the physics imposter on contact
  33732. * @param collideAgainst The physics object to collide against
  33733. * @param func Callback to execute on collision
  33734. */
  33735. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  33736. private _tmpQuat;
  33737. private _tmpQuat2;
  33738. /**
  33739. * Get the parent rotation
  33740. * @returns The parent rotation
  33741. */
  33742. getParentsRotation(): Quaternion;
  33743. /**
  33744. * this function is executed by the physics engine.
  33745. */
  33746. beforeStep: () => void;
  33747. /**
  33748. * this function is executed by the physics engine
  33749. */
  33750. afterStep: () => void;
  33751. /**
  33752. * Legacy collision detection event support
  33753. */
  33754. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  33755. /**
  33756. * event and body object due to cannon's event-based architecture.
  33757. */
  33758. onCollide: (e: {
  33759. body: any;
  33760. point: Nullable<Vector3>;
  33761. }) => void;
  33762. /**
  33763. * Apply a force
  33764. * @param force The force to apply
  33765. * @param contactPoint The contact point for the force
  33766. * @returns The physics imposter
  33767. */
  33768. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33769. /**
  33770. * Apply an impulse
  33771. * @param force The impulse force
  33772. * @param contactPoint The contact point for the impulse force
  33773. * @returns The physics imposter
  33774. */
  33775. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  33776. /**
  33777. * A help function to create a joint
  33778. * @param otherImpostor A physics imposter used to create a joint
  33779. * @param jointType The type of joint
  33780. * @param jointData The data for the joint
  33781. * @returns The physics imposter
  33782. */
  33783. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  33784. /**
  33785. * Add a joint to this impostor with a different impostor
  33786. * @param otherImpostor A physics imposter used to add a joint
  33787. * @param joint The joint to add
  33788. * @returns The physics imposter
  33789. */
  33790. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  33791. /**
  33792. * Add an anchor to a cloth impostor
  33793. * @param otherImpostor rigid impostor to anchor to
  33794. * @param width ratio across width from 0 to 1
  33795. * @param height ratio up height from 0 to 1
  33796. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  33797. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  33798. * @returns impostor the soft imposter
  33799. */
  33800. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33801. /**
  33802. * Add a hook to a rope impostor
  33803. * @param otherImpostor rigid impostor to anchor to
  33804. * @param length ratio across rope from 0 to 1
  33805. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  33806. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  33807. * @returns impostor the rope imposter
  33808. */
  33809. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  33810. /**
  33811. * Will keep this body still, in a sleep mode.
  33812. * @returns the physics imposter
  33813. */
  33814. sleep(): PhysicsImpostor;
  33815. /**
  33816. * Wake the body up.
  33817. * @returns The physics imposter
  33818. */
  33819. wakeUp(): PhysicsImpostor;
  33820. /**
  33821. * Clones the physics imposter
  33822. * @param newObject The physics imposter clones to this physics-enabled object
  33823. * @returns A nullable physics imposter
  33824. */
  33825. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  33826. /**
  33827. * Disposes the physics imposter
  33828. */
  33829. dispose(): void;
  33830. /**
  33831. * Sets the delta position
  33832. * @param position The delta position amount
  33833. */
  33834. setDeltaPosition(position: Vector3): void;
  33835. /**
  33836. * Sets the delta rotation
  33837. * @param rotation The delta rotation amount
  33838. */
  33839. setDeltaRotation(rotation: Quaternion): void;
  33840. /**
  33841. * Gets the box size of the physics imposter and stores the result in the input parameter
  33842. * @param result Stores the box size
  33843. * @returns The physics imposter
  33844. */
  33845. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  33846. /**
  33847. * Gets the radius of the physics imposter
  33848. * @returns Radius of the physics imposter
  33849. */
  33850. getRadius(): number;
  33851. /**
  33852. * Sync a bone with this impostor
  33853. * @param bone The bone to sync to the impostor.
  33854. * @param boneMesh The mesh that the bone is influencing.
  33855. * @param jointPivot The pivot of the joint / bone in local space.
  33856. * @param distToJoint Optional distance from the impostor to the joint.
  33857. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33858. */
  33859. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  33860. /**
  33861. * Sync impostor to a bone
  33862. * @param bone The bone that the impostor will be synced to.
  33863. * @param boneMesh The mesh that the bone is influencing.
  33864. * @param jointPivot The pivot of the joint / bone in local space.
  33865. * @param distToJoint Optional distance from the impostor to the joint.
  33866. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  33867. * @param boneAxis Optional vector3 axis the bone is aligned with
  33868. */
  33869. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  33870. /**
  33871. * No-Imposter type
  33872. */
  33873. static NoImpostor: number;
  33874. /**
  33875. * Sphere-Imposter type
  33876. */
  33877. static SphereImpostor: number;
  33878. /**
  33879. * Box-Imposter type
  33880. */
  33881. static BoxImpostor: number;
  33882. /**
  33883. * Plane-Imposter type
  33884. */
  33885. static PlaneImpostor: number;
  33886. /**
  33887. * Mesh-imposter type
  33888. */
  33889. static MeshImpostor: number;
  33890. /**
  33891. * Capsule-Impostor type (Ammo.js plugin only)
  33892. */
  33893. static CapsuleImpostor: number;
  33894. /**
  33895. * Cylinder-Imposter type
  33896. */
  33897. static CylinderImpostor: number;
  33898. /**
  33899. * Particle-Imposter type
  33900. */
  33901. static ParticleImpostor: number;
  33902. /**
  33903. * Heightmap-Imposter type
  33904. */
  33905. static HeightmapImpostor: number;
  33906. /**
  33907. * ConvexHull-Impostor type (Ammo.js plugin only)
  33908. */
  33909. static ConvexHullImpostor: number;
  33910. /**
  33911. * Custom-Imposter type (Ammo.js plugin only)
  33912. */
  33913. static CustomImpostor: number;
  33914. /**
  33915. * Rope-Imposter type
  33916. */
  33917. static RopeImpostor: number;
  33918. /**
  33919. * Cloth-Imposter type
  33920. */
  33921. static ClothImpostor: number;
  33922. /**
  33923. * Softbody-Imposter type
  33924. */
  33925. static SoftbodyImpostor: number;
  33926. }
  33927. }
  33928. declare module "babylonjs/Meshes/mesh" {
  33929. import { Observable } from "babylonjs/Misc/observable";
  33930. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33931. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  33932. import { Camera } from "babylonjs/Cameras/camera";
  33933. import { Scene } from "babylonjs/scene";
  33934. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  33935. import { Color4 } from "babylonjs/Maths/math.color";
  33936. import { Engine } from "babylonjs/Engines/engine";
  33937. import { Node } from "babylonjs/node";
  33938. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  33939. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33940. import { Buffer } from "babylonjs/Meshes/buffer";
  33941. import { Geometry } from "babylonjs/Meshes/geometry";
  33942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33943. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33944. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  33945. import { Effect } from "babylonjs/Materials/effect";
  33946. import { Material } from "babylonjs/Materials/material";
  33947. import { Skeleton } from "babylonjs/Bones/skeleton";
  33948. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33949. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  33950. import { Path3D } from "babylonjs/Maths/math.path";
  33951. import { Plane } from "babylonjs/Maths/math.plane";
  33952. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33953. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  33954. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  33955. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  33956. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  33957. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  33958. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  33959. /**
  33960. * @hidden
  33961. **/
  33962. export class _CreationDataStorage {
  33963. closePath?: boolean;
  33964. closeArray?: boolean;
  33965. idx: number[];
  33966. dashSize: number;
  33967. gapSize: number;
  33968. path3D: Path3D;
  33969. pathArray: Vector3[][];
  33970. arc: number;
  33971. radius: number;
  33972. cap: number;
  33973. tessellation: number;
  33974. }
  33975. /**
  33976. * @hidden
  33977. **/
  33978. class _InstanceDataStorage {
  33979. visibleInstances: any;
  33980. batchCache: _InstancesBatch;
  33981. instancesBufferSize: number;
  33982. instancesBuffer: Nullable<Buffer>;
  33983. instancesData: Float32Array;
  33984. overridenInstanceCount: number;
  33985. isFrozen: boolean;
  33986. previousBatch: Nullable<_InstancesBatch>;
  33987. hardwareInstancedRendering: boolean;
  33988. sideOrientation: number;
  33989. manualUpdate: boolean;
  33990. previousRenderId: number;
  33991. }
  33992. /**
  33993. * @hidden
  33994. **/
  33995. export class _InstancesBatch {
  33996. mustReturn: boolean;
  33997. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  33998. renderSelf: boolean[];
  33999. hardwareInstancedRendering: boolean[];
  34000. }
  34001. /**
  34002. * @hidden
  34003. **/
  34004. class _ThinInstanceDataStorage {
  34005. instancesCount: number;
  34006. matrixBuffer: Nullable<Buffer>;
  34007. matrixBufferSize: number;
  34008. matrixData: Nullable<Float32Array>;
  34009. boundingVectors: Array<Vector3>;
  34010. worldMatrices: Nullable<Matrix[]>;
  34011. }
  34012. /**
  34013. * Class used to represent renderable models
  34014. */
  34015. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  34016. /**
  34017. * Mesh side orientation : usually the external or front surface
  34018. */
  34019. static readonly FRONTSIDE: number;
  34020. /**
  34021. * Mesh side orientation : usually the internal or back surface
  34022. */
  34023. static readonly BACKSIDE: number;
  34024. /**
  34025. * Mesh side orientation : both internal and external or front and back surfaces
  34026. */
  34027. static readonly DOUBLESIDE: number;
  34028. /**
  34029. * Mesh side orientation : by default, `FRONTSIDE`
  34030. */
  34031. static readonly DEFAULTSIDE: number;
  34032. /**
  34033. * Mesh cap setting : no cap
  34034. */
  34035. static readonly NO_CAP: number;
  34036. /**
  34037. * Mesh cap setting : one cap at the beginning of the mesh
  34038. */
  34039. static readonly CAP_START: number;
  34040. /**
  34041. * Mesh cap setting : one cap at the end of the mesh
  34042. */
  34043. static readonly CAP_END: number;
  34044. /**
  34045. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  34046. */
  34047. static readonly CAP_ALL: number;
  34048. /**
  34049. * Mesh pattern setting : no flip or rotate
  34050. */
  34051. static readonly NO_FLIP: number;
  34052. /**
  34053. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  34054. */
  34055. static readonly FLIP_TILE: number;
  34056. /**
  34057. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  34058. */
  34059. static readonly ROTATE_TILE: number;
  34060. /**
  34061. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  34062. */
  34063. static readonly FLIP_ROW: number;
  34064. /**
  34065. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  34066. */
  34067. static readonly ROTATE_ROW: number;
  34068. /**
  34069. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  34070. */
  34071. static readonly FLIP_N_ROTATE_TILE: number;
  34072. /**
  34073. * Mesh pattern setting : rotate pattern and rotate
  34074. */
  34075. static readonly FLIP_N_ROTATE_ROW: number;
  34076. /**
  34077. * Mesh tile positioning : part tiles same on left/right or top/bottom
  34078. */
  34079. static readonly CENTER: number;
  34080. /**
  34081. * Mesh tile positioning : part tiles on left
  34082. */
  34083. static readonly LEFT: number;
  34084. /**
  34085. * Mesh tile positioning : part tiles on right
  34086. */
  34087. static readonly RIGHT: number;
  34088. /**
  34089. * Mesh tile positioning : part tiles on top
  34090. */
  34091. static readonly TOP: number;
  34092. /**
  34093. * Mesh tile positioning : part tiles on bottom
  34094. */
  34095. static readonly BOTTOM: number;
  34096. /**
  34097. * Gets the default side orientation.
  34098. * @param orientation the orientation to value to attempt to get
  34099. * @returns the default orientation
  34100. * @hidden
  34101. */
  34102. static _GetDefaultSideOrientation(orientation?: number): number;
  34103. private _internalMeshDataInfo;
  34104. get computeBonesUsingShaders(): boolean;
  34105. set computeBonesUsingShaders(value: boolean);
  34106. /**
  34107. * An event triggered before rendering the mesh
  34108. */
  34109. get onBeforeRenderObservable(): Observable<Mesh>;
  34110. /**
  34111. * An event triggered before binding the mesh
  34112. */
  34113. get onBeforeBindObservable(): Observable<Mesh>;
  34114. /**
  34115. * An event triggered after rendering the mesh
  34116. */
  34117. get onAfterRenderObservable(): Observable<Mesh>;
  34118. /**
  34119. * An event triggered before drawing the mesh
  34120. */
  34121. get onBeforeDrawObservable(): Observable<Mesh>;
  34122. private _onBeforeDrawObserver;
  34123. /**
  34124. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  34125. */
  34126. set onBeforeDraw(callback: () => void);
  34127. get hasInstances(): boolean;
  34128. get hasThinInstances(): boolean;
  34129. /**
  34130. * Gets the delay loading state of the mesh (when delay loading is turned on)
  34131. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  34132. */
  34133. delayLoadState: number;
  34134. /**
  34135. * Gets the list of instances created from this mesh
  34136. * it is not supposed to be modified manually.
  34137. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  34138. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34139. */
  34140. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  34141. /**
  34142. * Gets the file containing delay loading data for this mesh
  34143. */
  34144. delayLoadingFile: string;
  34145. /** @hidden */
  34146. _binaryInfo: any;
  34147. /**
  34148. * User defined function used to change how LOD level selection is done
  34149. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34150. */
  34151. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  34152. /**
  34153. * Gets or sets the morph target manager
  34154. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  34155. */
  34156. get morphTargetManager(): Nullable<MorphTargetManager>;
  34157. set morphTargetManager(value: Nullable<MorphTargetManager>);
  34158. /** @hidden */
  34159. _creationDataStorage: Nullable<_CreationDataStorage>;
  34160. /** @hidden */
  34161. _geometry: Nullable<Geometry>;
  34162. /** @hidden */
  34163. _delayInfo: Array<string>;
  34164. /** @hidden */
  34165. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  34166. /** @hidden */
  34167. _instanceDataStorage: _InstanceDataStorage;
  34168. /** @hidden */
  34169. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  34170. private _effectiveMaterial;
  34171. /** @hidden */
  34172. _shouldGenerateFlatShading: boolean;
  34173. /** @hidden */
  34174. _originalBuilderSideOrientation: number;
  34175. /**
  34176. * Use this property to change the original side orientation defined at construction time
  34177. */
  34178. overrideMaterialSideOrientation: Nullable<number>;
  34179. /**
  34180. * Gets the source mesh (the one used to clone this one from)
  34181. */
  34182. get source(): Nullable<Mesh>;
  34183. /**
  34184. * Gets the list of clones of this mesh
  34185. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  34186. * Note that useClonedMeshMap=true is the default setting
  34187. */
  34188. get cloneMeshMap(): Nullable<{
  34189. [id: string]: Mesh | undefined;
  34190. }>;
  34191. /**
  34192. * Gets or sets a boolean indicating that this mesh does not use index buffer
  34193. */
  34194. get isUnIndexed(): boolean;
  34195. set isUnIndexed(value: boolean);
  34196. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  34197. get worldMatrixInstancedBuffer(): Float32Array;
  34198. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  34199. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  34200. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  34201. /**
  34202. * @constructor
  34203. * @param name The value used by scene.getMeshByName() to do a lookup.
  34204. * @param scene The scene to add this mesh to.
  34205. * @param parent The parent of this mesh, if it has one
  34206. * @param source An optional Mesh from which geometry is shared, cloned.
  34207. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  34208. * When false, achieved by calling a clone(), also passing False.
  34209. * This will make creation of children, recursive.
  34210. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  34211. */
  34212. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  34213. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  34214. doNotInstantiate: boolean;
  34215. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  34216. /**
  34217. * Gets the class name
  34218. * @returns the string "Mesh".
  34219. */
  34220. getClassName(): string;
  34221. /** @hidden */
  34222. get _isMesh(): boolean;
  34223. /**
  34224. * Returns a description of this mesh
  34225. * @param fullDetails define if full details about this mesh must be used
  34226. * @returns a descriptive string representing this mesh
  34227. */
  34228. toString(fullDetails?: boolean): string;
  34229. /** @hidden */
  34230. _unBindEffect(): void;
  34231. /**
  34232. * Gets a boolean indicating if this mesh has LOD
  34233. */
  34234. get hasLODLevels(): boolean;
  34235. /**
  34236. * Gets the list of MeshLODLevel associated with the current mesh
  34237. * @returns an array of MeshLODLevel
  34238. */
  34239. getLODLevels(): MeshLODLevel[];
  34240. private _sortLODLevels;
  34241. /**
  34242. * Add a mesh as LOD level triggered at the given distance.
  34243. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34244. * @param distance The distance from the center of the object to show this level
  34245. * @param mesh The mesh to be added as LOD level (can be null)
  34246. * @return This mesh (for chaining)
  34247. */
  34248. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  34249. /**
  34250. * Returns the LOD level mesh at the passed distance or null if not found.
  34251. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34252. * @param distance The distance from the center of the object to show this level
  34253. * @returns a Mesh or `null`
  34254. */
  34255. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  34256. /**
  34257. * Remove a mesh from the LOD array
  34258. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34259. * @param mesh defines the mesh to be removed
  34260. * @return This mesh (for chaining)
  34261. */
  34262. removeLODLevel(mesh: Mesh): Mesh;
  34263. /**
  34264. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  34265. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  34266. * @param camera defines the camera to use to compute distance
  34267. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  34268. * @return This mesh (for chaining)
  34269. */
  34270. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  34271. /**
  34272. * Gets the mesh internal Geometry object
  34273. */
  34274. get geometry(): Nullable<Geometry>;
  34275. /**
  34276. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  34277. * @returns the total number of vertices
  34278. */
  34279. getTotalVertices(): number;
  34280. /**
  34281. * Returns the content of an associated vertex buffer
  34282. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34283. * - VertexBuffer.PositionKind
  34284. * - VertexBuffer.UVKind
  34285. * - VertexBuffer.UV2Kind
  34286. * - VertexBuffer.UV3Kind
  34287. * - VertexBuffer.UV4Kind
  34288. * - VertexBuffer.UV5Kind
  34289. * - VertexBuffer.UV6Kind
  34290. * - VertexBuffer.ColorKind
  34291. * - VertexBuffer.MatricesIndicesKind
  34292. * - VertexBuffer.MatricesIndicesExtraKind
  34293. * - VertexBuffer.MatricesWeightsKind
  34294. * - VertexBuffer.MatricesWeightsExtraKind
  34295. * @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
  34296. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  34297. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  34298. */
  34299. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  34300. /**
  34301. * Returns the mesh VertexBuffer object from the requested `kind`
  34302. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34303. * - VertexBuffer.PositionKind
  34304. * - VertexBuffer.NormalKind
  34305. * - VertexBuffer.UVKind
  34306. * - VertexBuffer.UV2Kind
  34307. * - VertexBuffer.UV3Kind
  34308. * - VertexBuffer.UV4Kind
  34309. * - VertexBuffer.UV5Kind
  34310. * - VertexBuffer.UV6Kind
  34311. * - VertexBuffer.ColorKind
  34312. * - VertexBuffer.MatricesIndicesKind
  34313. * - VertexBuffer.MatricesIndicesExtraKind
  34314. * - VertexBuffer.MatricesWeightsKind
  34315. * - VertexBuffer.MatricesWeightsExtraKind
  34316. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  34317. */
  34318. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  34319. /**
  34320. * Tests if a specific vertex buffer is associated with this mesh
  34321. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34322. * - VertexBuffer.PositionKind
  34323. * - VertexBuffer.NormalKind
  34324. * - VertexBuffer.UVKind
  34325. * - VertexBuffer.UV2Kind
  34326. * - VertexBuffer.UV3Kind
  34327. * - VertexBuffer.UV4Kind
  34328. * - VertexBuffer.UV5Kind
  34329. * - VertexBuffer.UV6Kind
  34330. * - VertexBuffer.ColorKind
  34331. * - VertexBuffer.MatricesIndicesKind
  34332. * - VertexBuffer.MatricesIndicesExtraKind
  34333. * - VertexBuffer.MatricesWeightsKind
  34334. * - VertexBuffer.MatricesWeightsExtraKind
  34335. * @returns a boolean
  34336. */
  34337. isVerticesDataPresent(kind: string): boolean;
  34338. /**
  34339. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  34340. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  34341. * - VertexBuffer.PositionKind
  34342. * - VertexBuffer.UVKind
  34343. * - VertexBuffer.UV2Kind
  34344. * - VertexBuffer.UV3Kind
  34345. * - VertexBuffer.UV4Kind
  34346. * - VertexBuffer.UV5Kind
  34347. * - VertexBuffer.UV6Kind
  34348. * - VertexBuffer.ColorKind
  34349. * - VertexBuffer.MatricesIndicesKind
  34350. * - VertexBuffer.MatricesIndicesExtraKind
  34351. * - VertexBuffer.MatricesWeightsKind
  34352. * - VertexBuffer.MatricesWeightsExtraKind
  34353. * @returns a boolean
  34354. */
  34355. isVertexBufferUpdatable(kind: string): boolean;
  34356. /**
  34357. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  34358. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  34359. * - VertexBuffer.PositionKind
  34360. * - VertexBuffer.NormalKind
  34361. * - VertexBuffer.UVKind
  34362. * - VertexBuffer.UV2Kind
  34363. * - VertexBuffer.UV3Kind
  34364. * - VertexBuffer.UV4Kind
  34365. * - VertexBuffer.UV5Kind
  34366. * - VertexBuffer.UV6Kind
  34367. * - VertexBuffer.ColorKind
  34368. * - VertexBuffer.MatricesIndicesKind
  34369. * - VertexBuffer.MatricesIndicesExtraKind
  34370. * - VertexBuffer.MatricesWeightsKind
  34371. * - VertexBuffer.MatricesWeightsExtraKind
  34372. * @returns an array of strings
  34373. */
  34374. getVerticesDataKinds(): string[];
  34375. /**
  34376. * Returns a positive integer : the total number of indices in this mesh geometry.
  34377. * @returns the numner of indices or zero if the mesh has no geometry.
  34378. */
  34379. getTotalIndices(): number;
  34380. /**
  34381. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  34382. * @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.
  34383. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  34384. * @returns the indices array or an empty array if the mesh has no geometry
  34385. */
  34386. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  34387. get isBlocked(): boolean;
  34388. /**
  34389. * Determine if the current mesh is ready to be rendered
  34390. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34391. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  34392. * @returns true if all associated assets are ready (material, textures, shaders)
  34393. */
  34394. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  34395. /**
  34396. * 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.
  34397. */
  34398. get areNormalsFrozen(): boolean;
  34399. /**
  34400. * 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.
  34401. * @returns the current mesh
  34402. */
  34403. freezeNormals(): Mesh;
  34404. /**
  34405. * 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
  34406. * @returns the current mesh
  34407. */
  34408. unfreezeNormals(): Mesh;
  34409. /**
  34410. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  34411. */
  34412. set overridenInstanceCount(count: number);
  34413. /** @hidden */
  34414. _preActivate(): Mesh;
  34415. /** @hidden */
  34416. _preActivateForIntermediateRendering(renderId: number): Mesh;
  34417. /** @hidden */
  34418. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  34419. protected _afterComputeWorldMatrix(): void;
  34420. /** @hidden */
  34421. _postActivate(): void;
  34422. /**
  34423. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  34424. * This means the mesh underlying bounding box and sphere are recomputed.
  34425. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  34426. * @returns the current mesh
  34427. */
  34428. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  34429. /** @hidden */
  34430. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  34431. /**
  34432. * This function will subdivide the mesh into multiple submeshes
  34433. * @param count defines the expected number of submeshes
  34434. */
  34435. subdivide(count: number): void;
  34436. /**
  34437. * Copy a FloatArray into a specific associated vertex buffer
  34438. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34439. * - VertexBuffer.PositionKind
  34440. * - VertexBuffer.UVKind
  34441. * - VertexBuffer.UV2Kind
  34442. * - VertexBuffer.UV3Kind
  34443. * - VertexBuffer.UV4Kind
  34444. * - VertexBuffer.UV5Kind
  34445. * - VertexBuffer.UV6Kind
  34446. * - VertexBuffer.ColorKind
  34447. * - VertexBuffer.MatricesIndicesKind
  34448. * - VertexBuffer.MatricesIndicesExtraKind
  34449. * - VertexBuffer.MatricesWeightsKind
  34450. * - VertexBuffer.MatricesWeightsExtraKind
  34451. * @param data defines the data source
  34452. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34453. * @param stride defines the data stride size (can be null)
  34454. * @returns the current mesh
  34455. */
  34456. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  34457. /**
  34458. * Delete a vertex buffer associated with this mesh
  34459. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  34460. * - VertexBuffer.PositionKind
  34461. * - VertexBuffer.UVKind
  34462. * - VertexBuffer.UV2Kind
  34463. * - VertexBuffer.UV3Kind
  34464. * - VertexBuffer.UV4Kind
  34465. * - VertexBuffer.UV5Kind
  34466. * - VertexBuffer.UV6Kind
  34467. * - VertexBuffer.ColorKind
  34468. * - VertexBuffer.MatricesIndicesKind
  34469. * - VertexBuffer.MatricesIndicesExtraKind
  34470. * - VertexBuffer.MatricesWeightsKind
  34471. * - VertexBuffer.MatricesWeightsExtraKind
  34472. */
  34473. removeVerticesData(kind: string): void;
  34474. /**
  34475. * Flags an associated vertex buffer as updatable
  34476. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  34477. * - VertexBuffer.PositionKind
  34478. * - VertexBuffer.UVKind
  34479. * - VertexBuffer.UV2Kind
  34480. * - VertexBuffer.UV3Kind
  34481. * - VertexBuffer.UV4Kind
  34482. * - VertexBuffer.UV5Kind
  34483. * - VertexBuffer.UV6Kind
  34484. * - VertexBuffer.ColorKind
  34485. * - VertexBuffer.MatricesIndicesKind
  34486. * - VertexBuffer.MatricesIndicesExtraKind
  34487. * - VertexBuffer.MatricesWeightsKind
  34488. * - VertexBuffer.MatricesWeightsExtraKind
  34489. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  34490. */
  34491. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  34492. /**
  34493. * Sets the mesh global Vertex Buffer
  34494. * @param buffer defines the buffer to use
  34495. * @returns the current mesh
  34496. */
  34497. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  34498. /**
  34499. * Update a specific associated vertex buffer
  34500. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  34501. * - VertexBuffer.PositionKind
  34502. * - VertexBuffer.UVKind
  34503. * - VertexBuffer.UV2Kind
  34504. * - VertexBuffer.UV3Kind
  34505. * - VertexBuffer.UV4Kind
  34506. * - VertexBuffer.UV5Kind
  34507. * - VertexBuffer.UV6Kind
  34508. * - VertexBuffer.ColorKind
  34509. * - VertexBuffer.MatricesIndicesKind
  34510. * - VertexBuffer.MatricesIndicesExtraKind
  34511. * - VertexBuffer.MatricesWeightsKind
  34512. * - VertexBuffer.MatricesWeightsExtraKind
  34513. * @param data defines the data source
  34514. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  34515. * @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)
  34516. * @returns the current mesh
  34517. */
  34518. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  34519. /**
  34520. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  34521. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  34522. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  34523. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  34524. * @returns the current mesh
  34525. */
  34526. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  34527. /**
  34528. * Creates a un-shared specific occurence of the geometry for the mesh.
  34529. * @returns the current mesh
  34530. */
  34531. makeGeometryUnique(): Mesh;
  34532. /**
  34533. * Set the index buffer of this mesh
  34534. * @param indices defines the source data
  34535. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  34536. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  34537. * @returns the current mesh
  34538. */
  34539. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  34540. /**
  34541. * Update the current index buffer
  34542. * @param indices defines the source data
  34543. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34544. * @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)
  34545. * @returns the current mesh
  34546. */
  34547. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34548. /**
  34549. * Invert the geometry to move from a right handed system to a left handed one.
  34550. * @returns the current mesh
  34551. */
  34552. toLeftHanded(): Mesh;
  34553. /** @hidden */
  34554. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  34555. /** @hidden */
  34556. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  34557. /**
  34558. * Registers for this mesh a javascript function called just before the rendering process
  34559. * @param func defines the function to call before rendering this mesh
  34560. * @returns the current mesh
  34561. */
  34562. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34563. /**
  34564. * Disposes a previously registered javascript function called before the rendering
  34565. * @param func defines the function to remove
  34566. * @returns the current mesh
  34567. */
  34568. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  34569. /**
  34570. * Registers for this mesh a javascript function called just after the rendering is complete
  34571. * @param func defines the function to call after rendering this mesh
  34572. * @returns the current mesh
  34573. */
  34574. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34575. /**
  34576. * Disposes a previously registered javascript function called after the rendering.
  34577. * @param func defines the function to remove
  34578. * @returns the current mesh
  34579. */
  34580. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  34581. /** @hidden */
  34582. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  34583. /** @hidden */
  34584. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  34585. /** @hidden */
  34586. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  34587. /** @hidden */
  34588. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  34589. /** @hidden */
  34590. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  34591. /** @hidden */
  34592. _rebuild(): void;
  34593. /** @hidden */
  34594. _freeze(): void;
  34595. /** @hidden */
  34596. _unFreeze(): void;
  34597. /**
  34598. * 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
  34599. * @param subMesh defines the subMesh to render
  34600. * @param enableAlphaMode defines if alpha mode can be changed
  34601. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  34602. * @returns the current mesh
  34603. */
  34604. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  34605. private _onBeforeDraw;
  34606. /**
  34607. * Renormalize the mesh and patch it up if there are no weights
  34608. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  34609. * However in the case of zero weights then we set just a single influence to 1.
  34610. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  34611. */
  34612. cleanMatrixWeights(): void;
  34613. private normalizeSkinFourWeights;
  34614. private normalizeSkinWeightsAndExtra;
  34615. /**
  34616. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  34617. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  34618. * the user know there was an issue with importing the mesh
  34619. * @returns a validation object with skinned, valid and report string
  34620. */
  34621. validateSkinning(): {
  34622. skinned: boolean;
  34623. valid: boolean;
  34624. report: string;
  34625. };
  34626. /** @hidden */
  34627. _checkDelayState(): Mesh;
  34628. private _queueLoad;
  34629. /**
  34630. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  34631. * A mesh is in the frustum if its bounding box intersects the frustum
  34632. * @param frustumPlanes defines the frustum to test
  34633. * @returns true if the mesh is in the frustum planes
  34634. */
  34635. isInFrustum(frustumPlanes: Plane[]): boolean;
  34636. /**
  34637. * Sets the mesh material by the material or multiMaterial `id` property
  34638. * @param id is a string identifying the material or the multiMaterial
  34639. * @returns the current mesh
  34640. */
  34641. setMaterialByID(id: string): Mesh;
  34642. /**
  34643. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  34644. * @returns an array of IAnimatable
  34645. */
  34646. getAnimatables(): IAnimatable[];
  34647. /**
  34648. * Modifies the mesh geometry according to the passed transformation matrix.
  34649. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  34650. * The mesh normals are modified using the same transformation.
  34651. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34652. * @param transform defines the transform matrix to use
  34653. * @see https://doc.babylonjs.com/resources/baking_transformations
  34654. * @returns the current mesh
  34655. */
  34656. bakeTransformIntoVertices(transform: Matrix): Mesh;
  34657. /**
  34658. * Modifies the mesh geometry according to its own current World Matrix.
  34659. * The mesh World Matrix is then reset.
  34660. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  34661. * Note that, under the hood, this method sets a new VertexBuffer each call.
  34662. * @see https://doc.babylonjs.com/resources/baking_transformations
  34663. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  34664. * @returns the current mesh
  34665. */
  34666. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  34667. /** @hidden */
  34668. get _positions(): Nullable<Vector3[]>;
  34669. /** @hidden */
  34670. _resetPointsArrayCache(): Mesh;
  34671. /** @hidden */
  34672. _generatePointsArray(): boolean;
  34673. /**
  34674. * Returns a new Mesh object generated from the current mesh properties.
  34675. * This method must not get confused with createInstance()
  34676. * @param name is a string, the name given to the new mesh
  34677. * @param newParent can be any Node object (default `null`)
  34678. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  34679. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  34680. * @returns a new mesh
  34681. */
  34682. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  34683. /**
  34684. * Releases resources associated with this mesh.
  34685. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34686. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34687. */
  34688. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34689. /** @hidden */
  34690. _disposeInstanceSpecificData(): void;
  34691. /** @hidden */
  34692. _disposeThinInstanceSpecificData(): void;
  34693. /**
  34694. * Modifies the mesh geometry according to a displacement map.
  34695. * 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.
  34696. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34697. * @param url is a string, the URL from the image file is to be downloaded.
  34698. * @param minHeight is the lower limit of the displacement.
  34699. * @param maxHeight is the upper limit of the displacement.
  34700. * @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.
  34701. * @param uvOffset is an optional vector2 used to offset UV.
  34702. * @param uvScale is an optional vector2 used to scale UV.
  34703. * @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.
  34704. * @returns the Mesh.
  34705. */
  34706. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34707. /**
  34708. * Modifies the mesh geometry according to a displacementMap buffer.
  34709. * 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.
  34710. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  34711. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  34712. * @param heightMapWidth is the width of the buffer image.
  34713. * @param heightMapHeight is the height of the buffer image.
  34714. * @param minHeight is the lower limit of the displacement.
  34715. * @param maxHeight is the upper limit of the displacement.
  34716. * @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.
  34717. * @param uvOffset is an optional vector2 used to offset UV.
  34718. * @param uvScale is an optional vector2 used to scale UV.
  34719. * @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.
  34720. * @returns the Mesh.
  34721. */
  34722. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  34723. /**
  34724. * Modify the mesh to get a flat shading rendering.
  34725. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  34726. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  34727. * @returns current mesh
  34728. */
  34729. convertToFlatShadedMesh(): Mesh;
  34730. /**
  34731. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  34732. * In other words, more vertices, no more indices and a single bigger VBO.
  34733. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  34734. * @returns current mesh
  34735. */
  34736. convertToUnIndexedMesh(): Mesh;
  34737. /**
  34738. * Inverses facet orientations.
  34739. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34740. * @param flipNormals will also inverts the normals
  34741. * @returns current mesh
  34742. */
  34743. flipFaces(flipNormals?: boolean): Mesh;
  34744. /**
  34745. * Increase the number of facets and hence vertices in a mesh
  34746. * Vertex normals are interpolated from existing vertex normals
  34747. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34748. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  34749. */
  34750. increaseVertices(numberPerEdge: number): void;
  34751. /**
  34752. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  34753. * This will undo any application of covertToFlatShadedMesh
  34754. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  34755. */
  34756. forceSharedVertices(): void;
  34757. /** @hidden */
  34758. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  34759. /** @hidden */
  34760. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  34761. /**
  34762. * Creates a new InstancedMesh object from the mesh model.
  34763. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  34764. * @param name defines the name of the new instance
  34765. * @returns a new InstancedMesh
  34766. */
  34767. createInstance(name: string): InstancedMesh;
  34768. /**
  34769. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  34770. * After this call, all the mesh instances have the same submeshes than the current mesh.
  34771. * @returns the current mesh
  34772. */
  34773. synchronizeInstances(): Mesh;
  34774. /**
  34775. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  34776. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  34777. * This should be used together with the simplification to avoid disappearing triangles.
  34778. * @param successCallback an optional success callback to be called after the optimization finished.
  34779. * @returns the current mesh
  34780. */
  34781. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  34782. /**
  34783. * Serialize current mesh
  34784. * @param serializationObject defines the object which will receive the serialization data
  34785. */
  34786. serialize(serializationObject: any): void;
  34787. /** @hidden */
  34788. _syncGeometryWithMorphTargetManager(): void;
  34789. /** @hidden */
  34790. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  34791. /**
  34792. * Returns a new Mesh object parsed from the source provided.
  34793. * @param parsedMesh is the source
  34794. * @param scene defines the hosting scene
  34795. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  34796. * @returns a new Mesh
  34797. */
  34798. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  34799. /**
  34800. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  34801. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34802. * @param name defines the name of the mesh to create
  34803. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  34804. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  34805. * @param closePath creates a seam between the first and the last points of each path of the path array
  34806. * @param offset is taken in account only if the `pathArray` is containing a single path
  34807. * @param scene defines the hosting scene
  34808. * @param updatable defines if the mesh must be flagged as updatable
  34809. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34810. * @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)
  34811. * @returns a new Mesh
  34812. */
  34813. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34814. /**
  34815. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  34816. * @param name defines the name of the mesh to create
  34817. * @param radius sets the radius size (float) of the polygon (default 0.5)
  34818. * @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
  34819. * @param scene defines the hosting scene
  34820. * @param updatable defines if the mesh must be flagged as updatable
  34821. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34822. * @returns a new Mesh
  34823. */
  34824. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34825. /**
  34826. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  34827. * @param name defines the name of the mesh to create
  34828. * @param size sets the size (float) of each box side (default 1)
  34829. * @param scene defines the hosting scene
  34830. * @param updatable defines if the mesh must be flagged as updatable
  34831. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34832. * @returns a new Mesh
  34833. */
  34834. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  34835. /**
  34836. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  34837. * @param name defines the name of the mesh to create
  34838. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34839. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34840. * @param scene defines the hosting scene
  34841. * @param updatable defines if the mesh must be flagged as updatable
  34842. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34843. * @returns a new Mesh
  34844. */
  34845. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34846. /**
  34847. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  34848. * @param name defines the name of the mesh to create
  34849. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  34850. * @param diameter sets the diameter size (float) of the sphere (default 1)
  34851. * @param scene defines the hosting scene
  34852. * @returns a new Mesh
  34853. */
  34854. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  34855. /**
  34856. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  34857. * @param name defines the name of the mesh to create
  34858. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  34859. * @param diameterTop set the top cap diameter (floats, default 1)
  34860. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  34861. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  34862. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  34863. * @param scene defines the hosting scene
  34864. * @param updatable defines if the mesh must be flagged as updatable
  34865. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34866. * @returns a new Mesh
  34867. */
  34868. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  34869. /**
  34870. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  34871. * @param name defines the name of the mesh to create
  34872. * @param diameter sets the diameter size (float) of the torus (default 1)
  34873. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  34874. * @param tessellation sets the number of torus sides (postive integer, default 16)
  34875. * @param scene defines the hosting scene
  34876. * @param updatable defines if the mesh must be flagged as updatable
  34877. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34878. * @returns a new Mesh
  34879. */
  34880. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34881. /**
  34882. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  34883. * @param name defines the name of the mesh to create
  34884. * @param radius sets the global radius size (float) of the torus knot (default 2)
  34885. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  34886. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  34887. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  34888. * @param p the number of windings on X axis (positive integers, default 2)
  34889. * @param q the number of windings on Y axis (positive integers, default 3)
  34890. * @param scene defines the hosting scene
  34891. * @param updatable defines if the mesh must be flagged as updatable
  34892. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34893. * @returns a new Mesh
  34894. */
  34895. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  34896. /**
  34897. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  34898. * @param name defines the name of the mesh to create
  34899. * @param points is an array successive Vector3
  34900. * @param scene defines the hosting scene
  34901. * @param updatable defines if the mesh must be flagged as updatable
  34902. * @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).
  34903. * @returns a new Mesh
  34904. */
  34905. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  34906. /**
  34907. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  34908. * @param name defines the name of the mesh to create
  34909. * @param points is an array successive Vector3
  34910. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  34911. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  34912. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  34913. * @param scene defines the hosting scene
  34914. * @param updatable defines if the mesh must be flagged as updatable
  34915. * @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)
  34916. * @returns a new Mesh
  34917. */
  34918. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  34919. /**
  34920. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  34921. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  34922. * 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.
  34923. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  34924. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  34925. * Remember you can only change the shape positions, not their number when updating a polygon.
  34926. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  34927. * @param name defines the name of the mesh to create
  34928. * @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
  34929. * @param scene defines the hosting scene
  34930. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34931. * @param updatable defines if the mesh must be flagged as updatable
  34932. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34933. * @param earcutInjection can be used to inject your own earcut reference
  34934. * @returns a new Mesh
  34935. */
  34936. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34937. /**
  34938. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  34939. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  34940. * @param name defines the name of the mesh to create
  34941. * @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
  34942. * @param depth defines the height of extrusion
  34943. * @param scene defines the hosting scene
  34944. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  34945. * @param updatable defines if the mesh must be flagged as updatable
  34946. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34947. * @param earcutInjection can be used to inject your own earcut reference
  34948. * @returns a new Mesh
  34949. */
  34950. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  34951. /**
  34952. * Creates an extruded shape mesh.
  34953. * 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
  34954. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  34955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34956. * @param name defines the name of the mesh to create
  34957. * @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
  34958. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34959. * @param scale is the value to scale the shape
  34960. * @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
  34961. * @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
  34962. * @param scene defines the hosting scene
  34963. * @param updatable defines if the mesh must be flagged as updatable
  34964. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34965. * @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)
  34966. * @returns a new Mesh
  34967. */
  34968. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  34969. /**
  34970. * Creates an custom extruded shape mesh.
  34971. * The custom extrusion is a parametric shape.
  34972. * It has no predefined shape. Its final shape will depend on the input parameters.
  34973. * Please consider using the same method from the MeshBuilder class instead
  34974. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  34975. * @param name defines the name of the mesh to create
  34976. * @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
  34977. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  34978. * @param scaleFunction is a custom Javascript function called on each path point
  34979. * @param rotationFunction is a custom Javascript function called on each path point
  34980. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  34981. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  34982. * @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
  34983. * @param scene defines the hosting scene
  34984. * @param updatable defines if the mesh must be flagged as updatable
  34985. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  34986. * @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)
  34987. * @returns a new Mesh
  34988. */
  34989. 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;
  34990. /**
  34991. * Creates lathe mesh.
  34992. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  34993. * Please consider using the same method from the MeshBuilder class instead
  34994. * @param name defines the name of the mesh to create
  34995. * @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
  34996. * @param radius is the radius value of the lathe
  34997. * @param tessellation is the side number of the lathe.
  34998. * @param scene defines the hosting scene
  34999. * @param updatable defines if the mesh must be flagged as updatable
  35000. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35001. * @returns a new Mesh
  35002. */
  35003. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35004. /**
  35005. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  35006. * @param name defines the name of the mesh to create
  35007. * @param size sets the size (float) of both sides of the plane at once (default 1)
  35008. * @param scene defines the hosting scene
  35009. * @param updatable defines if the mesh must be flagged as updatable
  35010. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35011. * @returns a new Mesh
  35012. */
  35013. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  35014. /**
  35015. * Creates a ground mesh.
  35016. * Please consider using the same method from the MeshBuilder class instead
  35017. * @param name defines the name of the mesh to create
  35018. * @param width set the width of the ground
  35019. * @param height set the height of the ground
  35020. * @param subdivisions sets the number of subdivisions per side
  35021. * @param scene defines the hosting scene
  35022. * @param updatable defines if the mesh must be flagged as updatable
  35023. * @returns a new Mesh
  35024. */
  35025. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  35026. /**
  35027. * Creates a tiled ground mesh.
  35028. * Please consider using the same method from the MeshBuilder class instead
  35029. * @param name defines the name of the mesh to create
  35030. * @param xmin set the ground minimum X coordinate
  35031. * @param zmin set the ground minimum Y coordinate
  35032. * @param xmax set the ground maximum X coordinate
  35033. * @param zmax set the ground maximum Z coordinate
  35034. * @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
  35035. * @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
  35036. * @param scene defines the hosting scene
  35037. * @param updatable defines if the mesh must be flagged as updatable
  35038. * @returns a new Mesh
  35039. */
  35040. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  35041. w: number;
  35042. h: number;
  35043. }, precision: {
  35044. w: number;
  35045. h: number;
  35046. }, scene: Scene, updatable?: boolean): Mesh;
  35047. /**
  35048. * Creates a ground mesh from a height map.
  35049. * Please consider using the same method from the MeshBuilder class instead
  35050. * @see https://doc.babylonjs.com/babylon101/height_map
  35051. * @param name defines the name of the mesh to create
  35052. * @param url sets the URL of the height map image resource
  35053. * @param width set the ground width size
  35054. * @param height set the ground height size
  35055. * @param subdivisions sets the number of subdivision per side
  35056. * @param minHeight is the minimum altitude on the ground
  35057. * @param maxHeight is the maximum altitude on the ground
  35058. * @param scene defines the hosting scene
  35059. * @param updatable defines if the mesh must be flagged as updatable
  35060. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  35061. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  35062. * @returns a new Mesh
  35063. */
  35064. 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;
  35065. /**
  35066. * Creates a tube mesh.
  35067. * The tube is a parametric shape.
  35068. * It has no predefined shape. Its final shape will depend on the input parameters.
  35069. * Please consider using the same method from the MeshBuilder class instead
  35070. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  35071. * @param name defines the name of the mesh to create
  35072. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  35073. * @param radius sets the tube radius size
  35074. * @param tessellation is the number of sides on the tubular surface
  35075. * @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
  35076. * @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
  35077. * @param scene defines the hosting scene
  35078. * @param updatable defines if the mesh must be flagged as updatable
  35079. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  35080. * @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)
  35081. * @returns a new Mesh
  35082. */
  35083. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  35084. (i: number, distance: number): number;
  35085. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  35086. /**
  35087. * Creates a polyhedron mesh.
  35088. * Please consider using the same method from the MeshBuilder class instead.
  35089. * * 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
  35090. * * The parameter `size` (positive float, default 1) sets the polygon size
  35091. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  35092. * * 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`
  35093. * * 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
  35094. * * 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)`)
  35095. * * 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
  35096. * * 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
  35097. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35098. * * 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
  35099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35100. * @param name defines the name of the mesh to create
  35101. * @param options defines the options used to create the mesh
  35102. * @param scene defines the hosting scene
  35103. * @returns a new Mesh
  35104. */
  35105. static CreatePolyhedron(name: string, options: {
  35106. type?: number;
  35107. size?: number;
  35108. sizeX?: number;
  35109. sizeY?: number;
  35110. sizeZ?: number;
  35111. custom?: any;
  35112. faceUV?: Vector4[];
  35113. faceColors?: Color4[];
  35114. updatable?: boolean;
  35115. sideOrientation?: number;
  35116. }, scene: Scene): Mesh;
  35117. /**
  35118. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  35119. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  35120. * * 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`)
  35121. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  35122. * * 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
  35123. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  35124. * * 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
  35125. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35126. * @param name defines the name of the mesh
  35127. * @param options defines the options used to create the mesh
  35128. * @param scene defines the hosting scene
  35129. * @returns a new Mesh
  35130. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  35131. */
  35132. static CreateIcoSphere(name: string, options: {
  35133. radius?: number;
  35134. flat?: boolean;
  35135. subdivisions?: number;
  35136. sideOrientation?: number;
  35137. updatable?: boolean;
  35138. }, scene: Scene): Mesh;
  35139. /**
  35140. * Creates a decal mesh.
  35141. * Please consider using the same method from the MeshBuilder class instead.
  35142. * A decal is a mesh usually applied as a model onto the surface of another mesh
  35143. * @param name defines the name of the mesh
  35144. * @param sourceMesh defines the mesh receiving the decal
  35145. * @param position sets the position of the decal in world coordinates
  35146. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  35147. * @param size sets the decal scaling
  35148. * @param angle sets the angle to rotate the decal
  35149. * @returns a new Mesh
  35150. */
  35151. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  35152. /** Creates a Capsule Mesh
  35153. * @param name defines the name of the mesh.
  35154. * @param options the constructors options used to shape the mesh.
  35155. * @param scene defines the scene the mesh is scoped to.
  35156. * @returns the capsule mesh
  35157. * @see https://doc.babylonjs.com/how_to/capsule_shape
  35158. */
  35159. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  35160. /**
  35161. * Prepare internal position array for software CPU skinning
  35162. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  35163. */
  35164. setPositionsForCPUSkinning(): Float32Array;
  35165. /**
  35166. * Prepare internal normal array for software CPU skinning
  35167. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  35168. */
  35169. setNormalsForCPUSkinning(): Float32Array;
  35170. /**
  35171. * Updates the vertex buffer by applying transformation from the bones
  35172. * @param skeleton defines the skeleton to apply to current mesh
  35173. * @returns the current mesh
  35174. */
  35175. applySkeleton(skeleton: Skeleton): Mesh;
  35176. /**
  35177. * 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
  35178. * @param meshes defines the list of meshes to scan
  35179. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  35180. */
  35181. static MinMax(meshes: AbstractMesh[]): {
  35182. min: Vector3;
  35183. max: Vector3;
  35184. };
  35185. /**
  35186. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  35187. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  35188. * @returns a vector3
  35189. */
  35190. static Center(meshesOrMinMaxVector: {
  35191. min: Vector3;
  35192. max: Vector3;
  35193. } | AbstractMesh[]): Vector3;
  35194. /**
  35195. * Merge the array of meshes into a single mesh for performance reasons.
  35196. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  35197. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  35198. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  35199. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  35200. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  35201. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  35202. * @returns a new mesh
  35203. */
  35204. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  35205. /** @hidden */
  35206. addInstance(instance: InstancedMesh): void;
  35207. /** @hidden */
  35208. removeInstance(instance: InstancedMesh): void;
  35209. }
  35210. }
  35211. declare module "babylonjs/Cameras/camera" {
  35212. import { SmartArray } from "babylonjs/Misc/smartArray";
  35213. import { Observable } from "babylonjs/Misc/observable";
  35214. import { Nullable } from "babylonjs/types";
  35215. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35216. import { Scene } from "babylonjs/scene";
  35217. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  35218. import { Node } from "babylonjs/node";
  35219. import { Mesh } from "babylonjs/Meshes/mesh";
  35220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35221. import { ICullable } from "babylonjs/Culling/boundingInfo";
  35222. import { Viewport } from "babylonjs/Maths/math.viewport";
  35223. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35224. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35225. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  35226. import { Ray } from "babylonjs/Culling/ray";
  35227. /**
  35228. * This is the base class of all the camera used in the application.
  35229. * @see https://doc.babylonjs.com/features/cameras
  35230. */
  35231. export class Camera extends Node {
  35232. /** @hidden */
  35233. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  35234. /**
  35235. * This is the default projection mode used by the cameras.
  35236. * It helps recreating a feeling of perspective and better appreciate depth.
  35237. * This is the best way to simulate real life cameras.
  35238. */
  35239. static readonly PERSPECTIVE_CAMERA: number;
  35240. /**
  35241. * This helps creating camera with an orthographic mode.
  35242. * 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.
  35243. */
  35244. static readonly ORTHOGRAPHIC_CAMERA: number;
  35245. /**
  35246. * This is the default FOV mode for perspective cameras.
  35247. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  35248. */
  35249. static readonly FOVMODE_VERTICAL_FIXED: number;
  35250. /**
  35251. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  35252. */
  35253. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  35254. /**
  35255. * This specifies ther is no need for a camera rig.
  35256. * Basically only one eye is rendered corresponding to the camera.
  35257. */
  35258. static readonly RIG_MODE_NONE: number;
  35259. /**
  35260. * Simulates a camera Rig with one blue eye and one red eye.
  35261. * This can be use with 3d blue and red glasses.
  35262. */
  35263. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  35264. /**
  35265. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  35266. */
  35267. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  35268. /**
  35269. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  35270. */
  35271. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  35272. /**
  35273. * Defines that both eyes of the camera will be rendered over under each other.
  35274. */
  35275. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  35276. /**
  35277. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  35278. */
  35279. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  35280. /**
  35281. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  35282. */
  35283. static readonly RIG_MODE_VR: number;
  35284. /**
  35285. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  35286. */
  35287. static readonly RIG_MODE_WEBVR: number;
  35288. /**
  35289. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  35290. */
  35291. static readonly RIG_MODE_CUSTOM: number;
  35292. /**
  35293. * Defines if by default attaching controls should prevent the default javascript event to continue.
  35294. */
  35295. static ForceAttachControlToAlwaysPreventDefault: boolean;
  35296. /**
  35297. * Define the input manager associated with the camera.
  35298. */
  35299. inputs: CameraInputsManager<Camera>;
  35300. /** @hidden */
  35301. _position: Vector3;
  35302. /**
  35303. * Define the current local position of the camera in the scene
  35304. */
  35305. get position(): Vector3;
  35306. set position(newPosition: Vector3);
  35307. protected _upVector: Vector3;
  35308. /**
  35309. * The vector the camera should consider as up.
  35310. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  35311. */
  35312. set upVector(vec: Vector3);
  35313. get upVector(): Vector3;
  35314. /**
  35315. * Define the current limit on the left side for an orthographic camera
  35316. * In scene unit
  35317. */
  35318. orthoLeft: Nullable<number>;
  35319. /**
  35320. * Define the current limit on the right side for an orthographic camera
  35321. * In scene unit
  35322. */
  35323. orthoRight: Nullable<number>;
  35324. /**
  35325. * Define the current limit on the bottom side for an orthographic camera
  35326. * In scene unit
  35327. */
  35328. orthoBottom: Nullable<number>;
  35329. /**
  35330. * Define the current limit on the top side for an orthographic camera
  35331. * In scene unit
  35332. */
  35333. orthoTop: Nullable<number>;
  35334. /**
  35335. * Field Of View is set in Radians. (default is 0.8)
  35336. */
  35337. fov: number;
  35338. /**
  35339. * Define the minimum distance the camera can see from.
  35340. * This is important to note that the depth buffer are not infinite and the closer it starts
  35341. * the more your scene might encounter depth fighting issue.
  35342. */
  35343. minZ: number;
  35344. /**
  35345. * Define the maximum distance the camera can see to.
  35346. * This is important to note that the depth buffer are not infinite and the further it end
  35347. * the more your scene might encounter depth fighting issue.
  35348. */
  35349. maxZ: number;
  35350. /**
  35351. * Define the default inertia of the camera.
  35352. * This helps giving a smooth feeling to the camera movement.
  35353. */
  35354. inertia: number;
  35355. /**
  35356. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  35357. */
  35358. mode: number;
  35359. /**
  35360. * Define whether the camera is intermediate.
  35361. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  35362. */
  35363. isIntermediate: boolean;
  35364. /**
  35365. * Define the viewport of the camera.
  35366. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  35367. */
  35368. viewport: Viewport;
  35369. /**
  35370. * Restricts the camera to viewing objects with the same layerMask.
  35371. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  35372. */
  35373. layerMask: number;
  35374. /**
  35375. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  35376. */
  35377. fovMode: number;
  35378. /**
  35379. * Rig mode of the camera.
  35380. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  35381. * This is normally controlled byt the camera themselves as internal use.
  35382. */
  35383. cameraRigMode: number;
  35384. /**
  35385. * Defines the distance between both "eyes" in case of a RIG
  35386. */
  35387. interaxialDistance: number;
  35388. /**
  35389. * Defines if stereoscopic rendering is done side by side or over under.
  35390. */
  35391. isStereoscopicSideBySide: boolean;
  35392. /**
  35393. * 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
  35394. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  35395. * else in the scene. (Eg. security camera)
  35396. *
  35397. * 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)
  35398. */
  35399. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  35400. /**
  35401. * When set, the camera will render to this render target instead of the default canvas
  35402. *
  35403. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  35404. */
  35405. outputRenderTarget: Nullable<RenderTargetTexture>;
  35406. /**
  35407. * Observable triggered when the camera view matrix has changed.
  35408. */
  35409. onViewMatrixChangedObservable: Observable<Camera>;
  35410. /**
  35411. * Observable triggered when the camera Projection matrix has changed.
  35412. */
  35413. onProjectionMatrixChangedObservable: Observable<Camera>;
  35414. /**
  35415. * Observable triggered when the inputs have been processed.
  35416. */
  35417. onAfterCheckInputsObservable: Observable<Camera>;
  35418. /**
  35419. * Observable triggered when reset has been called and applied to the camera.
  35420. */
  35421. onRestoreStateObservable: Observable<Camera>;
  35422. /**
  35423. * Is this camera a part of a rig system?
  35424. */
  35425. isRigCamera: boolean;
  35426. /**
  35427. * If isRigCamera set to true this will be set with the parent camera.
  35428. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  35429. */
  35430. rigParent?: Camera;
  35431. /** @hidden */
  35432. _cameraRigParams: any;
  35433. /** @hidden */
  35434. _rigCameras: Camera[];
  35435. /** @hidden */
  35436. _rigPostProcess: Nullable<PostProcess>;
  35437. protected _webvrViewMatrix: Matrix;
  35438. /** @hidden */
  35439. _skipRendering: boolean;
  35440. /** @hidden */
  35441. _projectionMatrix: Matrix;
  35442. /** @hidden */
  35443. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  35444. /** @hidden */
  35445. _activeMeshes: SmartArray<AbstractMesh>;
  35446. protected _globalPosition: Vector3;
  35447. /** @hidden */
  35448. _computedViewMatrix: Matrix;
  35449. private _doNotComputeProjectionMatrix;
  35450. private _transformMatrix;
  35451. private _frustumPlanes;
  35452. private _refreshFrustumPlanes;
  35453. private _storedFov;
  35454. private _stateStored;
  35455. /**
  35456. * Instantiates a new camera object.
  35457. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  35458. * @see https://doc.babylonjs.com/features/cameras
  35459. * @param name Defines the name of the camera in the scene
  35460. * @param position Defines the position of the camera
  35461. * @param scene Defines the scene the camera belongs too
  35462. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  35463. */
  35464. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35465. /**
  35466. * Store current camera state (fov, position, etc..)
  35467. * @returns the camera
  35468. */
  35469. storeState(): Camera;
  35470. /**
  35471. * Restores the camera state values if it has been stored. You must call storeState() first
  35472. */
  35473. protected _restoreStateValues(): boolean;
  35474. /**
  35475. * Restored camera state. You must call storeState() first.
  35476. * @returns true if restored and false otherwise
  35477. */
  35478. restoreState(): boolean;
  35479. /**
  35480. * Gets the class name of the camera.
  35481. * @returns the class name
  35482. */
  35483. getClassName(): string;
  35484. /** @hidden */
  35485. readonly _isCamera: boolean;
  35486. /**
  35487. * Gets a string representation of the camera useful for debug purpose.
  35488. * @param fullDetails Defines that a more verboe level of logging is required
  35489. * @returns the string representation
  35490. */
  35491. toString(fullDetails?: boolean): string;
  35492. /**
  35493. * Gets the current world space position of the camera.
  35494. */
  35495. get globalPosition(): Vector3;
  35496. /**
  35497. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  35498. * @returns the active meshe list
  35499. */
  35500. getActiveMeshes(): SmartArray<AbstractMesh>;
  35501. /**
  35502. * Check whether a mesh is part of the current active mesh list of the camera
  35503. * @param mesh Defines the mesh to check
  35504. * @returns true if active, false otherwise
  35505. */
  35506. isActiveMesh(mesh: Mesh): boolean;
  35507. /**
  35508. * Is this camera ready to be used/rendered
  35509. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  35510. * @return true if the camera is ready
  35511. */
  35512. isReady(completeCheck?: boolean): boolean;
  35513. /** @hidden */
  35514. _initCache(): void;
  35515. /** @hidden */
  35516. _updateCache(ignoreParentClass?: boolean): void;
  35517. /** @hidden */
  35518. _isSynchronized(): boolean;
  35519. /** @hidden */
  35520. _isSynchronizedViewMatrix(): boolean;
  35521. /** @hidden */
  35522. _isSynchronizedProjectionMatrix(): boolean;
  35523. /**
  35524. * Attach the input controls to a specific dom element to get the input from.
  35525. * @param element Defines the element the controls should be listened from
  35526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35527. */
  35528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35529. /**
  35530. * Detach the current controls from the specified dom element.
  35531. * @param element Defines the element to stop listening the inputs from
  35532. */
  35533. detachControl(element: HTMLElement): void;
  35534. /**
  35535. * Update the camera state according to the different inputs gathered during the frame.
  35536. */
  35537. update(): void;
  35538. /** @hidden */
  35539. _checkInputs(): void;
  35540. /** @hidden */
  35541. get rigCameras(): Camera[];
  35542. /**
  35543. * Gets the post process used by the rig cameras
  35544. */
  35545. get rigPostProcess(): Nullable<PostProcess>;
  35546. /**
  35547. * Internal, gets the first post proces.
  35548. * @returns the first post process to be run on this camera.
  35549. */
  35550. _getFirstPostProcess(): Nullable<PostProcess>;
  35551. private _cascadePostProcessesToRigCams;
  35552. /**
  35553. * Attach a post process to the camera.
  35554. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35555. * @param postProcess The post process to attach to the camera
  35556. * @param insertAt The position of the post process in case several of them are in use in the scene
  35557. * @returns the position the post process has been inserted at
  35558. */
  35559. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  35560. /**
  35561. * Detach a post process to the camera.
  35562. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  35563. * @param postProcess The post process to detach from the camera
  35564. */
  35565. detachPostProcess(postProcess: PostProcess): void;
  35566. /**
  35567. * Gets the current world matrix of the camera
  35568. */
  35569. getWorldMatrix(): Matrix;
  35570. /** @hidden */
  35571. _getViewMatrix(): Matrix;
  35572. /**
  35573. * Gets the current view matrix of the camera.
  35574. * @param force forces the camera to recompute the matrix without looking at the cached state
  35575. * @returns the view matrix
  35576. */
  35577. getViewMatrix(force?: boolean): Matrix;
  35578. /**
  35579. * Freeze the projection matrix.
  35580. * It will prevent the cache check of the camera projection compute and can speed up perf
  35581. * if no parameter of the camera are meant to change
  35582. * @param projection Defines manually a projection if necessary
  35583. */
  35584. freezeProjectionMatrix(projection?: Matrix): void;
  35585. /**
  35586. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  35587. */
  35588. unfreezeProjectionMatrix(): void;
  35589. /**
  35590. * Gets the current projection matrix of the camera.
  35591. * @param force forces the camera to recompute the matrix without looking at the cached state
  35592. * @returns the projection matrix
  35593. */
  35594. getProjectionMatrix(force?: boolean): Matrix;
  35595. /**
  35596. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  35597. * @returns a Matrix
  35598. */
  35599. getTransformationMatrix(): Matrix;
  35600. private _updateFrustumPlanes;
  35601. /**
  35602. * Checks if a cullable object (mesh...) is in the camera frustum
  35603. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  35604. * @param target The object to check
  35605. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  35606. * @returns true if the object is in frustum otherwise false
  35607. */
  35608. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  35609. /**
  35610. * Checks if a cullable object (mesh...) is in the camera frustum
  35611. * Unlike isInFrustum this cheks the full bounding box
  35612. * @param target The object to check
  35613. * @returns true if the object is in frustum otherwise false
  35614. */
  35615. isCompletelyInFrustum(target: ICullable): boolean;
  35616. /**
  35617. * Gets a ray in the forward direction from the camera.
  35618. * @param length Defines the length of the ray to create
  35619. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35620. * @param origin Defines the start point of the ray which defaults to the camera position
  35621. * @returns the forward ray
  35622. */
  35623. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35624. /**
  35625. * Gets a ray in the forward direction from the camera.
  35626. * @param refRay the ray to (re)use when setting the values
  35627. * @param length Defines the length of the ray to create
  35628. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  35629. * @param origin Defines the start point of the ray which defaults to the camera position
  35630. * @returns the forward ray
  35631. */
  35632. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  35633. /**
  35634. * Releases resources associated with this node.
  35635. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35636. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35637. */
  35638. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35639. /** @hidden */
  35640. _isLeftCamera: boolean;
  35641. /**
  35642. * Gets the left camera of a rig setup in case of Rigged Camera
  35643. */
  35644. get isLeftCamera(): boolean;
  35645. /** @hidden */
  35646. _isRightCamera: boolean;
  35647. /**
  35648. * Gets the right camera of a rig setup in case of Rigged Camera
  35649. */
  35650. get isRightCamera(): boolean;
  35651. /**
  35652. * Gets the left camera of a rig setup in case of Rigged Camera
  35653. */
  35654. get leftCamera(): Nullable<FreeCamera>;
  35655. /**
  35656. * Gets the right camera of a rig setup in case of Rigged Camera
  35657. */
  35658. get rightCamera(): Nullable<FreeCamera>;
  35659. /**
  35660. * Gets the left camera target of a rig setup in case of Rigged Camera
  35661. * @returns the target position
  35662. */
  35663. getLeftTarget(): Nullable<Vector3>;
  35664. /**
  35665. * Gets the right camera target of a rig setup in case of Rigged Camera
  35666. * @returns the target position
  35667. */
  35668. getRightTarget(): Nullable<Vector3>;
  35669. /**
  35670. * @hidden
  35671. */
  35672. setCameraRigMode(mode: number, rigParams: any): void;
  35673. /** @hidden */
  35674. static _setStereoscopicRigMode(camera: Camera): void;
  35675. /** @hidden */
  35676. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  35677. /** @hidden */
  35678. static _setVRRigMode(camera: Camera, rigParams: any): void;
  35679. /** @hidden */
  35680. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  35681. /** @hidden */
  35682. _getVRProjectionMatrix(): Matrix;
  35683. protected _updateCameraRotationMatrix(): void;
  35684. protected _updateWebVRCameraRotationMatrix(): void;
  35685. /**
  35686. * This function MUST be overwritten by the different WebVR cameras available.
  35687. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35688. * @hidden
  35689. */
  35690. _getWebVRProjectionMatrix(): Matrix;
  35691. /**
  35692. * This function MUST be overwritten by the different WebVR cameras available.
  35693. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  35694. * @hidden
  35695. */
  35696. _getWebVRViewMatrix(): Matrix;
  35697. /** @hidden */
  35698. setCameraRigParameter(name: string, value: any): void;
  35699. /**
  35700. * needs to be overridden by children so sub has required properties to be copied
  35701. * @hidden
  35702. */
  35703. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  35704. /**
  35705. * May need to be overridden by children
  35706. * @hidden
  35707. */
  35708. _updateRigCameras(): void;
  35709. /** @hidden */
  35710. _setupInputs(): void;
  35711. /**
  35712. * Serialiaze the camera setup to a json represention
  35713. * @returns the JSON representation
  35714. */
  35715. serialize(): any;
  35716. /**
  35717. * Clones the current camera.
  35718. * @param name The cloned camera name
  35719. * @returns the cloned camera
  35720. */
  35721. clone(name: string): Camera;
  35722. /**
  35723. * Gets the direction of the camera relative to a given local axis.
  35724. * @param localAxis Defines the reference axis to provide a relative direction.
  35725. * @return the direction
  35726. */
  35727. getDirection(localAxis: Vector3): Vector3;
  35728. /**
  35729. * Returns the current camera absolute rotation
  35730. */
  35731. get absoluteRotation(): Quaternion;
  35732. /**
  35733. * Gets the direction of the camera relative to a given local axis into a passed vector.
  35734. * @param localAxis Defines the reference axis to provide a relative direction.
  35735. * @param result Defines the vector to store the result in
  35736. */
  35737. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  35738. /**
  35739. * Gets a camera constructor for a given camera type
  35740. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  35741. * @param name The name of the camera the result will be able to instantiate
  35742. * @param scene The scene the result will construct the camera in
  35743. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  35744. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  35745. * @returns a factory method to construc the camera
  35746. */
  35747. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  35748. /**
  35749. * Compute the world matrix of the camera.
  35750. * @returns the camera world matrix
  35751. */
  35752. computeWorldMatrix(): Matrix;
  35753. /**
  35754. * Parse a JSON and creates the camera from the parsed information
  35755. * @param parsedCamera The JSON to parse
  35756. * @param scene The scene to instantiate the camera in
  35757. * @returns the newly constructed camera
  35758. */
  35759. static Parse(parsedCamera: any, scene: Scene): Camera;
  35760. }
  35761. }
  35762. declare module "babylonjs/Meshes/Builders/discBuilder" {
  35763. import { Nullable } from "babylonjs/types";
  35764. import { Scene } from "babylonjs/scene";
  35765. import { Vector4 } from "babylonjs/Maths/math.vector";
  35766. import { Mesh } from "babylonjs/Meshes/mesh";
  35767. /**
  35768. * Class containing static functions to help procedurally build meshes
  35769. */
  35770. export class DiscBuilder {
  35771. /**
  35772. * Creates a plane polygonal mesh. By default, this is a disc
  35773. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  35774. * * 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
  35775. * * 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
  35776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35777. * * 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
  35778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35779. * @param name defines the name of the mesh
  35780. * @param options defines the options used to create the mesh
  35781. * @param scene defines the hosting scene
  35782. * @returns the plane polygonal mesh
  35783. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  35784. */
  35785. static CreateDisc(name: string, options: {
  35786. radius?: number;
  35787. tessellation?: number;
  35788. arc?: number;
  35789. updatable?: boolean;
  35790. sideOrientation?: number;
  35791. frontUVs?: Vector4;
  35792. backUVs?: Vector4;
  35793. }, scene?: Nullable<Scene>): Mesh;
  35794. }
  35795. }
  35796. declare module "babylonjs/Particles/solidParticleSystem" {
  35797. import { Nullable } from "babylonjs/types";
  35798. import { Mesh } from "babylonjs/Meshes/mesh";
  35799. import { Scene, IDisposable } from "babylonjs/scene";
  35800. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  35801. import { Material } from "babylonjs/Materials/material";
  35802. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35803. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35804. /**
  35805. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  35806. *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.
  35807. * The SPS is also a particle system. It provides some methods to manage the particles.
  35808. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  35809. *
  35810. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  35811. */
  35812. export class SolidParticleSystem implements IDisposable {
  35813. /**
  35814. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  35815. * Example : var p = SPS.particles[i];
  35816. */
  35817. particles: SolidParticle[];
  35818. /**
  35819. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  35820. */
  35821. nbParticles: number;
  35822. /**
  35823. * If the particles must ever face the camera (default false). Useful for planar particles.
  35824. */
  35825. billboard: boolean;
  35826. /**
  35827. * Recompute normals when adding a shape
  35828. */
  35829. recomputeNormals: boolean;
  35830. /**
  35831. * This a counter ofr your own usage. It's not set by any SPS functions.
  35832. */
  35833. counter: number;
  35834. /**
  35835. * The SPS name. This name is also given to the underlying mesh.
  35836. */
  35837. name: string;
  35838. /**
  35839. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  35840. */
  35841. mesh: Mesh;
  35842. /**
  35843. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  35844. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  35845. */
  35846. vars: any;
  35847. /**
  35848. * This array is populated when the SPS is set as 'pickable'.
  35849. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  35850. * Each element of this array is an object `{idx: int, faceId: int}`.
  35851. * `idx` is the picked particle index in the `SPS.particles` array
  35852. * `faceId` is the picked face index counted within this particle.
  35853. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  35854. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  35855. * Use the method SPS.pickedParticle(pickingInfo) instead.
  35856. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35857. */
  35858. pickedParticles: {
  35859. idx: number;
  35860. faceId: number;
  35861. }[];
  35862. /**
  35863. * This array is populated when the SPS is set as 'pickable'
  35864. * Each key of this array is a submesh index.
  35865. * Each element of this array is a second array defined like this :
  35866. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  35867. * Each element of this second array is an object `{idx: int, faceId: int}`.
  35868. * `idx` is the picked particle index in the `SPS.particles` array
  35869. * `faceId` is the picked face index counted within this particle.
  35870. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  35871. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  35872. */
  35873. pickedBySubMesh: {
  35874. idx: number;
  35875. faceId: number;
  35876. }[][];
  35877. /**
  35878. * This array is populated when `enableDepthSort` is set to true.
  35879. * Each element of this array is an instance of the class DepthSortedParticle.
  35880. */
  35881. depthSortedParticles: DepthSortedParticle[];
  35882. /**
  35883. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  35884. * @hidden
  35885. */
  35886. _bSphereOnly: boolean;
  35887. /**
  35888. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  35889. * @hidden
  35890. */
  35891. _bSphereRadiusFactor: number;
  35892. private _scene;
  35893. private _positions;
  35894. private _indices;
  35895. private _normals;
  35896. private _colors;
  35897. private _uvs;
  35898. private _indices32;
  35899. private _positions32;
  35900. private _normals32;
  35901. private _fixedNormal32;
  35902. private _colors32;
  35903. private _uvs32;
  35904. private _index;
  35905. private _updatable;
  35906. private _pickable;
  35907. private _isVisibilityBoxLocked;
  35908. private _alwaysVisible;
  35909. private _depthSort;
  35910. private _expandable;
  35911. private _shapeCounter;
  35912. private _copy;
  35913. private _color;
  35914. private _computeParticleColor;
  35915. private _computeParticleTexture;
  35916. private _computeParticleRotation;
  35917. private _computeParticleVertex;
  35918. private _computeBoundingBox;
  35919. private _depthSortParticles;
  35920. private _camera;
  35921. private _mustUnrotateFixedNormals;
  35922. private _particlesIntersect;
  35923. private _needs32Bits;
  35924. private _isNotBuilt;
  35925. private _lastParticleId;
  35926. private _idxOfId;
  35927. private _multimaterialEnabled;
  35928. private _useModelMaterial;
  35929. private _indicesByMaterial;
  35930. private _materialIndexes;
  35931. private _depthSortFunction;
  35932. private _materialSortFunction;
  35933. private _materials;
  35934. private _multimaterial;
  35935. private _materialIndexesById;
  35936. private _defaultMaterial;
  35937. private _autoUpdateSubMeshes;
  35938. private _tmpVertex;
  35939. /**
  35940. * Creates a SPS (Solid Particle System) object.
  35941. * @param name (String) is the SPS name, this will be the underlying mesh name.
  35942. * @param scene (Scene) is the scene in which the SPS is added.
  35943. * @param options defines the options of the sps e.g.
  35944. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  35945. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  35946. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  35947. * * 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.
  35948. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  35949. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  35950. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  35951. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  35952. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  35953. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  35954. */
  35955. constructor(name: string, scene: Scene, options?: {
  35956. updatable?: boolean;
  35957. isPickable?: boolean;
  35958. enableDepthSort?: boolean;
  35959. particleIntersection?: boolean;
  35960. boundingSphereOnly?: boolean;
  35961. bSphereRadiusFactor?: number;
  35962. expandable?: boolean;
  35963. useModelMaterial?: boolean;
  35964. enableMultiMaterial?: boolean;
  35965. });
  35966. /**
  35967. * Builds the SPS underlying mesh. Returns a standard Mesh.
  35968. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  35969. * @returns the created mesh
  35970. */
  35971. buildMesh(): Mesh;
  35972. /**
  35973. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  35974. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  35975. * Thus the particles generated from `digest()` have their property `position` set yet.
  35976. * @param mesh ( Mesh ) is the mesh to be digested
  35977. * @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
  35978. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  35979. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  35980. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  35981. * @returns the current SPS
  35982. */
  35983. digest(mesh: Mesh, options?: {
  35984. facetNb?: number;
  35985. number?: number;
  35986. delta?: number;
  35987. storage?: [];
  35988. }): SolidParticleSystem;
  35989. /**
  35990. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  35991. * @hidden
  35992. */
  35993. private _unrotateFixedNormals;
  35994. /**
  35995. * Resets the temporary working copy particle
  35996. * @hidden
  35997. */
  35998. private _resetCopy;
  35999. /**
  36000. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  36001. * @param p the current index in the positions array to be updated
  36002. * @param ind the current index in the indices array
  36003. * @param shape a Vector3 array, the shape geometry
  36004. * @param positions the positions array to be updated
  36005. * @param meshInd the shape indices array
  36006. * @param indices the indices array to be updated
  36007. * @param meshUV the shape uv array
  36008. * @param uvs the uv array to be updated
  36009. * @param meshCol the shape color array
  36010. * @param colors the color array to be updated
  36011. * @param meshNor the shape normals array
  36012. * @param normals the normals array to be updated
  36013. * @param idx the particle index
  36014. * @param idxInShape the particle index in its shape
  36015. * @param options the addShape() method passed options
  36016. * @model the particle model
  36017. * @hidden
  36018. */
  36019. private _meshBuilder;
  36020. /**
  36021. * Returns a shape Vector3 array from positions float array
  36022. * @param positions float array
  36023. * @returns a vector3 array
  36024. * @hidden
  36025. */
  36026. private _posToShape;
  36027. /**
  36028. * Returns a shapeUV array from a float uvs (array deep copy)
  36029. * @param uvs as a float array
  36030. * @returns a shapeUV array
  36031. * @hidden
  36032. */
  36033. private _uvsToShapeUV;
  36034. /**
  36035. * Adds a new particle object in the particles array
  36036. * @param idx particle index in particles array
  36037. * @param id particle id
  36038. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  36039. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  36040. * @param model particle ModelShape object
  36041. * @param shapeId model shape identifier
  36042. * @param idxInShape index of the particle in the current model
  36043. * @param bInfo model bounding info object
  36044. * @param storage target storage array, if any
  36045. * @hidden
  36046. */
  36047. private _addParticle;
  36048. /**
  36049. * Adds some particles to the SPS from the model shape. Returns the shape id.
  36050. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  36051. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  36052. * @param nb (positive integer) the number of particles to be created from this model
  36053. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  36054. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  36055. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  36056. * @returns the number of shapes in the system
  36057. */
  36058. addShape(mesh: Mesh, nb: number, options?: {
  36059. positionFunction?: any;
  36060. vertexFunction?: any;
  36061. storage?: [];
  36062. }): number;
  36063. /**
  36064. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  36065. * @hidden
  36066. */
  36067. private _rebuildParticle;
  36068. /**
  36069. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  36070. * @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.
  36071. * @returns the SPS.
  36072. */
  36073. rebuildMesh(reset?: boolean): SolidParticleSystem;
  36074. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  36075. * Returns an array with the removed particles.
  36076. * 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.
  36077. * The SPS can't be empty so at least one particle needs to remain in place.
  36078. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  36079. * @param start index of the first particle to remove
  36080. * @param end index of the last particle to remove (included)
  36081. * @returns an array populated with the removed particles
  36082. */
  36083. removeParticles(start: number, end: number): SolidParticle[];
  36084. /**
  36085. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  36086. * @param solidParticleArray an array populated with Solid Particles objects
  36087. * @returns the SPS
  36088. */
  36089. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  36090. /**
  36091. * Creates a new particle and modifies the SPS mesh geometry :
  36092. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  36093. * - calls _addParticle() to populate the particle array
  36094. * factorized code from addShape() and insertParticlesFromArray()
  36095. * @param idx particle index in the particles array
  36096. * @param i particle index in its shape
  36097. * @param modelShape particle ModelShape object
  36098. * @param shape shape vertex array
  36099. * @param meshInd shape indices array
  36100. * @param meshUV shape uv array
  36101. * @param meshCol shape color array
  36102. * @param meshNor shape normals array
  36103. * @param bbInfo shape bounding info
  36104. * @param storage target particle storage
  36105. * @options addShape() passed options
  36106. * @hidden
  36107. */
  36108. private _insertNewParticle;
  36109. /**
  36110. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  36111. * This method calls `updateParticle()` for each particle of the SPS.
  36112. * For an animated SPS, it is usually called within the render loop.
  36113. * 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.
  36114. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  36115. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  36116. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  36117. * @returns the SPS.
  36118. */
  36119. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  36120. /**
  36121. * Disposes the SPS.
  36122. */
  36123. dispose(): void;
  36124. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  36125. * idx is the particle index in the SPS
  36126. * faceId is the picked face index counted within this particle.
  36127. * Returns null if the pickInfo can't identify a picked particle.
  36128. * @param pickingInfo (PickingInfo object)
  36129. * @returns {idx: number, faceId: number} or null
  36130. */
  36131. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  36132. idx: number;
  36133. faceId: number;
  36134. }>;
  36135. /**
  36136. * Returns a SolidParticle object from its identifier : particle.id
  36137. * @param id (integer) the particle Id
  36138. * @returns the searched particle or null if not found in the SPS.
  36139. */
  36140. getParticleById(id: number): Nullable<SolidParticle>;
  36141. /**
  36142. * Returns a new array populated with the particles having the passed shapeId.
  36143. * @param shapeId (integer) the shape identifier
  36144. * @returns a new solid particle array
  36145. */
  36146. getParticlesByShapeId(shapeId: number): SolidParticle[];
  36147. /**
  36148. * Populates the passed array "ref" with the particles having the passed shapeId.
  36149. * @param shapeId the shape identifier
  36150. * @returns the SPS
  36151. * @param ref
  36152. */
  36153. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  36154. /**
  36155. * Computes the required SubMeshes according the materials assigned to the particles.
  36156. * @returns the solid particle system.
  36157. * Does nothing if called before the SPS mesh is built.
  36158. */
  36159. computeSubMeshes(): SolidParticleSystem;
  36160. /**
  36161. * Sorts the solid particles by material when MultiMaterial is enabled.
  36162. * Updates the indices32 array.
  36163. * Updates the indicesByMaterial array.
  36164. * Updates the mesh indices array.
  36165. * @returns the SPS
  36166. * @hidden
  36167. */
  36168. private _sortParticlesByMaterial;
  36169. /**
  36170. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  36171. * @hidden
  36172. */
  36173. private _setMaterialIndexesById;
  36174. /**
  36175. * Returns an array with unique values of Materials from the passed array
  36176. * @param array the material array to be checked and filtered
  36177. * @hidden
  36178. */
  36179. private _filterUniqueMaterialId;
  36180. /**
  36181. * Sets a new Standard Material as _defaultMaterial if not already set.
  36182. * @hidden
  36183. */
  36184. private _setDefaultMaterial;
  36185. /**
  36186. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  36187. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36188. * @returns the SPS.
  36189. */
  36190. refreshVisibleSize(): SolidParticleSystem;
  36191. /**
  36192. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  36193. * @param size the size (float) of the visibility box
  36194. * note : this doesn't lock the SPS mesh bounding box.
  36195. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36196. */
  36197. setVisibilityBox(size: number): void;
  36198. /**
  36199. * Gets whether the SPS as always visible or not
  36200. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36201. */
  36202. get isAlwaysVisible(): boolean;
  36203. /**
  36204. * Sets the SPS as always visible or not
  36205. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36206. */
  36207. set isAlwaysVisible(val: boolean);
  36208. /**
  36209. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36210. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36211. */
  36212. set isVisibilityBoxLocked(val: boolean);
  36213. /**
  36214. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  36215. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  36216. */
  36217. get isVisibilityBoxLocked(): boolean;
  36218. /**
  36219. * Tells to `setParticles()` to compute the particle rotations or not.
  36220. * Default value : true. The SPS is faster when it's set to false.
  36221. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36222. */
  36223. set computeParticleRotation(val: boolean);
  36224. /**
  36225. * Tells to `setParticles()` to compute the particle colors or not.
  36226. * Default value : true. The SPS is faster when it's set to false.
  36227. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36228. */
  36229. set computeParticleColor(val: boolean);
  36230. set computeParticleTexture(val: boolean);
  36231. /**
  36232. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  36233. * Default value : false. The SPS is faster when it's set to false.
  36234. * Note : the particle custom vertex positions aren't stored values.
  36235. */
  36236. set computeParticleVertex(val: boolean);
  36237. /**
  36238. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  36239. */
  36240. set computeBoundingBox(val: boolean);
  36241. /**
  36242. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  36243. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36244. * Default : `true`
  36245. */
  36246. set depthSortParticles(val: boolean);
  36247. /**
  36248. * Gets if `setParticles()` computes the particle rotations or not.
  36249. * Default value : true. The SPS is faster when it's set to false.
  36250. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  36251. */
  36252. get computeParticleRotation(): boolean;
  36253. /**
  36254. * Gets if `setParticles()` computes the particle colors or not.
  36255. * Default value : true. The SPS is faster when it's set to false.
  36256. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  36257. */
  36258. get computeParticleColor(): boolean;
  36259. /**
  36260. * Gets if `setParticles()` computes the particle textures or not.
  36261. * Default value : true. The SPS is faster when it's set to false.
  36262. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  36263. */
  36264. get computeParticleTexture(): boolean;
  36265. /**
  36266. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  36267. * Default value : false. The SPS is faster when it's set to false.
  36268. * Note : the particle custom vertex positions aren't stored values.
  36269. */
  36270. get computeParticleVertex(): boolean;
  36271. /**
  36272. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  36273. */
  36274. get computeBoundingBox(): boolean;
  36275. /**
  36276. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  36277. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  36278. * Default : `true`
  36279. */
  36280. get depthSortParticles(): boolean;
  36281. /**
  36282. * Gets if the SPS is created as expandable at construction time.
  36283. * Default : `false`
  36284. */
  36285. get expandable(): boolean;
  36286. /**
  36287. * Gets if the SPS supports the Multi Materials
  36288. */
  36289. get multimaterialEnabled(): boolean;
  36290. /**
  36291. * Gets if the SPS uses the model materials for its own multimaterial.
  36292. */
  36293. get useModelMaterial(): boolean;
  36294. /**
  36295. * The SPS used material array.
  36296. */
  36297. get materials(): Material[];
  36298. /**
  36299. * Sets the SPS MultiMaterial from the passed materials.
  36300. * Note : the passed array is internally copied and not used then by reference.
  36301. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  36302. */
  36303. setMultiMaterial(materials: Material[]): void;
  36304. /**
  36305. * The SPS computed multimaterial object
  36306. */
  36307. get multimaterial(): MultiMaterial;
  36308. set multimaterial(mm: MultiMaterial);
  36309. /**
  36310. * If the subMeshes must be updated on the next call to setParticles()
  36311. */
  36312. get autoUpdateSubMeshes(): boolean;
  36313. set autoUpdateSubMeshes(val: boolean);
  36314. /**
  36315. * This function does nothing. It may be overwritten to set all the particle first values.
  36316. * The SPS doesn't call this function, you may have to call it by your own.
  36317. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36318. */
  36319. initParticles(): void;
  36320. /**
  36321. * This function does nothing. It may be overwritten to recycle a particle.
  36322. * The SPS doesn't call this function, you may have to call it by your own.
  36323. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36324. * @param particle The particle to recycle
  36325. * @returns the recycled particle
  36326. */
  36327. recycleParticle(particle: SolidParticle): SolidParticle;
  36328. /**
  36329. * Updates a particle : this function should be overwritten by the user.
  36330. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  36331. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  36332. * @example : just set a particle position or velocity and recycle conditions
  36333. * @param particle The particle to update
  36334. * @returns the updated particle
  36335. */
  36336. updateParticle(particle: SolidParticle): SolidParticle;
  36337. /**
  36338. * Updates a vertex of a particle : it can be overwritten by the user.
  36339. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  36340. * @param particle the current particle
  36341. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  36342. * @param pt the index of the current vertex in the particle shape
  36343. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  36344. * @example : just set a vertex particle position or color
  36345. * @returns the sps
  36346. */
  36347. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  36348. /**
  36349. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  36350. * This does nothing and may be overwritten by the user.
  36351. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36352. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36353. * @param update the boolean update value actually passed to setParticles()
  36354. */
  36355. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36356. /**
  36357. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  36358. * This will be passed three parameters.
  36359. * This does nothing and may be overwritten by the user.
  36360. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36361. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  36362. * @param update the boolean update value actually passed to setParticles()
  36363. */
  36364. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  36365. }
  36366. }
  36367. declare module "babylonjs/Particles/solidParticle" {
  36368. import { Nullable } from "babylonjs/types";
  36369. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  36370. import { Color4 } from "babylonjs/Maths/math.color";
  36371. import { Mesh } from "babylonjs/Meshes/mesh";
  36372. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36373. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  36374. import { Plane } from "babylonjs/Maths/math.plane";
  36375. import { Material } from "babylonjs/Materials/material";
  36376. /**
  36377. * Represents one particle of a solid particle system.
  36378. */
  36379. export class SolidParticle {
  36380. /**
  36381. * particle global index
  36382. */
  36383. idx: number;
  36384. /**
  36385. * particle identifier
  36386. */
  36387. id: number;
  36388. /**
  36389. * The color of the particle
  36390. */
  36391. color: Nullable<Color4>;
  36392. /**
  36393. * The world space position of the particle.
  36394. */
  36395. position: Vector3;
  36396. /**
  36397. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  36398. */
  36399. rotation: Vector3;
  36400. /**
  36401. * The world space rotation quaternion of the particle.
  36402. */
  36403. rotationQuaternion: Nullable<Quaternion>;
  36404. /**
  36405. * The scaling of the particle.
  36406. */
  36407. scaling: Vector3;
  36408. /**
  36409. * The uvs of the particle.
  36410. */
  36411. uvs: Vector4;
  36412. /**
  36413. * The current speed of the particle.
  36414. */
  36415. velocity: Vector3;
  36416. /**
  36417. * The pivot point in the particle local space.
  36418. */
  36419. pivot: Vector3;
  36420. /**
  36421. * Must the particle be translated from its pivot point in its local space ?
  36422. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  36423. * Default : false
  36424. */
  36425. translateFromPivot: boolean;
  36426. /**
  36427. * Is the particle active or not ?
  36428. */
  36429. alive: boolean;
  36430. /**
  36431. * Is the particle visible or not ?
  36432. */
  36433. isVisible: boolean;
  36434. /**
  36435. * Index of this particle in the global "positions" array (Internal use)
  36436. * @hidden
  36437. */
  36438. _pos: number;
  36439. /**
  36440. * @hidden Index of this particle in the global "indices" array (Internal use)
  36441. */
  36442. _ind: number;
  36443. /**
  36444. * @hidden ModelShape of this particle (Internal use)
  36445. */
  36446. _model: ModelShape;
  36447. /**
  36448. * ModelShape id of this particle
  36449. */
  36450. shapeId: number;
  36451. /**
  36452. * Index of the particle in its shape id
  36453. */
  36454. idxInShape: number;
  36455. /**
  36456. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  36457. */
  36458. _modelBoundingInfo: BoundingInfo;
  36459. /**
  36460. * @hidden Particle BoundingInfo object (Internal use)
  36461. */
  36462. _boundingInfo: BoundingInfo;
  36463. /**
  36464. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  36465. */
  36466. _sps: SolidParticleSystem;
  36467. /**
  36468. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  36469. */
  36470. _stillInvisible: boolean;
  36471. /**
  36472. * @hidden Last computed particle rotation matrix
  36473. */
  36474. _rotationMatrix: number[];
  36475. /**
  36476. * Parent particle Id, if any.
  36477. * Default null.
  36478. */
  36479. parentId: Nullable<number>;
  36480. /**
  36481. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  36482. */
  36483. materialIndex: Nullable<number>;
  36484. /**
  36485. * Custom object or properties.
  36486. */
  36487. props: Nullable<any>;
  36488. /**
  36489. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  36490. * The possible values are :
  36491. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36492. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36493. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36494. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36495. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36496. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  36497. * */
  36498. cullingStrategy: number;
  36499. /**
  36500. * @hidden Internal global position in the SPS.
  36501. */
  36502. _globalPosition: Vector3;
  36503. /**
  36504. * Creates a Solid Particle object.
  36505. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  36506. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  36507. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  36508. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  36509. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  36510. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  36511. * @param shapeId (integer) is the model shape identifier in the SPS.
  36512. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  36513. * @param sps defines the sps it is associated to
  36514. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  36515. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  36516. */
  36517. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  36518. /**
  36519. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  36520. * @param target the particle target
  36521. * @returns the current particle
  36522. */
  36523. copyToRef(target: SolidParticle): SolidParticle;
  36524. /**
  36525. * Legacy support, changed scale to scaling
  36526. */
  36527. get scale(): Vector3;
  36528. /**
  36529. * Legacy support, changed scale to scaling
  36530. */
  36531. set scale(scale: Vector3);
  36532. /**
  36533. * Legacy support, changed quaternion to rotationQuaternion
  36534. */
  36535. get quaternion(): Nullable<Quaternion>;
  36536. /**
  36537. * Legacy support, changed quaternion to rotationQuaternion
  36538. */
  36539. set quaternion(q: Nullable<Quaternion>);
  36540. /**
  36541. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  36542. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  36543. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  36544. * @returns true if it intersects
  36545. */
  36546. intersectsMesh(target: Mesh | SolidParticle): boolean;
  36547. /**
  36548. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  36549. * A particle is in the frustum if its bounding box intersects the frustum
  36550. * @param frustumPlanes defines the frustum to test
  36551. * @returns true if the particle is in the frustum planes
  36552. */
  36553. isInFrustum(frustumPlanes: Plane[]): boolean;
  36554. /**
  36555. * get the rotation matrix of the particle
  36556. * @hidden
  36557. */
  36558. getRotationMatrix(m: Matrix): void;
  36559. }
  36560. /**
  36561. * Represents the shape of the model used by one particle of a solid particle system.
  36562. * SPS internal tool, don't use it manually.
  36563. */
  36564. export class ModelShape {
  36565. /**
  36566. * The shape id
  36567. * @hidden
  36568. */
  36569. shapeID: number;
  36570. /**
  36571. * flat array of model positions (internal use)
  36572. * @hidden
  36573. */
  36574. _shape: Vector3[];
  36575. /**
  36576. * flat array of model UVs (internal use)
  36577. * @hidden
  36578. */
  36579. _shapeUV: number[];
  36580. /**
  36581. * color array of the model
  36582. * @hidden
  36583. */
  36584. _shapeColors: number[];
  36585. /**
  36586. * indices array of the model
  36587. * @hidden
  36588. */
  36589. _indices: number[];
  36590. /**
  36591. * normals array of the model
  36592. * @hidden
  36593. */
  36594. _normals: number[];
  36595. /**
  36596. * length of the shape in the model indices array (internal use)
  36597. * @hidden
  36598. */
  36599. _indicesLength: number;
  36600. /**
  36601. * Custom position function (internal use)
  36602. * @hidden
  36603. */
  36604. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  36605. /**
  36606. * Custom vertex function (internal use)
  36607. * @hidden
  36608. */
  36609. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  36610. /**
  36611. * Model material (internal use)
  36612. * @hidden
  36613. */
  36614. _material: Nullable<Material>;
  36615. /**
  36616. * 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.
  36617. * SPS internal tool, don't use it manually.
  36618. * @hidden
  36619. */
  36620. 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>);
  36621. }
  36622. /**
  36623. * Represents a Depth Sorted Particle in the solid particle system.
  36624. * @hidden
  36625. */
  36626. export class DepthSortedParticle {
  36627. /**
  36628. * Particle index
  36629. */
  36630. idx: number;
  36631. /**
  36632. * Index of the particle in the "indices" array
  36633. */
  36634. ind: number;
  36635. /**
  36636. * Length of the particle shape in the "indices" array
  36637. */
  36638. indicesLength: number;
  36639. /**
  36640. * Squared distance from the particle to the camera
  36641. */
  36642. sqDistance: number;
  36643. /**
  36644. * Material index when used with MultiMaterials
  36645. */
  36646. materialIndex: number;
  36647. /**
  36648. * Creates a new sorted particle
  36649. * @param materialIndex
  36650. */
  36651. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  36652. }
  36653. /**
  36654. * Represents a solid particle vertex
  36655. */
  36656. export class SolidParticleVertex {
  36657. /**
  36658. * Vertex position
  36659. */
  36660. position: Vector3;
  36661. /**
  36662. * Vertex color
  36663. */
  36664. color: Color4;
  36665. /**
  36666. * Vertex UV
  36667. */
  36668. uv: Vector2;
  36669. /**
  36670. * Creates a new solid particle vertex
  36671. */
  36672. constructor();
  36673. /** Vertex x coordinate */
  36674. get x(): number;
  36675. set x(val: number);
  36676. /** Vertex y coordinate */
  36677. get y(): number;
  36678. set y(val: number);
  36679. /** Vertex z coordinate */
  36680. get z(): number;
  36681. set z(val: number);
  36682. }
  36683. }
  36684. declare module "babylonjs/Collisions/meshCollisionData" {
  36685. import { Collider } from "babylonjs/Collisions/collider";
  36686. import { Vector3 } from "babylonjs/Maths/math.vector";
  36687. import { Nullable } from "babylonjs/types";
  36688. import { Observer } from "babylonjs/Misc/observable";
  36689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36690. /**
  36691. * @hidden
  36692. */
  36693. export class _MeshCollisionData {
  36694. _checkCollisions: boolean;
  36695. _collisionMask: number;
  36696. _collisionGroup: number;
  36697. _surroundingMeshes: Nullable<AbstractMesh[]>;
  36698. _collider: Nullable<Collider>;
  36699. _oldPositionForCollisions: Vector3;
  36700. _diffPositionForCollisions: Vector3;
  36701. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  36702. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  36703. _collisionResponse: boolean;
  36704. }
  36705. }
  36706. declare module "babylonjs/Meshes/abstractMesh" {
  36707. import { Observable } from "babylonjs/Misc/observable";
  36708. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  36709. import { Camera } from "babylonjs/Cameras/camera";
  36710. import { Scene, IDisposable } from "babylonjs/scene";
  36711. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  36712. import { Node } from "babylonjs/node";
  36713. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  36714. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36715. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36716. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36717. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  36718. import { Material } from "babylonjs/Materials/material";
  36719. import { Light } from "babylonjs/Lights/light";
  36720. import { Skeleton } from "babylonjs/Bones/skeleton";
  36721. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  36722. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  36723. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36724. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  36725. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  36726. import { Plane } from "babylonjs/Maths/math.plane";
  36727. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36728. import { Ray } from "babylonjs/Culling/ray";
  36729. import { Collider } from "babylonjs/Collisions/collider";
  36730. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36731. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  36732. /** @hidden */
  36733. class _FacetDataStorage {
  36734. facetPositions: Vector3[];
  36735. facetNormals: Vector3[];
  36736. facetPartitioning: number[][];
  36737. facetNb: number;
  36738. partitioningSubdivisions: number;
  36739. partitioningBBoxRatio: number;
  36740. facetDataEnabled: boolean;
  36741. facetParameters: any;
  36742. bbSize: Vector3;
  36743. subDiv: {
  36744. max: number;
  36745. X: number;
  36746. Y: number;
  36747. Z: number;
  36748. };
  36749. facetDepthSort: boolean;
  36750. facetDepthSortEnabled: boolean;
  36751. depthSortedIndices: IndicesArray;
  36752. depthSortedFacets: {
  36753. ind: number;
  36754. sqDistance: number;
  36755. }[];
  36756. facetDepthSortFunction: (f1: {
  36757. ind: number;
  36758. sqDistance: number;
  36759. }, f2: {
  36760. ind: number;
  36761. sqDistance: number;
  36762. }) => number;
  36763. facetDepthSortFrom: Vector3;
  36764. facetDepthSortOrigin: Vector3;
  36765. invertedMatrix: Matrix;
  36766. }
  36767. /**
  36768. * @hidden
  36769. **/
  36770. class _InternalAbstractMeshDataInfo {
  36771. _hasVertexAlpha: boolean;
  36772. _useVertexColors: boolean;
  36773. _numBoneInfluencers: number;
  36774. _applyFog: boolean;
  36775. _receiveShadows: boolean;
  36776. _facetData: _FacetDataStorage;
  36777. _visibility: number;
  36778. _skeleton: Nullable<Skeleton>;
  36779. _layerMask: number;
  36780. _computeBonesUsingShaders: boolean;
  36781. _isActive: boolean;
  36782. _onlyForInstances: boolean;
  36783. _isActiveIntermediate: boolean;
  36784. _onlyForInstancesIntermediate: boolean;
  36785. _actAsRegularMesh: boolean;
  36786. _currentLOD: Nullable<AbstractMesh>;
  36787. }
  36788. /**
  36789. * Class used to store all common mesh properties
  36790. */
  36791. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  36792. /** No occlusion */
  36793. static OCCLUSION_TYPE_NONE: number;
  36794. /** Occlusion set to optimisitic */
  36795. static OCCLUSION_TYPE_OPTIMISTIC: number;
  36796. /** Occlusion set to strict */
  36797. static OCCLUSION_TYPE_STRICT: number;
  36798. /** Use an accurante occlusion algorithm */
  36799. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  36800. /** Use a conservative occlusion algorithm */
  36801. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  36802. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  36803. * Test order :
  36804. * Is the bounding sphere outside the frustum ?
  36805. * If not, are the bounding box vertices outside the frustum ?
  36806. * It not, then the cullable object is in the frustum.
  36807. */
  36808. static readonly CULLINGSTRATEGY_STANDARD: number;
  36809. /** Culling strategy : Bounding Sphere Only.
  36810. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  36811. * It's also less accurate than the standard because some not visible objects can still be selected.
  36812. * Test : is the bounding sphere outside the frustum ?
  36813. * If not, then the cullable object is in the frustum.
  36814. */
  36815. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  36816. /** Culling strategy : Optimistic Inclusion.
  36817. * This in an inclusion test first, then the standard exclusion test.
  36818. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  36819. * 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.
  36820. * Anyway, it's as accurate as the standard strategy.
  36821. * Test :
  36822. * Is the cullable object bounding sphere center in the frustum ?
  36823. * If not, apply the default culling strategy.
  36824. */
  36825. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  36826. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  36827. * This in an inclusion test first, then the bounding sphere only exclusion test.
  36828. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  36829. * 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.
  36830. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  36831. * Test :
  36832. * Is the cullable object bounding sphere center in the frustum ?
  36833. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  36834. */
  36835. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  36836. /**
  36837. * No billboard
  36838. */
  36839. static get BILLBOARDMODE_NONE(): number;
  36840. /** Billboard on X axis */
  36841. static get BILLBOARDMODE_X(): number;
  36842. /** Billboard on Y axis */
  36843. static get BILLBOARDMODE_Y(): number;
  36844. /** Billboard on Z axis */
  36845. static get BILLBOARDMODE_Z(): number;
  36846. /** Billboard on all axes */
  36847. static get BILLBOARDMODE_ALL(): number;
  36848. /** Billboard on using position instead of orientation */
  36849. static get BILLBOARDMODE_USE_POSITION(): number;
  36850. /** @hidden */
  36851. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  36852. /**
  36853. * The culling strategy to use to check whether the mesh must be rendered or not.
  36854. * This value can be changed at any time and will be used on the next render mesh selection.
  36855. * The possible values are :
  36856. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  36857. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  36858. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  36859. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  36860. * Please read each static variable documentation to get details about the culling process.
  36861. * */
  36862. cullingStrategy: number;
  36863. /**
  36864. * Gets the number of facets in the mesh
  36865. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36866. */
  36867. get facetNb(): number;
  36868. /**
  36869. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  36870. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36871. */
  36872. get partitioningSubdivisions(): number;
  36873. set partitioningSubdivisions(nb: number);
  36874. /**
  36875. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  36876. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  36877. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  36878. */
  36879. get partitioningBBoxRatio(): number;
  36880. set partitioningBBoxRatio(ratio: number);
  36881. /**
  36882. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  36883. * Works only for updatable meshes.
  36884. * Doesn't work with multi-materials
  36885. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36886. */
  36887. get mustDepthSortFacets(): boolean;
  36888. set mustDepthSortFacets(sort: boolean);
  36889. /**
  36890. * The location (Vector3) where the facet depth sort must be computed from.
  36891. * By default, the active camera position.
  36892. * Used only when facet depth sort is enabled
  36893. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  36894. */
  36895. get facetDepthSortFrom(): Vector3;
  36896. set facetDepthSortFrom(location: Vector3);
  36897. /**
  36898. * gets a boolean indicating if facetData is enabled
  36899. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  36900. */
  36901. get isFacetDataEnabled(): boolean;
  36902. /** @hidden */
  36903. _updateNonUniformScalingState(value: boolean): boolean;
  36904. /**
  36905. * An event triggered when this mesh collides with another one
  36906. */
  36907. onCollideObservable: Observable<AbstractMesh>;
  36908. /** Set a function to call when this mesh collides with another one */
  36909. set onCollide(callback: () => void);
  36910. /**
  36911. * An event triggered when the collision's position changes
  36912. */
  36913. onCollisionPositionChangeObservable: Observable<Vector3>;
  36914. /** Set a function to call when the collision's position changes */
  36915. set onCollisionPositionChange(callback: () => void);
  36916. /**
  36917. * An event triggered when material is changed
  36918. */
  36919. onMaterialChangedObservable: Observable<AbstractMesh>;
  36920. /**
  36921. * Gets or sets the orientation for POV movement & rotation
  36922. */
  36923. definedFacingForward: boolean;
  36924. /** @hidden */
  36925. _occlusionQuery: Nullable<WebGLQuery>;
  36926. /** @hidden */
  36927. _renderingGroup: Nullable<RenderingGroup>;
  36928. /**
  36929. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36930. */
  36931. get visibility(): number;
  36932. /**
  36933. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  36934. */
  36935. set visibility(value: number);
  36936. /** Gets or sets the alpha index used to sort transparent meshes
  36937. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  36938. */
  36939. alphaIndex: number;
  36940. /**
  36941. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  36942. */
  36943. isVisible: boolean;
  36944. /**
  36945. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  36946. */
  36947. isPickable: boolean;
  36948. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  36949. showSubMeshesBoundingBox: boolean;
  36950. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  36951. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  36952. */
  36953. isBlocker: boolean;
  36954. /**
  36955. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  36956. */
  36957. enablePointerMoveEvents: boolean;
  36958. private _renderingGroupId;
  36959. /**
  36960. * Specifies the rendering group id for this mesh (0 by default)
  36961. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  36962. */
  36963. get renderingGroupId(): number;
  36964. set renderingGroupId(value: number);
  36965. private _material;
  36966. /** Gets or sets current material */
  36967. get material(): Nullable<Material>;
  36968. set material(value: Nullable<Material>);
  36969. /**
  36970. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  36971. * @see https://doc.babylonjs.com/babylon101/shadows
  36972. */
  36973. get receiveShadows(): boolean;
  36974. set receiveShadows(value: boolean);
  36975. /** Defines color to use when rendering outline */
  36976. outlineColor: Color3;
  36977. /** Define width to use when rendering outline */
  36978. outlineWidth: number;
  36979. /** Defines color to use when rendering overlay */
  36980. overlayColor: Color3;
  36981. /** Defines alpha to use when rendering overlay */
  36982. overlayAlpha: number;
  36983. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  36984. get hasVertexAlpha(): boolean;
  36985. set hasVertexAlpha(value: boolean);
  36986. /** 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) */
  36987. get useVertexColors(): boolean;
  36988. set useVertexColors(value: boolean);
  36989. /**
  36990. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  36991. */
  36992. get computeBonesUsingShaders(): boolean;
  36993. set computeBonesUsingShaders(value: boolean);
  36994. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  36995. get numBoneInfluencers(): number;
  36996. set numBoneInfluencers(value: number);
  36997. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  36998. get applyFog(): boolean;
  36999. set applyFog(value: boolean);
  37000. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  37001. useOctreeForRenderingSelection: boolean;
  37002. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  37003. useOctreeForPicking: boolean;
  37004. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  37005. useOctreeForCollisions: boolean;
  37006. /**
  37007. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  37008. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  37009. */
  37010. get layerMask(): number;
  37011. set layerMask(value: number);
  37012. /**
  37013. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  37014. */
  37015. alwaysSelectAsActiveMesh: boolean;
  37016. /**
  37017. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  37018. */
  37019. doNotSyncBoundingInfo: boolean;
  37020. /**
  37021. * Gets or sets the current action manager
  37022. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37023. */
  37024. actionManager: Nullable<AbstractActionManager>;
  37025. private _meshCollisionData;
  37026. /**
  37027. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  37028. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37029. */
  37030. ellipsoid: Vector3;
  37031. /**
  37032. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  37033. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37034. */
  37035. ellipsoidOffset: Vector3;
  37036. /**
  37037. * Gets or sets a collision mask used to mask collisions (default is -1).
  37038. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37039. */
  37040. get collisionMask(): number;
  37041. set collisionMask(mask: number);
  37042. /**
  37043. * Gets or sets a collision response flag (default is true).
  37044. * when collisionResponse is false, events are still triggered but colliding entity has no response
  37045. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  37046. * to respond to the collision.
  37047. */
  37048. get collisionResponse(): boolean;
  37049. set collisionResponse(response: boolean);
  37050. /**
  37051. * Gets or sets the current collision group mask (-1 by default).
  37052. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  37053. */
  37054. get collisionGroup(): number;
  37055. set collisionGroup(mask: number);
  37056. /**
  37057. * Gets or sets current surrounding meshes (null by default).
  37058. *
  37059. * By default collision detection is tested against every mesh in the scene.
  37060. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  37061. * meshes will be tested for the collision.
  37062. *
  37063. * Note: if set to an empty array no collision will happen when this mesh is moved.
  37064. */
  37065. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  37066. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  37067. /**
  37068. * Defines edge width used when edgesRenderer is enabled
  37069. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37070. */
  37071. edgesWidth: number;
  37072. /**
  37073. * Defines edge color used when edgesRenderer is enabled
  37074. * @see https://www.babylonjs-playground.com/#10OJSG#13
  37075. */
  37076. edgesColor: Color4;
  37077. /** @hidden */
  37078. _edgesRenderer: Nullable<IEdgesRenderer>;
  37079. /** @hidden */
  37080. _masterMesh: Nullable<AbstractMesh>;
  37081. /** @hidden */
  37082. _boundingInfo: Nullable<BoundingInfo>;
  37083. /** @hidden */
  37084. _renderId: number;
  37085. /**
  37086. * Gets or sets the list of subMeshes
  37087. * @see https://doc.babylonjs.com/how_to/multi_materials
  37088. */
  37089. subMeshes: SubMesh[];
  37090. /** @hidden */
  37091. _intersectionsInProgress: AbstractMesh[];
  37092. /** @hidden */
  37093. _unIndexed: boolean;
  37094. /** @hidden */
  37095. _lightSources: Light[];
  37096. /** Gets the list of lights affecting that mesh */
  37097. get lightSources(): Light[];
  37098. /** @hidden */
  37099. get _positions(): Nullable<Vector3[]>;
  37100. /** @hidden */
  37101. _waitingData: {
  37102. lods: Nullable<any>;
  37103. actions: Nullable<any>;
  37104. freezeWorldMatrix: Nullable<boolean>;
  37105. };
  37106. /** @hidden */
  37107. _bonesTransformMatrices: Nullable<Float32Array>;
  37108. /** @hidden */
  37109. _transformMatrixTexture: Nullable<RawTexture>;
  37110. /**
  37111. * Gets or sets a skeleton to apply skining transformations
  37112. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  37113. */
  37114. set skeleton(value: Nullable<Skeleton>);
  37115. get skeleton(): Nullable<Skeleton>;
  37116. /**
  37117. * An event triggered when the mesh is rebuilt.
  37118. */
  37119. onRebuildObservable: Observable<AbstractMesh>;
  37120. /**
  37121. * Creates a new AbstractMesh
  37122. * @param name defines the name of the mesh
  37123. * @param scene defines the hosting scene
  37124. */
  37125. constructor(name: string, scene?: Nullable<Scene>);
  37126. /**
  37127. * Returns the string "AbstractMesh"
  37128. * @returns "AbstractMesh"
  37129. */
  37130. getClassName(): string;
  37131. /**
  37132. * Gets a string representation of the current mesh
  37133. * @param fullDetails defines a boolean indicating if full details must be included
  37134. * @returns a string representation of the current mesh
  37135. */
  37136. toString(fullDetails?: boolean): string;
  37137. /**
  37138. * @hidden
  37139. */
  37140. protected _getEffectiveParent(): Nullable<Node>;
  37141. /** @hidden */
  37142. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  37143. /** @hidden */
  37144. _rebuild(): void;
  37145. /** @hidden */
  37146. _resyncLightSources(): void;
  37147. /** @hidden */
  37148. _resyncLightSource(light: Light): void;
  37149. /** @hidden */
  37150. _unBindEffect(): void;
  37151. /** @hidden */
  37152. _removeLightSource(light: Light, dispose: boolean): void;
  37153. private _markSubMeshesAsDirty;
  37154. /** @hidden */
  37155. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  37156. /** @hidden */
  37157. _markSubMeshesAsAttributesDirty(): void;
  37158. /** @hidden */
  37159. _markSubMeshesAsMiscDirty(): void;
  37160. /**
  37161. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  37162. */
  37163. get scaling(): Vector3;
  37164. set scaling(newScaling: Vector3);
  37165. /**
  37166. * Returns true if the mesh is blocked. Implemented by child classes
  37167. */
  37168. get isBlocked(): boolean;
  37169. /**
  37170. * Returns the mesh itself by default. Implemented by child classes
  37171. * @param camera defines the camera to use to pick the right LOD level
  37172. * @returns the currentAbstractMesh
  37173. */
  37174. getLOD(camera: Camera): Nullable<AbstractMesh>;
  37175. /**
  37176. * Returns 0 by default. Implemented by child classes
  37177. * @returns an integer
  37178. */
  37179. getTotalVertices(): number;
  37180. /**
  37181. * Returns a positive integer : the total number of indices in this mesh geometry.
  37182. * @returns the numner of indices or zero if the mesh has no geometry.
  37183. */
  37184. getTotalIndices(): number;
  37185. /**
  37186. * Returns null by default. Implemented by child classes
  37187. * @returns null
  37188. */
  37189. getIndices(): Nullable<IndicesArray>;
  37190. /**
  37191. * Returns the array of the requested vertex data kind. Implemented by child classes
  37192. * @param kind defines the vertex data kind to use
  37193. * @returns null
  37194. */
  37195. getVerticesData(kind: string): Nullable<FloatArray>;
  37196. /**
  37197. * Sets the vertex data of the mesh geometry for the requested `kind`.
  37198. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  37199. * Note that a new underlying VertexBuffer object is created each call.
  37200. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  37201. * @param kind defines vertex data kind:
  37202. * * VertexBuffer.PositionKind
  37203. * * VertexBuffer.UVKind
  37204. * * VertexBuffer.UV2Kind
  37205. * * VertexBuffer.UV3Kind
  37206. * * VertexBuffer.UV4Kind
  37207. * * VertexBuffer.UV5Kind
  37208. * * VertexBuffer.UV6Kind
  37209. * * VertexBuffer.ColorKind
  37210. * * VertexBuffer.MatricesIndicesKind
  37211. * * VertexBuffer.MatricesIndicesExtraKind
  37212. * * VertexBuffer.MatricesWeightsKind
  37213. * * VertexBuffer.MatricesWeightsExtraKind
  37214. * @param data defines the data source
  37215. * @param updatable defines if the data must be flagged as updatable (or static)
  37216. * @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
  37217. * @returns the current mesh
  37218. */
  37219. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  37220. /**
  37221. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  37222. * If the mesh has no geometry, it is simply returned as it is.
  37223. * @param kind defines vertex data kind:
  37224. * * VertexBuffer.PositionKind
  37225. * * VertexBuffer.UVKind
  37226. * * VertexBuffer.UV2Kind
  37227. * * VertexBuffer.UV3Kind
  37228. * * VertexBuffer.UV4Kind
  37229. * * VertexBuffer.UV5Kind
  37230. * * VertexBuffer.UV6Kind
  37231. * * VertexBuffer.ColorKind
  37232. * * VertexBuffer.MatricesIndicesKind
  37233. * * VertexBuffer.MatricesIndicesExtraKind
  37234. * * VertexBuffer.MatricesWeightsKind
  37235. * * VertexBuffer.MatricesWeightsExtraKind
  37236. * @param data defines the data source
  37237. * @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
  37238. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  37239. * @returns the current mesh
  37240. */
  37241. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  37242. /**
  37243. * Sets the mesh indices,
  37244. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  37245. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  37246. * @param totalVertices Defines the total number of vertices
  37247. * @returns the current mesh
  37248. */
  37249. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  37250. /**
  37251. * Gets a boolean indicating if specific vertex data is present
  37252. * @param kind defines the vertex data kind to use
  37253. * @returns true is data kind is present
  37254. */
  37255. isVerticesDataPresent(kind: string): boolean;
  37256. /**
  37257. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  37258. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  37259. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  37260. * @returns a BoundingInfo
  37261. */
  37262. getBoundingInfo(): BoundingInfo;
  37263. /**
  37264. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  37265. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  37266. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  37267. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  37268. * @returns the current mesh
  37269. */
  37270. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  37271. /**
  37272. * Overwrite the current bounding info
  37273. * @param boundingInfo defines the new bounding info
  37274. * @returns the current mesh
  37275. */
  37276. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  37277. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  37278. get useBones(): boolean;
  37279. /** @hidden */
  37280. _preActivate(): void;
  37281. /** @hidden */
  37282. _preActivateForIntermediateRendering(renderId: number): void;
  37283. /** @hidden */
  37284. _activate(renderId: number, intermediateRendering: boolean): boolean;
  37285. /** @hidden */
  37286. _postActivate(): void;
  37287. /** @hidden */
  37288. _freeze(): void;
  37289. /** @hidden */
  37290. _unFreeze(): void;
  37291. /**
  37292. * Gets the current world matrix
  37293. * @returns a Matrix
  37294. */
  37295. getWorldMatrix(): Matrix;
  37296. /** @hidden */
  37297. _getWorldMatrixDeterminant(): number;
  37298. /**
  37299. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  37300. */
  37301. get isAnInstance(): boolean;
  37302. /**
  37303. * Gets a boolean indicating if this mesh has instances
  37304. */
  37305. get hasInstances(): boolean;
  37306. /**
  37307. * Gets a boolean indicating if this mesh has thin instances
  37308. */
  37309. get hasThinInstances(): boolean;
  37310. /**
  37311. * Perform relative position change from the point of view of behind the front of the mesh.
  37312. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37313. * Supports definition of mesh facing forward or backward
  37314. * @param amountRight defines the distance on the right axis
  37315. * @param amountUp defines the distance on the up axis
  37316. * @param amountForward defines the distance on the forward axis
  37317. * @returns the current mesh
  37318. */
  37319. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  37320. /**
  37321. * Calculate relative position change from the point of view of behind the front of the mesh.
  37322. * This is performed taking into account the meshes current rotation, so you do not have to care.
  37323. * Supports definition of mesh facing forward or backward
  37324. * @param amountRight defines the distance on the right axis
  37325. * @param amountUp defines the distance on the up axis
  37326. * @param amountForward defines the distance on the forward axis
  37327. * @returns the new displacement vector
  37328. */
  37329. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  37330. /**
  37331. * Perform relative rotation change from the point of view of behind the front of the mesh.
  37332. * Supports definition of mesh facing forward or backward
  37333. * @param flipBack defines the flip
  37334. * @param twirlClockwise defines the twirl
  37335. * @param tiltRight defines the tilt
  37336. * @returns the current mesh
  37337. */
  37338. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  37339. /**
  37340. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  37341. * Supports definition of mesh facing forward or backward.
  37342. * @param flipBack defines the flip
  37343. * @param twirlClockwise defines the twirl
  37344. * @param tiltRight defines the tilt
  37345. * @returns the new rotation vector
  37346. */
  37347. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  37348. /**
  37349. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  37350. * This means the mesh underlying bounding box and sphere are recomputed.
  37351. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  37352. * @returns the current mesh
  37353. */
  37354. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  37355. /** @hidden */
  37356. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  37357. /** @hidden */
  37358. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  37359. /** @hidden */
  37360. _updateBoundingInfo(): AbstractMesh;
  37361. /** @hidden */
  37362. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  37363. /** @hidden */
  37364. protected _afterComputeWorldMatrix(): void;
  37365. /** @hidden */
  37366. get _effectiveMesh(): AbstractMesh;
  37367. /**
  37368. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  37369. * A mesh is in the frustum if its bounding box intersects the frustum
  37370. * @param frustumPlanes defines the frustum to test
  37371. * @returns true if the mesh is in the frustum planes
  37372. */
  37373. isInFrustum(frustumPlanes: Plane[]): boolean;
  37374. /**
  37375. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  37376. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  37377. * @param frustumPlanes defines the frustum to test
  37378. * @returns true if the mesh is completely in the frustum planes
  37379. */
  37380. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  37381. /**
  37382. * True if the mesh intersects another mesh or a SolidParticle object
  37383. * @param mesh defines a target mesh or SolidParticle to test
  37384. * @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)
  37385. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  37386. * @returns true if there is an intersection
  37387. */
  37388. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  37389. /**
  37390. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  37391. * @param point defines the point to test
  37392. * @returns true if there is an intersection
  37393. */
  37394. intersectsPoint(point: Vector3): boolean;
  37395. /**
  37396. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  37397. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37398. */
  37399. get checkCollisions(): boolean;
  37400. set checkCollisions(collisionEnabled: boolean);
  37401. /**
  37402. * Gets Collider object used to compute collisions (not physics)
  37403. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37404. */
  37405. get collider(): Nullable<Collider>;
  37406. /**
  37407. * Move the mesh using collision engine
  37408. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37409. * @param displacement defines the requested displacement vector
  37410. * @returns the current mesh
  37411. */
  37412. moveWithCollisions(displacement: Vector3): AbstractMesh;
  37413. private _onCollisionPositionChange;
  37414. /** @hidden */
  37415. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  37416. /** @hidden */
  37417. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  37418. /** @hidden */
  37419. _checkCollision(collider: Collider): AbstractMesh;
  37420. /** @hidden */
  37421. _generatePointsArray(): boolean;
  37422. /**
  37423. * Checks if the passed Ray intersects with the mesh
  37424. * @param ray defines the ray to use
  37425. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  37426. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37427. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  37428. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  37429. * @returns the picking info
  37430. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  37431. */
  37432. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  37433. /**
  37434. * Clones the current mesh
  37435. * @param name defines the mesh name
  37436. * @param newParent defines the new mesh parent
  37437. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  37438. * @returns the new mesh
  37439. */
  37440. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  37441. /**
  37442. * Disposes all the submeshes of the current meshnp
  37443. * @returns the current mesh
  37444. */
  37445. releaseSubMeshes(): AbstractMesh;
  37446. /**
  37447. * Releases resources associated with this abstract mesh.
  37448. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  37449. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  37450. */
  37451. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  37452. /**
  37453. * Adds the passed mesh as a child to the current mesh
  37454. * @param mesh defines the child mesh
  37455. * @returns the current mesh
  37456. */
  37457. addChild(mesh: AbstractMesh): AbstractMesh;
  37458. /**
  37459. * Removes the passed mesh from the current mesh children list
  37460. * @param mesh defines the child mesh
  37461. * @returns the current mesh
  37462. */
  37463. removeChild(mesh: AbstractMesh): AbstractMesh;
  37464. /** @hidden */
  37465. private _initFacetData;
  37466. /**
  37467. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  37468. * This method can be called within the render loop.
  37469. * 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
  37470. * @returns the current mesh
  37471. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37472. */
  37473. updateFacetData(): AbstractMesh;
  37474. /**
  37475. * Returns the facetLocalNormals array.
  37476. * The normals are expressed in the mesh local spac
  37477. * @returns an array of Vector3
  37478. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37479. */
  37480. getFacetLocalNormals(): Vector3[];
  37481. /**
  37482. * Returns the facetLocalPositions array.
  37483. * The facet positions are expressed in the mesh local space
  37484. * @returns an array of Vector3
  37485. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37486. */
  37487. getFacetLocalPositions(): Vector3[];
  37488. /**
  37489. * Returns the facetLocalPartioning array
  37490. * @returns an array of array of numbers
  37491. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37492. */
  37493. getFacetLocalPartitioning(): number[][];
  37494. /**
  37495. * Returns the i-th facet position in the world system.
  37496. * This method allocates a new Vector3 per call
  37497. * @param i defines the facet index
  37498. * @returns a new Vector3
  37499. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37500. */
  37501. getFacetPosition(i: number): Vector3;
  37502. /**
  37503. * Sets the reference Vector3 with the i-th facet position in the world system
  37504. * @param i defines the facet index
  37505. * @param ref defines the target vector
  37506. * @returns the current mesh
  37507. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37508. */
  37509. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  37510. /**
  37511. * Returns the i-th facet normal in the world system.
  37512. * This method allocates a new Vector3 per call
  37513. * @param i defines the facet index
  37514. * @returns a new Vector3
  37515. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37516. */
  37517. getFacetNormal(i: number): Vector3;
  37518. /**
  37519. * Sets the reference Vector3 with the i-th facet normal in the world system
  37520. * @param i defines the facet index
  37521. * @param ref defines the target vector
  37522. * @returns the current mesh
  37523. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37524. */
  37525. getFacetNormalToRef(i: number, ref: Vector3): this;
  37526. /**
  37527. * 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)
  37528. * @param x defines x coordinate
  37529. * @param y defines y coordinate
  37530. * @param z defines z coordinate
  37531. * @returns the array of facet indexes
  37532. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37533. */
  37534. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  37535. /**
  37536. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  37537. * @param projected sets as the (x,y,z) world projection on the facet
  37538. * @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
  37539. * @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
  37540. * @param x defines x coordinate
  37541. * @param y defines y coordinate
  37542. * @param z defines z coordinate
  37543. * @returns the face index if found (or null instead)
  37544. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37545. */
  37546. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37547. /**
  37548. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  37549. * @param projected sets as the (x,y,z) local projection on the facet
  37550. * @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
  37551. * @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
  37552. * @param x defines x coordinate
  37553. * @param y defines y coordinate
  37554. * @param z defines z coordinate
  37555. * @returns the face index if found (or null instead)
  37556. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37557. */
  37558. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  37559. /**
  37560. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  37561. * @returns the parameters
  37562. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37563. */
  37564. getFacetDataParameters(): any;
  37565. /**
  37566. * Disables the feature FacetData and frees the related memory
  37567. * @returns the current mesh
  37568. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  37569. */
  37570. disableFacetData(): AbstractMesh;
  37571. /**
  37572. * Updates the AbstractMesh indices array
  37573. * @param indices defines the data source
  37574. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  37575. * @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)
  37576. * @returns the current mesh
  37577. */
  37578. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  37579. /**
  37580. * Creates new normals data for the mesh
  37581. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  37582. * @returns the current mesh
  37583. */
  37584. createNormals(updatable: boolean): AbstractMesh;
  37585. /**
  37586. * Align the mesh with a normal
  37587. * @param normal defines the normal to use
  37588. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  37589. * @returns the current mesh
  37590. */
  37591. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  37592. /** @hidden */
  37593. _checkOcclusionQuery(): boolean;
  37594. /**
  37595. * Disables the mesh edge rendering mode
  37596. * @returns the currentAbstractMesh
  37597. */
  37598. disableEdgesRendering(): AbstractMesh;
  37599. /**
  37600. * Enables the edge rendering mode on the mesh.
  37601. * This mode makes the mesh edges visible
  37602. * @param epsilon defines the maximal distance between two angles to detect a face
  37603. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  37604. * @returns the currentAbstractMesh
  37605. * @see https://www.babylonjs-playground.com/#19O9TU#0
  37606. */
  37607. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  37608. /**
  37609. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  37610. * @returns an array of particle systems in the scene that use the mesh as an emitter
  37611. */
  37612. getConnectedParticleSystems(): IParticleSystem[];
  37613. }
  37614. }
  37615. declare module "babylonjs/Actions/actionEvent" {
  37616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37617. import { Nullable } from "babylonjs/types";
  37618. import { Sprite } from "babylonjs/Sprites/sprite";
  37619. import { Scene } from "babylonjs/scene";
  37620. import { Vector2 } from "babylonjs/Maths/math.vector";
  37621. /**
  37622. * Interface used to define ActionEvent
  37623. */
  37624. export interface IActionEvent {
  37625. /** The mesh or sprite that triggered the action */
  37626. source: any;
  37627. /** The X mouse cursor position at the time of the event */
  37628. pointerX: number;
  37629. /** The Y mouse cursor position at the time of the event */
  37630. pointerY: number;
  37631. /** The mesh that is currently pointed at (can be null) */
  37632. meshUnderPointer: Nullable<AbstractMesh>;
  37633. /** the original (browser) event that triggered the ActionEvent */
  37634. sourceEvent?: any;
  37635. /** additional data for the event */
  37636. additionalData?: any;
  37637. }
  37638. /**
  37639. * ActionEvent is the event being sent when an action is triggered.
  37640. */
  37641. export class ActionEvent implements IActionEvent {
  37642. /** The mesh or sprite that triggered the action */
  37643. source: any;
  37644. /** The X mouse cursor position at the time of the event */
  37645. pointerX: number;
  37646. /** The Y mouse cursor position at the time of the event */
  37647. pointerY: number;
  37648. /** The mesh that is currently pointed at (can be null) */
  37649. meshUnderPointer: Nullable<AbstractMesh>;
  37650. /** the original (browser) event that triggered the ActionEvent */
  37651. sourceEvent?: any;
  37652. /** additional data for the event */
  37653. additionalData?: any;
  37654. /**
  37655. * Creates a new ActionEvent
  37656. * @param source The mesh or sprite that triggered the action
  37657. * @param pointerX The X mouse cursor position at the time of the event
  37658. * @param pointerY The Y mouse cursor position at the time of the event
  37659. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  37660. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  37661. * @param additionalData additional data for the event
  37662. */
  37663. constructor(
  37664. /** The mesh or sprite that triggered the action */
  37665. source: any,
  37666. /** The X mouse cursor position at the time of the event */
  37667. pointerX: number,
  37668. /** The Y mouse cursor position at the time of the event */
  37669. pointerY: number,
  37670. /** The mesh that is currently pointed at (can be null) */
  37671. meshUnderPointer: Nullable<AbstractMesh>,
  37672. /** the original (browser) event that triggered the ActionEvent */
  37673. sourceEvent?: any,
  37674. /** additional data for the event */
  37675. additionalData?: any);
  37676. /**
  37677. * Helper function to auto-create an ActionEvent from a source mesh.
  37678. * @param source The source mesh that triggered the event
  37679. * @param evt The original (browser) event
  37680. * @param additionalData additional data for the event
  37681. * @returns the new ActionEvent
  37682. */
  37683. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  37684. /**
  37685. * Helper function to auto-create an ActionEvent from a source sprite
  37686. * @param source The source sprite that triggered the event
  37687. * @param scene Scene associated with the sprite
  37688. * @param evt The original (browser) event
  37689. * @param additionalData additional data for the event
  37690. * @returns the new ActionEvent
  37691. */
  37692. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  37693. /**
  37694. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  37695. * @param scene the scene where the event occurred
  37696. * @param evt The original (browser) event
  37697. * @returns the new ActionEvent
  37698. */
  37699. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  37700. /**
  37701. * Helper function to auto-create an ActionEvent from a primitive
  37702. * @param prim defines the target primitive
  37703. * @param pointerPos defines the pointer position
  37704. * @param evt The original (browser) event
  37705. * @param additionalData additional data for the event
  37706. * @returns the new ActionEvent
  37707. */
  37708. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  37709. }
  37710. }
  37711. declare module "babylonjs/Actions/abstractActionManager" {
  37712. import { IDisposable } from "babylonjs/scene";
  37713. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  37714. import { IAction } from "babylonjs/Actions/action";
  37715. import { Nullable } from "babylonjs/types";
  37716. /**
  37717. * Abstract class used to decouple action Manager from scene and meshes.
  37718. * Do not instantiate.
  37719. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  37720. */
  37721. export abstract class AbstractActionManager implements IDisposable {
  37722. /** Gets the list of active triggers */
  37723. static Triggers: {
  37724. [key: string]: number;
  37725. };
  37726. /** Gets the cursor to use when hovering items */
  37727. hoverCursor: string;
  37728. /** Gets the list of actions */
  37729. actions: IAction[];
  37730. /**
  37731. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  37732. */
  37733. isRecursive: boolean;
  37734. /**
  37735. * Releases all associated resources
  37736. */
  37737. abstract dispose(): void;
  37738. /**
  37739. * Does this action manager has pointer triggers
  37740. */
  37741. abstract get hasPointerTriggers(): boolean;
  37742. /**
  37743. * Does this action manager has pick triggers
  37744. */
  37745. abstract get hasPickTriggers(): boolean;
  37746. /**
  37747. * Process a specific trigger
  37748. * @param trigger defines the trigger to process
  37749. * @param evt defines the event details to be processed
  37750. */
  37751. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  37752. /**
  37753. * Does this action manager handles actions of any of the given triggers
  37754. * @param triggers defines the triggers to be tested
  37755. * @return a boolean indicating whether one (or more) of the triggers is handled
  37756. */
  37757. abstract hasSpecificTriggers(triggers: number[]): boolean;
  37758. /**
  37759. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  37760. * speed.
  37761. * @param triggerA defines the trigger to be tested
  37762. * @param triggerB defines the trigger to be tested
  37763. * @return a boolean indicating whether one (or more) of the triggers is handled
  37764. */
  37765. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  37766. /**
  37767. * Does this action manager handles actions of a given trigger
  37768. * @param trigger defines the trigger to be tested
  37769. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  37770. * @return whether the trigger is handled
  37771. */
  37772. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  37773. /**
  37774. * Serialize this manager to a JSON object
  37775. * @param name defines the property name to store this manager
  37776. * @returns a JSON representation of this manager
  37777. */
  37778. abstract serialize(name: string): any;
  37779. /**
  37780. * Registers an action to this action manager
  37781. * @param action defines the action to be registered
  37782. * @return the action amended (prepared) after registration
  37783. */
  37784. abstract registerAction(action: IAction): Nullable<IAction>;
  37785. /**
  37786. * Unregisters an action to this action manager
  37787. * @param action defines the action to be unregistered
  37788. * @return a boolean indicating whether the action has been unregistered
  37789. */
  37790. abstract unregisterAction(action: IAction): Boolean;
  37791. /**
  37792. * Does exist one action manager with at least one trigger
  37793. **/
  37794. static get HasTriggers(): boolean;
  37795. /**
  37796. * Does exist one action manager with at least one pick trigger
  37797. **/
  37798. static get HasPickTriggers(): boolean;
  37799. /**
  37800. * Does exist one action manager that handles actions of a given trigger
  37801. * @param trigger defines the trigger to be tested
  37802. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  37803. **/
  37804. static HasSpecificTrigger(trigger: number): boolean;
  37805. }
  37806. }
  37807. declare module "babylonjs/node" {
  37808. import { Scene } from "babylonjs/scene";
  37809. import { Nullable } from "babylonjs/types";
  37810. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  37811. import { Engine } from "babylonjs/Engines/engine";
  37812. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  37813. import { Observable } from "babylonjs/Misc/observable";
  37814. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  37815. import { IInspectable } from "babylonjs/Misc/iInspectable";
  37816. import { Animatable } from "babylonjs/Animations/animatable";
  37817. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  37818. import { Animation } from "babylonjs/Animations/animation";
  37819. import { AnimationRange } from "babylonjs/Animations/animationRange";
  37820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37821. /**
  37822. * Defines how a node can be built from a string name.
  37823. */
  37824. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  37825. /**
  37826. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  37827. */
  37828. export class Node implements IBehaviorAware<Node> {
  37829. /** @hidden */
  37830. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  37831. private static _NodeConstructors;
  37832. /**
  37833. * Add a new node constructor
  37834. * @param type defines the type name of the node to construct
  37835. * @param constructorFunc defines the constructor function
  37836. */
  37837. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  37838. /**
  37839. * Returns a node constructor based on type name
  37840. * @param type defines the type name
  37841. * @param name defines the new node name
  37842. * @param scene defines the hosting scene
  37843. * @param options defines optional options to transmit to constructors
  37844. * @returns the new constructor or null
  37845. */
  37846. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  37847. /**
  37848. * Gets or sets the name of the node
  37849. */
  37850. name: string;
  37851. /**
  37852. * Gets or sets the id of the node
  37853. */
  37854. id: string;
  37855. /**
  37856. * Gets or sets the unique id of the node
  37857. */
  37858. uniqueId: number;
  37859. /**
  37860. * Gets or sets a string used to store user defined state for the node
  37861. */
  37862. state: string;
  37863. /**
  37864. * Gets or sets an object used to store user defined information for the node
  37865. */
  37866. metadata: any;
  37867. /**
  37868. * For internal use only. Please do not use.
  37869. */
  37870. reservedDataStore: any;
  37871. /**
  37872. * List of inspectable custom properties (used by the Inspector)
  37873. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  37874. */
  37875. inspectableCustomProperties: IInspectable[];
  37876. private _doNotSerialize;
  37877. /**
  37878. * Gets or sets a boolean used to define if the node must be serialized
  37879. */
  37880. get doNotSerialize(): boolean;
  37881. set doNotSerialize(value: boolean);
  37882. /** @hidden */
  37883. _isDisposed: boolean;
  37884. /**
  37885. * Gets a list of Animations associated with the node
  37886. */
  37887. animations: import("babylonjs/Animations/animation").Animation[];
  37888. protected _ranges: {
  37889. [name: string]: Nullable<AnimationRange>;
  37890. };
  37891. /**
  37892. * Callback raised when the node is ready to be used
  37893. */
  37894. onReady: Nullable<(node: Node) => void>;
  37895. private _isEnabled;
  37896. private _isParentEnabled;
  37897. private _isReady;
  37898. /** @hidden */
  37899. _currentRenderId: number;
  37900. private _parentUpdateId;
  37901. /** @hidden */
  37902. _childUpdateId: number;
  37903. /** @hidden */
  37904. _waitingParentId: Nullable<string>;
  37905. /** @hidden */
  37906. _scene: Scene;
  37907. /** @hidden */
  37908. _cache: any;
  37909. private _parentNode;
  37910. private _children;
  37911. /** @hidden */
  37912. _worldMatrix: Matrix;
  37913. /** @hidden */
  37914. _worldMatrixDeterminant: number;
  37915. /** @hidden */
  37916. _worldMatrixDeterminantIsDirty: boolean;
  37917. /** @hidden */
  37918. private _sceneRootNodesIndex;
  37919. /**
  37920. * Gets a boolean indicating if the node has been disposed
  37921. * @returns true if the node was disposed
  37922. */
  37923. isDisposed(): boolean;
  37924. /**
  37925. * Gets or sets the parent of the node (without keeping the current position in the scene)
  37926. * @see https://doc.babylonjs.com/how_to/parenting
  37927. */
  37928. set parent(parent: Nullable<Node>);
  37929. get parent(): Nullable<Node>;
  37930. /** @hidden */
  37931. _addToSceneRootNodes(): void;
  37932. /** @hidden */
  37933. _removeFromSceneRootNodes(): void;
  37934. private _animationPropertiesOverride;
  37935. /**
  37936. * Gets or sets the animation properties override
  37937. */
  37938. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  37939. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  37940. /**
  37941. * Gets a string identifying the name of the class
  37942. * @returns "Node" string
  37943. */
  37944. getClassName(): string;
  37945. /** @hidden */
  37946. readonly _isNode: boolean;
  37947. /**
  37948. * An event triggered when the mesh is disposed
  37949. */
  37950. onDisposeObservable: Observable<Node>;
  37951. private _onDisposeObserver;
  37952. /**
  37953. * Sets a callback that will be raised when the node will be disposed
  37954. */
  37955. set onDispose(callback: () => void);
  37956. /**
  37957. * Creates a new Node
  37958. * @param name the name and id to be given to this node
  37959. * @param scene the scene this node will be added to
  37960. */
  37961. constructor(name: string, scene?: Nullable<Scene>);
  37962. /**
  37963. * Gets the scene of the node
  37964. * @returns a scene
  37965. */
  37966. getScene(): Scene;
  37967. /**
  37968. * Gets the engine of the node
  37969. * @returns a Engine
  37970. */
  37971. getEngine(): Engine;
  37972. private _behaviors;
  37973. /**
  37974. * Attach a behavior to the node
  37975. * @see https://doc.babylonjs.com/features/behaviour
  37976. * @param behavior defines the behavior to attach
  37977. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  37978. * @returns the current Node
  37979. */
  37980. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  37981. /**
  37982. * Remove an attached behavior
  37983. * @see https://doc.babylonjs.com/features/behaviour
  37984. * @param behavior defines the behavior to attach
  37985. * @returns the current Node
  37986. */
  37987. removeBehavior(behavior: Behavior<Node>): Node;
  37988. /**
  37989. * Gets the list of attached behaviors
  37990. * @see https://doc.babylonjs.com/features/behaviour
  37991. */
  37992. get behaviors(): Behavior<Node>[];
  37993. /**
  37994. * Gets an attached behavior by name
  37995. * @param name defines the name of the behavior to look for
  37996. * @see https://doc.babylonjs.com/features/behaviour
  37997. * @returns null if behavior was not found else the requested behavior
  37998. */
  37999. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  38000. /**
  38001. * Returns the latest update of the World matrix
  38002. * @returns a Matrix
  38003. */
  38004. getWorldMatrix(): Matrix;
  38005. /** @hidden */
  38006. _getWorldMatrixDeterminant(): number;
  38007. /**
  38008. * Returns directly the latest state of the mesh World matrix.
  38009. * A Matrix is returned.
  38010. */
  38011. get worldMatrixFromCache(): Matrix;
  38012. /** @hidden */
  38013. _initCache(): void;
  38014. /** @hidden */
  38015. updateCache(force?: boolean): void;
  38016. /** @hidden */
  38017. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  38018. /** @hidden */
  38019. _updateCache(ignoreParentClass?: boolean): void;
  38020. /** @hidden */
  38021. _isSynchronized(): boolean;
  38022. /** @hidden */
  38023. _markSyncedWithParent(): void;
  38024. /** @hidden */
  38025. isSynchronizedWithParent(): boolean;
  38026. /** @hidden */
  38027. isSynchronized(): boolean;
  38028. /**
  38029. * Is this node ready to be used/rendered
  38030. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  38031. * @return true if the node is ready
  38032. */
  38033. isReady(completeCheck?: boolean): boolean;
  38034. /**
  38035. * Is this node enabled?
  38036. * 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
  38037. * @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
  38038. * @return whether this node (and its parent) is enabled
  38039. */
  38040. isEnabled(checkAncestors?: boolean): boolean;
  38041. /** @hidden */
  38042. protected _syncParentEnabledState(): void;
  38043. /**
  38044. * Set the enabled state of this node
  38045. * @param value defines the new enabled state
  38046. */
  38047. setEnabled(value: boolean): void;
  38048. /**
  38049. * Is this node a descendant of the given node?
  38050. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  38051. * @param ancestor defines the parent node to inspect
  38052. * @returns a boolean indicating if this node is a descendant of the given node
  38053. */
  38054. isDescendantOf(ancestor: Node): boolean;
  38055. /** @hidden */
  38056. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  38057. /**
  38058. * Will return all nodes that have this node as ascendant
  38059. * @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
  38060. * @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
  38061. * @return all children nodes of all types
  38062. */
  38063. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  38064. /**
  38065. * Get all child-meshes of this node
  38066. * @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)
  38067. * @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
  38068. * @returns an array of AbstractMesh
  38069. */
  38070. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  38071. /**
  38072. * Get all direct children of this node
  38073. * @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
  38074. * @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)
  38075. * @returns an array of Node
  38076. */
  38077. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  38078. /** @hidden */
  38079. _setReady(state: boolean): void;
  38080. /**
  38081. * Get an animation by name
  38082. * @param name defines the name of the animation to look for
  38083. * @returns null if not found else the requested animation
  38084. */
  38085. getAnimationByName(name: string): Nullable<Animation>;
  38086. /**
  38087. * Creates an animation range for this node
  38088. * @param name defines the name of the range
  38089. * @param from defines the starting key
  38090. * @param to defines the end key
  38091. */
  38092. createAnimationRange(name: string, from: number, to: number): void;
  38093. /**
  38094. * Delete a specific animation range
  38095. * @param name defines the name of the range to delete
  38096. * @param deleteFrames defines if animation frames from the range must be deleted as well
  38097. */
  38098. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  38099. /**
  38100. * Get an animation range by name
  38101. * @param name defines the name of the animation range to look for
  38102. * @returns null if not found else the requested animation range
  38103. */
  38104. getAnimationRange(name: string): Nullable<AnimationRange>;
  38105. /**
  38106. * Gets the list of all animation ranges defined on this node
  38107. * @returns an array
  38108. */
  38109. getAnimationRanges(): Nullable<AnimationRange>[];
  38110. /**
  38111. * Will start the animation sequence
  38112. * @param name defines the range frames for animation sequence
  38113. * @param loop defines if the animation should loop (false by default)
  38114. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  38115. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  38116. * @returns the object created for this animation. If range does not exist, it will return null
  38117. */
  38118. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  38119. /**
  38120. * Serialize animation ranges into a JSON compatible object
  38121. * @returns serialization object
  38122. */
  38123. serializeAnimationRanges(): any;
  38124. /**
  38125. * Computes the world matrix of the node
  38126. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  38127. * @returns the world matrix
  38128. */
  38129. computeWorldMatrix(force?: boolean): Matrix;
  38130. /**
  38131. * Releases resources associated with this node.
  38132. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  38133. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  38134. */
  38135. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  38136. /**
  38137. * Parse animation range data from a serialization object and store them into a given node
  38138. * @param node defines where to store the animation ranges
  38139. * @param parsedNode defines the serialization object to read data from
  38140. * @param scene defines the hosting scene
  38141. */
  38142. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  38143. /**
  38144. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  38145. * @param includeDescendants Include bounding info from descendants as well (true by default)
  38146. * @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
  38147. * @returns the new bounding vectors
  38148. */
  38149. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  38150. min: Vector3;
  38151. max: Vector3;
  38152. };
  38153. }
  38154. }
  38155. declare module "babylonjs/Animations/animation" {
  38156. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  38157. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  38158. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  38159. import { Nullable } from "babylonjs/types";
  38160. import { Scene } from "babylonjs/scene";
  38161. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  38162. import { AnimationRange } from "babylonjs/Animations/animationRange";
  38163. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  38164. import { Node } from "babylonjs/node";
  38165. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38166. import { Size } from "babylonjs/Maths/math.size";
  38167. import { Animatable } from "babylonjs/Animations/animatable";
  38168. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  38169. /**
  38170. * @hidden
  38171. */
  38172. export class _IAnimationState {
  38173. key: number;
  38174. repeatCount: number;
  38175. workValue?: any;
  38176. loopMode?: number;
  38177. offsetValue?: any;
  38178. highLimitValue?: any;
  38179. }
  38180. /**
  38181. * Class used to store any kind of animation
  38182. */
  38183. export class Animation {
  38184. /**Name of the animation */
  38185. name: string;
  38186. /**Property to animate */
  38187. targetProperty: string;
  38188. /**The frames per second of the animation */
  38189. framePerSecond: number;
  38190. /**The data type of the animation */
  38191. dataType: number;
  38192. /**The loop mode of the animation */
  38193. loopMode?: number | undefined;
  38194. /**Specifies if blending should be enabled */
  38195. enableBlending?: boolean | undefined;
  38196. /**
  38197. * Use matrix interpolation instead of using direct key value when animating matrices
  38198. */
  38199. static AllowMatricesInterpolation: boolean;
  38200. /**
  38201. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  38202. */
  38203. static AllowMatrixDecomposeForInterpolation: boolean;
  38204. /** Define the Url to load snippets */
  38205. static SnippetUrl: string;
  38206. /** Snippet ID if the animation was created from the snippet server */
  38207. snippetId: string;
  38208. /**
  38209. * Stores the key frames of the animation
  38210. */
  38211. private _keys;
  38212. /**
  38213. * Stores the easing function of the animation
  38214. */
  38215. private _easingFunction;
  38216. /**
  38217. * @hidden Internal use only
  38218. */
  38219. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  38220. /**
  38221. * The set of event that will be linked to this animation
  38222. */
  38223. private _events;
  38224. /**
  38225. * Stores an array of target property paths
  38226. */
  38227. targetPropertyPath: string[];
  38228. /**
  38229. * Stores the blending speed of the animation
  38230. */
  38231. blendingSpeed: number;
  38232. /**
  38233. * Stores the animation ranges for the animation
  38234. */
  38235. private _ranges;
  38236. /**
  38237. * @hidden Internal use
  38238. */
  38239. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  38240. /**
  38241. * Sets up an animation
  38242. * @param property The property to animate
  38243. * @param animationType The animation type to apply
  38244. * @param framePerSecond The frames per second of the animation
  38245. * @param easingFunction The easing function used in the animation
  38246. * @returns The created animation
  38247. */
  38248. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  38249. /**
  38250. * Create and start an animation on a node
  38251. * @param name defines the name of the global animation that will be run on all nodes
  38252. * @param node defines the root node where the animation will take place
  38253. * @param targetProperty defines property to animate
  38254. * @param framePerSecond defines the number of frame per second yo use
  38255. * @param totalFrame defines the number of frames in total
  38256. * @param from defines the initial value
  38257. * @param to defines the final value
  38258. * @param loopMode defines which loop mode you want to use (off by default)
  38259. * @param easingFunction defines the easing function to use (linear by default)
  38260. * @param onAnimationEnd defines the callback to call when animation end
  38261. * @returns the animatable created for this animation
  38262. */
  38263. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38264. /**
  38265. * Create and start an animation on a node and its descendants
  38266. * @param name defines the name of the global animation that will be run on all nodes
  38267. * @param node defines the root node where the animation will take place
  38268. * @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
  38269. * @param targetProperty defines property to animate
  38270. * @param framePerSecond defines the number of frame per second to use
  38271. * @param totalFrame defines the number of frames in total
  38272. * @param from defines the initial value
  38273. * @param to defines the final value
  38274. * @param loopMode defines which loop mode you want to use (off by default)
  38275. * @param easingFunction defines the easing function to use (linear by default)
  38276. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  38277. * @returns the list of animatables created for all nodes
  38278. * @example https://www.babylonjs-playground.com/#MH0VLI
  38279. */
  38280. 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[]>;
  38281. /**
  38282. * Creates a new animation, merges it with the existing animations and starts it
  38283. * @param name Name of the animation
  38284. * @param node Node which contains the scene that begins the animations
  38285. * @param targetProperty Specifies which property to animate
  38286. * @param framePerSecond The frames per second of the animation
  38287. * @param totalFrame The total number of frames
  38288. * @param from The frame at the beginning of the animation
  38289. * @param to The frame at the end of the animation
  38290. * @param loopMode Specifies the loop mode of the animation
  38291. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  38292. * @param onAnimationEnd Callback to run once the animation is complete
  38293. * @returns Nullable animation
  38294. */
  38295. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  38296. /**
  38297. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  38298. * @param sourceAnimation defines the Animation containing keyframes to convert
  38299. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  38300. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  38301. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  38302. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  38303. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  38304. */
  38305. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  38306. /**
  38307. * Transition property of an host to the target Value
  38308. * @param property The property to transition
  38309. * @param targetValue The target Value of the property
  38310. * @param host The object where the property to animate belongs
  38311. * @param scene Scene used to run the animation
  38312. * @param frameRate Framerate (in frame/s) to use
  38313. * @param transition The transition type we want to use
  38314. * @param duration The duration of the animation, in milliseconds
  38315. * @param onAnimationEnd Callback trigger at the end of the animation
  38316. * @returns Nullable animation
  38317. */
  38318. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  38319. /**
  38320. * Return the array of runtime animations currently using this animation
  38321. */
  38322. get runtimeAnimations(): RuntimeAnimation[];
  38323. /**
  38324. * Specifies if any of the runtime animations are currently running
  38325. */
  38326. get hasRunningRuntimeAnimations(): boolean;
  38327. /**
  38328. * Initializes the animation
  38329. * @param name Name of the animation
  38330. * @param targetProperty Property to animate
  38331. * @param framePerSecond The frames per second of the animation
  38332. * @param dataType The data type of the animation
  38333. * @param loopMode The loop mode of the animation
  38334. * @param enableBlending Specifies if blending should be enabled
  38335. */
  38336. constructor(
  38337. /**Name of the animation */
  38338. name: string,
  38339. /**Property to animate */
  38340. targetProperty: string,
  38341. /**The frames per second of the animation */
  38342. framePerSecond: number,
  38343. /**The data type of the animation */
  38344. dataType: number,
  38345. /**The loop mode of the animation */
  38346. loopMode?: number | undefined,
  38347. /**Specifies if blending should be enabled */
  38348. enableBlending?: boolean | undefined);
  38349. /**
  38350. * Converts the animation to a string
  38351. * @param fullDetails support for multiple levels of logging within scene loading
  38352. * @returns String form of the animation
  38353. */
  38354. toString(fullDetails?: boolean): string;
  38355. /**
  38356. * Add an event to this animation
  38357. * @param event Event to add
  38358. */
  38359. addEvent(event: AnimationEvent): void;
  38360. /**
  38361. * Remove all events found at the given frame
  38362. * @param frame The frame to remove events from
  38363. */
  38364. removeEvents(frame: number): void;
  38365. /**
  38366. * Retrieves all the events from the animation
  38367. * @returns Events from the animation
  38368. */
  38369. getEvents(): AnimationEvent[];
  38370. /**
  38371. * Creates an animation range
  38372. * @param name Name of the animation range
  38373. * @param from Starting frame of the animation range
  38374. * @param to Ending frame of the animation
  38375. */
  38376. createRange(name: string, from: number, to: number): void;
  38377. /**
  38378. * Deletes an animation range by name
  38379. * @param name Name of the animation range to delete
  38380. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  38381. */
  38382. deleteRange(name: string, deleteFrames?: boolean): void;
  38383. /**
  38384. * Gets the animation range by name, or null if not defined
  38385. * @param name Name of the animation range
  38386. * @returns Nullable animation range
  38387. */
  38388. getRange(name: string): Nullable<AnimationRange>;
  38389. /**
  38390. * Gets the key frames from the animation
  38391. * @returns The key frames of the animation
  38392. */
  38393. getKeys(): Array<IAnimationKey>;
  38394. /**
  38395. * Gets the highest frame rate of the animation
  38396. * @returns Highest frame rate of the animation
  38397. */
  38398. getHighestFrame(): number;
  38399. /**
  38400. * Gets the easing function of the animation
  38401. * @returns Easing function of the animation
  38402. */
  38403. getEasingFunction(): IEasingFunction;
  38404. /**
  38405. * Sets the easing function of the animation
  38406. * @param easingFunction A custom mathematical formula for animation
  38407. */
  38408. setEasingFunction(easingFunction: EasingFunction): void;
  38409. /**
  38410. * Interpolates a scalar linearly
  38411. * @param startValue Start value of the animation curve
  38412. * @param endValue End value of the animation curve
  38413. * @param gradient Scalar amount to interpolate
  38414. * @returns Interpolated scalar value
  38415. */
  38416. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  38417. /**
  38418. * Interpolates a scalar cubically
  38419. * @param startValue Start value of the animation curve
  38420. * @param outTangent End tangent of the animation
  38421. * @param endValue End value of the animation curve
  38422. * @param inTangent Start tangent of the animation curve
  38423. * @param gradient Scalar amount to interpolate
  38424. * @returns Interpolated scalar value
  38425. */
  38426. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  38427. /**
  38428. * Interpolates a quaternion using a spherical linear interpolation
  38429. * @param startValue Start value of the animation curve
  38430. * @param endValue End value of the animation curve
  38431. * @param gradient Scalar amount to interpolate
  38432. * @returns Interpolated quaternion value
  38433. */
  38434. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  38435. /**
  38436. * Interpolates a quaternion cubically
  38437. * @param startValue Start value of the animation curve
  38438. * @param outTangent End tangent of the animation curve
  38439. * @param endValue End value of the animation curve
  38440. * @param inTangent Start tangent of the animation curve
  38441. * @param gradient Scalar amount to interpolate
  38442. * @returns Interpolated quaternion value
  38443. */
  38444. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  38445. /**
  38446. * Interpolates a Vector3 linearl
  38447. * @param startValue Start value of the animation curve
  38448. * @param endValue End value of the animation curve
  38449. * @param gradient Scalar amount to interpolate
  38450. * @returns Interpolated scalar value
  38451. */
  38452. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  38453. /**
  38454. * Interpolates a Vector3 cubically
  38455. * @param startValue Start value of the animation curve
  38456. * @param outTangent End tangent of the animation
  38457. * @param endValue End value of the animation curve
  38458. * @param inTangent Start tangent of the animation curve
  38459. * @param gradient Scalar amount to interpolate
  38460. * @returns InterpolatedVector3 value
  38461. */
  38462. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  38463. /**
  38464. * Interpolates a Vector2 linearly
  38465. * @param startValue Start value of the animation curve
  38466. * @param endValue End value of the animation curve
  38467. * @param gradient Scalar amount to interpolate
  38468. * @returns Interpolated Vector2 value
  38469. */
  38470. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  38471. /**
  38472. * Interpolates a Vector2 cubically
  38473. * @param startValue Start value of the animation curve
  38474. * @param outTangent End tangent of the animation
  38475. * @param endValue End value of the animation curve
  38476. * @param inTangent Start tangent of the animation curve
  38477. * @param gradient Scalar amount to interpolate
  38478. * @returns Interpolated Vector2 value
  38479. */
  38480. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  38481. /**
  38482. * Interpolates a size linearly
  38483. * @param startValue Start value of the animation curve
  38484. * @param endValue End value of the animation curve
  38485. * @param gradient Scalar amount to interpolate
  38486. * @returns Interpolated Size value
  38487. */
  38488. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  38489. /**
  38490. * Interpolates a Color3 linearly
  38491. * @param startValue Start value of the animation curve
  38492. * @param endValue End value of the animation curve
  38493. * @param gradient Scalar amount to interpolate
  38494. * @returns Interpolated Color3 value
  38495. */
  38496. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  38497. /**
  38498. * Interpolates a Color4 linearly
  38499. * @param startValue Start value of the animation curve
  38500. * @param endValue End value of the animation curve
  38501. * @param gradient Scalar amount to interpolate
  38502. * @returns Interpolated Color3 value
  38503. */
  38504. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  38505. /**
  38506. * @hidden Internal use only
  38507. */
  38508. _getKeyValue(value: any): any;
  38509. /**
  38510. * @hidden Internal use only
  38511. */
  38512. _interpolate(currentFrame: number, state: _IAnimationState): any;
  38513. /**
  38514. * Defines the function to use to interpolate matrices
  38515. * @param startValue defines the start matrix
  38516. * @param endValue defines the end matrix
  38517. * @param gradient defines the gradient between both matrices
  38518. * @param result defines an optional target matrix where to store the interpolation
  38519. * @returns the interpolated matrix
  38520. */
  38521. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  38522. /**
  38523. * Makes a copy of the animation
  38524. * @returns Cloned animation
  38525. */
  38526. clone(): Animation;
  38527. /**
  38528. * Sets the key frames of the animation
  38529. * @param values The animation key frames to set
  38530. */
  38531. setKeys(values: Array<IAnimationKey>): void;
  38532. /**
  38533. * Serializes the animation to an object
  38534. * @returns Serialized object
  38535. */
  38536. serialize(): any;
  38537. /**
  38538. * Float animation type
  38539. */
  38540. static readonly ANIMATIONTYPE_FLOAT: number;
  38541. /**
  38542. * Vector3 animation type
  38543. */
  38544. static readonly ANIMATIONTYPE_VECTOR3: number;
  38545. /**
  38546. * Quaternion animation type
  38547. */
  38548. static readonly ANIMATIONTYPE_QUATERNION: number;
  38549. /**
  38550. * Matrix animation type
  38551. */
  38552. static readonly ANIMATIONTYPE_MATRIX: number;
  38553. /**
  38554. * Color3 animation type
  38555. */
  38556. static readonly ANIMATIONTYPE_COLOR3: number;
  38557. /**
  38558. * Color3 animation type
  38559. */
  38560. static readonly ANIMATIONTYPE_COLOR4: number;
  38561. /**
  38562. * Vector2 animation type
  38563. */
  38564. static readonly ANIMATIONTYPE_VECTOR2: number;
  38565. /**
  38566. * Size animation type
  38567. */
  38568. static readonly ANIMATIONTYPE_SIZE: number;
  38569. /**
  38570. * Relative Loop Mode
  38571. */
  38572. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  38573. /**
  38574. * Cycle Loop Mode
  38575. */
  38576. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  38577. /**
  38578. * Constant Loop Mode
  38579. */
  38580. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  38581. /** @hidden */
  38582. static _UniversalLerp(left: any, right: any, amount: number): any;
  38583. /**
  38584. * Parses an animation object and creates an animation
  38585. * @param parsedAnimation Parsed animation object
  38586. * @returns Animation object
  38587. */
  38588. static Parse(parsedAnimation: any): Animation;
  38589. /**
  38590. * Appends the serialized animations from the source animations
  38591. * @param source Source containing the animations
  38592. * @param destination Target to store the animations
  38593. */
  38594. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38595. /**
  38596. * Creates a new animation or an array of animations from a snippet saved in a remote file
  38597. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  38598. * @param url defines the url to load from
  38599. * @returns a promise that will resolve to the new animation or an array of animations
  38600. */
  38601. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  38602. /**
  38603. * Creates an animation or an array of animations from a snippet saved by the Inspector
  38604. * @param snippetId defines the snippet to load
  38605. * @returns a promise that will resolve to the new animation or a new array of animations
  38606. */
  38607. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  38608. }
  38609. }
  38610. declare module "babylonjs/Animations/animatable.interface" {
  38611. import { Nullable } from "babylonjs/types";
  38612. import { Animation } from "babylonjs/Animations/animation";
  38613. /**
  38614. * Interface containing an array of animations
  38615. */
  38616. export interface IAnimatable {
  38617. /**
  38618. * Array of animations
  38619. */
  38620. animations: Nullable<Array<Animation>>;
  38621. }
  38622. }
  38623. declare module "babylonjs/Misc/decorators" {
  38624. import { Nullable } from "babylonjs/types";
  38625. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38626. import { Scene } from "babylonjs/scene";
  38627. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  38628. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  38629. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  38630. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38631. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  38632. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38633. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38634. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38635. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38636. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38637. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38638. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38639. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38640. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38641. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38642. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38643. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38644. /**
  38645. * Decorator used to define property that can be serialized as reference to a camera
  38646. * @param sourceName defines the name of the property to decorate
  38647. */
  38648. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  38649. /**
  38650. * Class used to help serialization objects
  38651. */
  38652. export class SerializationHelper {
  38653. /** @hidden */
  38654. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  38655. /** @hidden */
  38656. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  38657. /** @hidden */
  38658. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  38659. /** @hidden */
  38660. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  38661. /**
  38662. * Appends the serialized animations from the source animations
  38663. * @param source Source containing the animations
  38664. * @param destination Target to store the animations
  38665. */
  38666. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  38667. /**
  38668. * Static function used to serialized a specific entity
  38669. * @param entity defines the entity to serialize
  38670. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  38671. * @returns a JSON compatible object representing the serialization of the entity
  38672. */
  38673. static Serialize<T>(entity: T, serializationObject?: any): any;
  38674. /**
  38675. * Creates a new entity from a serialization data object
  38676. * @param creationFunction defines a function used to instanciated the new entity
  38677. * @param source defines the source serialization data
  38678. * @param scene defines the hosting scene
  38679. * @param rootUrl defines the root url for resources
  38680. * @returns a new entity
  38681. */
  38682. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  38683. /**
  38684. * Clones an object
  38685. * @param creationFunction defines the function used to instanciate the new object
  38686. * @param source defines the source object
  38687. * @returns the cloned object
  38688. */
  38689. static Clone<T>(creationFunction: () => T, source: T): T;
  38690. /**
  38691. * Instanciates a new object based on a source one (some data will be shared between both object)
  38692. * @param creationFunction defines the function used to instanciate the new object
  38693. * @param source defines the source object
  38694. * @returns the new object
  38695. */
  38696. static Instanciate<T>(creationFunction: () => T, source: T): T;
  38697. }
  38698. }
  38699. declare module "babylonjs/Materials/Textures/baseTexture" {
  38700. import { Observable } from "babylonjs/Misc/observable";
  38701. import { Nullable } from "babylonjs/types";
  38702. import { Scene } from "babylonjs/scene";
  38703. import { Matrix } from "babylonjs/Maths/math.vector";
  38704. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38705. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  38706. import { ISize } from "babylonjs/Maths/math.size";
  38707. import "babylonjs/Misc/fileTools";
  38708. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  38709. /**
  38710. * Base class of all the textures in babylon.
  38711. * It groups all the common properties the materials, post process, lights... might need
  38712. * in order to make a correct use of the texture.
  38713. */
  38714. export class BaseTexture implements IAnimatable {
  38715. /**
  38716. * Default anisotropic filtering level for the application.
  38717. * It is set to 4 as a good tradeoff between perf and quality.
  38718. */
  38719. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  38720. /**
  38721. * Gets or sets the unique id of the texture
  38722. */
  38723. uniqueId: number;
  38724. /**
  38725. * Define the name of the texture.
  38726. */
  38727. name: string;
  38728. /**
  38729. * Gets or sets an object used to store user defined information.
  38730. */
  38731. metadata: any;
  38732. /**
  38733. * For internal use only. Please do not use.
  38734. */
  38735. reservedDataStore: any;
  38736. private _hasAlpha;
  38737. /**
  38738. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  38739. */
  38740. set hasAlpha(value: boolean);
  38741. get hasAlpha(): boolean;
  38742. /**
  38743. * Defines if the alpha value should be determined via the rgb values.
  38744. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  38745. */
  38746. getAlphaFromRGB: boolean;
  38747. /**
  38748. * Intensity or strength of the texture.
  38749. * It is commonly used by materials to fine tune the intensity of the texture
  38750. */
  38751. level: number;
  38752. /**
  38753. * Define the UV chanel to use starting from 0 and defaulting to 0.
  38754. * This is part of the texture as textures usually maps to one uv set.
  38755. */
  38756. coordinatesIndex: number;
  38757. protected _coordinatesMode: number;
  38758. /**
  38759. * How a texture is mapped.
  38760. *
  38761. * | Value | Type | Description |
  38762. * | ----- | ----------------------------------- | ----------- |
  38763. * | 0 | EXPLICIT_MODE | |
  38764. * | 1 | SPHERICAL_MODE | |
  38765. * | 2 | PLANAR_MODE | |
  38766. * | 3 | CUBIC_MODE | |
  38767. * | 4 | PROJECTION_MODE | |
  38768. * | 5 | SKYBOX_MODE | |
  38769. * | 6 | INVCUBIC_MODE | |
  38770. * | 7 | EQUIRECTANGULAR_MODE | |
  38771. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  38772. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  38773. */
  38774. set coordinatesMode(value: number);
  38775. get coordinatesMode(): number;
  38776. private _wrapU;
  38777. /**
  38778. * | Value | Type | Description |
  38779. * | ----- | ------------------ | ----------- |
  38780. * | 0 | CLAMP_ADDRESSMODE | |
  38781. * | 1 | WRAP_ADDRESSMODE | |
  38782. * | 2 | MIRROR_ADDRESSMODE | |
  38783. */
  38784. get wrapU(): number;
  38785. set wrapU(value: number);
  38786. private _wrapV;
  38787. /**
  38788. * | Value | Type | Description |
  38789. * | ----- | ------------------ | ----------- |
  38790. * | 0 | CLAMP_ADDRESSMODE | |
  38791. * | 1 | WRAP_ADDRESSMODE | |
  38792. * | 2 | MIRROR_ADDRESSMODE | |
  38793. */
  38794. get wrapV(): number;
  38795. set wrapV(value: number);
  38796. /**
  38797. * | Value | Type | Description |
  38798. * | ----- | ------------------ | ----------- |
  38799. * | 0 | CLAMP_ADDRESSMODE | |
  38800. * | 1 | WRAP_ADDRESSMODE | |
  38801. * | 2 | MIRROR_ADDRESSMODE | |
  38802. */
  38803. wrapR: number;
  38804. /**
  38805. * With compliant hardware and browser (supporting anisotropic filtering)
  38806. * this defines the level of anisotropic filtering in the texture.
  38807. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  38808. */
  38809. anisotropicFilteringLevel: number;
  38810. /**
  38811. * Define if the texture is a cube texture or if false a 2d texture.
  38812. */
  38813. get isCube(): boolean;
  38814. set isCube(value: boolean);
  38815. /**
  38816. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  38817. */
  38818. get is3D(): boolean;
  38819. set is3D(value: boolean);
  38820. /**
  38821. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  38822. */
  38823. get is2DArray(): boolean;
  38824. set is2DArray(value: boolean);
  38825. private _gammaSpace;
  38826. /**
  38827. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  38828. * HDR texture are usually stored in linear space.
  38829. * This only impacts the PBR and Background materials
  38830. */
  38831. get gammaSpace(): boolean;
  38832. set gammaSpace(gamma: boolean);
  38833. /**
  38834. * Gets or sets whether or not the texture contains RGBD data.
  38835. */
  38836. get isRGBD(): boolean;
  38837. set isRGBD(value: boolean);
  38838. /**
  38839. * Is Z inverted in the texture (useful in a cube texture).
  38840. */
  38841. invertZ: boolean;
  38842. /**
  38843. * Are mip maps generated for this texture or not.
  38844. */
  38845. get noMipmap(): boolean;
  38846. /**
  38847. * @hidden
  38848. */
  38849. lodLevelInAlpha: boolean;
  38850. /**
  38851. * With prefiltered texture, defined the offset used during the prefiltering steps.
  38852. */
  38853. get lodGenerationOffset(): number;
  38854. set lodGenerationOffset(value: number);
  38855. /**
  38856. * With prefiltered texture, defined the scale used during the prefiltering steps.
  38857. */
  38858. get lodGenerationScale(): number;
  38859. set lodGenerationScale(value: number);
  38860. /**
  38861. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  38862. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  38863. * average roughness values.
  38864. */
  38865. get linearSpecularLOD(): boolean;
  38866. set linearSpecularLOD(value: boolean);
  38867. /**
  38868. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  38869. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  38870. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  38871. */
  38872. get irradianceTexture(): Nullable<BaseTexture>;
  38873. set irradianceTexture(value: Nullable<BaseTexture>);
  38874. /**
  38875. * Define if the texture is a render target.
  38876. */
  38877. isRenderTarget: boolean;
  38878. /**
  38879. * Define the unique id of the texture in the scene.
  38880. */
  38881. get uid(): string;
  38882. /** @hidden */
  38883. _prefiltered: boolean;
  38884. /**
  38885. * Return a string representation of the texture.
  38886. * @returns the texture as a string
  38887. */
  38888. toString(): string;
  38889. /**
  38890. * Get the class name of the texture.
  38891. * @returns "BaseTexture"
  38892. */
  38893. getClassName(): string;
  38894. /**
  38895. * Define the list of animation attached to the texture.
  38896. */
  38897. animations: import("babylonjs/Animations/animation").Animation[];
  38898. /**
  38899. * An event triggered when the texture is disposed.
  38900. */
  38901. onDisposeObservable: Observable<BaseTexture>;
  38902. private _onDisposeObserver;
  38903. /**
  38904. * Callback triggered when the texture has been disposed.
  38905. * Kept for back compatibility, you can use the onDisposeObservable instead.
  38906. */
  38907. set onDispose(callback: () => void);
  38908. /**
  38909. * Define the current state of the loading sequence when in delayed load mode.
  38910. */
  38911. delayLoadState: number;
  38912. protected _scene: Nullable<Scene>;
  38913. protected _engine: Nullable<ThinEngine>;
  38914. /** @hidden */
  38915. _texture: Nullable<InternalTexture>;
  38916. private _uid;
  38917. /**
  38918. * Define if the texture is preventinga material to render or not.
  38919. * If not and the texture is not ready, the engine will use a default black texture instead.
  38920. */
  38921. get isBlocking(): boolean;
  38922. /**
  38923. * Instantiates a new BaseTexture.
  38924. * Base class of all the textures in babylon.
  38925. * It groups all the common properties the materials, post process, lights... might need
  38926. * in order to make a correct use of the texture.
  38927. * @param sceneOrEngine Define the scene or engine the texture blongs to
  38928. */
  38929. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  38930. /**
  38931. * Get the scene the texture belongs to.
  38932. * @returns the scene or null if undefined
  38933. */
  38934. getScene(): Nullable<Scene>;
  38935. /** @hidden */
  38936. protected _getEngine(): Nullable<ThinEngine>;
  38937. /**
  38938. * Checks if the texture has the same transform matrix than another texture
  38939. * @param texture texture to check against
  38940. * @returns true if the transforms are the same, else false
  38941. */
  38942. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  38943. /**
  38944. * Get the texture transform matrix used to offset tile the texture for istance.
  38945. * @returns the transformation matrix
  38946. */
  38947. getTextureMatrix(): Matrix;
  38948. /**
  38949. * Get the texture reflection matrix used to rotate/transform the reflection.
  38950. * @returns the reflection matrix
  38951. */
  38952. getReflectionTextureMatrix(): Matrix;
  38953. /**
  38954. * Get the underlying lower level texture from Babylon.
  38955. * @returns the insternal texture
  38956. */
  38957. getInternalTexture(): Nullable<InternalTexture>;
  38958. /**
  38959. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  38960. * @returns true if ready or not blocking
  38961. */
  38962. isReadyOrNotBlocking(): boolean;
  38963. /**
  38964. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  38965. * @returns true if fully ready
  38966. */
  38967. isReady(): boolean;
  38968. private _cachedSize;
  38969. /**
  38970. * Get the size of the texture.
  38971. * @returns the texture size.
  38972. */
  38973. getSize(): ISize;
  38974. /**
  38975. * Get the base size of the texture.
  38976. * It can be different from the size if the texture has been resized for POT for instance
  38977. * @returns the base size
  38978. */
  38979. getBaseSize(): ISize;
  38980. /**
  38981. * Update the sampling mode of the texture.
  38982. * Default is Trilinear mode.
  38983. *
  38984. * | Value | Type | Description |
  38985. * | ----- | ------------------ | ----------- |
  38986. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  38987. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  38988. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  38989. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  38990. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  38991. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  38992. * | 7 | NEAREST_LINEAR | |
  38993. * | 8 | NEAREST_NEAREST | |
  38994. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  38995. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  38996. * | 11 | LINEAR_LINEAR | |
  38997. * | 12 | LINEAR_NEAREST | |
  38998. *
  38999. * > _mag_: magnification filter (close to the viewer)
  39000. * > _min_: minification filter (far from the viewer)
  39001. * > _mip_: filter used between mip map levels
  39002. *@param samplingMode Define the new sampling mode of the texture
  39003. */
  39004. updateSamplingMode(samplingMode: number): void;
  39005. /**
  39006. * Scales the texture if is `canRescale()`
  39007. * @param ratio the resize factor we want to use to rescale
  39008. */
  39009. scale(ratio: number): void;
  39010. /**
  39011. * Get if the texture can rescale.
  39012. */
  39013. get canRescale(): boolean;
  39014. /** @hidden */
  39015. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  39016. /** @hidden */
  39017. _rebuild(): void;
  39018. /**
  39019. * Triggers the load sequence in delayed load mode.
  39020. */
  39021. delayLoad(): void;
  39022. /**
  39023. * Clones the texture.
  39024. * @returns the cloned texture
  39025. */
  39026. clone(): Nullable<BaseTexture>;
  39027. /**
  39028. * Get the texture underlying type (INT, FLOAT...)
  39029. */
  39030. get textureType(): number;
  39031. /**
  39032. * Get the texture underlying format (RGB, RGBA...)
  39033. */
  39034. get textureFormat(): number;
  39035. /**
  39036. * Indicates that textures need to be re-calculated for all materials
  39037. */
  39038. protected _markAllSubMeshesAsTexturesDirty(): void;
  39039. /**
  39040. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  39041. * This will returns an RGBA array buffer containing either in values (0-255) or
  39042. * float values (0-1) depending of the underlying buffer type.
  39043. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  39044. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  39045. * @param buffer defines a user defined buffer to fill with data (can be null)
  39046. * @returns The Array buffer containing the pixels data.
  39047. */
  39048. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  39049. /**
  39050. * Release and destroy the underlying lower level texture aka internalTexture.
  39051. */
  39052. releaseInternalTexture(): void;
  39053. /** @hidden */
  39054. get _lodTextureHigh(): Nullable<BaseTexture>;
  39055. /** @hidden */
  39056. get _lodTextureMid(): Nullable<BaseTexture>;
  39057. /** @hidden */
  39058. get _lodTextureLow(): Nullable<BaseTexture>;
  39059. /**
  39060. * Dispose the texture and release its associated resources.
  39061. */
  39062. dispose(): void;
  39063. /**
  39064. * Serialize the texture into a JSON representation that can be parsed later on.
  39065. * @returns the JSON representation of the texture
  39066. */
  39067. serialize(): any;
  39068. /**
  39069. * Helper function to be called back once a list of texture contains only ready textures.
  39070. * @param textures Define the list of textures to wait for
  39071. * @param callback Define the callback triggered once the entire list will be ready
  39072. */
  39073. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  39074. private static _isScene;
  39075. }
  39076. }
  39077. declare module "babylonjs/Materials/effect" {
  39078. import { Observable } from "babylonjs/Misc/observable";
  39079. import { Nullable } from "babylonjs/types";
  39080. import { IDisposable } from "babylonjs/scene";
  39081. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  39082. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  39083. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  39084. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  39085. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  39086. import { Engine } from "babylonjs/Engines/engine";
  39087. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39088. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39089. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39090. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39091. /**
  39092. * Options to be used when creating an effect.
  39093. */
  39094. export interface IEffectCreationOptions {
  39095. /**
  39096. * Atrributes that will be used in the shader.
  39097. */
  39098. attributes: string[];
  39099. /**
  39100. * Uniform varible names that will be set in the shader.
  39101. */
  39102. uniformsNames: string[];
  39103. /**
  39104. * Uniform buffer variable names that will be set in the shader.
  39105. */
  39106. uniformBuffersNames: string[];
  39107. /**
  39108. * Sampler texture variable names that will be set in the shader.
  39109. */
  39110. samplers: string[];
  39111. /**
  39112. * Define statements that will be set in the shader.
  39113. */
  39114. defines: any;
  39115. /**
  39116. * Possible fallbacks for this effect to improve performance when needed.
  39117. */
  39118. fallbacks: Nullable<IEffectFallbacks>;
  39119. /**
  39120. * Callback that will be called when the shader is compiled.
  39121. */
  39122. onCompiled: Nullable<(effect: Effect) => void>;
  39123. /**
  39124. * Callback that will be called if an error occurs during shader compilation.
  39125. */
  39126. onError: Nullable<(effect: Effect, errors: string) => void>;
  39127. /**
  39128. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39129. */
  39130. indexParameters?: any;
  39131. /**
  39132. * Max number of lights that can be used in the shader.
  39133. */
  39134. maxSimultaneousLights?: number;
  39135. /**
  39136. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  39137. */
  39138. transformFeedbackVaryings?: Nullable<string[]>;
  39139. /**
  39140. * 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
  39141. */
  39142. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  39143. /**
  39144. * Is this effect rendering to several color attachments ?
  39145. */
  39146. multiTarget?: boolean;
  39147. }
  39148. /**
  39149. * Effect containing vertex and fragment shader that can be executed on an object.
  39150. */
  39151. export class Effect implements IDisposable {
  39152. /**
  39153. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  39154. */
  39155. static ShadersRepository: string;
  39156. /**
  39157. * Enable logging of the shader code when a compilation error occurs
  39158. */
  39159. static LogShaderCodeOnCompilationError: boolean;
  39160. /**
  39161. * Name of the effect.
  39162. */
  39163. name: any;
  39164. /**
  39165. * String container all the define statements that should be set on the shader.
  39166. */
  39167. defines: string;
  39168. /**
  39169. * Callback that will be called when the shader is compiled.
  39170. */
  39171. onCompiled: Nullable<(effect: Effect) => void>;
  39172. /**
  39173. * Callback that will be called if an error occurs during shader compilation.
  39174. */
  39175. onError: Nullable<(effect: Effect, errors: string) => void>;
  39176. /**
  39177. * Callback that will be called when effect is bound.
  39178. */
  39179. onBind: Nullable<(effect: Effect) => void>;
  39180. /**
  39181. * Unique ID of the effect.
  39182. */
  39183. uniqueId: number;
  39184. /**
  39185. * Observable that will be called when the shader is compiled.
  39186. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  39187. */
  39188. onCompileObservable: Observable<Effect>;
  39189. /**
  39190. * Observable that will be called if an error occurs during shader compilation.
  39191. */
  39192. onErrorObservable: Observable<Effect>;
  39193. /** @hidden */
  39194. _onBindObservable: Nullable<Observable<Effect>>;
  39195. /**
  39196. * @hidden
  39197. * Specifies if the effect was previously ready
  39198. */
  39199. _wasPreviouslyReady: boolean;
  39200. /**
  39201. * Observable that will be called when effect is bound.
  39202. */
  39203. get onBindObservable(): Observable<Effect>;
  39204. /** @hidden */
  39205. _bonesComputationForcedToCPU: boolean;
  39206. /** @hidden */
  39207. _multiTarget: boolean;
  39208. private static _uniqueIdSeed;
  39209. private _engine;
  39210. private _uniformBuffersNames;
  39211. private _uniformBuffersNamesList;
  39212. private _uniformsNames;
  39213. private _samplerList;
  39214. private _samplers;
  39215. private _isReady;
  39216. private _compilationError;
  39217. private _allFallbacksProcessed;
  39218. private _attributesNames;
  39219. private _attributes;
  39220. private _attributeLocationByName;
  39221. private _uniforms;
  39222. /**
  39223. * Key for the effect.
  39224. * @hidden
  39225. */
  39226. _key: string;
  39227. private _indexParameters;
  39228. private _fallbacks;
  39229. private _vertexSourceCode;
  39230. private _fragmentSourceCode;
  39231. private _vertexSourceCodeOverride;
  39232. private _fragmentSourceCodeOverride;
  39233. private _transformFeedbackVaryings;
  39234. /**
  39235. * Compiled shader to webGL program.
  39236. * @hidden
  39237. */
  39238. _pipelineContext: Nullable<IPipelineContext>;
  39239. private _valueCache;
  39240. private static _baseCache;
  39241. /**
  39242. * Instantiates an effect.
  39243. * An effect can be used to create/manage/execute vertex and fragment shaders.
  39244. * @param baseName Name of the effect.
  39245. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  39246. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  39247. * @param samplers List of sampler variables that will be passed to the shader.
  39248. * @param engine Engine to be used to render the effect
  39249. * @param defines Define statements to be added to the shader.
  39250. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  39251. * @param onCompiled Callback that will be called when the shader is compiled.
  39252. * @param onError Callback that will be called if an error occurs during shader compilation.
  39253. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  39254. */
  39255. 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);
  39256. private _useFinalCode;
  39257. /**
  39258. * Unique key for this effect
  39259. */
  39260. get key(): string;
  39261. /**
  39262. * If the effect has been compiled and prepared.
  39263. * @returns if the effect is compiled and prepared.
  39264. */
  39265. isReady(): boolean;
  39266. private _isReadyInternal;
  39267. /**
  39268. * The engine the effect was initialized with.
  39269. * @returns the engine.
  39270. */
  39271. getEngine(): Engine;
  39272. /**
  39273. * The pipeline context for this effect
  39274. * @returns the associated pipeline context
  39275. */
  39276. getPipelineContext(): Nullable<IPipelineContext>;
  39277. /**
  39278. * The set of names of attribute variables for the shader.
  39279. * @returns An array of attribute names.
  39280. */
  39281. getAttributesNames(): string[];
  39282. /**
  39283. * Returns the attribute at the given index.
  39284. * @param index The index of the attribute.
  39285. * @returns The location of the attribute.
  39286. */
  39287. getAttributeLocation(index: number): number;
  39288. /**
  39289. * Returns the attribute based on the name of the variable.
  39290. * @param name of the attribute to look up.
  39291. * @returns the attribute location.
  39292. */
  39293. getAttributeLocationByName(name: string): number;
  39294. /**
  39295. * The number of attributes.
  39296. * @returns the numnber of attributes.
  39297. */
  39298. getAttributesCount(): number;
  39299. /**
  39300. * Gets the index of a uniform variable.
  39301. * @param uniformName of the uniform to look up.
  39302. * @returns the index.
  39303. */
  39304. getUniformIndex(uniformName: string): number;
  39305. /**
  39306. * Returns the attribute based on the name of the variable.
  39307. * @param uniformName of the uniform to look up.
  39308. * @returns the location of the uniform.
  39309. */
  39310. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  39311. /**
  39312. * Returns an array of sampler variable names
  39313. * @returns The array of sampler variable names.
  39314. */
  39315. getSamplers(): string[];
  39316. /**
  39317. * Returns an array of uniform variable names
  39318. * @returns The array of uniform variable names.
  39319. */
  39320. getUniformNames(): string[];
  39321. /**
  39322. * Returns an array of uniform buffer variable names
  39323. * @returns The array of uniform buffer variable names.
  39324. */
  39325. getUniformBuffersNames(): string[];
  39326. /**
  39327. * Returns the index parameters used to create the effect
  39328. * @returns The index parameters object
  39329. */
  39330. getIndexParameters(): any;
  39331. /**
  39332. * The error from the last compilation.
  39333. * @returns the error string.
  39334. */
  39335. getCompilationError(): string;
  39336. /**
  39337. * Gets a boolean indicating that all fallbacks were used during compilation
  39338. * @returns true if all fallbacks were used
  39339. */
  39340. allFallbacksProcessed(): boolean;
  39341. /**
  39342. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  39343. * @param func The callback to be used.
  39344. */
  39345. executeWhenCompiled(func: (effect: Effect) => void): void;
  39346. private _checkIsReady;
  39347. private _loadShader;
  39348. /**
  39349. * Gets the vertex shader source code of this effect
  39350. */
  39351. get vertexSourceCode(): string;
  39352. /**
  39353. * Gets the fragment shader source code of this effect
  39354. */
  39355. get fragmentSourceCode(): string;
  39356. /**
  39357. * Recompiles the webGL program
  39358. * @param vertexSourceCode The source code for the vertex shader.
  39359. * @param fragmentSourceCode The source code for the fragment shader.
  39360. * @param onCompiled Callback called when completed.
  39361. * @param onError Callback called on error.
  39362. * @hidden
  39363. */
  39364. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  39365. /**
  39366. * Prepares the effect
  39367. * @hidden
  39368. */
  39369. _prepareEffect(): void;
  39370. private _getShaderCodeAndErrorLine;
  39371. private _processCompilationErrors;
  39372. /**
  39373. * Checks if the effect is supported. (Must be called after compilation)
  39374. */
  39375. get isSupported(): boolean;
  39376. /**
  39377. * Binds a texture to the engine to be used as output of the shader.
  39378. * @param channel Name of the output variable.
  39379. * @param texture Texture to bind.
  39380. * @hidden
  39381. */
  39382. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  39383. /**
  39384. * Sets a texture on the engine to be used in the shader.
  39385. * @param channel Name of the sampler variable.
  39386. * @param texture Texture to set.
  39387. */
  39388. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  39389. /**
  39390. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  39391. * @param channel Name of the sampler variable.
  39392. * @param texture Texture to set.
  39393. */
  39394. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  39395. /**
  39396. * Sets an array of textures on the engine to be used in the shader.
  39397. * @param channel Name of the variable.
  39398. * @param textures Textures to set.
  39399. */
  39400. setTextureArray(channel: string, textures: BaseTexture[]): void;
  39401. /**
  39402. * 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)
  39403. * @param channel Name of the sampler variable.
  39404. * @param postProcess Post process to get the input texture from.
  39405. */
  39406. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  39407. /**
  39408. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  39409. * 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)
  39410. * @param channel Name of the sampler variable.
  39411. * @param postProcess Post process to get the output texture from.
  39412. */
  39413. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  39414. /** @hidden */
  39415. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  39416. /** @hidden */
  39417. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  39418. /** @hidden */
  39419. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  39420. /** @hidden */
  39421. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  39422. /**
  39423. * Binds a buffer to a uniform.
  39424. * @param buffer Buffer to bind.
  39425. * @param name Name of the uniform variable to bind to.
  39426. */
  39427. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  39428. /**
  39429. * Binds block to a uniform.
  39430. * @param blockName Name of the block to bind.
  39431. * @param index Index to bind.
  39432. */
  39433. bindUniformBlock(blockName: string, index: number): void;
  39434. /**
  39435. * Sets an interger value on a uniform variable.
  39436. * @param uniformName Name of the variable.
  39437. * @param value Value to be set.
  39438. * @returns this effect.
  39439. */
  39440. setInt(uniformName: string, value: number): Effect;
  39441. /**
  39442. * Sets an int array on a uniform variable.
  39443. * @param uniformName Name of the variable.
  39444. * @param array array to be set.
  39445. * @returns this effect.
  39446. */
  39447. setIntArray(uniformName: string, array: Int32Array): Effect;
  39448. /**
  39449. * 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)
  39450. * @param uniformName Name of the variable.
  39451. * @param array array to be set.
  39452. * @returns this effect.
  39453. */
  39454. setIntArray2(uniformName: string, array: Int32Array): Effect;
  39455. /**
  39456. * 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)
  39457. * @param uniformName Name of the variable.
  39458. * @param array array to be set.
  39459. * @returns this effect.
  39460. */
  39461. setIntArray3(uniformName: string, array: Int32Array): Effect;
  39462. /**
  39463. * 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)
  39464. * @param uniformName Name of the variable.
  39465. * @param array array to be set.
  39466. * @returns this effect.
  39467. */
  39468. setIntArray4(uniformName: string, array: Int32Array): Effect;
  39469. /**
  39470. * Sets an float array on a uniform variable.
  39471. * @param uniformName Name of the variable.
  39472. * @param array array to be set.
  39473. * @returns this effect.
  39474. */
  39475. setFloatArray(uniformName: string, array: Float32Array): Effect;
  39476. /**
  39477. * 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)
  39478. * @param uniformName Name of the variable.
  39479. * @param array array to be set.
  39480. * @returns this effect.
  39481. */
  39482. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  39483. /**
  39484. * 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)
  39485. * @param uniformName Name of the variable.
  39486. * @param array array to be set.
  39487. * @returns this effect.
  39488. */
  39489. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  39490. /**
  39491. * 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)
  39492. * @param uniformName Name of the variable.
  39493. * @param array array to be set.
  39494. * @returns this effect.
  39495. */
  39496. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  39497. /**
  39498. * Sets an array on a uniform variable.
  39499. * @param uniformName Name of the variable.
  39500. * @param array array to be set.
  39501. * @returns this effect.
  39502. */
  39503. setArray(uniformName: string, array: number[]): Effect;
  39504. /**
  39505. * 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)
  39506. * @param uniformName Name of the variable.
  39507. * @param array array to be set.
  39508. * @returns this effect.
  39509. */
  39510. setArray2(uniformName: string, array: number[]): Effect;
  39511. /**
  39512. * 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)
  39513. * @param uniformName Name of the variable.
  39514. * @param array array to be set.
  39515. * @returns this effect.
  39516. */
  39517. setArray3(uniformName: string, array: number[]): Effect;
  39518. /**
  39519. * 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)
  39520. * @param uniformName Name of the variable.
  39521. * @param array array to be set.
  39522. * @returns this effect.
  39523. */
  39524. setArray4(uniformName: string, array: number[]): Effect;
  39525. /**
  39526. * Sets matrices on a uniform variable.
  39527. * @param uniformName Name of the variable.
  39528. * @param matrices matrices to be set.
  39529. * @returns this effect.
  39530. */
  39531. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  39532. /**
  39533. * Sets matrix on a uniform variable.
  39534. * @param uniformName Name of the variable.
  39535. * @param matrix matrix to be set.
  39536. * @returns this effect.
  39537. */
  39538. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  39539. /**
  39540. * 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)
  39541. * @param uniformName Name of the variable.
  39542. * @param matrix matrix to be set.
  39543. * @returns this effect.
  39544. */
  39545. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39546. /**
  39547. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  39548. * @param uniformName Name of the variable.
  39549. * @param matrix matrix to be set.
  39550. * @returns this effect.
  39551. */
  39552. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  39553. /**
  39554. * Sets a float on a uniform variable.
  39555. * @param uniformName Name of the variable.
  39556. * @param value value to be set.
  39557. * @returns this effect.
  39558. */
  39559. setFloat(uniformName: string, value: number): Effect;
  39560. /**
  39561. * Sets a boolean on a uniform variable.
  39562. * @param uniformName Name of the variable.
  39563. * @param bool value to be set.
  39564. * @returns this effect.
  39565. */
  39566. setBool(uniformName: string, bool: boolean): Effect;
  39567. /**
  39568. * Sets a Vector2 on a uniform variable.
  39569. * @param uniformName Name of the variable.
  39570. * @param vector2 vector2 to be set.
  39571. * @returns this effect.
  39572. */
  39573. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  39574. /**
  39575. * Sets a float2 on a uniform variable.
  39576. * @param uniformName Name of the variable.
  39577. * @param x First float in float2.
  39578. * @param y Second float in float2.
  39579. * @returns this effect.
  39580. */
  39581. setFloat2(uniformName: string, x: number, y: number): Effect;
  39582. /**
  39583. * Sets a Vector3 on a uniform variable.
  39584. * @param uniformName Name of the variable.
  39585. * @param vector3 Value to be set.
  39586. * @returns this effect.
  39587. */
  39588. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  39589. /**
  39590. * Sets a float3 on a uniform variable.
  39591. * @param uniformName Name of the variable.
  39592. * @param x First float in float3.
  39593. * @param y Second float in float3.
  39594. * @param z Third float in float3.
  39595. * @returns this effect.
  39596. */
  39597. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  39598. /**
  39599. * Sets a Vector4 on a uniform variable.
  39600. * @param uniformName Name of the variable.
  39601. * @param vector4 Value to be set.
  39602. * @returns this effect.
  39603. */
  39604. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  39605. /**
  39606. * Sets a float4 on a uniform variable.
  39607. * @param uniformName Name of the variable.
  39608. * @param x First float in float4.
  39609. * @param y Second float in float4.
  39610. * @param z Third float in float4.
  39611. * @param w Fourth float in float4.
  39612. * @returns this effect.
  39613. */
  39614. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  39615. /**
  39616. * Sets a Color3 on a uniform variable.
  39617. * @param uniformName Name of the variable.
  39618. * @param color3 Value to be set.
  39619. * @returns this effect.
  39620. */
  39621. setColor3(uniformName: string, color3: IColor3Like): Effect;
  39622. /**
  39623. * Sets a Color4 on a uniform variable.
  39624. * @param uniformName Name of the variable.
  39625. * @param color3 Value to be set.
  39626. * @param alpha Alpha value to be set.
  39627. * @returns this effect.
  39628. */
  39629. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  39630. /**
  39631. * Sets a Color4 on a uniform variable
  39632. * @param uniformName defines the name of the variable
  39633. * @param color4 defines the value to be set
  39634. * @returns this effect.
  39635. */
  39636. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  39637. /** Release all associated resources */
  39638. dispose(): void;
  39639. /**
  39640. * This function will add a new shader to the shader store
  39641. * @param name the name of the shader
  39642. * @param pixelShader optional pixel shader content
  39643. * @param vertexShader optional vertex shader content
  39644. */
  39645. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  39646. /**
  39647. * Store of each shader (The can be looked up using effect.key)
  39648. */
  39649. static ShadersStore: {
  39650. [key: string]: string;
  39651. };
  39652. /**
  39653. * Store of each included file for a shader (The can be looked up using effect.key)
  39654. */
  39655. static IncludesShadersStore: {
  39656. [key: string]: string;
  39657. };
  39658. /**
  39659. * Resets the cache of effects.
  39660. */
  39661. static ResetCache(): void;
  39662. }
  39663. }
  39664. declare module "babylonjs/Engines/engineCapabilities" {
  39665. /**
  39666. * Interface used to describe the capabilities of the engine relatively to the current browser
  39667. */
  39668. export interface EngineCapabilities {
  39669. /** Maximum textures units per fragment shader */
  39670. maxTexturesImageUnits: number;
  39671. /** Maximum texture units per vertex shader */
  39672. maxVertexTextureImageUnits: number;
  39673. /** Maximum textures units in the entire pipeline */
  39674. maxCombinedTexturesImageUnits: number;
  39675. /** Maximum texture size */
  39676. maxTextureSize: number;
  39677. /** Maximum texture samples */
  39678. maxSamples?: number;
  39679. /** Maximum cube texture size */
  39680. maxCubemapTextureSize: number;
  39681. /** Maximum render texture size */
  39682. maxRenderTextureSize: number;
  39683. /** Maximum number of vertex attributes */
  39684. maxVertexAttribs: number;
  39685. /** Maximum number of varyings */
  39686. maxVaryingVectors: number;
  39687. /** Maximum number of uniforms per vertex shader */
  39688. maxVertexUniformVectors: number;
  39689. /** Maximum number of uniforms per fragment shader */
  39690. maxFragmentUniformVectors: number;
  39691. /** Defines if standard derivates (dx/dy) are supported */
  39692. standardDerivatives: boolean;
  39693. /** Defines if s3tc texture compression is supported */
  39694. s3tc?: WEBGL_compressed_texture_s3tc;
  39695. /** Defines if pvrtc texture compression is supported */
  39696. pvrtc: any;
  39697. /** Defines if etc1 texture compression is supported */
  39698. etc1: any;
  39699. /** Defines if etc2 texture compression is supported */
  39700. etc2: any;
  39701. /** Defines if astc texture compression is supported */
  39702. astc: any;
  39703. /** Defines if bptc texture compression is supported */
  39704. bptc: any;
  39705. /** Defines if float textures are supported */
  39706. textureFloat: boolean;
  39707. /** Defines if vertex array objects are supported */
  39708. vertexArrayObject: boolean;
  39709. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  39710. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  39711. /** Gets the maximum level of anisotropy supported */
  39712. maxAnisotropy: number;
  39713. /** Defines if instancing is supported */
  39714. instancedArrays: boolean;
  39715. /** Defines if 32 bits indices are supported */
  39716. uintIndices: boolean;
  39717. /** Defines if high precision shaders are supported */
  39718. highPrecisionShaderSupported: boolean;
  39719. /** Defines if depth reading in the fragment shader is supported */
  39720. fragmentDepthSupported: boolean;
  39721. /** Defines if float texture linear filtering is supported*/
  39722. textureFloatLinearFiltering: boolean;
  39723. /** Defines if rendering to float textures is supported */
  39724. textureFloatRender: boolean;
  39725. /** Defines if half float textures are supported*/
  39726. textureHalfFloat: boolean;
  39727. /** Defines if half float texture linear filtering is supported*/
  39728. textureHalfFloatLinearFiltering: boolean;
  39729. /** Defines if rendering to half float textures is supported */
  39730. textureHalfFloatRender: boolean;
  39731. /** Defines if textureLOD shader command is supported */
  39732. textureLOD: boolean;
  39733. /** Defines if draw buffers extension is supported */
  39734. drawBuffersExtension: boolean;
  39735. /** Defines if depth textures are supported */
  39736. depthTextureExtension: boolean;
  39737. /** Defines if float color buffer are supported */
  39738. colorBufferFloat: boolean;
  39739. /** Gets disjoint timer query extension (null if not supported) */
  39740. timerQuery?: EXT_disjoint_timer_query;
  39741. /** Defines if timestamp can be used with timer query */
  39742. canUseTimestampForTimerQuery: boolean;
  39743. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  39744. multiview?: any;
  39745. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  39746. oculusMultiview?: any;
  39747. /** Function used to let the system compiles shaders in background */
  39748. parallelShaderCompile?: {
  39749. COMPLETION_STATUS_KHR: number;
  39750. };
  39751. /** Max number of texture samples for MSAA */
  39752. maxMSAASamples: number;
  39753. /** Defines if the blend min max extension is supported */
  39754. blendMinMax: boolean;
  39755. }
  39756. }
  39757. declare module "babylonjs/States/depthCullingState" {
  39758. import { Nullable } from "babylonjs/types";
  39759. /**
  39760. * @hidden
  39761. **/
  39762. export class DepthCullingState {
  39763. private _isDepthTestDirty;
  39764. private _isDepthMaskDirty;
  39765. private _isDepthFuncDirty;
  39766. private _isCullFaceDirty;
  39767. private _isCullDirty;
  39768. private _isZOffsetDirty;
  39769. private _isFrontFaceDirty;
  39770. private _depthTest;
  39771. private _depthMask;
  39772. private _depthFunc;
  39773. private _cull;
  39774. private _cullFace;
  39775. private _zOffset;
  39776. private _frontFace;
  39777. /**
  39778. * Initializes the state.
  39779. */
  39780. constructor();
  39781. get isDirty(): boolean;
  39782. get zOffset(): number;
  39783. set zOffset(value: number);
  39784. get cullFace(): Nullable<number>;
  39785. set cullFace(value: Nullable<number>);
  39786. get cull(): Nullable<boolean>;
  39787. set cull(value: Nullable<boolean>);
  39788. get depthFunc(): Nullable<number>;
  39789. set depthFunc(value: Nullable<number>);
  39790. get depthMask(): boolean;
  39791. set depthMask(value: boolean);
  39792. get depthTest(): boolean;
  39793. set depthTest(value: boolean);
  39794. get frontFace(): Nullable<number>;
  39795. set frontFace(value: Nullable<number>);
  39796. reset(): void;
  39797. apply(gl: WebGLRenderingContext): void;
  39798. }
  39799. }
  39800. declare module "babylonjs/States/stencilState" {
  39801. /**
  39802. * @hidden
  39803. **/
  39804. export class StencilState {
  39805. /** 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 */
  39806. static readonly ALWAYS: number;
  39807. /** Passed to stencilOperation to specify that stencil value must be kept */
  39808. static readonly KEEP: number;
  39809. /** Passed to stencilOperation to specify that stencil value must be replaced */
  39810. static readonly REPLACE: number;
  39811. private _isStencilTestDirty;
  39812. private _isStencilMaskDirty;
  39813. private _isStencilFuncDirty;
  39814. private _isStencilOpDirty;
  39815. private _stencilTest;
  39816. private _stencilMask;
  39817. private _stencilFunc;
  39818. private _stencilFuncRef;
  39819. private _stencilFuncMask;
  39820. private _stencilOpStencilFail;
  39821. private _stencilOpDepthFail;
  39822. private _stencilOpStencilDepthPass;
  39823. get isDirty(): boolean;
  39824. get stencilFunc(): number;
  39825. set stencilFunc(value: number);
  39826. get stencilFuncRef(): number;
  39827. set stencilFuncRef(value: number);
  39828. get stencilFuncMask(): number;
  39829. set stencilFuncMask(value: number);
  39830. get stencilOpStencilFail(): number;
  39831. set stencilOpStencilFail(value: number);
  39832. get stencilOpDepthFail(): number;
  39833. set stencilOpDepthFail(value: number);
  39834. get stencilOpStencilDepthPass(): number;
  39835. set stencilOpStencilDepthPass(value: number);
  39836. get stencilMask(): number;
  39837. set stencilMask(value: number);
  39838. get stencilTest(): boolean;
  39839. set stencilTest(value: boolean);
  39840. constructor();
  39841. reset(): void;
  39842. apply(gl: WebGLRenderingContext): void;
  39843. }
  39844. }
  39845. declare module "babylonjs/States/alphaCullingState" {
  39846. /**
  39847. * @hidden
  39848. **/
  39849. export class AlphaState {
  39850. private _isAlphaBlendDirty;
  39851. private _isBlendFunctionParametersDirty;
  39852. private _isBlendEquationParametersDirty;
  39853. private _isBlendConstantsDirty;
  39854. private _alphaBlend;
  39855. private _blendFunctionParameters;
  39856. private _blendEquationParameters;
  39857. private _blendConstants;
  39858. /**
  39859. * Initializes the state.
  39860. */
  39861. constructor();
  39862. get isDirty(): boolean;
  39863. get alphaBlend(): boolean;
  39864. set alphaBlend(value: boolean);
  39865. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  39866. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  39867. setAlphaEquationParameters(rgb: number, alpha: number): void;
  39868. reset(): void;
  39869. apply(gl: WebGLRenderingContext): void;
  39870. }
  39871. }
  39872. declare module "babylonjs/Engines/WebGL/webGLShaderProcessors" {
  39873. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39874. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  39875. /** @hidden */
  39876. export class WebGLShaderProcessor implements IShaderProcessor {
  39877. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  39878. }
  39879. }
  39880. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  39881. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  39882. /** @hidden */
  39883. export class WebGL2ShaderProcessor implements IShaderProcessor {
  39884. attributeProcessor(attribute: string): string;
  39885. varyingProcessor(varying: string, isFragment: boolean): string;
  39886. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  39887. }
  39888. }
  39889. declare module "babylonjs/Engines/instancingAttributeInfo" {
  39890. /**
  39891. * Interface for attribute information associated with buffer instanciation
  39892. */
  39893. export interface InstancingAttributeInfo {
  39894. /**
  39895. * Name of the GLSL attribute
  39896. * if attribute index is not specified, this is used to retrieve the index from the effect
  39897. */
  39898. attributeName: string;
  39899. /**
  39900. * Index/offset of the attribute in the vertex shader
  39901. * if not specified, this will be computes from the name.
  39902. */
  39903. index?: number;
  39904. /**
  39905. * size of the attribute, 1, 2, 3 or 4
  39906. */
  39907. attributeSize: number;
  39908. /**
  39909. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  39910. */
  39911. offset: number;
  39912. /**
  39913. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  39914. * default to 1
  39915. */
  39916. divisor?: number;
  39917. /**
  39918. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  39919. * default is FLOAT
  39920. */
  39921. attributeType?: number;
  39922. /**
  39923. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  39924. */
  39925. normalized?: boolean;
  39926. }
  39927. }
  39928. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  39929. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39930. import { Nullable } from "babylonjs/types";
  39931. module "babylonjs/Engines/thinEngine" {
  39932. interface ThinEngine {
  39933. /**
  39934. * Update a video texture
  39935. * @param texture defines the texture to update
  39936. * @param video defines the video element to use
  39937. * @param invertY defines if data must be stored with Y axis inverted
  39938. */
  39939. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  39940. }
  39941. }
  39942. }
  39943. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  39944. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  39945. import { Nullable } from "babylonjs/types";
  39946. module "babylonjs/Engines/thinEngine" {
  39947. interface ThinEngine {
  39948. /**
  39949. * Creates a dynamic texture
  39950. * @param width defines the width of the texture
  39951. * @param height defines the height of the texture
  39952. * @param generateMipMaps defines if the engine should generate the mip levels
  39953. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  39954. * @returns the dynamic texture inside an InternalTexture
  39955. */
  39956. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  39957. /**
  39958. * Update the content of a dynamic texture
  39959. * @param texture defines the texture to update
  39960. * @param canvas defines the canvas containing the source
  39961. * @param invertY defines if data must be stored with Y axis inverted
  39962. * @param premulAlpha defines if alpha is stored as premultiplied
  39963. * @param format defines the format of the data
  39964. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  39965. */
  39966. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  39967. }
  39968. }
  39969. }
  39970. declare module "babylonjs/Materials/Textures/videoTexture" {
  39971. import { Observable } from "babylonjs/Misc/observable";
  39972. import { Nullable } from "babylonjs/types";
  39973. import { Scene } from "babylonjs/scene";
  39974. import { Texture } from "babylonjs/Materials/Textures/texture";
  39975. import "babylonjs/Engines/Extensions/engine.videoTexture";
  39976. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  39977. /**
  39978. * Settings for finer control over video usage
  39979. */
  39980. export interface VideoTextureSettings {
  39981. /**
  39982. * Applies `autoplay` to video, if specified
  39983. */
  39984. autoPlay?: boolean;
  39985. /**
  39986. * Applies `muted` to video, if specified
  39987. */
  39988. muted?: boolean;
  39989. /**
  39990. * Applies `loop` to video, if specified
  39991. */
  39992. loop?: boolean;
  39993. /**
  39994. * Automatically updates internal texture from video at every frame in the render loop
  39995. */
  39996. autoUpdateTexture: boolean;
  39997. /**
  39998. * Image src displayed during the video loading or until the user interacts with the video.
  39999. */
  40000. poster?: string;
  40001. }
  40002. /**
  40003. * If you want to display a video in your scene, this is the special texture for that.
  40004. * This special texture works similar to other textures, with the exception of a few parameters.
  40005. * @see https://doc.babylonjs.com/how_to/video_texture
  40006. */
  40007. export class VideoTexture extends Texture {
  40008. /**
  40009. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  40010. */
  40011. readonly autoUpdateTexture: boolean;
  40012. /**
  40013. * The video instance used by the texture internally
  40014. */
  40015. readonly video: HTMLVideoElement;
  40016. private _onUserActionRequestedObservable;
  40017. /**
  40018. * Event triggerd when a dom action is required by the user to play the video.
  40019. * This happens due to recent changes in browser policies preventing video to auto start.
  40020. */
  40021. get onUserActionRequestedObservable(): Observable<Texture>;
  40022. private _generateMipMaps;
  40023. private _stillImageCaptured;
  40024. private _displayingPosterTexture;
  40025. private _settings;
  40026. private _createInternalTextureOnEvent;
  40027. private _frameId;
  40028. private _currentSrc;
  40029. /**
  40030. * Creates a video texture.
  40031. * If you want to display a video in your scene, this is the special texture for that.
  40032. * This special texture works similar to other textures, with the exception of a few parameters.
  40033. * @see https://doc.babylonjs.com/how_to/video_texture
  40034. * @param name optional name, will detect from video source, if not defined
  40035. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  40036. * @param scene is obviously the current scene.
  40037. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  40038. * @param invertY is false by default but can be used to invert video on Y axis
  40039. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  40040. * @param settings allows finer control over video usage
  40041. */
  40042. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  40043. private _getName;
  40044. private _getVideo;
  40045. private _createInternalTexture;
  40046. private reset;
  40047. /**
  40048. * @hidden Internal method to initiate `update`.
  40049. */
  40050. _rebuild(): void;
  40051. /**
  40052. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  40053. */
  40054. update(): void;
  40055. /**
  40056. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  40057. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  40058. */
  40059. updateTexture(isVisible: boolean): void;
  40060. protected _updateInternalTexture: () => void;
  40061. /**
  40062. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  40063. * @param url New url.
  40064. */
  40065. updateURL(url: string): void;
  40066. /**
  40067. * Clones the texture.
  40068. * @returns the cloned texture
  40069. */
  40070. clone(): VideoTexture;
  40071. /**
  40072. * Dispose the texture and release its associated resources.
  40073. */
  40074. dispose(): void;
  40075. /**
  40076. * Creates a video texture straight from a stream.
  40077. * @param scene Define the scene the texture should be created in
  40078. * @param stream Define the stream the texture should be created from
  40079. * @returns The created video texture as a promise
  40080. */
  40081. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  40082. /**
  40083. * Creates a video texture straight from your WebCam video feed.
  40084. * @param scene Define the scene the texture should be created in
  40085. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40086. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40087. * @returns The created video texture as a promise
  40088. */
  40089. static CreateFromWebCamAsync(scene: Scene, constraints: {
  40090. minWidth: number;
  40091. maxWidth: number;
  40092. minHeight: number;
  40093. maxHeight: number;
  40094. deviceId: string;
  40095. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  40096. /**
  40097. * Creates a video texture straight from your WebCam video feed.
  40098. * @param scene Define the scene the texture should be created in
  40099. * @param onReady Define a callback to triggered once the texture will be ready
  40100. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  40101. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  40102. */
  40103. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  40104. minWidth: number;
  40105. maxWidth: number;
  40106. minHeight: number;
  40107. maxHeight: number;
  40108. deviceId: string;
  40109. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  40110. }
  40111. }
  40112. declare module "babylonjs/Engines/thinEngine" {
  40113. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  40114. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  40115. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  40116. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40117. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  40118. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  40119. import { Observable } from "babylonjs/Misc/observable";
  40120. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  40121. import { StencilState } from "babylonjs/States/stencilState";
  40122. import { AlphaState } from "babylonjs/States/alphaCullingState";
  40123. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  40124. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  40125. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  40126. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40127. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  40128. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  40129. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  40130. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  40131. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40132. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40133. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  40134. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  40135. import { WebRequest } from "babylonjs/Misc/webRequest";
  40136. import { LoadFileError } from "babylonjs/Misc/fileTools";
  40137. /**
  40138. * Defines the interface used by objects working like Scene
  40139. * @hidden
  40140. */
  40141. export interface ISceneLike {
  40142. _addPendingData(data: any): void;
  40143. _removePendingData(data: any): void;
  40144. offlineProvider: IOfflineProvider;
  40145. }
  40146. /**
  40147. * Information about the current host
  40148. */
  40149. export interface HostInformation {
  40150. /**
  40151. * Defines if the current host is a mobile
  40152. */
  40153. isMobile: boolean;
  40154. }
  40155. /** Interface defining initialization parameters for Engine class */
  40156. export interface EngineOptions extends WebGLContextAttributes {
  40157. /**
  40158. * Defines if the engine should no exceed a specified device ratio
  40159. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  40160. */
  40161. limitDeviceRatio?: number;
  40162. /**
  40163. * Defines if webvr should be enabled automatically
  40164. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40165. */
  40166. autoEnableWebVR?: boolean;
  40167. /**
  40168. * Defines if webgl2 should be turned off even if supported
  40169. * @see https://doc.babylonjs.com/features/webgl2
  40170. */
  40171. disableWebGL2Support?: boolean;
  40172. /**
  40173. * Defines if webaudio should be initialized as well
  40174. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40175. */
  40176. audioEngine?: boolean;
  40177. /**
  40178. * Defines if animations should run using a deterministic lock step
  40179. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40180. */
  40181. deterministicLockstep?: boolean;
  40182. /** Defines the maximum steps to use with deterministic lock step mode */
  40183. lockstepMaxSteps?: number;
  40184. /** Defines the seconds between each deterministic lock step */
  40185. timeStep?: number;
  40186. /**
  40187. * Defines that engine should ignore context lost events
  40188. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  40189. */
  40190. doNotHandleContextLost?: boolean;
  40191. /**
  40192. * Defines that engine should ignore modifying touch action attribute and style
  40193. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  40194. */
  40195. doNotHandleTouchAction?: boolean;
  40196. /**
  40197. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  40198. */
  40199. useHighPrecisionFloats?: boolean;
  40200. /**
  40201. * Make the canvas XR Compatible for XR sessions
  40202. */
  40203. xrCompatible?: boolean;
  40204. /**
  40205. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  40206. */
  40207. useHighPrecisionMatrix?: boolean;
  40208. /**
  40209. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  40210. */
  40211. failIfMajorPerformanceCaveat?: boolean;
  40212. }
  40213. /**
  40214. * The base engine class (root of all engines)
  40215. */
  40216. export class ThinEngine {
  40217. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  40218. static ExceptionList: ({
  40219. key: string;
  40220. capture: string;
  40221. captureConstraint: number;
  40222. targets: string[];
  40223. } | {
  40224. key: string;
  40225. capture: null;
  40226. captureConstraint: null;
  40227. targets: string[];
  40228. })[];
  40229. /** @hidden */
  40230. static _TextureLoaders: IInternalTextureLoader[];
  40231. /**
  40232. * Returns the current npm package of the sdk
  40233. */
  40234. static get NpmPackage(): string;
  40235. /**
  40236. * Returns the current version of the framework
  40237. */
  40238. static get Version(): string;
  40239. /**
  40240. * Returns a string describing the current engine
  40241. */
  40242. get description(): string;
  40243. /**
  40244. * Gets or sets the epsilon value used by collision engine
  40245. */
  40246. static CollisionsEpsilon: number;
  40247. /**
  40248. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  40249. */
  40250. static get ShadersRepository(): string;
  40251. static set ShadersRepository(value: string);
  40252. /** @hidden */
  40253. _shaderProcessor: IShaderProcessor;
  40254. /**
  40255. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  40256. */
  40257. forcePOTTextures: boolean;
  40258. /**
  40259. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  40260. */
  40261. isFullscreen: boolean;
  40262. /**
  40263. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  40264. */
  40265. cullBackFaces: boolean;
  40266. /**
  40267. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  40268. */
  40269. renderEvenInBackground: boolean;
  40270. /**
  40271. * Gets or sets a boolean indicating that cache can be kept between frames
  40272. */
  40273. preventCacheWipeBetweenFrames: boolean;
  40274. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  40275. validateShaderPrograms: boolean;
  40276. /**
  40277. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  40278. * This can provide greater z depth for distant objects.
  40279. */
  40280. useReverseDepthBuffer: boolean;
  40281. /**
  40282. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  40283. */
  40284. disableUniformBuffers: boolean;
  40285. /** @hidden */
  40286. _uniformBuffers: UniformBuffer[];
  40287. /**
  40288. * Gets a boolean indicating that the engine supports uniform buffers
  40289. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  40290. */
  40291. get supportsUniformBuffers(): boolean;
  40292. /** @hidden */
  40293. _gl: WebGLRenderingContext;
  40294. /** @hidden */
  40295. _webGLVersion: number;
  40296. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  40297. protected _windowIsBackground: boolean;
  40298. protected _creationOptions: EngineOptions;
  40299. protected _highPrecisionShadersAllowed: boolean;
  40300. /** @hidden */
  40301. get _shouldUseHighPrecisionShader(): boolean;
  40302. /**
  40303. * Gets a boolean indicating that only power of 2 textures are supported
  40304. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  40305. */
  40306. get needPOTTextures(): boolean;
  40307. /** @hidden */
  40308. _badOS: boolean;
  40309. /** @hidden */
  40310. _badDesktopOS: boolean;
  40311. private _hardwareScalingLevel;
  40312. /** @hidden */
  40313. _caps: EngineCapabilities;
  40314. private _isStencilEnable;
  40315. private _glVersion;
  40316. private _glRenderer;
  40317. private _glVendor;
  40318. /** @hidden */
  40319. _videoTextureSupported: boolean;
  40320. protected _renderingQueueLaunched: boolean;
  40321. protected _activeRenderLoops: (() => void)[];
  40322. /**
  40323. * Observable signaled when a context lost event is raised
  40324. */
  40325. onContextLostObservable: Observable<ThinEngine>;
  40326. /**
  40327. * Observable signaled when a context restored event is raised
  40328. */
  40329. onContextRestoredObservable: Observable<ThinEngine>;
  40330. private _onContextLost;
  40331. private _onContextRestored;
  40332. protected _contextWasLost: boolean;
  40333. /** @hidden */
  40334. _doNotHandleContextLost: boolean;
  40335. /**
  40336. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  40337. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  40338. */
  40339. get doNotHandleContextLost(): boolean;
  40340. set doNotHandleContextLost(value: boolean);
  40341. /**
  40342. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  40343. */
  40344. disableVertexArrayObjects: boolean;
  40345. /** @hidden */
  40346. protected _colorWrite: boolean;
  40347. /** @hidden */
  40348. protected _colorWriteChanged: boolean;
  40349. /** @hidden */
  40350. protected _depthCullingState: DepthCullingState;
  40351. /** @hidden */
  40352. protected _stencilState: StencilState;
  40353. /** @hidden */
  40354. _alphaState: AlphaState;
  40355. /** @hidden */
  40356. _alphaMode: number;
  40357. /** @hidden */
  40358. _alphaEquation: number;
  40359. /** @hidden */
  40360. _internalTexturesCache: InternalTexture[];
  40361. /** @hidden */
  40362. protected _activeChannel: number;
  40363. private _currentTextureChannel;
  40364. /** @hidden */
  40365. protected _boundTexturesCache: {
  40366. [key: string]: Nullable<InternalTexture>;
  40367. };
  40368. /** @hidden */
  40369. protected _currentEffect: Nullable<Effect>;
  40370. /** @hidden */
  40371. protected _currentProgram: Nullable<WebGLProgram>;
  40372. private _compiledEffects;
  40373. private _vertexAttribArraysEnabled;
  40374. /** @hidden */
  40375. protected _cachedViewport: Nullable<IViewportLike>;
  40376. private _cachedVertexArrayObject;
  40377. /** @hidden */
  40378. protected _cachedVertexBuffers: any;
  40379. /** @hidden */
  40380. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  40381. /** @hidden */
  40382. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  40383. /** @hidden */
  40384. _currentRenderTarget: Nullable<InternalTexture>;
  40385. private _uintIndicesCurrentlySet;
  40386. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  40387. /** @hidden */
  40388. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  40389. /** @hidden */
  40390. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  40391. private _currentBufferPointers;
  40392. private _currentInstanceLocations;
  40393. private _currentInstanceBuffers;
  40394. private _textureUnits;
  40395. /** @hidden */
  40396. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  40397. /** @hidden */
  40398. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  40399. /** @hidden */
  40400. _boundRenderFunction: any;
  40401. private _vaoRecordInProgress;
  40402. private _mustWipeVertexAttributes;
  40403. private _emptyTexture;
  40404. private _emptyCubeTexture;
  40405. private _emptyTexture3D;
  40406. private _emptyTexture2DArray;
  40407. /** @hidden */
  40408. _frameHandler: number;
  40409. private _nextFreeTextureSlots;
  40410. private _maxSimultaneousTextures;
  40411. private _activeRequests;
  40412. /** @hidden */
  40413. _transformTextureUrl: Nullable<(url: string) => string>;
  40414. /**
  40415. * Gets information about the current host
  40416. */
  40417. hostInformation: HostInformation;
  40418. protected get _supportsHardwareTextureRescaling(): boolean;
  40419. private _framebufferDimensionsObject;
  40420. /**
  40421. * sets the object from which width and height will be taken from when getting render width and height
  40422. * Will fallback to the gl object
  40423. * @param dimensions the framebuffer width and height that will be used.
  40424. */
  40425. set framebufferDimensionsObject(dimensions: Nullable<{
  40426. framebufferWidth: number;
  40427. framebufferHeight: number;
  40428. }>);
  40429. /**
  40430. * Gets the current viewport
  40431. */
  40432. get currentViewport(): Nullable<IViewportLike>;
  40433. /**
  40434. * Gets the default empty texture
  40435. */
  40436. get emptyTexture(): InternalTexture;
  40437. /**
  40438. * Gets the default empty 3D texture
  40439. */
  40440. get emptyTexture3D(): InternalTexture;
  40441. /**
  40442. * Gets the default empty 2D array texture
  40443. */
  40444. get emptyTexture2DArray(): InternalTexture;
  40445. /**
  40446. * Gets the default empty cube texture
  40447. */
  40448. get emptyCubeTexture(): InternalTexture;
  40449. /**
  40450. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  40451. */
  40452. readonly premultipliedAlpha: boolean;
  40453. /**
  40454. * Observable event triggered before each texture is initialized
  40455. */
  40456. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  40457. /**
  40458. * Creates a new engine
  40459. * @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
  40460. * @param antialias defines enable antialiasing (default: false)
  40461. * @param options defines further options to be sent to the getContext() function
  40462. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40463. */
  40464. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40465. private _rebuildInternalTextures;
  40466. private _rebuildEffects;
  40467. /**
  40468. * Gets a boolean indicating if all created effects are ready
  40469. * @returns true if all effects are ready
  40470. */
  40471. areAllEffectsReady(): boolean;
  40472. protected _rebuildBuffers(): void;
  40473. protected _initGLContext(): void;
  40474. /**
  40475. * Gets version of the current webGL context
  40476. */
  40477. get webGLVersion(): number;
  40478. /**
  40479. * Gets a string identifying the name of the class
  40480. * @returns "Engine" string
  40481. */
  40482. getClassName(): string;
  40483. /**
  40484. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  40485. */
  40486. get isStencilEnable(): boolean;
  40487. /** @hidden */
  40488. _prepareWorkingCanvas(): void;
  40489. /**
  40490. * Reset the texture cache to empty state
  40491. */
  40492. resetTextureCache(): void;
  40493. /**
  40494. * Gets an object containing information about the current webGL context
  40495. * @returns an object containing the vender, the renderer and the version of the current webGL context
  40496. */
  40497. getGlInfo(): {
  40498. vendor: string;
  40499. renderer: string;
  40500. version: string;
  40501. };
  40502. /**
  40503. * Defines the hardware scaling level.
  40504. * By default the hardware scaling level is computed from the window device ratio.
  40505. * 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.
  40506. * @param level defines the level to use
  40507. */
  40508. setHardwareScalingLevel(level: number): void;
  40509. /**
  40510. * Gets the current hardware scaling level.
  40511. * By default the hardware scaling level is computed from the window device ratio.
  40512. * 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.
  40513. * @returns a number indicating the current hardware scaling level
  40514. */
  40515. getHardwareScalingLevel(): number;
  40516. /**
  40517. * Gets the list of loaded textures
  40518. * @returns an array containing all loaded textures
  40519. */
  40520. getLoadedTexturesCache(): InternalTexture[];
  40521. /**
  40522. * Gets the object containing all engine capabilities
  40523. * @returns the EngineCapabilities object
  40524. */
  40525. getCaps(): EngineCapabilities;
  40526. /**
  40527. * stop executing a render loop function and remove it from the execution array
  40528. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  40529. */
  40530. stopRenderLoop(renderFunction?: () => void): void;
  40531. /** @hidden */
  40532. _renderLoop(): void;
  40533. /**
  40534. * Gets the HTML canvas attached with the current webGL context
  40535. * @returns a HTML canvas
  40536. */
  40537. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  40538. /**
  40539. * Gets host window
  40540. * @returns the host window object
  40541. */
  40542. getHostWindow(): Nullable<Window>;
  40543. /**
  40544. * Gets the current render width
  40545. * @param useScreen defines if screen size must be used (or the current render target if any)
  40546. * @returns a number defining the current render width
  40547. */
  40548. getRenderWidth(useScreen?: boolean): number;
  40549. /**
  40550. * Gets the current render height
  40551. * @param useScreen defines if screen size must be used (or the current render target if any)
  40552. * @returns a number defining the current render height
  40553. */
  40554. getRenderHeight(useScreen?: boolean): number;
  40555. /**
  40556. * Can be used to override the current requestAnimationFrame requester.
  40557. * @hidden
  40558. */
  40559. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  40560. /**
  40561. * Register and execute a render loop. The engine can have more than one render function
  40562. * @param renderFunction defines the function to continuously execute
  40563. */
  40564. runRenderLoop(renderFunction: () => void): void;
  40565. /**
  40566. * Clear the current render buffer or the current render target (if any is set up)
  40567. * @param color defines the color to use
  40568. * @param backBuffer defines if the back buffer must be cleared
  40569. * @param depth defines if the depth buffer must be cleared
  40570. * @param stencil defines if the stencil buffer must be cleared
  40571. */
  40572. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  40573. private _viewportCached;
  40574. /** @hidden */
  40575. _viewport(x: number, y: number, width: number, height: number): void;
  40576. /**
  40577. * Set the WebGL's viewport
  40578. * @param viewport defines the viewport element to be used
  40579. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  40580. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  40581. */
  40582. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  40583. /**
  40584. * Begin a new frame
  40585. */
  40586. beginFrame(): void;
  40587. /**
  40588. * Enf the current frame
  40589. */
  40590. endFrame(): void;
  40591. /**
  40592. * Resize the view according to the canvas' size
  40593. */
  40594. resize(): void;
  40595. /**
  40596. * Force a specific size of the canvas
  40597. * @param width defines the new canvas' width
  40598. * @param height defines the new canvas' height
  40599. * @returns true if the size was changed
  40600. */
  40601. setSize(width: number, height: number): boolean;
  40602. /**
  40603. * Binds the frame buffer to the specified texture.
  40604. * @param texture The texture to render to or null for the default canvas
  40605. * @param faceIndex The face of the texture to render to in case of cube texture
  40606. * @param requiredWidth The width of the target to render to
  40607. * @param requiredHeight The height of the target to render to
  40608. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  40609. * @param lodLevel defines the lod level to bind to the frame buffer
  40610. * @param layer defines the 2d array index to bind to frame buffer to
  40611. */
  40612. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  40613. /** @hidden */
  40614. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  40615. /**
  40616. * Unbind the current render target texture from the webGL context
  40617. * @param texture defines the render target texture to unbind
  40618. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  40619. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  40620. */
  40621. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  40622. /**
  40623. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  40624. */
  40625. flushFramebuffer(): void;
  40626. /**
  40627. * Unbind the current render target and bind the default framebuffer
  40628. */
  40629. restoreDefaultFramebuffer(): void;
  40630. /** @hidden */
  40631. protected _resetVertexBufferBinding(): void;
  40632. /**
  40633. * Creates a vertex buffer
  40634. * @param data the data for the vertex buffer
  40635. * @returns the new WebGL static buffer
  40636. */
  40637. createVertexBuffer(data: DataArray): DataBuffer;
  40638. private _createVertexBuffer;
  40639. /**
  40640. * Creates a dynamic vertex buffer
  40641. * @param data the data for the dynamic vertex buffer
  40642. * @returns the new WebGL dynamic buffer
  40643. */
  40644. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  40645. protected _resetIndexBufferBinding(): void;
  40646. /**
  40647. * Creates a new index buffer
  40648. * @param indices defines the content of the index buffer
  40649. * @param updatable defines if the index buffer must be updatable
  40650. * @returns a new webGL buffer
  40651. */
  40652. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  40653. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  40654. /**
  40655. * Bind a webGL buffer to the webGL context
  40656. * @param buffer defines the buffer to bind
  40657. */
  40658. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  40659. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  40660. private bindBuffer;
  40661. /**
  40662. * update the bound buffer with the given data
  40663. * @param data defines the data to update
  40664. */
  40665. updateArrayBuffer(data: Float32Array): void;
  40666. private _vertexAttribPointer;
  40667. /** @hidden */
  40668. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  40669. private _bindVertexBuffersAttributes;
  40670. /**
  40671. * Records a vertex array object
  40672. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40673. * @param vertexBuffers defines the list of vertex buffers to store
  40674. * @param indexBuffer defines the index buffer to store
  40675. * @param effect defines the effect to store
  40676. * @returns the new vertex array object
  40677. */
  40678. recordVertexArrayObject(vertexBuffers: {
  40679. [key: string]: VertexBuffer;
  40680. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  40681. /**
  40682. * Bind a specific vertex array object
  40683. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  40684. * @param vertexArrayObject defines the vertex array object to bind
  40685. * @param indexBuffer defines the index buffer to bind
  40686. */
  40687. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  40688. /**
  40689. * Bind webGl buffers directly to the webGL context
  40690. * @param vertexBuffer defines the vertex buffer to bind
  40691. * @param indexBuffer defines the index buffer to bind
  40692. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  40693. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  40694. * @param effect defines the effect associated with the vertex buffer
  40695. */
  40696. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  40697. private _unbindVertexArrayObject;
  40698. /**
  40699. * Bind a list of vertex buffers to the webGL context
  40700. * @param vertexBuffers defines the list of vertex buffers to bind
  40701. * @param indexBuffer defines the index buffer to bind
  40702. * @param effect defines the effect associated with the vertex buffers
  40703. */
  40704. bindBuffers(vertexBuffers: {
  40705. [key: string]: Nullable<VertexBuffer>;
  40706. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  40707. /**
  40708. * Unbind all instance attributes
  40709. */
  40710. unbindInstanceAttributes(): void;
  40711. /**
  40712. * Release and free the memory of a vertex array object
  40713. * @param vao defines the vertex array object to delete
  40714. */
  40715. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  40716. /** @hidden */
  40717. _releaseBuffer(buffer: DataBuffer): boolean;
  40718. protected _deleteBuffer(buffer: DataBuffer): void;
  40719. /**
  40720. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  40721. * @param instancesBuffer defines the webGL buffer to update and bind
  40722. * @param data defines the data to store in the buffer
  40723. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  40724. */
  40725. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  40726. /**
  40727. * Bind the content of a webGL buffer used with instantiation
  40728. * @param instancesBuffer defines the webGL buffer to bind
  40729. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  40730. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  40731. */
  40732. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  40733. /**
  40734. * Disable the instance attribute corresponding to the name in parameter
  40735. * @param name defines the name of the attribute to disable
  40736. */
  40737. disableInstanceAttributeByName(name: string): void;
  40738. /**
  40739. * Disable the instance attribute corresponding to the location in parameter
  40740. * @param attributeLocation defines the attribute location of the attribute to disable
  40741. */
  40742. disableInstanceAttribute(attributeLocation: number): void;
  40743. /**
  40744. * Disable the attribute corresponding to the location in parameter
  40745. * @param attributeLocation defines the attribute location of the attribute to disable
  40746. */
  40747. disableAttributeByIndex(attributeLocation: number): void;
  40748. /**
  40749. * Send a draw order
  40750. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40751. * @param indexStart defines the starting index
  40752. * @param indexCount defines the number of index to draw
  40753. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40754. */
  40755. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  40756. /**
  40757. * Draw a list of points
  40758. * @param verticesStart defines the index of first vertex to draw
  40759. * @param verticesCount defines the count of vertices to draw
  40760. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40761. */
  40762. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40763. /**
  40764. * Draw a list of unindexed primitives
  40765. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  40766. * @param verticesStart defines the index of first vertex to draw
  40767. * @param verticesCount defines the count of vertices to draw
  40768. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40769. */
  40770. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40771. /**
  40772. * Draw a list of indexed primitives
  40773. * @param fillMode defines the primitive to use
  40774. * @param indexStart defines the starting index
  40775. * @param indexCount defines the number of index to draw
  40776. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40777. */
  40778. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  40779. /**
  40780. * Draw a list of unindexed primitives
  40781. * @param fillMode defines the primitive to use
  40782. * @param verticesStart defines the index of first vertex to draw
  40783. * @param verticesCount defines the count of vertices to draw
  40784. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  40785. */
  40786. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  40787. private _drawMode;
  40788. /** @hidden */
  40789. protected _reportDrawCall(): void;
  40790. /** @hidden */
  40791. _releaseEffect(effect: Effect): void;
  40792. /** @hidden */
  40793. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40794. /**
  40795. * Create a new effect (used to store vertex/fragment shaders)
  40796. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  40797. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  40798. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  40799. * @param samplers defines an array of string used to represent textures
  40800. * @param defines defines the string containing the defines to use to compile the shaders
  40801. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  40802. * @param onCompiled defines a function to call when the effect creation is successful
  40803. * @param onError defines a function to call when the effect creation has failed
  40804. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  40805. * @returns the new Effect
  40806. */
  40807. 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;
  40808. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  40809. private _compileShader;
  40810. private _compileRawShader;
  40811. /** @hidden */
  40812. _getShaderSource(shader: WebGLShader): Nullable<string>;
  40813. /**
  40814. * Directly creates a webGL program
  40815. * @param pipelineContext defines the pipeline context to attach to
  40816. * @param vertexCode defines the vertex shader code to use
  40817. * @param fragmentCode defines the fragment shader code to use
  40818. * @param context defines the webGL context to use (if not set, the current one will be used)
  40819. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40820. * @returns the new webGL program
  40821. */
  40822. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40823. /**
  40824. * Creates a webGL program
  40825. * @param pipelineContext defines the pipeline context to attach to
  40826. * @param vertexCode defines the vertex shader code to use
  40827. * @param fragmentCode defines the fragment shader code to use
  40828. * @param defines defines the string containing the defines to use to compile the shaders
  40829. * @param context defines the webGL context to use (if not set, the current one will be used)
  40830. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  40831. * @returns the new webGL program
  40832. */
  40833. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40834. /**
  40835. * Creates a new pipeline context
  40836. * @returns the new pipeline
  40837. */
  40838. createPipelineContext(): IPipelineContext;
  40839. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40840. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  40841. /** @hidden */
  40842. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  40843. /** @hidden */
  40844. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  40845. /** @hidden */
  40846. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  40847. /**
  40848. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  40849. * @param pipelineContext defines the pipeline context to use
  40850. * @param uniformsNames defines the list of uniform names
  40851. * @returns an array of webGL uniform locations
  40852. */
  40853. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  40854. /**
  40855. * Gets the lsit of active attributes for a given webGL program
  40856. * @param pipelineContext defines the pipeline context to use
  40857. * @param attributesNames defines the list of attribute names to get
  40858. * @returns an array of indices indicating the offset of each attribute
  40859. */
  40860. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  40861. /**
  40862. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  40863. * @param effect defines the effect to activate
  40864. */
  40865. enableEffect(effect: Nullable<Effect>): void;
  40866. /**
  40867. * Set the value of an uniform to a number (int)
  40868. * @param uniform defines the webGL uniform location where to store the value
  40869. * @param value defines the int number to store
  40870. * @returns true if the value was set
  40871. */
  40872. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40873. /**
  40874. * Set the value of an uniform to an array of int32
  40875. * @param uniform defines the webGL uniform location where to store the value
  40876. * @param array defines the array of int32 to store
  40877. * @returns true if the value was set
  40878. */
  40879. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40880. /**
  40881. * Set the value of an uniform to an array of int32 (stored as vec2)
  40882. * @param uniform defines the webGL uniform location where to store the value
  40883. * @param array defines the array of int32 to store
  40884. * @returns true if the value was set
  40885. */
  40886. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40887. /**
  40888. * Set the value of an uniform to an array of int32 (stored as vec3)
  40889. * @param uniform defines the webGL uniform location where to store the value
  40890. * @param array defines the array of int32 to store
  40891. * @returns true if the value was set
  40892. */
  40893. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40894. /**
  40895. * Set the value of an uniform to an array of int32 (stored as vec4)
  40896. * @param uniform defines the webGL uniform location where to store the value
  40897. * @param array defines the array of int32 to store
  40898. * @returns true if the value was set
  40899. */
  40900. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  40901. /**
  40902. * Set the value of an uniform to an array of number
  40903. * @param uniform defines the webGL uniform location where to store the value
  40904. * @param array defines the array of number to store
  40905. * @returns true if the value was set
  40906. */
  40907. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40908. /**
  40909. * Set the value of an uniform to an array of number (stored as vec2)
  40910. * @param uniform defines the webGL uniform location where to store the value
  40911. * @param array defines the array of number to store
  40912. * @returns true if the value was set
  40913. */
  40914. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40915. /**
  40916. * Set the value of an uniform to an array of number (stored as vec3)
  40917. * @param uniform defines the webGL uniform location where to store the value
  40918. * @param array defines the array of number to store
  40919. * @returns true if the value was set
  40920. */
  40921. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40922. /**
  40923. * Set the value of an uniform to an array of number (stored as vec4)
  40924. * @param uniform defines the webGL uniform location where to store the value
  40925. * @param array defines the array of number to store
  40926. * @returns true if the value was set
  40927. */
  40928. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  40929. /**
  40930. * Set the value of an uniform to an array of float32 (stored as matrices)
  40931. * @param uniform defines the webGL uniform location where to store the value
  40932. * @param matrices defines the array of float32 to store
  40933. * @returns true if the value was set
  40934. */
  40935. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  40936. /**
  40937. * Set the value of an uniform to a matrix (3x3)
  40938. * @param uniform defines the webGL uniform location where to store the value
  40939. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  40940. * @returns true if the value was set
  40941. */
  40942. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40943. /**
  40944. * Set the value of an uniform to a matrix (2x2)
  40945. * @param uniform defines the webGL uniform location where to store the value
  40946. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  40947. * @returns true if the value was set
  40948. */
  40949. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  40950. /**
  40951. * Set the value of an uniform to a number (float)
  40952. * @param uniform defines the webGL uniform location where to store the value
  40953. * @param value defines the float number to store
  40954. * @returns true if the value was transfered
  40955. */
  40956. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  40957. /**
  40958. * Set the value of an uniform to a vec2
  40959. * @param uniform defines the webGL uniform location where to store the value
  40960. * @param x defines the 1st component of the value
  40961. * @param y defines the 2nd component of the value
  40962. * @returns true if the value was set
  40963. */
  40964. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  40965. /**
  40966. * Set the value of an uniform to a vec3
  40967. * @param uniform defines the webGL uniform location where to store the value
  40968. * @param x defines the 1st component of the value
  40969. * @param y defines the 2nd component of the value
  40970. * @param z defines the 3rd component of the value
  40971. * @returns true if the value was set
  40972. */
  40973. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  40974. /**
  40975. * Set the value of an uniform to a vec4
  40976. * @param uniform defines the webGL uniform location where to store the value
  40977. * @param x defines the 1st component of the value
  40978. * @param y defines the 2nd component of the value
  40979. * @param z defines the 3rd component of the value
  40980. * @param w defines the 4th component of the value
  40981. * @returns true if the value was set
  40982. */
  40983. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  40984. /**
  40985. * Apply all cached states (depth, culling, stencil and alpha)
  40986. */
  40987. applyStates(): void;
  40988. /**
  40989. * Enable or disable color writing
  40990. * @param enable defines the state to set
  40991. */
  40992. setColorWrite(enable: boolean): void;
  40993. /**
  40994. * Gets a boolean indicating if color writing is enabled
  40995. * @returns the current color writing state
  40996. */
  40997. getColorWrite(): boolean;
  40998. /**
  40999. * Gets the depth culling state manager
  41000. */
  41001. get depthCullingState(): DepthCullingState;
  41002. /**
  41003. * Gets the alpha state manager
  41004. */
  41005. get alphaState(): AlphaState;
  41006. /**
  41007. * Gets the stencil state manager
  41008. */
  41009. get stencilState(): StencilState;
  41010. /**
  41011. * Clears the list of texture accessible through engine.
  41012. * This can help preventing texture load conflict due to name collision.
  41013. */
  41014. clearInternalTexturesCache(): void;
  41015. /**
  41016. * Force the entire cache to be cleared
  41017. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  41018. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  41019. */
  41020. wipeCaches(bruteForce?: boolean): void;
  41021. /** @hidden */
  41022. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  41023. min: number;
  41024. mag: number;
  41025. };
  41026. /** @hidden */
  41027. _createTexture(): WebGLTexture;
  41028. /**
  41029. * Usually called from Texture.ts.
  41030. * Passed information to create a WebGLTexture
  41031. * @param url defines a value which contains one of the following:
  41032. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  41033. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  41034. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  41035. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  41036. * @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)
  41037. * @param scene needed for loading to the correct scene
  41038. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  41039. * @param onLoad optional callback to be called upon successful completion
  41040. * @param onError optional callback to be called upon failure
  41041. * @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
  41042. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  41043. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  41044. * @param forcedExtension defines the extension to use to pick the right loader
  41045. * @param mimeType defines an optional mime type
  41046. * @param loaderOptions options to be passed to the loader
  41047. * @returns a InternalTexture for assignment back into BABYLON.Texture
  41048. */
  41049. 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;
  41050. /**
  41051. * Loads an image as an HTMLImageElement.
  41052. * @param input url string, ArrayBuffer, or Blob to load
  41053. * @param onLoad callback called when the image successfully loads
  41054. * @param onError callback called when the image fails to load
  41055. * @param offlineProvider offline provider for caching
  41056. * @param mimeType optional mime type
  41057. * @returns the HTMLImageElement of the loaded image
  41058. * @hidden
  41059. */
  41060. 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>;
  41061. /**
  41062. * @hidden
  41063. */
  41064. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41065. private _unpackFlipYCached;
  41066. /**
  41067. * In case you are sharing the context with other applications, it might
  41068. * be interested to not cache the unpack flip y state to ensure a consistent
  41069. * value would be set.
  41070. */
  41071. enableUnpackFlipYCached: boolean;
  41072. /** @hidden */
  41073. _unpackFlipY(value: boolean): void;
  41074. /** @hidden */
  41075. _getUnpackAlignement(): number;
  41076. private _getTextureTarget;
  41077. /**
  41078. * Update the sampling mode of a given texture
  41079. * @param samplingMode defines the required sampling mode
  41080. * @param texture defines the texture to update
  41081. * @param generateMipMaps defines whether to generate mipmaps for the texture
  41082. */
  41083. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  41084. /**
  41085. * Update the sampling mode of a given texture
  41086. * @param texture defines the texture to update
  41087. * @param wrapU defines the texture wrap mode of the u coordinates
  41088. * @param wrapV defines the texture wrap mode of the v coordinates
  41089. * @param wrapR defines the texture wrap mode of the r coordinates
  41090. */
  41091. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  41092. /** @hidden */
  41093. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  41094. width: number;
  41095. height: number;
  41096. layers?: number;
  41097. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  41098. /** @hidden */
  41099. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41100. /** @hidden */
  41101. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  41102. /**
  41103. * Update a portion of an internal texture
  41104. * @param texture defines the texture to update
  41105. * @param imageData defines the data to store into the texture
  41106. * @param xOffset defines the x coordinates of the update rectangle
  41107. * @param yOffset defines the y coordinates of the update rectangle
  41108. * @param width defines the width of the update rectangle
  41109. * @param height defines the height of the update rectangle
  41110. * @param faceIndex defines the face index if texture is a cube (0 by default)
  41111. * @param lod defines the lod level to update (0 by default)
  41112. */
  41113. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  41114. /** @hidden */
  41115. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  41116. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  41117. private _prepareWebGLTexture;
  41118. /** @hidden */
  41119. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  41120. private _getDepthStencilBuffer;
  41121. /** @hidden */
  41122. _releaseFramebufferObjects(texture: InternalTexture): void;
  41123. /** @hidden */
  41124. _releaseTexture(texture: InternalTexture): void;
  41125. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  41126. protected _setProgram(program: WebGLProgram): void;
  41127. protected _boundUniforms: {
  41128. [key: number]: WebGLUniformLocation;
  41129. };
  41130. /**
  41131. * Binds an effect to the webGL context
  41132. * @param effect defines the effect to bind
  41133. */
  41134. bindSamplers(effect: Effect): void;
  41135. private _activateCurrentTexture;
  41136. /** @hidden */
  41137. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  41138. /** @hidden */
  41139. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  41140. /**
  41141. * Unbind all textures from the webGL context
  41142. */
  41143. unbindAllTextures(): void;
  41144. /**
  41145. * Sets a texture to the according uniform.
  41146. * @param channel The texture channel
  41147. * @param uniform The uniform to set
  41148. * @param texture The texture to apply
  41149. */
  41150. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  41151. private _bindSamplerUniformToChannel;
  41152. private _getTextureWrapMode;
  41153. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  41154. /**
  41155. * Sets an array of texture to the webGL context
  41156. * @param channel defines the channel where the texture array must be set
  41157. * @param uniform defines the associated uniform location
  41158. * @param textures defines the array of textures to bind
  41159. */
  41160. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  41161. /** @hidden */
  41162. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  41163. private _setTextureParameterFloat;
  41164. private _setTextureParameterInteger;
  41165. /**
  41166. * Unbind all vertex attributes from the webGL context
  41167. */
  41168. unbindAllAttributes(): void;
  41169. /**
  41170. * 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
  41171. */
  41172. releaseEffects(): void;
  41173. /**
  41174. * Dispose and release all associated resources
  41175. */
  41176. dispose(): void;
  41177. /**
  41178. * Attach a new callback raised when context lost event is fired
  41179. * @param callback defines the callback to call
  41180. */
  41181. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41182. /**
  41183. * Attach a new callback raised when context restored event is fired
  41184. * @param callback defines the callback to call
  41185. */
  41186. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  41187. /**
  41188. * Get the current error code of the webGL context
  41189. * @returns the error code
  41190. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  41191. */
  41192. getError(): number;
  41193. private _canRenderToFloatFramebuffer;
  41194. private _canRenderToHalfFloatFramebuffer;
  41195. private _canRenderToFramebuffer;
  41196. /** @hidden */
  41197. _getWebGLTextureType(type: number): number;
  41198. /** @hidden */
  41199. _getInternalFormat(format: number): number;
  41200. /** @hidden */
  41201. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  41202. /** @hidden */
  41203. _getRGBAMultiSampleBufferFormat(type: number): number;
  41204. /** @hidden */
  41205. _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;
  41206. /**
  41207. * Loads a file from a url
  41208. * @param url url to load
  41209. * @param onSuccess callback called when the file successfully loads
  41210. * @param onProgress callback called while file is loading (if the server supports this mode)
  41211. * @param offlineProvider defines the offline provider for caching
  41212. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41213. * @param onError callback called when the file fails to load
  41214. * @returns a file request object
  41215. * @hidden
  41216. */
  41217. 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;
  41218. /**
  41219. * Reads pixels from the current frame buffer. Please note that this function can be slow
  41220. * @param x defines the x coordinate of the rectangle where pixels must be read
  41221. * @param y defines the y coordinate of the rectangle where pixels must be read
  41222. * @param width defines the width of the rectangle where pixels must be read
  41223. * @param height defines the height of the rectangle where pixels must be read
  41224. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  41225. * @returns a Uint8Array containing RGBA colors
  41226. */
  41227. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  41228. private static _IsSupported;
  41229. private static _HasMajorPerformanceCaveat;
  41230. /**
  41231. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41232. */
  41233. static get IsSupported(): boolean;
  41234. /**
  41235. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  41236. * @returns true if the engine can be created
  41237. * @ignorenaming
  41238. */
  41239. static isSupported(): boolean;
  41240. /**
  41241. * 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)
  41242. */
  41243. static get HasMajorPerformanceCaveat(): boolean;
  41244. /**
  41245. * Find the next highest power of two.
  41246. * @param x Number to start search from.
  41247. * @return Next highest power of two.
  41248. */
  41249. static CeilingPOT(x: number): number;
  41250. /**
  41251. * Find the next lowest power of two.
  41252. * @param x Number to start search from.
  41253. * @return Next lowest power of two.
  41254. */
  41255. static FloorPOT(x: number): number;
  41256. /**
  41257. * Find the nearest power of two.
  41258. * @param x Number to start search from.
  41259. * @return Next nearest power of two.
  41260. */
  41261. static NearestPOT(x: number): number;
  41262. /**
  41263. * Get the closest exponent of two
  41264. * @param value defines the value to approximate
  41265. * @param max defines the maximum value to return
  41266. * @param mode defines how to define the closest value
  41267. * @returns closest exponent of two of the given value
  41268. */
  41269. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  41270. /**
  41271. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  41272. * @param func - the function to be called
  41273. * @param requester - the object that will request the next frame. Falls back to window.
  41274. * @returns frame number
  41275. */
  41276. static QueueNewFrame(func: () => void, requester?: any): number;
  41277. /**
  41278. * Gets host document
  41279. * @returns the host document object
  41280. */
  41281. getHostDocument(): Nullable<Document>;
  41282. }
  41283. }
  41284. declare module "babylonjs/Materials/Textures/internalTexture" {
  41285. import { Observable } from "babylonjs/Misc/observable";
  41286. import { Nullable, int } from "babylonjs/types";
  41287. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  41288. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41289. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  41290. /**
  41291. * Defines the source of the internal texture
  41292. */
  41293. export enum InternalTextureSource {
  41294. /**
  41295. * The source of the texture data is unknown
  41296. */
  41297. Unknown = 0,
  41298. /**
  41299. * Texture data comes from an URL
  41300. */
  41301. Url = 1,
  41302. /**
  41303. * Texture data is only used for temporary storage
  41304. */
  41305. Temp = 2,
  41306. /**
  41307. * Texture data comes from raw data (ArrayBuffer)
  41308. */
  41309. Raw = 3,
  41310. /**
  41311. * Texture content is dynamic (video or dynamic texture)
  41312. */
  41313. Dynamic = 4,
  41314. /**
  41315. * Texture content is generated by rendering to it
  41316. */
  41317. RenderTarget = 5,
  41318. /**
  41319. * Texture content is part of a multi render target process
  41320. */
  41321. MultiRenderTarget = 6,
  41322. /**
  41323. * Texture data comes from a cube data file
  41324. */
  41325. Cube = 7,
  41326. /**
  41327. * Texture data comes from a raw cube data
  41328. */
  41329. CubeRaw = 8,
  41330. /**
  41331. * Texture data come from a prefiltered cube data file
  41332. */
  41333. CubePrefiltered = 9,
  41334. /**
  41335. * Texture content is raw 3D data
  41336. */
  41337. Raw3D = 10,
  41338. /**
  41339. * Texture content is raw 2D array data
  41340. */
  41341. Raw2DArray = 11,
  41342. /**
  41343. * Texture content is a depth texture
  41344. */
  41345. Depth = 12,
  41346. /**
  41347. * Texture data comes from a raw cube data encoded with RGBD
  41348. */
  41349. CubeRawRGBD = 13
  41350. }
  41351. /**
  41352. * Class used to store data associated with WebGL texture data for the engine
  41353. * This class should not be used directly
  41354. */
  41355. export class InternalTexture {
  41356. /** @hidden */
  41357. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  41358. /**
  41359. * Defines if the texture is ready
  41360. */
  41361. isReady: boolean;
  41362. /**
  41363. * Defines if the texture is a cube texture
  41364. */
  41365. isCube: boolean;
  41366. /**
  41367. * Defines if the texture contains 3D data
  41368. */
  41369. is3D: boolean;
  41370. /**
  41371. * Defines if the texture contains 2D array data
  41372. */
  41373. is2DArray: boolean;
  41374. /**
  41375. * Defines if the texture contains multiview data
  41376. */
  41377. isMultiview: boolean;
  41378. /**
  41379. * Gets the URL used to load this texture
  41380. */
  41381. url: string;
  41382. /**
  41383. * Gets the sampling mode of the texture
  41384. */
  41385. samplingMode: number;
  41386. /**
  41387. * Gets a boolean indicating if the texture needs mipmaps generation
  41388. */
  41389. generateMipMaps: boolean;
  41390. /**
  41391. * Gets the number of samples used by the texture (WebGL2+ only)
  41392. */
  41393. samples: number;
  41394. /**
  41395. * Gets the type of the texture (int, float...)
  41396. */
  41397. type: number;
  41398. /**
  41399. * Gets the format of the texture (RGB, RGBA...)
  41400. */
  41401. format: number;
  41402. /**
  41403. * Observable called when the texture is loaded
  41404. */
  41405. onLoadedObservable: Observable<InternalTexture>;
  41406. /**
  41407. * Gets the width of the texture
  41408. */
  41409. width: number;
  41410. /**
  41411. * Gets the height of the texture
  41412. */
  41413. height: number;
  41414. /**
  41415. * Gets the depth of the texture
  41416. */
  41417. depth: number;
  41418. /**
  41419. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  41420. */
  41421. baseWidth: number;
  41422. /**
  41423. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  41424. */
  41425. baseHeight: number;
  41426. /**
  41427. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  41428. */
  41429. baseDepth: number;
  41430. /**
  41431. * Gets a boolean indicating if the texture is inverted on Y axis
  41432. */
  41433. invertY: boolean;
  41434. /** @hidden */
  41435. _invertVScale: boolean;
  41436. /** @hidden */
  41437. _associatedChannel: number;
  41438. /** @hidden */
  41439. _source: InternalTextureSource;
  41440. /** @hidden */
  41441. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  41442. /** @hidden */
  41443. _bufferView: Nullable<ArrayBufferView>;
  41444. /** @hidden */
  41445. _bufferViewArray: Nullable<ArrayBufferView[]>;
  41446. /** @hidden */
  41447. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  41448. /** @hidden */
  41449. _size: number;
  41450. /** @hidden */
  41451. _extension: string;
  41452. /** @hidden */
  41453. _files: Nullable<string[]>;
  41454. /** @hidden */
  41455. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  41456. /** @hidden */
  41457. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  41458. /** @hidden */
  41459. _framebuffer: Nullable<WebGLFramebuffer>;
  41460. /** @hidden */
  41461. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  41462. /** @hidden */
  41463. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  41464. /** @hidden */
  41465. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  41466. /** @hidden */
  41467. _attachments: Nullable<number[]>;
  41468. /** @hidden */
  41469. _textureArray: Nullable<InternalTexture[]>;
  41470. /** @hidden */
  41471. _cachedCoordinatesMode: Nullable<number>;
  41472. /** @hidden */
  41473. _cachedWrapU: Nullable<number>;
  41474. /** @hidden */
  41475. _cachedWrapV: Nullable<number>;
  41476. /** @hidden */
  41477. _cachedWrapR: Nullable<number>;
  41478. /** @hidden */
  41479. _cachedAnisotropicFilteringLevel: Nullable<number>;
  41480. /** @hidden */
  41481. _isDisabled: boolean;
  41482. /** @hidden */
  41483. _compression: Nullable<string>;
  41484. /** @hidden */
  41485. _generateStencilBuffer: boolean;
  41486. /** @hidden */
  41487. _generateDepthBuffer: boolean;
  41488. /** @hidden */
  41489. _comparisonFunction: number;
  41490. /** @hidden */
  41491. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  41492. /** @hidden */
  41493. _lodGenerationScale: number;
  41494. /** @hidden */
  41495. _lodGenerationOffset: number;
  41496. /** @hidden */
  41497. _depthStencilTexture: Nullable<InternalTexture>;
  41498. /** @hidden */
  41499. _colorTextureArray: Nullable<WebGLTexture>;
  41500. /** @hidden */
  41501. _depthStencilTextureArray: Nullable<WebGLTexture>;
  41502. /** @hidden */
  41503. _lodTextureHigh: Nullable<BaseTexture>;
  41504. /** @hidden */
  41505. _lodTextureMid: Nullable<BaseTexture>;
  41506. /** @hidden */
  41507. _lodTextureLow: Nullable<BaseTexture>;
  41508. /** @hidden */
  41509. _isRGBD: boolean;
  41510. /** @hidden */
  41511. _linearSpecularLOD: boolean;
  41512. /** @hidden */
  41513. _irradianceTexture: Nullable<BaseTexture>;
  41514. /** @hidden */
  41515. _webGLTexture: Nullable<WebGLTexture>;
  41516. /** @hidden */
  41517. _references: number;
  41518. /** @hidden */
  41519. _gammaSpace: Nullable<boolean>;
  41520. private _engine;
  41521. /**
  41522. * Gets the Engine the texture belongs to.
  41523. * @returns The babylon engine
  41524. */
  41525. getEngine(): ThinEngine;
  41526. /**
  41527. * Gets the data source type of the texture
  41528. */
  41529. get source(): InternalTextureSource;
  41530. /**
  41531. * Creates a new InternalTexture
  41532. * @param engine defines the engine to use
  41533. * @param source defines the type of data that will be used
  41534. * @param delayAllocation if the texture allocation should be delayed (default: false)
  41535. */
  41536. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  41537. /**
  41538. * Increments the number of references (ie. the number of Texture that point to it)
  41539. */
  41540. incrementReferences(): void;
  41541. /**
  41542. * Change the size of the texture (not the size of the content)
  41543. * @param width defines the new width
  41544. * @param height defines the new height
  41545. * @param depth defines the new depth (1 by default)
  41546. */
  41547. updateSize(width: int, height: int, depth?: int): void;
  41548. /** @hidden */
  41549. _rebuild(): void;
  41550. /** @hidden */
  41551. _swapAndDie(target: InternalTexture): void;
  41552. /**
  41553. * Dispose the current allocated resources
  41554. */
  41555. dispose(): void;
  41556. }
  41557. }
  41558. declare module "babylonjs/Audio/analyser" {
  41559. import { Scene } from "babylonjs/scene";
  41560. /**
  41561. * Class used to work with sound analyzer using fast fourier transform (FFT)
  41562. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41563. */
  41564. export class Analyser {
  41565. /**
  41566. * Gets or sets the smoothing
  41567. * @ignorenaming
  41568. */
  41569. SMOOTHING: number;
  41570. /**
  41571. * Gets or sets the FFT table size
  41572. * @ignorenaming
  41573. */
  41574. FFT_SIZE: number;
  41575. /**
  41576. * Gets or sets the bar graph amplitude
  41577. * @ignorenaming
  41578. */
  41579. BARGRAPHAMPLITUDE: number;
  41580. /**
  41581. * Gets or sets the position of the debug canvas
  41582. * @ignorenaming
  41583. */
  41584. DEBUGCANVASPOS: {
  41585. x: number;
  41586. y: number;
  41587. };
  41588. /**
  41589. * Gets or sets the debug canvas size
  41590. * @ignorenaming
  41591. */
  41592. DEBUGCANVASSIZE: {
  41593. width: number;
  41594. height: number;
  41595. };
  41596. private _byteFreqs;
  41597. private _byteTime;
  41598. private _floatFreqs;
  41599. private _webAudioAnalyser;
  41600. private _debugCanvas;
  41601. private _debugCanvasContext;
  41602. private _scene;
  41603. private _registerFunc;
  41604. private _audioEngine;
  41605. /**
  41606. * Creates a new analyser
  41607. * @param scene defines hosting scene
  41608. */
  41609. constructor(scene: Scene);
  41610. /**
  41611. * Get the number of data values you will have to play with for the visualization
  41612. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  41613. * @returns a number
  41614. */
  41615. getFrequencyBinCount(): number;
  41616. /**
  41617. * Gets the current frequency data as a byte array
  41618. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41619. * @returns a Uint8Array
  41620. */
  41621. getByteFrequencyData(): Uint8Array;
  41622. /**
  41623. * Gets the current waveform as a byte array
  41624. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  41625. * @returns a Uint8Array
  41626. */
  41627. getByteTimeDomainData(): Uint8Array;
  41628. /**
  41629. * Gets the current frequency data as a float array
  41630. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  41631. * @returns a Float32Array
  41632. */
  41633. getFloatFrequencyData(): Float32Array;
  41634. /**
  41635. * Renders the debug canvas
  41636. */
  41637. drawDebugCanvas(): void;
  41638. /**
  41639. * Stops rendering the debug canvas and removes it
  41640. */
  41641. stopDebugCanvas(): void;
  41642. /**
  41643. * Connects two audio nodes
  41644. * @param inputAudioNode defines first node to connect
  41645. * @param outputAudioNode defines second node to connect
  41646. */
  41647. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  41648. /**
  41649. * Releases all associated resources
  41650. */
  41651. dispose(): void;
  41652. }
  41653. }
  41654. declare module "babylonjs/Audio/audioEngine" {
  41655. import { IDisposable } from "babylonjs/scene";
  41656. import { Analyser } from "babylonjs/Audio/analyser";
  41657. import { Nullable } from "babylonjs/types";
  41658. import { Observable } from "babylonjs/Misc/observable";
  41659. /**
  41660. * This represents an audio engine and it is responsible
  41661. * to play, synchronize and analyse sounds throughout the application.
  41662. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41663. */
  41664. export interface IAudioEngine extends IDisposable {
  41665. /**
  41666. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41667. */
  41668. readonly canUseWebAudio: boolean;
  41669. /**
  41670. * Gets the current AudioContext if available.
  41671. */
  41672. readonly audioContext: Nullable<AudioContext>;
  41673. /**
  41674. * The master gain node defines the global audio volume of your audio engine.
  41675. */
  41676. readonly masterGain: GainNode;
  41677. /**
  41678. * Gets whether or not mp3 are supported by your browser.
  41679. */
  41680. readonly isMP3supported: boolean;
  41681. /**
  41682. * Gets whether or not ogg are supported by your browser.
  41683. */
  41684. readonly isOGGsupported: boolean;
  41685. /**
  41686. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41687. * @ignoreNaming
  41688. */
  41689. WarnedWebAudioUnsupported: boolean;
  41690. /**
  41691. * Defines if the audio engine relies on a custom unlocked button.
  41692. * In this case, the embedded button will not be displayed.
  41693. */
  41694. useCustomUnlockedButton: boolean;
  41695. /**
  41696. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  41697. */
  41698. readonly unlocked: boolean;
  41699. /**
  41700. * Event raised when audio has been unlocked on the browser.
  41701. */
  41702. onAudioUnlockedObservable: Observable<AudioEngine>;
  41703. /**
  41704. * Event raised when audio has been locked on the browser.
  41705. */
  41706. onAudioLockedObservable: Observable<AudioEngine>;
  41707. /**
  41708. * Flags the audio engine in Locked state.
  41709. * This happens due to new browser policies preventing audio to autoplay.
  41710. */
  41711. lock(): void;
  41712. /**
  41713. * Unlocks the audio engine once a user action has been done on the dom.
  41714. * This is helpful to resume play once browser policies have been satisfied.
  41715. */
  41716. unlock(): void;
  41717. /**
  41718. * Gets the global volume sets on the master gain.
  41719. * @returns the global volume if set or -1 otherwise
  41720. */
  41721. getGlobalVolume(): number;
  41722. /**
  41723. * Sets the global volume of your experience (sets on the master gain).
  41724. * @param newVolume Defines the new global volume of the application
  41725. */
  41726. setGlobalVolume(newVolume: number): void;
  41727. /**
  41728. * Connect the audio engine to an audio analyser allowing some amazing
  41729. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41730. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41731. * @param analyser The analyser to connect to the engine
  41732. */
  41733. connectToAnalyser(analyser: Analyser): void;
  41734. }
  41735. /**
  41736. * This represents the default audio engine used in babylon.
  41737. * It is responsible to play, synchronize and analyse sounds throughout the application.
  41738. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41739. */
  41740. export class AudioEngine implements IAudioEngine {
  41741. private _audioContext;
  41742. private _audioContextInitialized;
  41743. private _muteButton;
  41744. private _hostElement;
  41745. /**
  41746. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  41747. */
  41748. canUseWebAudio: boolean;
  41749. /**
  41750. * The master gain node defines the global audio volume of your audio engine.
  41751. */
  41752. masterGain: GainNode;
  41753. /**
  41754. * Defines if Babylon should emit a warning if WebAudio is not supported.
  41755. * @ignoreNaming
  41756. */
  41757. WarnedWebAudioUnsupported: boolean;
  41758. /**
  41759. * Gets whether or not mp3 are supported by your browser.
  41760. */
  41761. isMP3supported: boolean;
  41762. /**
  41763. * Gets whether or not ogg are supported by your browser.
  41764. */
  41765. isOGGsupported: boolean;
  41766. /**
  41767. * Gets whether audio has been unlocked on the device.
  41768. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  41769. * a user interaction has happened.
  41770. */
  41771. unlocked: boolean;
  41772. /**
  41773. * Defines if the audio engine relies on a custom unlocked button.
  41774. * In this case, the embedded button will not be displayed.
  41775. */
  41776. useCustomUnlockedButton: boolean;
  41777. /**
  41778. * Event raised when audio has been unlocked on the browser.
  41779. */
  41780. onAudioUnlockedObservable: Observable<AudioEngine>;
  41781. /**
  41782. * Event raised when audio has been locked on the browser.
  41783. */
  41784. onAudioLockedObservable: Observable<AudioEngine>;
  41785. /**
  41786. * Gets the current AudioContext if available.
  41787. */
  41788. get audioContext(): Nullable<AudioContext>;
  41789. private _connectedAnalyser;
  41790. /**
  41791. * Instantiates a new audio engine.
  41792. *
  41793. * There should be only one per page as some browsers restrict the number
  41794. * of audio contexts you can create.
  41795. * @param hostElement defines the host element where to display the mute icon if necessary
  41796. */
  41797. constructor(hostElement?: Nullable<HTMLElement>);
  41798. /**
  41799. * Flags the audio engine in Locked state.
  41800. * This happens due to new browser policies preventing audio to autoplay.
  41801. */
  41802. lock(): void;
  41803. /**
  41804. * Unlocks the audio engine once a user action has been done on the dom.
  41805. * This is helpful to resume play once browser policies have been satisfied.
  41806. */
  41807. unlock(): void;
  41808. private _resumeAudioContext;
  41809. private _initializeAudioContext;
  41810. private _tryToRun;
  41811. private _triggerRunningState;
  41812. private _triggerSuspendedState;
  41813. private _displayMuteButton;
  41814. private _moveButtonToTopLeft;
  41815. private _onResize;
  41816. private _hideMuteButton;
  41817. /**
  41818. * Destroy and release the resources associated with the audio ccontext.
  41819. */
  41820. dispose(): void;
  41821. /**
  41822. * Gets the global volume sets on the master gain.
  41823. * @returns the global volume if set or -1 otherwise
  41824. */
  41825. getGlobalVolume(): number;
  41826. /**
  41827. * Sets the global volume of your experience (sets on the master gain).
  41828. * @param newVolume Defines the new global volume of the application
  41829. */
  41830. setGlobalVolume(newVolume: number): void;
  41831. /**
  41832. * Connect the audio engine to an audio analyser allowing some amazing
  41833. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  41834. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  41835. * @param analyser The analyser to connect to the engine
  41836. */
  41837. connectToAnalyser(analyser: Analyser): void;
  41838. }
  41839. }
  41840. declare module "babylonjs/Loading/loadingScreen" {
  41841. /**
  41842. * Interface used to present a loading screen while loading a scene
  41843. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41844. */
  41845. export interface ILoadingScreen {
  41846. /**
  41847. * Function called to display the loading screen
  41848. */
  41849. displayLoadingUI: () => void;
  41850. /**
  41851. * Function called to hide the loading screen
  41852. */
  41853. hideLoadingUI: () => void;
  41854. /**
  41855. * Gets or sets the color to use for the background
  41856. */
  41857. loadingUIBackgroundColor: string;
  41858. /**
  41859. * Gets or sets the text to display while loading
  41860. */
  41861. loadingUIText: string;
  41862. }
  41863. /**
  41864. * Class used for the default loading screen
  41865. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41866. */
  41867. export class DefaultLoadingScreen implements ILoadingScreen {
  41868. private _renderingCanvas;
  41869. private _loadingText;
  41870. private _loadingDivBackgroundColor;
  41871. private _loadingDiv;
  41872. private _loadingTextDiv;
  41873. /** Gets or sets the logo url to use for the default loading screen */
  41874. static DefaultLogoUrl: string;
  41875. /** Gets or sets the spinner url to use for the default loading screen */
  41876. static DefaultSpinnerUrl: string;
  41877. /**
  41878. * Creates a new default loading screen
  41879. * @param _renderingCanvas defines the canvas used to render the scene
  41880. * @param _loadingText defines the default text to display
  41881. * @param _loadingDivBackgroundColor defines the default background color
  41882. */
  41883. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  41884. /**
  41885. * Function called to display the loading screen
  41886. */
  41887. displayLoadingUI(): void;
  41888. /**
  41889. * Function called to hide the loading screen
  41890. */
  41891. hideLoadingUI(): void;
  41892. /**
  41893. * Gets or sets the text to display while loading
  41894. */
  41895. set loadingUIText(text: string);
  41896. get loadingUIText(): string;
  41897. /**
  41898. * Gets or sets the color to use for the background
  41899. */
  41900. get loadingUIBackgroundColor(): string;
  41901. set loadingUIBackgroundColor(color: string);
  41902. private _resizeLoadingUI;
  41903. }
  41904. }
  41905. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  41906. /**
  41907. * Interface for any object that can request an animation frame
  41908. */
  41909. export interface ICustomAnimationFrameRequester {
  41910. /**
  41911. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  41912. */
  41913. renderFunction?: Function;
  41914. /**
  41915. * Called to request the next frame to render to
  41916. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  41917. */
  41918. requestAnimationFrame: Function;
  41919. /**
  41920. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  41921. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  41922. */
  41923. requestID?: number;
  41924. }
  41925. }
  41926. declare module "babylonjs/Misc/performanceMonitor" {
  41927. /**
  41928. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  41929. */
  41930. export class PerformanceMonitor {
  41931. private _enabled;
  41932. private _rollingFrameTime;
  41933. private _lastFrameTimeMs;
  41934. /**
  41935. * constructor
  41936. * @param frameSampleSize The number of samples required to saturate the sliding window
  41937. */
  41938. constructor(frameSampleSize?: number);
  41939. /**
  41940. * Samples current frame
  41941. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  41942. */
  41943. sampleFrame(timeMs?: number): void;
  41944. /**
  41945. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41946. */
  41947. get averageFrameTime(): number;
  41948. /**
  41949. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  41950. */
  41951. get averageFrameTimeVariance(): number;
  41952. /**
  41953. * Returns the frame time of the most recent frame
  41954. */
  41955. get instantaneousFrameTime(): number;
  41956. /**
  41957. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  41958. */
  41959. get averageFPS(): number;
  41960. /**
  41961. * Returns the average framerate in frames per second using the most recent frame time
  41962. */
  41963. get instantaneousFPS(): number;
  41964. /**
  41965. * Returns true if enough samples have been taken to completely fill the sliding window
  41966. */
  41967. get isSaturated(): boolean;
  41968. /**
  41969. * Enables contributions to the sliding window sample set
  41970. */
  41971. enable(): void;
  41972. /**
  41973. * Disables contributions to the sliding window sample set
  41974. * Samples will not be interpolated over the disabled period
  41975. */
  41976. disable(): void;
  41977. /**
  41978. * Returns true if sampling is enabled
  41979. */
  41980. get isEnabled(): boolean;
  41981. /**
  41982. * Resets performance monitor
  41983. */
  41984. reset(): void;
  41985. }
  41986. /**
  41987. * RollingAverage
  41988. *
  41989. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  41990. */
  41991. export class RollingAverage {
  41992. /**
  41993. * Current average
  41994. */
  41995. average: number;
  41996. /**
  41997. * Current variance
  41998. */
  41999. variance: number;
  42000. protected _samples: Array<number>;
  42001. protected _sampleCount: number;
  42002. protected _pos: number;
  42003. protected _m2: number;
  42004. /**
  42005. * constructor
  42006. * @param length The number of samples required to saturate the sliding window
  42007. */
  42008. constructor(length: number);
  42009. /**
  42010. * Adds a sample to the sample set
  42011. * @param v The sample value
  42012. */
  42013. add(v: number): void;
  42014. /**
  42015. * Returns previously added values or null if outside of history or outside the sliding window domain
  42016. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  42017. * @return Value previously recorded with add() or null if outside of range
  42018. */
  42019. history(i: number): number;
  42020. /**
  42021. * Returns true if enough samples have been taken to completely fill the sliding window
  42022. * @return true if sample-set saturated
  42023. */
  42024. isSaturated(): boolean;
  42025. /**
  42026. * Resets the rolling average (equivalent to 0 samples taken so far)
  42027. */
  42028. reset(): void;
  42029. /**
  42030. * Wraps a value around the sample range boundaries
  42031. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  42032. * @return Wrapped position in sample range
  42033. */
  42034. protected _wrapPosition(i: number): number;
  42035. }
  42036. }
  42037. declare module "babylonjs/Misc/perfCounter" {
  42038. /**
  42039. * This class is used to track a performance counter which is number based.
  42040. * The user has access to many properties which give statistics of different nature.
  42041. *
  42042. * The implementer can track two kinds of Performance Counter: time and count.
  42043. * 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.
  42044. * 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.
  42045. */
  42046. export class PerfCounter {
  42047. /**
  42048. * Gets or sets a global boolean to turn on and off all the counters
  42049. */
  42050. static Enabled: boolean;
  42051. /**
  42052. * Returns the smallest value ever
  42053. */
  42054. get min(): number;
  42055. /**
  42056. * Returns the biggest value ever
  42057. */
  42058. get max(): number;
  42059. /**
  42060. * Returns the average value since the performance counter is running
  42061. */
  42062. get average(): number;
  42063. /**
  42064. * Returns the average value of the last second the counter was monitored
  42065. */
  42066. get lastSecAverage(): number;
  42067. /**
  42068. * Returns the current value
  42069. */
  42070. get current(): number;
  42071. /**
  42072. * Gets the accumulated total
  42073. */
  42074. get total(): number;
  42075. /**
  42076. * Gets the total value count
  42077. */
  42078. get count(): number;
  42079. /**
  42080. * Creates a new counter
  42081. */
  42082. constructor();
  42083. /**
  42084. * Call this method to start monitoring a new frame.
  42085. * 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.
  42086. */
  42087. fetchNewFrame(): void;
  42088. /**
  42089. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  42090. * @param newCount the count value to add to the monitored count
  42091. * @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.
  42092. */
  42093. addCount(newCount: number, fetchResult: boolean): void;
  42094. /**
  42095. * Start monitoring this performance counter
  42096. */
  42097. beginMonitoring(): void;
  42098. /**
  42099. * Compute the time lapsed since the previous beginMonitoring() call.
  42100. * @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
  42101. */
  42102. endMonitoring(newFrame?: boolean): void;
  42103. private _fetchResult;
  42104. private _startMonitoringTime;
  42105. private _min;
  42106. private _max;
  42107. private _average;
  42108. private _current;
  42109. private _totalValueCount;
  42110. private _totalAccumulated;
  42111. private _lastSecAverage;
  42112. private _lastSecAccumulated;
  42113. private _lastSecTime;
  42114. private _lastSecValueCount;
  42115. }
  42116. }
  42117. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  42118. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42119. import { Nullable } from "babylonjs/types";
  42120. module "babylonjs/Engines/thinEngine" {
  42121. interface ThinEngine {
  42122. /** @hidden */
  42123. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  42124. }
  42125. }
  42126. }
  42127. declare module "babylonjs/Engines/engine" {
  42128. import { Observable } from "babylonjs/Misc/observable";
  42129. import { Nullable } from "babylonjs/types";
  42130. import { Scene } from "babylonjs/scene";
  42131. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42132. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  42133. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  42134. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  42135. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  42136. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  42137. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  42138. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  42139. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  42140. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42141. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  42142. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  42143. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  42144. import "babylonjs/Engines/Extensions/engine.alpha";
  42145. import "babylonjs/Engines/Extensions/engine.readTexture";
  42146. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  42147. import { Material } from "babylonjs/Materials/material";
  42148. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  42149. /**
  42150. * Defines the interface used by display changed events
  42151. */
  42152. export interface IDisplayChangedEventArgs {
  42153. /** Gets the vrDisplay object (if any) */
  42154. vrDisplay: Nullable<any>;
  42155. /** Gets a boolean indicating if webVR is supported */
  42156. vrSupported: boolean;
  42157. }
  42158. /**
  42159. * Defines the interface used by objects containing a viewport (like a camera)
  42160. */
  42161. interface IViewportOwnerLike {
  42162. /**
  42163. * Gets or sets the viewport
  42164. */
  42165. viewport: IViewportLike;
  42166. }
  42167. /**
  42168. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  42169. */
  42170. export class Engine extends ThinEngine {
  42171. /** Defines that alpha blending is disabled */
  42172. static readonly ALPHA_DISABLE: number;
  42173. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  42174. static readonly ALPHA_ADD: number;
  42175. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  42176. static readonly ALPHA_COMBINE: number;
  42177. /** Defines that alpha blending to DEST - SRC * DEST */
  42178. static readonly ALPHA_SUBTRACT: number;
  42179. /** Defines that alpha blending to SRC * DEST */
  42180. static readonly ALPHA_MULTIPLY: number;
  42181. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  42182. static readonly ALPHA_MAXIMIZED: number;
  42183. /** Defines that alpha blending to SRC + DEST */
  42184. static readonly ALPHA_ONEONE: number;
  42185. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  42186. static readonly ALPHA_PREMULTIPLIED: number;
  42187. /**
  42188. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  42189. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  42190. */
  42191. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  42192. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  42193. static readonly ALPHA_INTERPOLATE: number;
  42194. /**
  42195. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  42196. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  42197. */
  42198. static readonly ALPHA_SCREENMODE: number;
  42199. /** Defines that the ressource is not delayed*/
  42200. static readonly DELAYLOADSTATE_NONE: number;
  42201. /** Defines that the ressource was successfully delay loaded */
  42202. static readonly DELAYLOADSTATE_LOADED: number;
  42203. /** Defines that the ressource is currently delay loading */
  42204. static readonly DELAYLOADSTATE_LOADING: number;
  42205. /** Defines that the ressource is delayed and has not started loading */
  42206. static readonly DELAYLOADSTATE_NOTLOADED: number;
  42207. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  42208. static readonly NEVER: number;
  42209. /** 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 */
  42210. static readonly ALWAYS: number;
  42211. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  42212. static readonly LESS: number;
  42213. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  42214. static readonly EQUAL: number;
  42215. /** 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 */
  42216. static readonly LEQUAL: number;
  42217. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  42218. static readonly GREATER: number;
  42219. /** 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 */
  42220. static readonly GEQUAL: number;
  42221. /** 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 */
  42222. static readonly NOTEQUAL: number;
  42223. /** Passed to stencilOperation to specify that stencil value must be kept */
  42224. static readonly KEEP: number;
  42225. /** Passed to stencilOperation to specify that stencil value must be replaced */
  42226. static readonly REPLACE: number;
  42227. /** Passed to stencilOperation to specify that stencil value must be incremented */
  42228. static readonly INCR: number;
  42229. /** Passed to stencilOperation to specify that stencil value must be decremented */
  42230. static readonly DECR: number;
  42231. /** Passed to stencilOperation to specify that stencil value must be inverted */
  42232. static readonly INVERT: number;
  42233. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  42234. static readonly INCR_WRAP: number;
  42235. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  42236. static readonly DECR_WRAP: number;
  42237. /** Texture is not repeating outside of 0..1 UVs */
  42238. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  42239. /** Texture is repeating outside of 0..1 UVs */
  42240. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  42241. /** Texture is repeating and mirrored */
  42242. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  42243. /** ALPHA */
  42244. static readonly TEXTUREFORMAT_ALPHA: number;
  42245. /** LUMINANCE */
  42246. static readonly TEXTUREFORMAT_LUMINANCE: number;
  42247. /** LUMINANCE_ALPHA */
  42248. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  42249. /** RGB */
  42250. static readonly TEXTUREFORMAT_RGB: number;
  42251. /** RGBA */
  42252. static readonly TEXTUREFORMAT_RGBA: number;
  42253. /** RED */
  42254. static readonly TEXTUREFORMAT_RED: number;
  42255. /** RED (2nd reference) */
  42256. static readonly TEXTUREFORMAT_R: number;
  42257. /** RG */
  42258. static readonly TEXTUREFORMAT_RG: number;
  42259. /** RED_INTEGER */
  42260. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  42261. /** RED_INTEGER (2nd reference) */
  42262. static readonly TEXTUREFORMAT_R_INTEGER: number;
  42263. /** RG_INTEGER */
  42264. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  42265. /** RGB_INTEGER */
  42266. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  42267. /** RGBA_INTEGER */
  42268. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  42269. /** UNSIGNED_BYTE */
  42270. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  42271. /** UNSIGNED_BYTE (2nd reference) */
  42272. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  42273. /** FLOAT */
  42274. static readonly TEXTURETYPE_FLOAT: number;
  42275. /** HALF_FLOAT */
  42276. static readonly TEXTURETYPE_HALF_FLOAT: number;
  42277. /** BYTE */
  42278. static readonly TEXTURETYPE_BYTE: number;
  42279. /** SHORT */
  42280. static readonly TEXTURETYPE_SHORT: number;
  42281. /** UNSIGNED_SHORT */
  42282. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  42283. /** INT */
  42284. static readonly TEXTURETYPE_INT: number;
  42285. /** UNSIGNED_INT */
  42286. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  42287. /** UNSIGNED_SHORT_4_4_4_4 */
  42288. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  42289. /** UNSIGNED_SHORT_5_5_5_1 */
  42290. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  42291. /** UNSIGNED_SHORT_5_6_5 */
  42292. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  42293. /** UNSIGNED_INT_2_10_10_10_REV */
  42294. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  42295. /** UNSIGNED_INT_24_8 */
  42296. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  42297. /** UNSIGNED_INT_10F_11F_11F_REV */
  42298. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  42299. /** UNSIGNED_INT_5_9_9_9_REV */
  42300. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  42301. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  42302. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  42303. /** nearest is mag = nearest and min = nearest and mip = linear */
  42304. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  42305. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42306. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  42307. /** Trilinear is mag = linear and min = linear and mip = linear */
  42308. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  42309. /** nearest is mag = nearest and min = nearest and mip = linear */
  42310. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  42311. /** Bilinear is mag = linear and min = linear and mip = nearest */
  42312. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  42313. /** Trilinear is mag = linear and min = linear and mip = linear */
  42314. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  42315. /** mag = nearest and min = nearest and mip = nearest */
  42316. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  42317. /** mag = nearest and min = linear and mip = nearest */
  42318. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  42319. /** mag = nearest and min = linear and mip = linear */
  42320. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  42321. /** mag = nearest and min = linear and mip = none */
  42322. static readonly TEXTURE_NEAREST_LINEAR: number;
  42323. /** mag = nearest and min = nearest and mip = none */
  42324. static readonly TEXTURE_NEAREST_NEAREST: number;
  42325. /** mag = linear and min = nearest and mip = nearest */
  42326. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  42327. /** mag = linear and min = nearest and mip = linear */
  42328. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  42329. /** mag = linear and min = linear and mip = none */
  42330. static readonly TEXTURE_LINEAR_LINEAR: number;
  42331. /** mag = linear and min = nearest and mip = none */
  42332. static readonly TEXTURE_LINEAR_NEAREST: number;
  42333. /** Explicit coordinates mode */
  42334. static readonly TEXTURE_EXPLICIT_MODE: number;
  42335. /** Spherical coordinates mode */
  42336. static readonly TEXTURE_SPHERICAL_MODE: number;
  42337. /** Planar coordinates mode */
  42338. static readonly TEXTURE_PLANAR_MODE: number;
  42339. /** Cubic coordinates mode */
  42340. static readonly TEXTURE_CUBIC_MODE: number;
  42341. /** Projection coordinates mode */
  42342. static readonly TEXTURE_PROJECTION_MODE: number;
  42343. /** Skybox coordinates mode */
  42344. static readonly TEXTURE_SKYBOX_MODE: number;
  42345. /** Inverse Cubic coordinates mode */
  42346. static readonly TEXTURE_INVCUBIC_MODE: number;
  42347. /** Equirectangular coordinates mode */
  42348. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  42349. /** Equirectangular Fixed coordinates mode */
  42350. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  42351. /** Equirectangular Fixed Mirrored coordinates mode */
  42352. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  42353. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  42354. static readonly SCALEMODE_FLOOR: number;
  42355. /** Defines that texture rescaling will look for the nearest power of 2 size */
  42356. static readonly SCALEMODE_NEAREST: number;
  42357. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  42358. static readonly SCALEMODE_CEILING: number;
  42359. /**
  42360. * Returns the current npm package of the sdk
  42361. */
  42362. static get NpmPackage(): string;
  42363. /**
  42364. * Returns the current version of the framework
  42365. */
  42366. static get Version(): string;
  42367. /** Gets the list of created engines */
  42368. static get Instances(): Engine[];
  42369. /**
  42370. * Gets the latest created engine
  42371. */
  42372. static get LastCreatedEngine(): Nullable<Engine>;
  42373. /**
  42374. * Gets the latest created scene
  42375. */
  42376. static get LastCreatedScene(): Nullable<Scene>;
  42377. /**
  42378. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  42379. * @param flag defines which part of the materials must be marked as dirty
  42380. * @param predicate defines a predicate used to filter which materials should be affected
  42381. */
  42382. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42383. /**
  42384. * Method called to create the default loading screen.
  42385. * This can be overriden in your own app.
  42386. * @param canvas The rendering canvas element
  42387. * @returns The loading screen
  42388. */
  42389. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  42390. /**
  42391. * Method called to create the default rescale post process on each engine.
  42392. */
  42393. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  42394. /**
  42395. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  42396. **/
  42397. enableOfflineSupport: boolean;
  42398. /**
  42399. * 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)
  42400. **/
  42401. disableManifestCheck: boolean;
  42402. /**
  42403. * Gets the list of created scenes
  42404. */
  42405. scenes: Scene[];
  42406. /**
  42407. * Event raised when a new scene is created
  42408. */
  42409. onNewSceneAddedObservable: Observable<Scene>;
  42410. /**
  42411. * Gets the list of created postprocesses
  42412. */
  42413. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42414. /**
  42415. * Gets a boolean indicating if the pointer is currently locked
  42416. */
  42417. isPointerLock: boolean;
  42418. /**
  42419. * Observable event triggered each time the rendering canvas is resized
  42420. */
  42421. onResizeObservable: Observable<Engine>;
  42422. /**
  42423. * Observable event triggered each time the canvas loses focus
  42424. */
  42425. onCanvasBlurObservable: Observable<Engine>;
  42426. /**
  42427. * Observable event triggered each time the canvas gains focus
  42428. */
  42429. onCanvasFocusObservable: Observable<Engine>;
  42430. /**
  42431. * Observable event triggered each time the canvas receives pointerout event
  42432. */
  42433. onCanvasPointerOutObservable: Observable<PointerEvent>;
  42434. /**
  42435. * Observable raised when the engine begins a new frame
  42436. */
  42437. onBeginFrameObservable: Observable<Engine>;
  42438. /**
  42439. * If set, will be used to request the next animation frame for the render loop
  42440. */
  42441. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  42442. /**
  42443. * Observable raised when the engine ends the current frame
  42444. */
  42445. onEndFrameObservable: Observable<Engine>;
  42446. /**
  42447. * Observable raised when the engine is about to compile a shader
  42448. */
  42449. onBeforeShaderCompilationObservable: Observable<Engine>;
  42450. /**
  42451. * Observable raised when the engine has jsut compiled a shader
  42452. */
  42453. onAfterShaderCompilationObservable: Observable<Engine>;
  42454. /**
  42455. * Gets the audio engine
  42456. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42457. * @ignorenaming
  42458. */
  42459. static audioEngine: IAudioEngine;
  42460. /**
  42461. * Default AudioEngine factory responsible of creating the Audio Engine.
  42462. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  42463. */
  42464. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  42465. /**
  42466. * Default offline support factory responsible of creating a tool used to store data locally.
  42467. * By default, this will create a Database object if the workload has been embedded.
  42468. */
  42469. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  42470. private _loadingScreen;
  42471. private _pointerLockRequested;
  42472. private _rescalePostProcess;
  42473. private _deterministicLockstep;
  42474. private _lockstepMaxSteps;
  42475. private _timeStep;
  42476. protected get _supportsHardwareTextureRescaling(): boolean;
  42477. private _fps;
  42478. private _deltaTime;
  42479. /** @hidden */
  42480. _drawCalls: PerfCounter;
  42481. /** 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 */
  42482. canvasTabIndex: number;
  42483. /**
  42484. * Turn this value on if you want to pause FPS computation when in background
  42485. */
  42486. disablePerformanceMonitorInBackground: boolean;
  42487. private _performanceMonitor;
  42488. /**
  42489. * Gets the performance monitor attached to this engine
  42490. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  42491. */
  42492. get performanceMonitor(): PerformanceMonitor;
  42493. private _onFocus;
  42494. private _onBlur;
  42495. private _onCanvasPointerOut;
  42496. private _onCanvasBlur;
  42497. private _onCanvasFocus;
  42498. private _onFullscreenChange;
  42499. private _onPointerLockChange;
  42500. /**
  42501. * Gets the HTML element used to attach event listeners
  42502. * @returns a HTML element
  42503. */
  42504. getInputElement(): Nullable<HTMLElement>;
  42505. /**
  42506. * Creates a new engine
  42507. * @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
  42508. * @param antialias defines enable antialiasing (default: false)
  42509. * @param options defines further options to be sent to the getContext() function
  42510. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  42511. */
  42512. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  42513. /**
  42514. * Gets current aspect ratio
  42515. * @param viewportOwner defines the camera to use to get the aspect ratio
  42516. * @param useScreen defines if screen size must be used (or the current render target if any)
  42517. * @returns a number defining the aspect ratio
  42518. */
  42519. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  42520. /**
  42521. * Gets current screen aspect ratio
  42522. * @returns a number defining the aspect ratio
  42523. */
  42524. getScreenAspectRatio(): number;
  42525. /**
  42526. * Gets the client rect of the HTML canvas attached with the current webGL context
  42527. * @returns a client rectanglee
  42528. */
  42529. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  42530. /**
  42531. * Gets the client rect of the HTML element used for events
  42532. * @returns a client rectanglee
  42533. */
  42534. getInputElementClientRect(): Nullable<ClientRect>;
  42535. /**
  42536. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  42537. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42538. * @returns true if engine is in deterministic lock step mode
  42539. */
  42540. isDeterministicLockStep(): boolean;
  42541. /**
  42542. * Gets the max steps when engine is running in deterministic lock step
  42543. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42544. * @returns the max steps
  42545. */
  42546. getLockstepMaxSteps(): number;
  42547. /**
  42548. * Returns the time in ms between steps when using deterministic lock step.
  42549. * @returns time step in (ms)
  42550. */
  42551. getTimeStep(): number;
  42552. /**
  42553. * Force the mipmap generation for the given render target texture
  42554. * @param texture defines the render target texture to use
  42555. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  42556. */
  42557. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  42558. /** States */
  42559. /**
  42560. * Set various states to the webGL context
  42561. * @param culling defines backface culling state
  42562. * @param zOffset defines the value to apply to zOffset (0 by default)
  42563. * @param force defines if states must be applied even if cache is up to date
  42564. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  42565. */
  42566. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42567. /**
  42568. * Set the z offset to apply to current rendering
  42569. * @param value defines the offset to apply
  42570. */
  42571. setZOffset(value: number): void;
  42572. /**
  42573. * Gets the current value of the zOffset
  42574. * @returns the current zOffset state
  42575. */
  42576. getZOffset(): number;
  42577. /**
  42578. * Enable or disable depth buffering
  42579. * @param enable defines the state to set
  42580. */
  42581. setDepthBuffer(enable: boolean): void;
  42582. /**
  42583. * Gets a boolean indicating if depth writing is enabled
  42584. * @returns the current depth writing state
  42585. */
  42586. getDepthWrite(): boolean;
  42587. /**
  42588. * Enable or disable depth writing
  42589. * @param enable defines the state to set
  42590. */
  42591. setDepthWrite(enable: boolean): void;
  42592. /**
  42593. * Gets a boolean indicating if stencil buffer is enabled
  42594. * @returns the current stencil buffer state
  42595. */
  42596. getStencilBuffer(): boolean;
  42597. /**
  42598. * Enable or disable the stencil buffer
  42599. * @param enable defines if the stencil buffer must be enabled or disabled
  42600. */
  42601. setStencilBuffer(enable: boolean): void;
  42602. /**
  42603. * Gets the current stencil mask
  42604. * @returns a number defining the new stencil mask to use
  42605. */
  42606. getStencilMask(): number;
  42607. /**
  42608. * Sets the current stencil mask
  42609. * @param mask defines the new stencil mask to use
  42610. */
  42611. setStencilMask(mask: number): void;
  42612. /**
  42613. * Gets the current stencil function
  42614. * @returns a number defining the stencil function to use
  42615. */
  42616. getStencilFunction(): number;
  42617. /**
  42618. * Gets the current stencil reference value
  42619. * @returns a number defining the stencil reference value to use
  42620. */
  42621. getStencilFunctionReference(): number;
  42622. /**
  42623. * Gets the current stencil mask
  42624. * @returns a number defining the stencil mask to use
  42625. */
  42626. getStencilFunctionMask(): number;
  42627. /**
  42628. * Sets the current stencil function
  42629. * @param stencilFunc defines the new stencil function to use
  42630. */
  42631. setStencilFunction(stencilFunc: number): void;
  42632. /**
  42633. * Sets the current stencil reference
  42634. * @param reference defines the new stencil reference to use
  42635. */
  42636. setStencilFunctionReference(reference: number): void;
  42637. /**
  42638. * Sets the current stencil mask
  42639. * @param mask defines the new stencil mask to use
  42640. */
  42641. setStencilFunctionMask(mask: number): void;
  42642. /**
  42643. * Gets the current stencil operation when stencil fails
  42644. * @returns a number defining stencil operation to use when stencil fails
  42645. */
  42646. getStencilOperationFail(): number;
  42647. /**
  42648. * Gets the current stencil operation when depth fails
  42649. * @returns a number defining stencil operation to use when depth fails
  42650. */
  42651. getStencilOperationDepthFail(): number;
  42652. /**
  42653. * Gets the current stencil operation when stencil passes
  42654. * @returns a number defining stencil operation to use when stencil passes
  42655. */
  42656. getStencilOperationPass(): number;
  42657. /**
  42658. * Sets the stencil operation to use when stencil fails
  42659. * @param operation defines the stencil operation to use when stencil fails
  42660. */
  42661. setStencilOperationFail(operation: number): void;
  42662. /**
  42663. * Sets the stencil operation to use when depth fails
  42664. * @param operation defines the stencil operation to use when depth fails
  42665. */
  42666. setStencilOperationDepthFail(operation: number): void;
  42667. /**
  42668. * Sets the stencil operation to use when stencil passes
  42669. * @param operation defines the stencil operation to use when stencil passes
  42670. */
  42671. setStencilOperationPass(operation: number): void;
  42672. /**
  42673. * Sets a boolean indicating if the dithering state is enabled or disabled
  42674. * @param value defines the dithering state
  42675. */
  42676. setDitheringState(value: boolean): void;
  42677. /**
  42678. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  42679. * @param value defines the rasterizer state
  42680. */
  42681. setRasterizerState(value: boolean): void;
  42682. /**
  42683. * Gets the current depth function
  42684. * @returns a number defining the depth function
  42685. */
  42686. getDepthFunction(): Nullable<number>;
  42687. /**
  42688. * Sets the current depth function
  42689. * @param depthFunc defines the function to use
  42690. */
  42691. setDepthFunction(depthFunc: number): void;
  42692. /**
  42693. * Sets the current depth function to GREATER
  42694. */
  42695. setDepthFunctionToGreater(): void;
  42696. /**
  42697. * Sets the current depth function to GEQUAL
  42698. */
  42699. setDepthFunctionToGreaterOrEqual(): void;
  42700. /**
  42701. * Sets the current depth function to LESS
  42702. */
  42703. setDepthFunctionToLess(): void;
  42704. /**
  42705. * Sets the current depth function to LEQUAL
  42706. */
  42707. setDepthFunctionToLessOrEqual(): void;
  42708. private _cachedStencilBuffer;
  42709. private _cachedStencilFunction;
  42710. private _cachedStencilMask;
  42711. private _cachedStencilOperationPass;
  42712. private _cachedStencilOperationFail;
  42713. private _cachedStencilOperationDepthFail;
  42714. private _cachedStencilReference;
  42715. /**
  42716. * Caches the the state of the stencil buffer
  42717. */
  42718. cacheStencilState(): void;
  42719. /**
  42720. * Restores the state of the stencil buffer
  42721. */
  42722. restoreStencilState(): void;
  42723. /**
  42724. * Directly set the WebGL Viewport
  42725. * @param x defines the x coordinate of the viewport (in screen space)
  42726. * @param y defines the y coordinate of the viewport (in screen space)
  42727. * @param width defines the width of the viewport (in screen space)
  42728. * @param height defines the height of the viewport (in screen space)
  42729. * @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
  42730. */
  42731. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  42732. /**
  42733. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  42734. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42735. * @param y defines the y-coordinate of the corner of the clear rectangle
  42736. * @param width defines the width of the clear rectangle
  42737. * @param height defines the height of the clear rectangle
  42738. * @param clearColor defines the clear color
  42739. */
  42740. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  42741. /**
  42742. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  42743. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  42744. * @param y defines the y-coordinate of the corner of the clear rectangle
  42745. * @param width defines the width of the clear rectangle
  42746. * @param height defines the height of the clear rectangle
  42747. */
  42748. enableScissor(x: number, y: number, width: number, height: number): void;
  42749. /**
  42750. * Disable previously set scissor test rectangle
  42751. */
  42752. disableScissor(): void;
  42753. protected _reportDrawCall(): void;
  42754. /**
  42755. * Initializes a webVR display and starts listening to display change events
  42756. * The onVRDisplayChangedObservable will be notified upon these changes
  42757. * @returns The onVRDisplayChangedObservable
  42758. */
  42759. initWebVR(): Observable<IDisplayChangedEventArgs>;
  42760. /** @hidden */
  42761. _prepareVRComponent(): void;
  42762. /** @hidden */
  42763. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  42764. /** @hidden */
  42765. _submitVRFrame(): void;
  42766. /**
  42767. * Call this function to leave webVR mode
  42768. * Will do nothing if webVR is not supported or if there is no webVR device
  42769. * @see https://doc.babylonjs.com/how_to/webvr_camera
  42770. */
  42771. disableVR(): void;
  42772. /**
  42773. * Gets a boolean indicating that the system is in VR mode and is presenting
  42774. * @returns true if VR mode is engaged
  42775. */
  42776. isVRPresenting(): boolean;
  42777. /** @hidden */
  42778. _requestVRFrame(): void;
  42779. /** @hidden */
  42780. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42781. /**
  42782. * Gets the source code of the vertex shader associated with a specific webGL program
  42783. * @param program defines the program to use
  42784. * @returns a string containing the source code of the vertex shader associated with the program
  42785. */
  42786. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  42787. /**
  42788. * Gets the source code of the fragment shader associated with a specific webGL program
  42789. * @param program defines the program to use
  42790. * @returns a string containing the source code of the fragment shader associated with the program
  42791. */
  42792. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  42793. /**
  42794. * Sets a depth stencil texture from a render target to the according uniform.
  42795. * @param channel The texture channel
  42796. * @param uniform The uniform to set
  42797. * @param texture The render target texture containing the depth stencil texture to apply
  42798. */
  42799. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  42800. /**
  42801. * Sets a texture to the webGL context from a postprocess
  42802. * @param channel defines the channel to use
  42803. * @param postProcess defines the source postprocess
  42804. */
  42805. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  42806. /**
  42807. * Binds the output of the passed in post process to the texture channel specified
  42808. * @param channel The channel the texture should be bound to
  42809. * @param postProcess The post process which's output should be bound
  42810. */
  42811. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  42812. protected _rebuildBuffers(): void;
  42813. /** @hidden */
  42814. _renderFrame(): void;
  42815. _renderLoop(): void;
  42816. /** @hidden */
  42817. _renderViews(): boolean;
  42818. /**
  42819. * Toggle full screen mode
  42820. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42821. */
  42822. switchFullscreen(requestPointerLock: boolean): void;
  42823. /**
  42824. * Enters full screen mode
  42825. * @param requestPointerLock defines if a pointer lock should be requested from the user
  42826. */
  42827. enterFullscreen(requestPointerLock: boolean): void;
  42828. /**
  42829. * Exits full screen mode
  42830. */
  42831. exitFullscreen(): void;
  42832. /**
  42833. * Enters Pointerlock mode
  42834. */
  42835. enterPointerlock(): void;
  42836. /**
  42837. * Exits Pointerlock mode
  42838. */
  42839. exitPointerlock(): void;
  42840. /**
  42841. * Begin a new frame
  42842. */
  42843. beginFrame(): void;
  42844. /**
  42845. * Enf the current frame
  42846. */
  42847. endFrame(): void;
  42848. resize(): void;
  42849. /**
  42850. * Force a specific size of the canvas
  42851. * @param width defines the new canvas' width
  42852. * @param height defines the new canvas' height
  42853. * @returns true if the size was changed
  42854. */
  42855. setSize(width: number, height: number): boolean;
  42856. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  42857. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42858. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  42859. _releaseTexture(texture: InternalTexture): void;
  42860. /**
  42861. * @hidden
  42862. * Rescales a texture
  42863. * @param source input texutre
  42864. * @param destination destination texture
  42865. * @param scene scene to use to render the resize
  42866. * @param internalFormat format to use when resizing
  42867. * @param onComplete callback to be called when resize has completed
  42868. */
  42869. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  42870. /**
  42871. * Gets the current framerate
  42872. * @returns a number representing the framerate
  42873. */
  42874. getFps(): number;
  42875. /**
  42876. * Gets the time spent between current and previous frame
  42877. * @returns a number representing the delta time in ms
  42878. */
  42879. getDeltaTime(): number;
  42880. private _measureFps;
  42881. /** @hidden */
  42882. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  42883. /**
  42884. * Updates the sample count of a render target texture
  42885. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42886. * @param texture defines the texture to update
  42887. * @param samples defines the sample count to set
  42888. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42889. */
  42890. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  42891. /**
  42892. * Updates a depth texture Comparison Mode and Function.
  42893. * If the comparison Function is equal to 0, the mode will be set to none.
  42894. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  42895. * @param texture The texture to set the comparison function for
  42896. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  42897. */
  42898. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  42899. /**
  42900. * Creates a webGL buffer to use with instanciation
  42901. * @param capacity defines the size of the buffer
  42902. * @returns the webGL buffer
  42903. */
  42904. createInstancesBuffer(capacity: number): DataBuffer;
  42905. /**
  42906. * Delete a webGL buffer used with instanciation
  42907. * @param buffer defines the webGL buffer to delete
  42908. */
  42909. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  42910. private _clientWaitAsync;
  42911. /** @hidden */
  42912. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  42913. dispose(): void;
  42914. private _disableTouchAction;
  42915. /**
  42916. * Display the loading screen
  42917. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42918. */
  42919. displayLoadingUI(): void;
  42920. /**
  42921. * Hide the loading screen
  42922. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42923. */
  42924. hideLoadingUI(): void;
  42925. /**
  42926. * Gets the current loading screen object
  42927. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42928. */
  42929. get loadingScreen(): ILoadingScreen;
  42930. /**
  42931. * Sets the current loading screen object
  42932. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42933. */
  42934. set loadingScreen(loadingScreen: ILoadingScreen);
  42935. /**
  42936. * Sets the current loading screen text
  42937. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42938. */
  42939. set loadingUIText(text: string);
  42940. /**
  42941. * Sets the current loading screen background color
  42942. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  42943. */
  42944. set loadingUIBackgroundColor(color: string);
  42945. /** Pointerlock and fullscreen */
  42946. /**
  42947. * Ask the browser to promote the current element to pointerlock mode
  42948. * @param element defines the DOM element to promote
  42949. */
  42950. static _RequestPointerlock(element: HTMLElement): void;
  42951. /**
  42952. * Asks the browser to exit pointerlock mode
  42953. */
  42954. static _ExitPointerlock(): void;
  42955. /**
  42956. * Ask the browser to promote the current element to fullscreen rendering mode
  42957. * @param element defines the DOM element to promote
  42958. */
  42959. static _RequestFullscreen(element: HTMLElement): void;
  42960. /**
  42961. * Asks the browser to exit fullscreen mode
  42962. */
  42963. static _ExitFullscreen(): void;
  42964. }
  42965. }
  42966. declare module "babylonjs/Engines/engineStore" {
  42967. import { Nullable } from "babylonjs/types";
  42968. import { Engine } from "babylonjs/Engines/engine";
  42969. import { Scene } from "babylonjs/scene";
  42970. /**
  42971. * The engine store class is responsible to hold all the instances of Engine and Scene created
  42972. * during the life time of the application.
  42973. */
  42974. export class EngineStore {
  42975. /** Gets the list of created engines */
  42976. static Instances: import("babylonjs/Engines/engine").Engine[];
  42977. /** @hidden */
  42978. static _LastCreatedScene: Nullable<Scene>;
  42979. /**
  42980. * Gets the latest created engine
  42981. */
  42982. static get LastCreatedEngine(): Nullable<Engine>;
  42983. /**
  42984. * Gets the latest created scene
  42985. */
  42986. static get LastCreatedScene(): Nullable<Scene>;
  42987. /**
  42988. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  42989. * @ignorenaming
  42990. */
  42991. static UseFallbackTexture: boolean;
  42992. /**
  42993. * Texture content used if a texture cannot loaded
  42994. * @ignorenaming
  42995. */
  42996. static FallbackTexture: string;
  42997. }
  42998. }
  42999. declare module "babylonjs/Misc/promise" {
  43000. /**
  43001. * Helper class that provides a small promise polyfill
  43002. */
  43003. export class PromisePolyfill {
  43004. /**
  43005. * Static function used to check if the polyfill is required
  43006. * If this is the case then the function will inject the polyfill to window.Promise
  43007. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  43008. */
  43009. static Apply(force?: boolean): void;
  43010. }
  43011. }
  43012. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  43013. /**
  43014. * Interface for screenshot methods with describe argument called `size` as object with options
  43015. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  43016. */
  43017. export interface IScreenshotSize {
  43018. /**
  43019. * number in pixels for canvas height
  43020. */
  43021. height?: number;
  43022. /**
  43023. * multiplier allowing render at a higher or lower resolution
  43024. * If value is defined then height and width will be ignored and taken from camera
  43025. */
  43026. precision?: number;
  43027. /**
  43028. * number in pixels for canvas width
  43029. */
  43030. width?: number;
  43031. }
  43032. }
  43033. declare module "babylonjs/Misc/tools" {
  43034. import { Nullable, float } from "babylonjs/types";
  43035. import { DomManagement } from "babylonjs/Misc/domManagement";
  43036. import { WebRequest } from "babylonjs/Misc/webRequest";
  43037. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  43038. import { ReadFileError } from "babylonjs/Misc/fileTools";
  43039. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  43040. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  43041. import { Camera } from "babylonjs/Cameras/camera";
  43042. import { Engine } from "babylonjs/Engines/engine";
  43043. interface IColor4Like {
  43044. r: float;
  43045. g: float;
  43046. b: float;
  43047. a: float;
  43048. }
  43049. /**
  43050. * Class containing a set of static utilities functions
  43051. */
  43052. export class Tools {
  43053. /**
  43054. * Gets or sets the base URL to use to load assets
  43055. */
  43056. static get BaseUrl(): string;
  43057. static set BaseUrl(value: string);
  43058. /**
  43059. * Enable/Disable Custom HTTP Request Headers globally.
  43060. * default = false
  43061. * @see CustomRequestHeaders
  43062. */
  43063. static UseCustomRequestHeaders: boolean;
  43064. /**
  43065. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  43066. * i.e. when loading files, where the server/service expects an Authorization header
  43067. */
  43068. static CustomRequestHeaders: {
  43069. [key: string]: string;
  43070. };
  43071. /**
  43072. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  43073. */
  43074. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  43075. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  43076. /**
  43077. * Default behaviour for cors in the application.
  43078. * It can be a string if the expected behavior is identical in the entire app.
  43079. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  43080. */
  43081. static get CorsBehavior(): string | ((url: string | string[]) => string);
  43082. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  43083. /**
  43084. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  43085. * @ignorenaming
  43086. */
  43087. static get UseFallbackTexture(): boolean;
  43088. static set UseFallbackTexture(value: boolean);
  43089. /**
  43090. * Use this object to register external classes like custom textures or material
  43091. * to allow the laoders to instantiate them
  43092. */
  43093. static get RegisteredExternalClasses(): {
  43094. [key: string]: Object;
  43095. };
  43096. static set RegisteredExternalClasses(classes: {
  43097. [key: string]: Object;
  43098. });
  43099. /**
  43100. * Texture content used if a texture cannot loaded
  43101. * @ignorenaming
  43102. */
  43103. static get fallbackTexture(): string;
  43104. static set fallbackTexture(value: string);
  43105. /**
  43106. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  43107. * @param u defines the coordinate on X axis
  43108. * @param v defines the coordinate on Y axis
  43109. * @param width defines the width of the source data
  43110. * @param height defines the height of the source data
  43111. * @param pixels defines the source byte array
  43112. * @param color defines the output color
  43113. */
  43114. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  43115. /**
  43116. * Interpolates between a and b via alpha
  43117. * @param a The lower value (returned when alpha = 0)
  43118. * @param b The upper value (returned when alpha = 1)
  43119. * @param alpha The interpolation-factor
  43120. * @return The mixed value
  43121. */
  43122. static Mix(a: number, b: number, alpha: number): number;
  43123. /**
  43124. * Tries to instantiate a new object from a given class name
  43125. * @param className defines the class name to instantiate
  43126. * @returns the new object or null if the system was not able to do the instantiation
  43127. */
  43128. static Instantiate(className: string): any;
  43129. /**
  43130. * Provides a slice function that will work even on IE
  43131. * @param data defines the array to slice
  43132. * @param start defines the start of the data (optional)
  43133. * @param end defines the end of the data (optional)
  43134. * @returns the new sliced array
  43135. */
  43136. static Slice<T>(data: T, start?: number, end?: number): T;
  43137. /**
  43138. * Provides a slice function that will work even on IE
  43139. * The difference between this and Slice is that this will force-convert to array
  43140. * @param data defines the array to slice
  43141. * @param start defines the start of the data (optional)
  43142. * @param end defines the end of the data (optional)
  43143. * @returns the new sliced array
  43144. */
  43145. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  43146. /**
  43147. * Polyfill for setImmediate
  43148. * @param action defines the action to execute after the current execution block
  43149. */
  43150. static SetImmediate(action: () => void): void;
  43151. /**
  43152. * Function indicating if a number is an exponent of 2
  43153. * @param value defines the value to test
  43154. * @returns true if the value is an exponent of 2
  43155. */
  43156. static IsExponentOfTwo(value: number): boolean;
  43157. private static _tmpFloatArray;
  43158. /**
  43159. * Returns the nearest 32-bit single precision float representation of a Number
  43160. * @param value A Number. If the parameter is of a different type, it will get converted
  43161. * to a number or to NaN if it cannot be converted
  43162. * @returns number
  43163. */
  43164. static FloatRound(value: number): number;
  43165. /**
  43166. * Extracts the filename from a path
  43167. * @param path defines the path to use
  43168. * @returns the filename
  43169. */
  43170. static GetFilename(path: string): string;
  43171. /**
  43172. * Extracts the "folder" part of a path (everything before the filename).
  43173. * @param uri The URI to extract the info from
  43174. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  43175. * @returns The "folder" part of the path
  43176. */
  43177. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  43178. /**
  43179. * Extracts text content from a DOM element hierarchy
  43180. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  43181. */
  43182. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  43183. /**
  43184. * Convert an angle in radians to degrees
  43185. * @param angle defines the angle to convert
  43186. * @returns the angle in degrees
  43187. */
  43188. static ToDegrees(angle: number): number;
  43189. /**
  43190. * Convert an angle in degrees to radians
  43191. * @param angle defines the angle to convert
  43192. * @returns the angle in radians
  43193. */
  43194. static ToRadians(angle: number): number;
  43195. /**
  43196. * Returns an array if obj is not an array
  43197. * @param obj defines the object to evaluate as an array
  43198. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  43199. * @returns either obj directly if obj is an array or a new array containing obj
  43200. */
  43201. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  43202. /**
  43203. * Gets the pointer prefix to use
  43204. * @param engine defines the engine we are finding the prefix for
  43205. * @returns "pointer" if touch is enabled. Else returns "mouse"
  43206. */
  43207. static GetPointerPrefix(engine: Engine): string;
  43208. /**
  43209. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  43210. * @param url define the url we are trying
  43211. * @param element define the dom element where to configure the cors policy
  43212. */
  43213. static SetCorsBehavior(url: string | string[], element: {
  43214. crossOrigin: string | null;
  43215. }): void;
  43216. /**
  43217. * Removes unwanted characters from an url
  43218. * @param url defines the url to clean
  43219. * @returns the cleaned url
  43220. */
  43221. static CleanUrl(url: string): string;
  43222. /**
  43223. * Gets or sets a function used to pre-process url before using them to load assets
  43224. */
  43225. static get PreprocessUrl(): (url: string) => string;
  43226. static set PreprocessUrl(processor: (url: string) => string);
  43227. /**
  43228. * Loads an image as an HTMLImageElement.
  43229. * @param input url string, ArrayBuffer, or Blob to load
  43230. * @param onLoad callback called when the image successfully loads
  43231. * @param onError callback called when the image fails to load
  43232. * @param offlineProvider offline provider for caching
  43233. * @param mimeType optional mime type
  43234. * @returns the HTMLImageElement of the loaded image
  43235. */
  43236. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  43237. /**
  43238. * Loads a file from a url
  43239. * @param url url string, ArrayBuffer, or Blob to load
  43240. * @param onSuccess callback called when the file successfully loads
  43241. * @param onProgress callback called while file is loading (if the server supports this mode)
  43242. * @param offlineProvider defines the offline provider for caching
  43243. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43244. * @param onError callback called when the file fails to load
  43245. * @returns a file request object
  43246. */
  43247. 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;
  43248. /**
  43249. * Loads a file from a url
  43250. * @param url the file url to load
  43251. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  43252. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  43253. */
  43254. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  43255. /**
  43256. * Load a script (identified by an url). When the url returns, the
  43257. * content of this file is added into a new script element, attached to the DOM (body element)
  43258. * @param scriptUrl defines the url of the script to laod
  43259. * @param onSuccess defines the callback called when the script is loaded
  43260. * @param onError defines the callback to call if an error occurs
  43261. * @param scriptId defines the id of the script element
  43262. */
  43263. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  43264. /**
  43265. * Load an asynchronous script (identified by an url). When the url returns, the
  43266. * content of this file is added into a new script element, attached to the DOM (body element)
  43267. * @param scriptUrl defines the url of the script to laod
  43268. * @param scriptId defines the id of the script element
  43269. * @returns a promise request object
  43270. */
  43271. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  43272. /**
  43273. * Loads a file from a blob
  43274. * @param fileToLoad defines the blob to use
  43275. * @param callback defines the callback to call when data is loaded
  43276. * @param progressCallback defines the callback to call during loading process
  43277. * @returns a file request object
  43278. */
  43279. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  43280. /**
  43281. * Reads a file from a File object
  43282. * @param file defines the file to load
  43283. * @param onSuccess defines the callback to call when data is loaded
  43284. * @param onProgress defines the callback to call during loading process
  43285. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  43286. * @param onError defines the callback to call when an error occurs
  43287. * @returns a file request object
  43288. */
  43289. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  43290. /**
  43291. * Creates a data url from a given string content
  43292. * @param content defines the content to convert
  43293. * @returns the new data url link
  43294. */
  43295. static FileAsURL(content: string): string;
  43296. /**
  43297. * Format the given number to a specific decimal format
  43298. * @param value defines the number to format
  43299. * @param decimals defines the number of decimals to use
  43300. * @returns the formatted string
  43301. */
  43302. static Format(value: number, decimals?: number): string;
  43303. /**
  43304. * Tries to copy an object by duplicating every property
  43305. * @param source defines the source object
  43306. * @param destination defines the target object
  43307. * @param doNotCopyList defines a list of properties to avoid
  43308. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  43309. */
  43310. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  43311. /**
  43312. * Gets a boolean indicating if the given object has no own property
  43313. * @param obj defines the object to test
  43314. * @returns true if object has no own property
  43315. */
  43316. static IsEmpty(obj: any): boolean;
  43317. /**
  43318. * Function used to register events at window level
  43319. * @param windowElement defines the Window object to use
  43320. * @param events defines the events to register
  43321. */
  43322. static RegisterTopRootEvents(windowElement: Window, events: {
  43323. name: string;
  43324. handler: Nullable<(e: FocusEvent) => any>;
  43325. }[]): void;
  43326. /**
  43327. * Function used to unregister events from window level
  43328. * @param windowElement defines the Window object to use
  43329. * @param events defines the events to unregister
  43330. */
  43331. static UnregisterTopRootEvents(windowElement: Window, events: {
  43332. name: string;
  43333. handler: Nullable<(e: FocusEvent) => any>;
  43334. }[]): void;
  43335. /**
  43336. * @ignore
  43337. */
  43338. static _ScreenshotCanvas: HTMLCanvasElement;
  43339. /**
  43340. * Dumps the current bound framebuffer
  43341. * @param width defines the rendering width
  43342. * @param height defines the rendering height
  43343. * @param engine defines the hosting engine
  43344. * @param successCallback defines the callback triggered once the data are available
  43345. * @param mimeType defines the mime type of the result
  43346. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  43347. */
  43348. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43349. /**
  43350. * Converts the canvas data to blob.
  43351. * This acts as a polyfill for browsers not supporting the to blob function.
  43352. * @param canvas Defines the canvas to extract the data from
  43353. * @param successCallback Defines the callback triggered once the data are available
  43354. * @param mimeType Defines the mime type of the result
  43355. */
  43356. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  43357. /**
  43358. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  43359. * @param successCallback defines the callback triggered once the data are available
  43360. * @param mimeType defines the mime type of the result
  43361. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  43362. */
  43363. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  43364. /**
  43365. * Downloads a blob in the browser
  43366. * @param blob defines the blob to download
  43367. * @param fileName defines the name of the downloaded file
  43368. */
  43369. static Download(blob: Blob, fileName: string): void;
  43370. /**
  43371. * Captures a screenshot of the current rendering
  43372. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43373. * @param engine defines the rendering engine
  43374. * @param camera defines the source camera
  43375. * @param size This parameter can be set to a single number or to an object with the
  43376. * following (optional) properties: precision, width, height. If a single number is passed,
  43377. * it will be used for both width and height. If an object is passed, the screenshot size
  43378. * will be derived from the parameters. The precision property is a multiplier allowing
  43379. * rendering at a higher or lower resolution
  43380. * @param successCallback defines the callback receives a single parameter which contains the
  43381. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43382. * src parameter of an <img> to display it
  43383. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43384. * Check your browser for supported MIME types
  43385. */
  43386. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  43387. /**
  43388. * Captures a screenshot of the current rendering
  43389. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43390. * @param engine defines the rendering engine
  43391. * @param camera defines the source camera
  43392. * @param size This parameter can be set to a single number or to an object with the
  43393. * following (optional) properties: precision, width, height. If a single number is passed,
  43394. * it will be used for both width and height. If an object is passed, the screenshot size
  43395. * will be derived from the parameters. The precision property is a multiplier allowing
  43396. * rendering at a higher or lower resolution
  43397. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  43398. * Check your browser for supported MIME types
  43399. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43400. * to the src parameter of an <img> to display it
  43401. */
  43402. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  43403. /**
  43404. * Generates an image screenshot from the specified camera.
  43405. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43406. * @param engine The engine to use for rendering
  43407. * @param camera The camera to use for rendering
  43408. * @param size This parameter can be set to a single number or to an object with the
  43409. * following (optional) properties: precision, width, height. If a single number is passed,
  43410. * it will be used for both width and height. If an object is passed, the screenshot size
  43411. * will be derived from the parameters. The precision property is a multiplier allowing
  43412. * rendering at a higher or lower resolution
  43413. * @param successCallback The callback receives a single parameter which contains the
  43414. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  43415. * src parameter of an <img> to display it
  43416. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43417. * Check your browser for supported MIME types
  43418. * @param samples Texture samples (default: 1)
  43419. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43420. * @param fileName A name for for the downloaded file.
  43421. */
  43422. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  43423. /**
  43424. * Generates an image screenshot from the specified camera.
  43425. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  43426. * @param engine The engine to use for rendering
  43427. * @param camera The camera to use for rendering
  43428. * @param size This parameter can be set to a single number or to an object with the
  43429. * following (optional) properties: precision, width, height. If a single number is passed,
  43430. * it will be used for both width and height. If an object is passed, the screenshot size
  43431. * will be derived from the parameters. The precision property is a multiplier allowing
  43432. * rendering at a higher or lower resolution
  43433. * @param mimeType The MIME type of the screenshot image (default: image/png).
  43434. * Check your browser for supported MIME types
  43435. * @param samples Texture samples (default: 1)
  43436. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  43437. * @param fileName A name for for the downloaded file.
  43438. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  43439. * to the src parameter of an <img> to display it
  43440. */
  43441. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  43442. /**
  43443. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  43444. * Be aware Math.random() could cause collisions, but:
  43445. * "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"
  43446. * @returns a pseudo random id
  43447. */
  43448. static RandomId(): string;
  43449. /**
  43450. * Test if the given uri is a base64 string
  43451. * @param uri The uri to test
  43452. * @return True if the uri is a base64 string or false otherwise
  43453. */
  43454. static IsBase64(uri: string): boolean;
  43455. /**
  43456. * Decode the given base64 uri.
  43457. * @param uri The uri to decode
  43458. * @return The decoded base64 data.
  43459. */
  43460. static DecodeBase64(uri: string): ArrayBuffer;
  43461. /**
  43462. * Gets the absolute url.
  43463. * @param url the input url
  43464. * @return the absolute url
  43465. */
  43466. static GetAbsoluteUrl(url: string): string;
  43467. /**
  43468. * No log
  43469. */
  43470. static readonly NoneLogLevel: number;
  43471. /**
  43472. * Only message logs
  43473. */
  43474. static readonly MessageLogLevel: number;
  43475. /**
  43476. * Only warning logs
  43477. */
  43478. static readonly WarningLogLevel: number;
  43479. /**
  43480. * Only error logs
  43481. */
  43482. static readonly ErrorLogLevel: number;
  43483. /**
  43484. * All logs
  43485. */
  43486. static readonly AllLogLevel: number;
  43487. /**
  43488. * Gets a value indicating the number of loading errors
  43489. * @ignorenaming
  43490. */
  43491. static get errorsCount(): number;
  43492. /**
  43493. * Callback called when a new log is added
  43494. */
  43495. static OnNewCacheEntry: (entry: string) => void;
  43496. /**
  43497. * Log a message to the console
  43498. * @param message defines the message to log
  43499. */
  43500. static Log(message: string): void;
  43501. /**
  43502. * Write a warning message to the console
  43503. * @param message defines the message to log
  43504. */
  43505. static Warn(message: string): void;
  43506. /**
  43507. * Write an error message to the console
  43508. * @param message defines the message to log
  43509. */
  43510. static Error(message: string): void;
  43511. /**
  43512. * Gets current log cache (list of logs)
  43513. */
  43514. static get LogCache(): string;
  43515. /**
  43516. * Clears the log cache
  43517. */
  43518. static ClearLogCache(): void;
  43519. /**
  43520. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  43521. */
  43522. static set LogLevels(level: number);
  43523. /**
  43524. * Checks if the window object exists
  43525. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  43526. */
  43527. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  43528. /**
  43529. * No performance log
  43530. */
  43531. static readonly PerformanceNoneLogLevel: number;
  43532. /**
  43533. * Use user marks to log performance
  43534. */
  43535. static readonly PerformanceUserMarkLogLevel: number;
  43536. /**
  43537. * Log performance to the console
  43538. */
  43539. static readonly PerformanceConsoleLogLevel: number;
  43540. private static _performance;
  43541. /**
  43542. * Sets the current performance log level
  43543. */
  43544. static set PerformanceLogLevel(level: number);
  43545. private static _StartPerformanceCounterDisabled;
  43546. private static _EndPerformanceCounterDisabled;
  43547. private static _StartUserMark;
  43548. private static _EndUserMark;
  43549. private static _StartPerformanceConsole;
  43550. private static _EndPerformanceConsole;
  43551. /**
  43552. * Starts a performance counter
  43553. */
  43554. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43555. /**
  43556. * Ends a specific performance coutner
  43557. */
  43558. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  43559. /**
  43560. * Gets either window.performance.now() if supported or Date.now() else
  43561. */
  43562. static get Now(): number;
  43563. /**
  43564. * This method will return the name of the class used to create the instance of the given object.
  43565. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  43566. * @param object the object to get the class name from
  43567. * @param isType defines if the object is actually a type
  43568. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  43569. */
  43570. static GetClassName(object: any, isType?: boolean): string;
  43571. /**
  43572. * Gets the first element of an array satisfying a given predicate
  43573. * @param array defines the array to browse
  43574. * @param predicate defines the predicate to use
  43575. * @returns null if not found or the element
  43576. */
  43577. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  43578. /**
  43579. * This method will return the name of the full name of the class, including its owning module (if any).
  43580. * 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).
  43581. * @param object the object to get the class name from
  43582. * @param isType defines if the object is actually a type
  43583. * @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.
  43584. * @ignorenaming
  43585. */
  43586. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  43587. /**
  43588. * Returns a promise that resolves after the given amount of time.
  43589. * @param delay Number of milliseconds to delay
  43590. * @returns Promise that resolves after the given amount of time
  43591. */
  43592. static DelayAsync(delay: number): Promise<void>;
  43593. /**
  43594. * Utility function to detect if the current user agent is Safari
  43595. * @returns whether or not the current user agent is safari
  43596. */
  43597. static IsSafari(): boolean;
  43598. }
  43599. /**
  43600. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  43601. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  43602. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  43603. * @param name The name of the class, case should be preserved
  43604. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  43605. */
  43606. export function className(name: string, module?: string): (target: Object) => void;
  43607. /**
  43608. * An implementation of a loop for asynchronous functions.
  43609. */
  43610. export class AsyncLoop {
  43611. /**
  43612. * Defines the number of iterations for the loop
  43613. */
  43614. iterations: number;
  43615. /**
  43616. * Defines the current index of the loop.
  43617. */
  43618. index: number;
  43619. private _done;
  43620. private _fn;
  43621. private _successCallback;
  43622. /**
  43623. * Constructor.
  43624. * @param iterations the number of iterations.
  43625. * @param func the function to run each iteration
  43626. * @param successCallback the callback that will be called upon succesful execution
  43627. * @param offset starting offset.
  43628. */
  43629. constructor(
  43630. /**
  43631. * Defines the number of iterations for the loop
  43632. */
  43633. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  43634. /**
  43635. * Execute the next iteration. Must be called after the last iteration was finished.
  43636. */
  43637. executeNext(): void;
  43638. /**
  43639. * Break the loop and run the success callback.
  43640. */
  43641. breakLoop(): void;
  43642. /**
  43643. * Create and run an async loop.
  43644. * @param iterations the number of iterations.
  43645. * @param fn the function to run each iteration
  43646. * @param successCallback the callback that will be called upon succesful execution
  43647. * @param offset starting offset.
  43648. * @returns the created async loop object
  43649. */
  43650. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  43651. /**
  43652. * A for-loop that will run a given number of iterations synchronous and the rest async.
  43653. * @param iterations total number of iterations
  43654. * @param syncedIterations number of synchronous iterations in each async iteration.
  43655. * @param fn the function to call each iteration.
  43656. * @param callback a success call back that will be called when iterating stops.
  43657. * @param breakFunction a break condition (optional)
  43658. * @param timeout timeout settings for the setTimeout function. default - 0.
  43659. * @returns the created async loop object
  43660. */
  43661. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  43662. }
  43663. }
  43664. declare module "babylonjs/Misc/stringDictionary" {
  43665. import { Nullable } from "babylonjs/types";
  43666. /**
  43667. * This class implement a typical dictionary using a string as key and the generic type T as value.
  43668. * The underlying implementation relies on an associative array to ensure the best performances.
  43669. * The value can be anything including 'null' but except 'undefined'
  43670. */
  43671. export class StringDictionary<T> {
  43672. /**
  43673. * This will clear this dictionary and copy the content from the 'source' one.
  43674. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  43675. * @param source the dictionary to take the content from and copy to this dictionary
  43676. */
  43677. copyFrom(source: StringDictionary<T>): void;
  43678. /**
  43679. * Get a value based from its key
  43680. * @param key the given key to get the matching value from
  43681. * @return the value if found, otherwise undefined is returned
  43682. */
  43683. get(key: string): T | undefined;
  43684. /**
  43685. * Get a value from its key or add it if it doesn't exist.
  43686. * This method will ensure you that a given key/data will be present in the dictionary.
  43687. * @param key the given key to get the matching value from
  43688. * @param factory the factory that will create the value if the key is not present in the dictionary.
  43689. * The factory will only be invoked if there's no data for the given key.
  43690. * @return the value corresponding to the key.
  43691. */
  43692. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  43693. /**
  43694. * Get a value from its key if present in the dictionary otherwise add it
  43695. * @param key the key to get the value from
  43696. * @param val if there's no such key/value pair in the dictionary add it with this value
  43697. * @return the value corresponding to the key
  43698. */
  43699. getOrAdd(key: string, val: T): T;
  43700. /**
  43701. * Check if there's a given key in the dictionary
  43702. * @param key the key to check for
  43703. * @return true if the key is present, false otherwise
  43704. */
  43705. contains(key: string): boolean;
  43706. /**
  43707. * Add a new key and its corresponding value
  43708. * @param key the key to add
  43709. * @param value the value corresponding to the key
  43710. * @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
  43711. */
  43712. add(key: string, value: T): boolean;
  43713. /**
  43714. * Update a specific value associated to a key
  43715. * @param key defines the key to use
  43716. * @param value defines the value to store
  43717. * @returns true if the value was updated (or false if the key was not found)
  43718. */
  43719. set(key: string, value: T): boolean;
  43720. /**
  43721. * Get the element of the given key and remove it from the dictionary
  43722. * @param key defines the key to search
  43723. * @returns the value associated with the key or null if not found
  43724. */
  43725. getAndRemove(key: string): Nullable<T>;
  43726. /**
  43727. * Remove a key/value from the dictionary.
  43728. * @param key the key to remove
  43729. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  43730. */
  43731. remove(key: string): boolean;
  43732. /**
  43733. * Clear the whole content of the dictionary
  43734. */
  43735. clear(): void;
  43736. /**
  43737. * Gets the current count
  43738. */
  43739. get count(): number;
  43740. /**
  43741. * Execute a callback on each key/val of the dictionary.
  43742. * Note that you can remove any element in this dictionary in the callback implementation
  43743. * @param callback the callback to execute on a given key/value pair
  43744. */
  43745. forEach(callback: (key: string, val: T) => void): void;
  43746. /**
  43747. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  43748. * If the callback returns null or undefined the method will iterate to the next key/value pair
  43749. * Note that you can remove any element in this dictionary in the callback implementation
  43750. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  43751. * @returns the first item
  43752. */
  43753. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  43754. private _count;
  43755. private _data;
  43756. }
  43757. }
  43758. declare module "babylonjs/Collisions/collisionCoordinator" {
  43759. import { Nullable } from "babylonjs/types";
  43760. import { Scene } from "babylonjs/scene";
  43761. import { Vector3 } from "babylonjs/Maths/math.vector";
  43762. import { Collider } from "babylonjs/Collisions/collider";
  43763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43764. /** @hidden */
  43765. export interface ICollisionCoordinator {
  43766. createCollider(): Collider;
  43767. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43768. init(scene: Scene): void;
  43769. }
  43770. /** @hidden */
  43771. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  43772. private _scene;
  43773. private _scaledPosition;
  43774. private _scaledVelocity;
  43775. private _finalPosition;
  43776. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  43777. createCollider(): Collider;
  43778. init(scene: Scene): void;
  43779. private _collideWithWorld;
  43780. }
  43781. }
  43782. declare module "babylonjs/Inputs/scene.inputManager" {
  43783. import { Nullable } from "babylonjs/types";
  43784. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  43785. import { Vector2 } from "babylonjs/Maths/math.vector";
  43786. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43787. import { Scene } from "babylonjs/scene";
  43788. /**
  43789. * Class used to manage all inputs for the scene.
  43790. */
  43791. export class InputManager {
  43792. /** The distance in pixel that you have to move to prevent some events */
  43793. static DragMovementThreshold: number;
  43794. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  43795. static LongPressDelay: number;
  43796. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  43797. static DoubleClickDelay: number;
  43798. /** If you need to check double click without raising a single click at first click, enable this flag */
  43799. static ExclusiveDoubleClickMode: boolean;
  43800. /** 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. */
  43801. private _alreadyAttached;
  43802. private _alreadyAttachedTo;
  43803. private _wheelEventName;
  43804. private _onPointerMove;
  43805. private _onPointerDown;
  43806. private _onPointerUp;
  43807. private _initClickEvent;
  43808. private _initActionManager;
  43809. private _delayedSimpleClick;
  43810. private _delayedSimpleClickTimeout;
  43811. private _previousDelayedSimpleClickTimeout;
  43812. private _meshPickProceed;
  43813. private _previousButtonPressed;
  43814. private _currentPickResult;
  43815. private _previousPickResult;
  43816. private _totalPointersPressed;
  43817. private _doubleClickOccured;
  43818. private _pointerOverMesh;
  43819. private _pickedDownMesh;
  43820. private _pickedUpMesh;
  43821. private _pointerX;
  43822. private _pointerY;
  43823. private _unTranslatedPointerX;
  43824. private _unTranslatedPointerY;
  43825. private _startingPointerPosition;
  43826. private _previousStartingPointerPosition;
  43827. private _startingPointerTime;
  43828. private _previousStartingPointerTime;
  43829. private _pointerCaptures;
  43830. private _meshUnderPointerId;
  43831. private _onKeyDown;
  43832. private _onKeyUp;
  43833. private _keyboardIsAttached;
  43834. private _onCanvasFocusObserver;
  43835. private _onCanvasBlurObserver;
  43836. private _scene;
  43837. /**
  43838. * Creates a new InputManager
  43839. * @param scene defines the hosting scene
  43840. */
  43841. constructor(scene: Scene);
  43842. /**
  43843. * Gets the mesh that is currently under the pointer
  43844. */
  43845. get meshUnderPointer(): Nullable<AbstractMesh>;
  43846. /**
  43847. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  43848. * @param pointerId the pointer id to use
  43849. * @returns The mesh under this pointer id or null if not found
  43850. */
  43851. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  43852. /**
  43853. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  43854. */
  43855. get unTranslatedPointer(): Vector2;
  43856. /**
  43857. * Gets or sets the current on-screen X position of the pointer
  43858. */
  43859. get pointerX(): number;
  43860. set pointerX(value: number);
  43861. /**
  43862. * Gets or sets the current on-screen Y position of the pointer
  43863. */
  43864. get pointerY(): number;
  43865. set pointerY(value: number);
  43866. private _updatePointerPosition;
  43867. private _processPointerMove;
  43868. private _setRayOnPointerInfo;
  43869. private _checkPrePointerObservable;
  43870. /**
  43871. * Use this method to simulate a pointer move on a mesh
  43872. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43873. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43874. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43875. */
  43876. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43877. /**
  43878. * Use this method to simulate a pointer down on a mesh
  43879. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43880. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43881. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43882. */
  43883. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  43884. private _processPointerDown;
  43885. /** @hidden */
  43886. _isPointerSwiping(): boolean;
  43887. /**
  43888. * Use this method to simulate a pointer up on a mesh
  43889. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43890. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43891. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43892. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43893. */
  43894. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  43895. private _processPointerUp;
  43896. /**
  43897. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43898. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43899. * @returns true if the pointer was captured
  43900. */
  43901. isPointerCaptured(pointerId?: number): boolean;
  43902. /**
  43903. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43904. * @param attachUp defines if you want to attach events to pointerup
  43905. * @param attachDown defines if you want to attach events to pointerdown
  43906. * @param attachMove defines if you want to attach events to pointermove
  43907. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  43908. */
  43909. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  43910. /**
  43911. * Detaches all event handlers
  43912. */
  43913. detachControl(): void;
  43914. /**
  43915. * Force the value of meshUnderPointer
  43916. * @param mesh defines the mesh to use
  43917. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  43918. */
  43919. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  43920. /**
  43921. * Gets the mesh under the pointer
  43922. * @returns a Mesh or null if no mesh is under the pointer
  43923. */
  43924. getPointerOverMesh(): Nullable<AbstractMesh>;
  43925. }
  43926. }
  43927. declare module "babylonjs/Animations/animationGroup" {
  43928. import { Animatable } from "babylonjs/Animations/animatable";
  43929. import { Animation } from "babylonjs/Animations/animation";
  43930. import { Scene, IDisposable } from "babylonjs/scene";
  43931. import { Observable } from "babylonjs/Misc/observable";
  43932. import { Nullable } from "babylonjs/types";
  43933. import "babylonjs/Animations/animatable";
  43934. /**
  43935. * This class defines the direct association between an animation and a target
  43936. */
  43937. export class TargetedAnimation {
  43938. /**
  43939. * Animation to perform
  43940. */
  43941. animation: Animation;
  43942. /**
  43943. * Target to animate
  43944. */
  43945. target: any;
  43946. /**
  43947. * Returns the string "TargetedAnimation"
  43948. * @returns "TargetedAnimation"
  43949. */
  43950. getClassName(): string;
  43951. /**
  43952. * Serialize the object
  43953. * @returns the JSON object representing the current entity
  43954. */
  43955. serialize(): any;
  43956. }
  43957. /**
  43958. * Use this class to create coordinated animations on multiple targets
  43959. */
  43960. export class AnimationGroup implements IDisposable {
  43961. /** The name of the animation group */
  43962. name: string;
  43963. private _scene;
  43964. private _targetedAnimations;
  43965. private _animatables;
  43966. private _from;
  43967. private _to;
  43968. private _isStarted;
  43969. private _isPaused;
  43970. private _speedRatio;
  43971. private _loopAnimation;
  43972. private _isAdditive;
  43973. /**
  43974. * Gets or sets the unique id of the node
  43975. */
  43976. uniqueId: number;
  43977. /**
  43978. * This observable will notify when one animation have ended
  43979. */
  43980. onAnimationEndObservable: Observable<TargetedAnimation>;
  43981. /**
  43982. * Observer raised when one animation loops
  43983. */
  43984. onAnimationLoopObservable: Observable<TargetedAnimation>;
  43985. /**
  43986. * Observer raised when all animations have looped
  43987. */
  43988. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  43989. /**
  43990. * This observable will notify when all animations have ended.
  43991. */
  43992. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  43993. /**
  43994. * This observable will notify when all animations have paused.
  43995. */
  43996. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  43997. /**
  43998. * This observable will notify when all animations are playing.
  43999. */
  44000. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  44001. /**
  44002. * Gets the first frame
  44003. */
  44004. get from(): number;
  44005. /**
  44006. * Gets the last frame
  44007. */
  44008. get to(): number;
  44009. /**
  44010. * Define if the animations are started
  44011. */
  44012. get isStarted(): boolean;
  44013. /**
  44014. * Gets a value indicating that the current group is playing
  44015. */
  44016. get isPlaying(): boolean;
  44017. /**
  44018. * Gets or sets the speed ratio to use for all animations
  44019. */
  44020. get speedRatio(): number;
  44021. /**
  44022. * Gets or sets the speed ratio to use for all animations
  44023. */
  44024. set speedRatio(value: number);
  44025. /**
  44026. * Gets or sets if all animations should loop or not
  44027. */
  44028. get loopAnimation(): boolean;
  44029. set loopAnimation(value: boolean);
  44030. /**
  44031. * Gets or sets if all animations should be evaluated additively
  44032. */
  44033. get isAdditive(): boolean;
  44034. set isAdditive(value: boolean);
  44035. /**
  44036. * Gets the targeted animations for this animation group
  44037. */
  44038. get targetedAnimations(): Array<TargetedAnimation>;
  44039. /**
  44040. * returning the list of animatables controlled by this animation group.
  44041. */
  44042. get animatables(): Array<Animatable>;
  44043. /**
  44044. * Gets the list of target animations
  44045. */
  44046. get children(): TargetedAnimation[];
  44047. /**
  44048. * Instantiates a new Animation Group.
  44049. * This helps managing several animations at once.
  44050. * @see https://doc.babylonjs.com/how_to/group
  44051. * @param name Defines the name of the group
  44052. * @param scene Defines the scene the group belongs to
  44053. */
  44054. constructor(
  44055. /** The name of the animation group */
  44056. name: string, scene?: Nullable<Scene>);
  44057. /**
  44058. * Add an animation (with its target) in the group
  44059. * @param animation defines the animation we want to add
  44060. * @param target defines the target of the animation
  44061. * @returns the TargetedAnimation object
  44062. */
  44063. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  44064. /**
  44065. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  44066. * It can add constant keys at begin or end
  44067. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  44068. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  44069. * @returns the animation group
  44070. */
  44071. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  44072. private _animationLoopCount;
  44073. private _animationLoopFlags;
  44074. private _processLoop;
  44075. /**
  44076. * Start all animations on given targets
  44077. * @param loop defines if animations must loop
  44078. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  44079. * @param from defines the from key (optional)
  44080. * @param to defines the to key (optional)
  44081. * @param isAdditive defines the additive state for the resulting animatables (optional)
  44082. * @returns the current animation group
  44083. */
  44084. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  44085. /**
  44086. * Pause all animations
  44087. * @returns the animation group
  44088. */
  44089. pause(): AnimationGroup;
  44090. /**
  44091. * Play all animations to initial state
  44092. * This function will start() the animations if they were not started or will restart() them if they were paused
  44093. * @param loop defines if animations must loop
  44094. * @returns the animation group
  44095. */
  44096. play(loop?: boolean): AnimationGroup;
  44097. /**
  44098. * Reset all animations to initial state
  44099. * @returns the animation group
  44100. */
  44101. reset(): AnimationGroup;
  44102. /**
  44103. * Restart animations from key 0
  44104. * @returns the animation group
  44105. */
  44106. restart(): AnimationGroup;
  44107. /**
  44108. * Stop all animations
  44109. * @returns the animation group
  44110. */
  44111. stop(): AnimationGroup;
  44112. /**
  44113. * Set animation weight for all animatables
  44114. * @param weight defines the weight to use
  44115. * @return the animationGroup
  44116. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44117. */
  44118. setWeightForAllAnimatables(weight: number): AnimationGroup;
  44119. /**
  44120. * Synchronize and normalize all animatables with a source animatable
  44121. * @param root defines the root animatable to synchronize with
  44122. * @return the animationGroup
  44123. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  44124. */
  44125. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  44126. /**
  44127. * Goes to a specific frame in this animation group
  44128. * @param frame the frame number to go to
  44129. * @return the animationGroup
  44130. */
  44131. goToFrame(frame: number): AnimationGroup;
  44132. /**
  44133. * Dispose all associated resources
  44134. */
  44135. dispose(): void;
  44136. private _checkAnimationGroupEnded;
  44137. /**
  44138. * Clone the current animation group and returns a copy
  44139. * @param newName defines the name of the new group
  44140. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  44141. * @returns the new aniamtion group
  44142. */
  44143. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  44144. /**
  44145. * Serializes the animationGroup to an object
  44146. * @returns Serialized object
  44147. */
  44148. serialize(): any;
  44149. /**
  44150. * Returns a new AnimationGroup object parsed from the source provided.
  44151. * @param parsedAnimationGroup defines the source
  44152. * @param scene defines the scene that will receive the animationGroup
  44153. * @returns a new AnimationGroup
  44154. */
  44155. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  44156. /**
  44157. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  44158. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  44159. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  44160. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  44161. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  44162. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  44163. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  44164. */
  44165. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  44166. /**
  44167. * Returns the string "AnimationGroup"
  44168. * @returns "AnimationGroup"
  44169. */
  44170. getClassName(): string;
  44171. /**
  44172. * Creates a detailled string about the object
  44173. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  44174. * @returns a string representing the object
  44175. */
  44176. toString(fullDetails?: boolean): string;
  44177. }
  44178. }
  44179. declare module "babylonjs/scene" {
  44180. import { Nullable } from "babylonjs/types";
  44181. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  44182. import { Observable } from "babylonjs/Misc/observable";
  44183. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44184. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  44185. import { Geometry } from "babylonjs/Meshes/geometry";
  44186. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44187. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44189. import { Mesh } from "babylonjs/Meshes/mesh";
  44190. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44191. import { Bone } from "babylonjs/Bones/bone";
  44192. import { Skeleton } from "babylonjs/Bones/skeleton";
  44193. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  44194. import { Camera } from "babylonjs/Cameras/camera";
  44195. import { AbstractScene } from "babylonjs/abstractScene";
  44196. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44197. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44198. import { Material } from "babylonjs/Materials/material";
  44199. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44200. import { Effect } from "babylonjs/Materials/effect";
  44201. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  44202. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  44203. import { Light } from "babylonjs/Lights/light";
  44204. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  44205. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  44206. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  44207. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  44208. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  44209. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  44210. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  44211. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, PreActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  44212. import { Engine } from "babylonjs/Engines/engine";
  44213. import { Node } from "babylonjs/node";
  44214. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  44215. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  44216. import { WebRequest } from "babylonjs/Misc/webRequest";
  44217. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  44218. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  44219. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44220. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  44221. import { Plane } from "babylonjs/Maths/math.plane";
  44222. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  44223. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  44224. import { Ray } from "babylonjs/Culling/ray";
  44225. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  44226. import { Animation } from "babylonjs/Animations/animation";
  44227. import { Animatable } from "babylonjs/Animations/animatable";
  44228. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44229. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  44230. import { Collider } from "babylonjs/Collisions/collider";
  44231. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  44232. /**
  44233. * Define an interface for all classes that will hold resources
  44234. */
  44235. export interface IDisposable {
  44236. /**
  44237. * Releases all held resources
  44238. */
  44239. dispose(): void;
  44240. }
  44241. /** Interface defining initialization parameters for Scene class */
  44242. export interface SceneOptions {
  44243. /**
  44244. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  44245. * It will improve performance when the number of geometries becomes important.
  44246. */
  44247. useGeometryUniqueIdsMap?: boolean;
  44248. /**
  44249. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  44250. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44251. */
  44252. useMaterialMeshMap?: boolean;
  44253. /**
  44254. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  44255. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  44256. */
  44257. useClonedMeshMap?: boolean;
  44258. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  44259. virtual?: boolean;
  44260. }
  44261. /**
  44262. * Represents a scene to be rendered by the engine.
  44263. * @see https://doc.babylonjs.com/features/scene
  44264. */
  44265. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  44266. /** The fog is deactivated */
  44267. static readonly FOGMODE_NONE: number;
  44268. /** The fog density is following an exponential function */
  44269. static readonly FOGMODE_EXP: number;
  44270. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  44271. static readonly FOGMODE_EXP2: number;
  44272. /** The fog density is following a linear function. */
  44273. static readonly FOGMODE_LINEAR: number;
  44274. /**
  44275. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  44276. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44277. */
  44278. static MinDeltaTime: number;
  44279. /**
  44280. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  44281. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44282. */
  44283. static MaxDeltaTime: number;
  44284. /**
  44285. * Factory used to create the default material.
  44286. * @param name The name of the material to create
  44287. * @param scene The scene to create the material for
  44288. * @returns The default material
  44289. */
  44290. static DefaultMaterialFactory(scene: Scene): Material;
  44291. /**
  44292. * Factory used to create the a collision coordinator.
  44293. * @returns The collision coordinator
  44294. */
  44295. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  44296. /** @hidden */
  44297. _inputManager: InputManager;
  44298. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  44299. cameraToUseForPointers: Nullable<Camera>;
  44300. /** @hidden */
  44301. readonly _isScene: boolean;
  44302. /** @hidden */
  44303. _blockEntityCollection: boolean;
  44304. /**
  44305. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  44306. */
  44307. autoClear: boolean;
  44308. /**
  44309. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  44310. */
  44311. autoClearDepthAndStencil: boolean;
  44312. /**
  44313. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  44314. */
  44315. clearColor: Color4;
  44316. /**
  44317. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  44318. */
  44319. ambientColor: Color3;
  44320. /**
  44321. * This is use to store the default BRDF lookup for PBR materials in your scene.
  44322. * It should only be one of the following (if not the default embedded one):
  44323. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  44324. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  44325. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  44326. * The material properties need to be setup according to the type of texture in use.
  44327. */
  44328. environmentBRDFTexture: BaseTexture;
  44329. /**
  44330. * Texture used in all pbr material as the reflection texture.
  44331. * As in the majority of the scene they are the same (exception for multi room and so on),
  44332. * this is easier to reference from here than from all the materials.
  44333. */
  44334. get environmentTexture(): Nullable<BaseTexture>;
  44335. /**
  44336. * Texture used in all pbr material as the reflection texture.
  44337. * As in the majority of the scene they are the same (exception for multi room and so on),
  44338. * this is easier to set here than in all the materials.
  44339. */
  44340. set environmentTexture(value: Nullable<BaseTexture>);
  44341. /** @hidden */
  44342. protected _environmentIntensity: number;
  44343. /**
  44344. * Intensity of the environment in all pbr material.
  44345. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44346. * As in the majority of the scene they are the same (exception for multi room and so on),
  44347. * this is easier to reference from here than from all the materials.
  44348. */
  44349. get environmentIntensity(): number;
  44350. /**
  44351. * Intensity of the environment in all pbr material.
  44352. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  44353. * As in the majority of the scene they are the same (exception for multi room and so on),
  44354. * this is easier to set here than in all the materials.
  44355. */
  44356. set environmentIntensity(value: number);
  44357. /** @hidden */
  44358. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44359. /**
  44360. * Default image processing configuration used either in the rendering
  44361. * Forward main pass or through the imageProcessingPostProcess if present.
  44362. * As in the majority of the scene they are the same (exception for multi camera),
  44363. * this is easier to reference from here than from all the materials and post process.
  44364. *
  44365. * No setter as we it is a shared configuration, you can set the values instead.
  44366. */
  44367. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44368. private _forceWireframe;
  44369. /**
  44370. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  44371. */
  44372. set forceWireframe(value: boolean);
  44373. get forceWireframe(): boolean;
  44374. private _skipFrustumClipping;
  44375. /**
  44376. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  44377. */
  44378. set skipFrustumClipping(value: boolean);
  44379. get skipFrustumClipping(): boolean;
  44380. private _forcePointsCloud;
  44381. /**
  44382. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  44383. */
  44384. set forcePointsCloud(value: boolean);
  44385. get forcePointsCloud(): boolean;
  44386. /**
  44387. * Gets or sets the active clipplane 1
  44388. */
  44389. clipPlane: Nullable<Plane>;
  44390. /**
  44391. * Gets or sets the active clipplane 2
  44392. */
  44393. clipPlane2: Nullable<Plane>;
  44394. /**
  44395. * Gets or sets the active clipplane 3
  44396. */
  44397. clipPlane3: Nullable<Plane>;
  44398. /**
  44399. * Gets or sets the active clipplane 4
  44400. */
  44401. clipPlane4: Nullable<Plane>;
  44402. /**
  44403. * Gets or sets the active clipplane 5
  44404. */
  44405. clipPlane5: Nullable<Plane>;
  44406. /**
  44407. * Gets or sets the active clipplane 6
  44408. */
  44409. clipPlane6: Nullable<Plane>;
  44410. /**
  44411. * Gets or sets a boolean indicating if animations are enabled
  44412. */
  44413. animationsEnabled: boolean;
  44414. private _animationPropertiesOverride;
  44415. /**
  44416. * Gets or sets the animation properties override
  44417. */
  44418. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  44419. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  44420. /**
  44421. * Gets or sets a boolean indicating if a constant deltatime has to be used
  44422. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  44423. */
  44424. useConstantAnimationDeltaTime: boolean;
  44425. /**
  44426. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  44427. * Please note that it requires to run a ray cast through the scene on every frame
  44428. */
  44429. constantlyUpdateMeshUnderPointer: boolean;
  44430. /**
  44431. * Defines the HTML cursor to use when hovering over interactive elements
  44432. */
  44433. hoverCursor: string;
  44434. /**
  44435. * Defines the HTML default cursor to use (empty by default)
  44436. */
  44437. defaultCursor: string;
  44438. /**
  44439. * Defines whether cursors are handled by the scene.
  44440. */
  44441. doNotHandleCursors: boolean;
  44442. /**
  44443. * This is used to call preventDefault() on pointer down
  44444. * in order to block unwanted artifacts like system double clicks
  44445. */
  44446. preventDefaultOnPointerDown: boolean;
  44447. /**
  44448. * This is used to call preventDefault() on pointer up
  44449. * in order to block unwanted artifacts like system double clicks
  44450. */
  44451. preventDefaultOnPointerUp: boolean;
  44452. /**
  44453. * Gets or sets user defined metadata
  44454. */
  44455. metadata: any;
  44456. /**
  44457. * For internal use only. Please do not use.
  44458. */
  44459. reservedDataStore: any;
  44460. /**
  44461. * Gets the name of the plugin used to load this scene (null by default)
  44462. */
  44463. loadingPluginName: string;
  44464. /**
  44465. * Use this array to add regular expressions used to disable offline support for specific urls
  44466. */
  44467. disableOfflineSupportExceptionRules: RegExp[];
  44468. /**
  44469. * An event triggered when the scene is disposed.
  44470. */
  44471. onDisposeObservable: Observable<Scene>;
  44472. private _onDisposeObserver;
  44473. /** Sets a function to be executed when this scene is disposed. */
  44474. set onDispose(callback: () => void);
  44475. /**
  44476. * An event triggered before rendering the scene (right after animations and physics)
  44477. */
  44478. onBeforeRenderObservable: Observable<Scene>;
  44479. private _onBeforeRenderObserver;
  44480. /** Sets a function to be executed before rendering this scene */
  44481. set beforeRender(callback: Nullable<() => void>);
  44482. /**
  44483. * An event triggered after rendering the scene
  44484. */
  44485. onAfterRenderObservable: Observable<Scene>;
  44486. /**
  44487. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  44488. */
  44489. onAfterRenderCameraObservable: Observable<Camera>;
  44490. private _onAfterRenderObserver;
  44491. /** Sets a function to be executed after rendering this scene */
  44492. set afterRender(callback: Nullable<() => void>);
  44493. /**
  44494. * An event triggered before animating the scene
  44495. */
  44496. onBeforeAnimationsObservable: Observable<Scene>;
  44497. /**
  44498. * An event triggered after animations processing
  44499. */
  44500. onAfterAnimationsObservable: Observable<Scene>;
  44501. /**
  44502. * An event triggered before draw calls are ready to be sent
  44503. */
  44504. onBeforeDrawPhaseObservable: Observable<Scene>;
  44505. /**
  44506. * An event triggered after draw calls have been sent
  44507. */
  44508. onAfterDrawPhaseObservable: Observable<Scene>;
  44509. /**
  44510. * An event triggered when the scene is ready
  44511. */
  44512. onReadyObservable: Observable<Scene>;
  44513. /**
  44514. * An event triggered before rendering a camera
  44515. */
  44516. onBeforeCameraRenderObservable: Observable<Camera>;
  44517. private _onBeforeCameraRenderObserver;
  44518. /** Sets a function to be executed before rendering a camera*/
  44519. set beforeCameraRender(callback: () => void);
  44520. /**
  44521. * An event triggered after rendering a camera
  44522. */
  44523. onAfterCameraRenderObservable: Observable<Camera>;
  44524. private _onAfterCameraRenderObserver;
  44525. /** Sets a function to be executed after rendering a camera*/
  44526. set afterCameraRender(callback: () => void);
  44527. /**
  44528. * An event triggered when active meshes evaluation is about to start
  44529. */
  44530. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  44531. /**
  44532. * An event triggered when active meshes evaluation is done
  44533. */
  44534. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  44535. /**
  44536. * An event triggered when particles rendering is about to start
  44537. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44538. */
  44539. onBeforeParticlesRenderingObservable: Observable<Scene>;
  44540. /**
  44541. * An event triggered when particles rendering is done
  44542. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  44543. */
  44544. onAfterParticlesRenderingObservable: Observable<Scene>;
  44545. /**
  44546. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  44547. */
  44548. onDataLoadedObservable: Observable<Scene>;
  44549. /**
  44550. * An event triggered when a camera is created
  44551. */
  44552. onNewCameraAddedObservable: Observable<Camera>;
  44553. /**
  44554. * An event triggered when a camera is removed
  44555. */
  44556. onCameraRemovedObservable: Observable<Camera>;
  44557. /**
  44558. * An event triggered when a light is created
  44559. */
  44560. onNewLightAddedObservable: Observable<Light>;
  44561. /**
  44562. * An event triggered when a light is removed
  44563. */
  44564. onLightRemovedObservable: Observable<Light>;
  44565. /**
  44566. * An event triggered when a geometry is created
  44567. */
  44568. onNewGeometryAddedObservable: Observable<Geometry>;
  44569. /**
  44570. * An event triggered when a geometry is removed
  44571. */
  44572. onGeometryRemovedObservable: Observable<Geometry>;
  44573. /**
  44574. * An event triggered when a transform node is created
  44575. */
  44576. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  44577. /**
  44578. * An event triggered when a transform node is removed
  44579. */
  44580. onTransformNodeRemovedObservable: Observable<TransformNode>;
  44581. /**
  44582. * An event triggered when a mesh is created
  44583. */
  44584. onNewMeshAddedObservable: Observable<AbstractMesh>;
  44585. /**
  44586. * An event triggered when a mesh is removed
  44587. */
  44588. onMeshRemovedObservable: Observable<AbstractMesh>;
  44589. /**
  44590. * An event triggered when a skeleton is created
  44591. */
  44592. onNewSkeletonAddedObservable: Observable<Skeleton>;
  44593. /**
  44594. * An event triggered when a skeleton is removed
  44595. */
  44596. onSkeletonRemovedObservable: Observable<Skeleton>;
  44597. /**
  44598. * An event triggered when a material is created
  44599. */
  44600. onNewMaterialAddedObservable: Observable<Material>;
  44601. /**
  44602. * An event triggered when a material is removed
  44603. */
  44604. onMaterialRemovedObservable: Observable<Material>;
  44605. /**
  44606. * An event triggered when a texture is created
  44607. */
  44608. onNewTextureAddedObservable: Observable<BaseTexture>;
  44609. /**
  44610. * An event triggered when a texture is removed
  44611. */
  44612. onTextureRemovedObservable: Observable<BaseTexture>;
  44613. /**
  44614. * An event triggered when render targets are about to be rendered
  44615. * Can happen multiple times per frame.
  44616. */
  44617. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  44618. /**
  44619. * An event triggered when render targets were rendered.
  44620. * Can happen multiple times per frame.
  44621. */
  44622. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  44623. /**
  44624. * An event triggered before calculating deterministic simulation step
  44625. */
  44626. onBeforeStepObservable: Observable<Scene>;
  44627. /**
  44628. * An event triggered after calculating deterministic simulation step
  44629. */
  44630. onAfterStepObservable: Observable<Scene>;
  44631. /**
  44632. * An event triggered when the activeCamera property is updated
  44633. */
  44634. onActiveCameraChanged: Observable<Scene>;
  44635. /**
  44636. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  44637. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44638. * 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)
  44639. */
  44640. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44641. /**
  44642. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  44643. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  44644. * 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)
  44645. */
  44646. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  44647. /**
  44648. * This Observable will when a mesh has been imported into the scene.
  44649. */
  44650. onMeshImportedObservable: Observable<AbstractMesh>;
  44651. /**
  44652. * This Observable will when an animation file has been imported into the scene.
  44653. */
  44654. onAnimationFileImportedObservable: Observable<Scene>;
  44655. /**
  44656. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  44657. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  44658. */
  44659. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  44660. /** @hidden */
  44661. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  44662. /**
  44663. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  44664. */
  44665. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  44666. /**
  44667. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  44668. */
  44669. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  44670. /**
  44671. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  44672. */
  44673. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  44674. /** Callback called when a pointer move is detected */
  44675. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44676. /** Callback called when a pointer down is detected */
  44677. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  44678. /** Callback called when a pointer up is detected */
  44679. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  44680. /** Callback called when a pointer pick is detected */
  44681. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  44682. /**
  44683. * 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).
  44684. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  44685. */
  44686. onPrePointerObservable: Observable<PointerInfoPre>;
  44687. /**
  44688. * Observable event triggered each time an input event is received from the rendering canvas
  44689. */
  44690. onPointerObservable: Observable<PointerInfo>;
  44691. /**
  44692. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  44693. */
  44694. get unTranslatedPointer(): Vector2;
  44695. /**
  44696. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  44697. */
  44698. static get DragMovementThreshold(): number;
  44699. static set DragMovementThreshold(value: number);
  44700. /**
  44701. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  44702. */
  44703. static get LongPressDelay(): number;
  44704. static set LongPressDelay(value: number);
  44705. /**
  44706. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  44707. */
  44708. static get DoubleClickDelay(): number;
  44709. static set DoubleClickDelay(value: number);
  44710. /** If you need to check double click without raising a single click at first click, enable this flag */
  44711. static get ExclusiveDoubleClickMode(): boolean;
  44712. static set ExclusiveDoubleClickMode(value: boolean);
  44713. /** @hidden */
  44714. _mirroredCameraPosition: Nullable<Vector3>;
  44715. /**
  44716. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  44717. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  44718. */
  44719. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  44720. /**
  44721. * Observable event triggered each time an keyboard event is received from the hosting window
  44722. */
  44723. onKeyboardObservable: Observable<KeyboardInfo>;
  44724. private _useRightHandedSystem;
  44725. /**
  44726. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  44727. */
  44728. set useRightHandedSystem(value: boolean);
  44729. get useRightHandedSystem(): boolean;
  44730. private _timeAccumulator;
  44731. private _currentStepId;
  44732. private _currentInternalStep;
  44733. /**
  44734. * Sets the step Id used by deterministic lock step
  44735. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44736. * @param newStepId defines the step Id
  44737. */
  44738. setStepId(newStepId: number): void;
  44739. /**
  44740. * Gets the step Id used by deterministic lock step
  44741. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44742. * @returns the step Id
  44743. */
  44744. getStepId(): number;
  44745. /**
  44746. * Gets the internal step used by deterministic lock step
  44747. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  44748. * @returns the internal step
  44749. */
  44750. getInternalStep(): number;
  44751. private _fogEnabled;
  44752. /**
  44753. * Gets or sets a boolean indicating if fog is enabled on this scene
  44754. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44755. * (Default is true)
  44756. */
  44757. set fogEnabled(value: boolean);
  44758. get fogEnabled(): boolean;
  44759. private _fogMode;
  44760. /**
  44761. * Gets or sets the fog mode to use
  44762. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44763. * | mode | value |
  44764. * | --- | --- |
  44765. * | FOGMODE_NONE | 0 |
  44766. * | FOGMODE_EXP | 1 |
  44767. * | FOGMODE_EXP2 | 2 |
  44768. * | FOGMODE_LINEAR | 3 |
  44769. */
  44770. set fogMode(value: number);
  44771. get fogMode(): number;
  44772. /**
  44773. * Gets or sets the fog color to use
  44774. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44775. * (Default is Color3(0.2, 0.2, 0.3))
  44776. */
  44777. fogColor: Color3;
  44778. /**
  44779. * Gets or sets the fog density to use
  44780. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44781. * (Default is 0.1)
  44782. */
  44783. fogDensity: number;
  44784. /**
  44785. * Gets or sets the fog start distance to use
  44786. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44787. * (Default is 0)
  44788. */
  44789. fogStart: number;
  44790. /**
  44791. * Gets or sets the fog end distance to use
  44792. * @see https://doc.babylonjs.com/babylon101/environment#fog
  44793. * (Default is 1000)
  44794. */
  44795. fogEnd: number;
  44796. /**
  44797. * Flag indicating that the frame buffer binding is handled by another component
  44798. */
  44799. prePass: boolean;
  44800. private _shadowsEnabled;
  44801. /**
  44802. * Gets or sets a boolean indicating if shadows are enabled on this scene
  44803. */
  44804. set shadowsEnabled(value: boolean);
  44805. get shadowsEnabled(): boolean;
  44806. private _lightsEnabled;
  44807. /**
  44808. * Gets or sets a boolean indicating if lights are enabled on this scene
  44809. */
  44810. set lightsEnabled(value: boolean);
  44811. get lightsEnabled(): boolean;
  44812. /** All of the active cameras added to this scene. */
  44813. activeCameras: Camera[];
  44814. /** @hidden */
  44815. _activeCamera: Nullable<Camera>;
  44816. /** Gets or sets the current active camera */
  44817. get activeCamera(): Nullable<Camera>;
  44818. set activeCamera(value: Nullable<Camera>);
  44819. private _defaultMaterial;
  44820. /** The default material used on meshes when no material is affected */
  44821. get defaultMaterial(): Material;
  44822. /** The default material used on meshes when no material is affected */
  44823. set defaultMaterial(value: Material);
  44824. private _texturesEnabled;
  44825. /**
  44826. * Gets or sets a boolean indicating if textures are enabled on this scene
  44827. */
  44828. set texturesEnabled(value: boolean);
  44829. get texturesEnabled(): boolean;
  44830. /**
  44831. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  44832. */
  44833. physicsEnabled: boolean;
  44834. /**
  44835. * Gets or sets a boolean indicating if particles are enabled on this scene
  44836. */
  44837. particlesEnabled: boolean;
  44838. /**
  44839. * Gets or sets a boolean indicating if sprites are enabled on this scene
  44840. */
  44841. spritesEnabled: boolean;
  44842. private _skeletonsEnabled;
  44843. /**
  44844. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  44845. */
  44846. set skeletonsEnabled(value: boolean);
  44847. get skeletonsEnabled(): boolean;
  44848. /**
  44849. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  44850. */
  44851. lensFlaresEnabled: boolean;
  44852. /**
  44853. * Gets or sets a boolean indicating if collisions are enabled on this scene
  44854. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44855. */
  44856. collisionsEnabled: boolean;
  44857. private _collisionCoordinator;
  44858. /** @hidden */
  44859. get collisionCoordinator(): ICollisionCoordinator;
  44860. /**
  44861. * Defines the gravity applied to this scene (used only for collisions)
  44862. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  44863. */
  44864. gravity: Vector3;
  44865. /**
  44866. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  44867. */
  44868. postProcessesEnabled: boolean;
  44869. /**
  44870. * Gets the current postprocess manager
  44871. */
  44872. postProcessManager: PostProcessManager;
  44873. /**
  44874. * Gets or sets a boolean indicating if render targets are enabled on this scene
  44875. */
  44876. renderTargetsEnabled: boolean;
  44877. /**
  44878. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  44879. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  44880. */
  44881. dumpNextRenderTargets: boolean;
  44882. /**
  44883. * The list of user defined render targets added to the scene
  44884. */
  44885. customRenderTargets: RenderTargetTexture[];
  44886. /**
  44887. * Defines if texture loading must be delayed
  44888. * If true, textures will only be loaded when they need to be rendered
  44889. */
  44890. useDelayedTextureLoading: boolean;
  44891. /**
  44892. * Gets the list of meshes imported to the scene through SceneLoader
  44893. */
  44894. importedMeshesFiles: String[];
  44895. /**
  44896. * Gets or sets a boolean indicating if probes are enabled on this scene
  44897. */
  44898. probesEnabled: boolean;
  44899. /**
  44900. * Gets or sets the current offline provider to use to store scene data
  44901. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  44902. */
  44903. offlineProvider: IOfflineProvider;
  44904. /**
  44905. * Gets or sets the action manager associated with the scene
  44906. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44907. */
  44908. actionManager: AbstractActionManager;
  44909. private _meshesForIntersections;
  44910. /**
  44911. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  44912. */
  44913. proceduralTexturesEnabled: boolean;
  44914. private _engine;
  44915. private _totalVertices;
  44916. /** @hidden */
  44917. _activeIndices: PerfCounter;
  44918. /** @hidden */
  44919. _activeParticles: PerfCounter;
  44920. /** @hidden */
  44921. _activeBones: PerfCounter;
  44922. private _animationRatio;
  44923. /** @hidden */
  44924. _animationTimeLast: number;
  44925. /** @hidden */
  44926. _animationTime: number;
  44927. /**
  44928. * Gets or sets a general scale for animation speed
  44929. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  44930. */
  44931. animationTimeScale: number;
  44932. /** @hidden */
  44933. _cachedMaterial: Nullable<Material>;
  44934. /** @hidden */
  44935. _cachedEffect: Nullable<Effect>;
  44936. /** @hidden */
  44937. _cachedVisibility: Nullable<number>;
  44938. private _renderId;
  44939. private _frameId;
  44940. private _executeWhenReadyTimeoutId;
  44941. private _intermediateRendering;
  44942. private _viewUpdateFlag;
  44943. private _projectionUpdateFlag;
  44944. /** @hidden */
  44945. _toBeDisposed: Nullable<IDisposable>[];
  44946. private _activeRequests;
  44947. /** @hidden */
  44948. _pendingData: any[];
  44949. private _isDisposed;
  44950. /**
  44951. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  44952. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  44953. */
  44954. dispatchAllSubMeshesOfActiveMeshes: boolean;
  44955. private _activeMeshes;
  44956. private _processedMaterials;
  44957. private _renderTargets;
  44958. /** @hidden */
  44959. _activeParticleSystems: SmartArray<IParticleSystem>;
  44960. private _activeSkeletons;
  44961. private _softwareSkinnedMeshes;
  44962. private _renderingManager;
  44963. /** @hidden */
  44964. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  44965. private _transformMatrix;
  44966. private _sceneUbo;
  44967. /** @hidden */
  44968. _viewMatrix: Matrix;
  44969. private _projectionMatrix;
  44970. /** @hidden */
  44971. _forcedViewPosition: Nullable<Vector3>;
  44972. /** @hidden */
  44973. _frustumPlanes: Plane[];
  44974. /**
  44975. * Gets the list of frustum planes (built from the active camera)
  44976. */
  44977. get frustumPlanes(): Plane[];
  44978. /**
  44979. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  44980. * This is useful if there are more lights that the maximum simulteanous authorized
  44981. */
  44982. requireLightSorting: boolean;
  44983. /** @hidden */
  44984. readonly useMaterialMeshMap: boolean;
  44985. /** @hidden */
  44986. readonly useClonedMeshMap: boolean;
  44987. private _externalData;
  44988. private _uid;
  44989. /**
  44990. * @hidden
  44991. * Backing store of defined scene components.
  44992. */
  44993. _components: ISceneComponent[];
  44994. /**
  44995. * @hidden
  44996. * Backing store of defined scene components.
  44997. */
  44998. _serializableComponents: ISceneSerializableComponent[];
  44999. /**
  45000. * List of components to register on the next registration step.
  45001. */
  45002. private _transientComponents;
  45003. /**
  45004. * Registers the transient components if needed.
  45005. */
  45006. private _registerTransientComponents;
  45007. /**
  45008. * @hidden
  45009. * Add a component to the scene.
  45010. * Note that the ccomponent could be registered on th next frame if this is called after
  45011. * the register component stage.
  45012. * @param component Defines the component to add to the scene
  45013. */
  45014. _addComponent(component: ISceneComponent): void;
  45015. /**
  45016. * @hidden
  45017. * Gets a component from the scene.
  45018. * @param name defines the name of the component to retrieve
  45019. * @returns the component or null if not present
  45020. */
  45021. _getComponent(name: string): Nullable<ISceneComponent>;
  45022. /**
  45023. * @hidden
  45024. * Defines the actions happening before camera updates.
  45025. */
  45026. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  45027. /**
  45028. * @hidden
  45029. * Defines the actions happening before clear the canvas.
  45030. */
  45031. _beforeClearStage: Stage<SimpleStageAction>;
  45032. /**
  45033. * @hidden
  45034. * Defines the actions when collecting render targets for the frame.
  45035. */
  45036. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  45037. /**
  45038. * @hidden
  45039. * Defines the actions happening for one camera in the frame.
  45040. */
  45041. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  45042. /**
  45043. * @hidden
  45044. * Defines the actions happening during the per mesh ready checks.
  45045. */
  45046. _isReadyForMeshStage: Stage<MeshStageAction>;
  45047. /**
  45048. * @hidden
  45049. * Defines the actions happening before evaluate active mesh checks.
  45050. */
  45051. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  45052. /**
  45053. * @hidden
  45054. * Defines the actions happening during the evaluate sub mesh checks.
  45055. */
  45056. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  45057. /**
  45058. * @hidden
  45059. * Defines the actions happening during the active mesh stage.
  45060. */
  45061. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  45062. /**
  45063. * @hidden
  45064. * Defines the actions happening during the per camera render target step.
  45065. */
  45066. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  45067. /**
  45068. * @hidden
  45069. * Defines the actions happening just before the active camera is drawing.
  45070. */
  45071. _beforeCameraDrawStage: Stage<CameraStageAction>;
  45072. /**
  45073. * @hidden
  45074. * Defines the actions happening just before a render target is drawing.
  45075. */
  45076. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45077. /**
  45078. * @hidden
  45079. * Defines the actions happening just before a rendering group is drawing.
  45080. */
  45081. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45082. /**
  45083. * @hidden
  45084. * Defines the actions happening just before a mesh is drawing.
  45085. */
  45086. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45087. /**
  45088. * @hidden
  45089. * Defines the actions happening just after a mesh has been drawn.
  45090. */
  45091. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  45092. /**
  45093. * @hidden
  45094. * Defines the actions happening just after a rendering group has been drawn.
  45095. */
  45096. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  45097. /**
  45098. * @hidden
  45099. * Defines the actions happening just after the active camera has been drawn.
  45100. */
  45101. _afterCameraDrawStage: Stage<CameraStageAction>;
  45102. /**
  45103. * @hidden
  45104. * Defines the actions happening just after a render target has been drawn.
  45105. */
  45106. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  45107. /**
  45108. * @hidden
  45109. * Defines the actions happening just after rendering all cameras and computing intersections.
  45110. */
  45111. _afterRenderStage: Stage<SimpleStageAction>;
  45112. /**
  45113. * @hidden
  45114. * Defines the actions happening when a pointer move event happens.
  45115. */
  45116. _pointerMoveStage: Stage<PointerMoveStageAction>;
  45117. /**
  45118. * @hidden
  45119. * Defines the actions happening when a pointer down event happens.
  45120. */
  45121. _pointerDownStage: Stage<PointerUpDownStageAction>;
  45122. /**
  45123. * @hidden
  45124. * Defines the actions happening when a pointer up event happens.
  45125. */
  45126. _pointerUpStage: Stage<PointerUpDownStageAction>;
  45127. /**
  45128. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  45129. */
  45130. private geometriesByUniqueId;
  45131. /**
  45132. * Creates a new Scene
  45133. * @param engine defines the engine to use to render this scene
  45134. * @param options defines the scene options
  45135. */
  45136. constructor(engine: Engine, options?: SceneOptions);
  45137. /**
  45138. * Gets a string identifying the name of the class
  45139. * @returns "Scene" string
  45140. */
  45141. getClassName(): string;
  45142. private _defaultMeshCandidates;
  45143. /**
  45144. * @hidden
  45145. */
  45146. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  45147. private _defaultSubMeshCandidates;
  45148. /**
  45149. * @hidden
  45150. */
  45151. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  45152. /**
  45153. * Sets the default candidate providers for the scene.
  45154. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  45155. * and getCollidingSubMeshCandidates to their default function
  45156. */
  45157. setDefaultCandidateProviders(): void;
  45158. /**
  45159. * Gets the mesh that is currently under the pointer
  45160. */
  45161. get meshUnderPointer(): Nullable<AbstractMesh>;
  45162. /**
  45163. * Gets or sets the current on-screen X position of the pointer
  45164. */
  45165. get pointerX(): number;
  45166. set pointerX(value: number);
  45167. /**
  45168. * Gets or sets the current on-screen Y position of the pointer
  45169. */
  45170. get pointerY(): number;
  45171. set pointerY(value: number);
  45172. /**
  45173. * Gets the cached material (ie. the latest rendered one)
  45174. * @returns the cached material
  45175. */
  45176. getCachedMaterial(): Nullable<Material>;
  45177. /**
  45178. * Gets the cached effect (ie. the latest rendered one)
  45179. * @returns the cached effect
  45180. */
  45181. getCachedEffect(): Nullable<Effect>;
  45182. /**
  45183. * Gets the cached visibility state (ie. the latest rendered one)
  45184. * @returns the cached visibility state
  45185. */
  45186. getCachedVisibility(): Nullable<number>;
  45187. /**
  45188. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  45189. * @param material defines the current material
  45190. * @param effect defines the current effect
  45191. * @param visibility defines the current visibility state
  45192. * @returns true if one parameter is not cached
  45193. */
  45194. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  45195. /**
  45196. * Gets the engine associated with the scene
  45197. * @returns an Engine
  45198. */
  45199. getEngine(): Engine;
  45200. /**
  45201. * Gets the total number of vertices rendered per frame
  45202. * @returns the total number of vertices rendered per frame
  45203. */
  45204. getTotalVertices(): number;
  45205. /**
  45206. * Gets the performance counter for total vertices
  45207. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45208. */
  45209. get totalVerticesPerfCounter(): PerfCounter;
  45210. /**
  45211. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  45212. * @returns the total number of active indices rendered per frame
  45213. */
  45214. getActiveIndices(): number;
  45215. /**
  45216. * Gets the performance counter for active indices
  45217. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45218. */
  45219. get totalActiveIndicesPerfCounter(): PerfCounter;
  45220. /**
  45221. * Gets the total number of active particles rendered per frame
  45222. * @returns the total number of active particles rendered per frame
  45223. */
  45224. getActiveParticles(): number;
  45225. /**
  45226. * Gets the performance counter for active particles
  45227. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45228. */
  45229. get activeParticlesPerfCounter(): PerfCounter;
  45230. /**
  45231. * Gets the total number of active bones rendered per frame
  45232. * @returns the total number of active bones rendered per frame
  45233. */
  45234. getActiveBones(): number;
  45235. /**
  45236. * Gets the performance counter for active bones
  45237. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  45238. */
  45239. get activeBonesPerfCounter(): PerfCounter;
  45240. /**
  45241. * Gets the array of active meshes
  45242. * @returns an array of AbstractMesh
  45243. */
  45244. getActiveMeshes(): SmartArray<AbstractMesh>;
  45245. /**
  45246. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  45247. * @returns a number
  45248. */
  45249. getAnimationRatio(): number;
  45250. /**
  45251. * Gets an unique Id for the current render phase
  45252. * @returns a number
  45253. */
  45254. getRenderId(): number;
  45255. /**
  45256. * Gets an unique Id for the current frame
  45257. * @returns a number
  45258. */
  45259. getFrameId(): number;
  45260. /** Call this function if you want to manually increment the render Id*/
  45261. incrementRenderId(): void;
  45262. private _createUbo;
  45263. /**
  45264. * Use this method to simulate a pointer move on a mesh
  45265. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45266. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45267. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45268. * @returns the current scene
  45269. */
  45270. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45271. /**
  45272. * Use this method to simulate a pointer down on a mesh
  45273. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45274. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45275. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45276. * @returns the current scene
  45277. */
  45278. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  45279. /**
  45280. * Use this method to simulate a pointer up on a mesh
  45281. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  45282. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  45283. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  45284. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  45285. * @returns the current scene
  45286. */
  45287. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  45288. /**
  45289. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  45290. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  45291. * @returns true if the pointer was captured
  45292. */
  45293. isPointerCaptured(pointerId?: number): boolean;
  45294. /**
  45295. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  45296. * @param attachUp defines if you want to attach events to pointerup
  45297. * @param attachDown defines if you want to attach events to pointerdown
  45298. * @param attachMove defines if you want to attach events to pointermove
  45299. */
  45300. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  45301. /** Detaches all event handlers*/
  45302. detachControl(): void;
  45303. /**
  45304. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  45305. * Delay loaded resources are not taking in account
  45306. * @return true if all required resources are ready
  45307. */
  45308. isReady(): boolean;
  45309. /** Resets all cached information relative to material (including effect and visibility) */
  45310. resetCachedMaterial(): void;
  45311. /**
  45312. * Registers a function to be called before every frame render
  45313. * @param func defines the function to register
  45314. */
  45315. registerBeforeRender(func: () => void): void;
  45316. /**
  45317. * Unregisters a function called before every frame render
  45318. * @param func defines the function to unregister
  45319. */
  45320. unregisterBeforeRender(func: () => void): void;
  45321. /**
  45322. * Registers a function to be called after every frame render
  45323. * @param func defines the function to register
  45324. */
  45325. registerAfterRender(func: () => void): void;
  45326. /**
  45327. * Unregisters a function called after every frame render
  45328. * @param func defines the function to unregister
  45329. */
  45330. unregisterAfterRender(func: () => void): void;
  45331. private _executeOnceBeforeRender;
  45332. /**
  45333. * The provided function will run before render once and will be disposed afterwards.
  45334. * A timeout delay can be provided so that the function will be executed in N ms.
  45335. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  45336. * @param func The function to be executed.
  45337. * @param timeout optional delay in ms
  45338. */
  45339. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  45340. /** @hidden */
  45341. _addPendingData(data: any): void;
  45342. /** @hidden */
  45343. _removePendingData(data: any): void;
  45344. /**
  45345. * Returns the number of items waiting to be loaded
  45346. * @returns the number of items waiting to be loaded
  45347. */
  45348. getWaitingItemsCount(): number;
  45349. /**
  45350. * Returns a boolean indicating if the scene is still loading data
  45351. */
  45352. get isLoading(): boolean;
  45353. /**
  45354. * Registers a function to be executed when the scene is ready
  45355. * @param {Function} func - the function to be executed
  45356. */
  45357. executeWhenReady(func: () => void): void;
  45358. /**
  45359. * Returns a promise that resolves when the scene is ready
  45360. * @returns A promise that resolves when the scene is ready
  45361. */
  45362. whenReadyAsync(): Promise<void>;
  45363. /** @hidden */
  45364. _checkIsReady(): void;
  45365. /**
  45366. * Gets all animatable attached to the scene
  45367. */
  45368. get animatables(): Animatable[];
  45369. /**
  45370. * Resets the last animation time frame.
  45371. * Useful to override when animations start running when loading a scene for the first time.
  45372. */
  45373. resetLastAnimationTimeFrame(): void;
  45374. /**
  45375. * Gets the current view matrix
  45376. * @returns a Matrix
  45377. */
  45378. getViewMatrix(): Matrix;
  45379. /**
  45380. * Gets the current projection matrix
  45381. * @returns a Matrix
  45382. */
  45383. getProjectionMatrix(): Matrix;
  45384. /**
  45385. * Gets the current transform matrix
  45386. * @returns a Matrix made of View * Projection
  45387. */
  45388. getTransformMatrix(): Matrix;
  45389. /**
  45390. * Sets the current transform matrix
  45391. * @param viewL defines the View matrix to use
  45392. * @param projectionL defines the Projection matrix to use
  45393. * @param viewR defines the right View matrix to use (if provided)
  45394. * @param projectionR defines the right Projection matrix to use (if provided)
  45395. */
  45396. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  45397. /**
  45398. * Gets the uniform buffer used to store scene data
  45399. * @returns a UniformBuffer
  45400. */
  45401. getSceneUniformBuffer(): UniformBuffer;
  45402. /**
  45403. * Gets an unique (relatively to the current scene) Id
  45404. * @returns an unique number for the scene
  45405. */
  45406. getUniqueId(): number;
  45407. /**
  45408. * Add a mesh to the list of scene's meshes
  45409. * @param newMesh defines the mesh to add
  45410. * @param recursive if all child meshes should also be added to the scene
  45411. */
  45412. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  45413. /**
  45414. * Remove a mesh for the list of scene's meshes
  45415. * @param toRemove defines the mesh to remove
  45416. * @param recursive if all child meshes should also be removed from the scene
  45417. * @returns the index where the mesh was in the mesh list
  45418. */
  45419. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  45420. /**
  45421. * Add a transform node to the list of scene's transform nodes
  45422. * @param newTransformNode defines the transform node to add
  45423. */
  45424. addTransformNode(newTransformNode: TransformNode): void;
  45425. /**
  45426. * Remove a transform node for the list of scene's transform nodes
  45427. * @param toRemove defines the transform node to remove
  45428. * @returns the index where the transform node was in the transform node list
  45429. */
  45430. removeTransformNode(toRemove: TransformNode): number;
  45431. /**
  45432. * Remove a skeleton for the list of scene's skeletons
  45433. * @param toRemove defines the skeleton to remove
  45434. * @returns the index where the skeleton was in the skeleton list
  45435. */
  45436. removeSkeleton(toRemove: Skeleton): number;
  45437. /**
  45438. * Remove a morph target for the list of scene's morph targets
  45439. * @param toRemove defines the morph target to remove
  45440. * @returns the index where the morph target was in the morph target list
  45441. */
  45442. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  45443. /**
  45444. * Remove a light for the list of scene's lights
  45445. * @param toRemove defines the light to remove
  45446. * @returns the index where the light was in the light list
  45447. */
  45448. removeLight(toRemove: Light): number;
  45449. /**
  45450. * Remove a camera for the list of scene's cameras
  45451. * @param toRemove defines the camera to remove
  45452. * @returns the index where the camera was in the camera list
  45453. */
  45454. removeCamera(toRemove: Camera): number;
  45455. /**
  45456. * Remove a particle system for the list of scene's particle systems
  45457. * @param toRemove defines the particle system to remove
  45458. * @returns the index where the particle system was in the particle system list
  45459. */
  45460. removeParticleSystem(toRemove: IParticleSystem): number;
  45461. /**
  45462. * Remove a animation for the list of scene's animations
  45463. * @param toRemove defines the animation to remove
  45464. * @returns the index where the animation was in the animation list
  45465. */
  45466. removeAnimation(toRemove: Animation): number;
  45467. /**
  45468. * Will stop the animation of the given target
  45469. * @param target - the target
  45470. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  45471. * @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)
  45472. */
  45473. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  45474. /**
  45475. * Removes the given animation group from this scene.
  45476. * @param toRemove The animation group to remove
  45477. * @returns The index of the removed animation group
  45478. */
  45479. removeAnimationGroup(toRemove: AnimationGroup): number;
  45480. /**
  45481. * Removes the given multi-material from this scene.
  45482. * @param toRemove The multi-material to remove
  45483. * @returns The index of the removed multi-material
  45484. */
  45485. removeMultiMaterial(toRemove: MultiMaterial): number;
  45486. /**
  45487. * Removes the given material from this scene.
  45488. * @param toRemove The material to remove
  45489. * @returns The index of the removed material
  45490. */
  45491. removeMaterial(toRemove: Material): number;
  45492. /**
  45493. * Removes the given action manager from this scene.
  45494. * @param toRemove The action manager to remove
  45495. * @returns The index of the removed action manager
  45496. */
  45497. removeActionManager(toRemove: AbstractActionManager): number;
  45498. /**
  45499. * Removes the given texture from this scene.
  45500. * @param toRemove The texture to remove
  45501. * @returns The index of the removed texture
  45502. */
  45503. removeTexture(toRemove: BaseTexture): number;
  45504. /**
  45505. * Adds the given light to this scene
  45506. * @param newLight The light to add
  45507. */
  45508. addLight(newLight: Light): void;
  45509. /**
  45510. * Sorts the list list based on light priorities
  45511. */
  45512. sortLightsByPriority(): void;
  45513. /**
  45514. * Adds the given camera to this scene
  45515. * @param newCamera The camera to add
  45516. */
  45517. addCamera(newCamera: Camera): void;
  45518. /**
  45519. * Adds the given skeleton to this scene
  45520. * @param newSkeleton The skeleton to add
  45521. */
  45522. addSkeleton(newSkeleton: Skeleton): void;
  45523. /**
  45524. * Adds the given particle system to this scene
  45525. * @param newParticleSystem The particle system to add
  45526. */
  45527. addParticleSystem(newParticleSystem: IParticleSystem): void;
  45528. /**
  45529. * Adds the given animation to this scene
  45530. * @param newAnimation The animation to add
  45531. */
  45532. addAnimation(newAnimation: Animation): void;
  45533. /**
  45534. * Adds the given animation group to this scene.
  45535. * @param newAnimationGroup The animation group to add
  45536. */
  45537. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  45538. /**
  45539. * Adds the given multi-material to this scene
  45540. * @param newMultiMaterial The multi-material to add
  45541. */
  45542. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  45543. /**
  45544. * Adds the given material to this scene
  45545. * @param newMaterial The material to add
  45546. */
  45547. addMaterial(newMaterial: Material): void;
  45548. /**
  45549. * Adds the given morph target to this scene
  45550. * @param newMorphTargetManager The morph target to add
  45551. */
  45552. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  45553. /**
  45554. * Adds the given geometry to this scene
  45555. * @param newGeometry The geometry to add
  45556. */
  45557. addGeometry(newGeometry: Geometry): void;
  45558. /**
  45559. * Adds the given action manager to this scene
  45560. * @param newActionManager The action manager to add
  45561. */
  45562. addActionManager(newActionManager: AbstractActionManager): void;
  45563. /**
  45564. * Adds the given texture to this scene.
  45565. * @param newTexture The texture to add
  45566. */
  45567. addTexture(newTexture: BaseTexture): void;
  45568. /**
  45569. * Switch active camera
  45570. * @param newCamera defines the new active camera
  45571. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  45572. */
  45573. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  45574. /**
  45575. * sets the active camera of the scene using its ID
  45576. * @param id defines the camera's ID
  45577. * @return the new active camera or null if none found.
  45578. */
  45579. setActiveCameraByID(id: string): Nullable<Camera>;
  45580. /**
  45581. * sets the active camera of the scene using its name
  45582. * @param name defines the camera's name
  45583. * @returns the new active camera or null if none found.
  45584. */
  45585. setActiveCameraByName(name: string): Nullable<Camera>;
  45586. /**
  45587. * get an animation group using its name
  45588. * @param name defines the material's name
  45589. * @return the animation group or null if none found.
  45590. */
  45591. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  45592. /**
  45593. * Get a material using its unique id
  45594. * @param uniqueId defines the material's unique id
  45595. * @return the material or null if none found.
  45596. */
  45597. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  45598. /**
  45599. * get a material using its id
  45600. * @param id defines the material's ID
  45601. * @return the material or null if none found.
  45602. */
  45603. getMaterialByID(id: string): Nullable<Material>;
  45604. /**
  45605. * Gets a the last added material using a given id
  45606. * @param id defines the material's ID
  45607. * @return the last material with the given id or null if none found.
  45608. */
  45609. getLastMaterialByID(id: string): Nullable<Material>;
  45610. /**
  45611. * Gets a material using its name
  45612. * @param name defines the material's name
  45613. * @return the material or null if none found.
  45614. */
  45615. getMaterialByName(name: string): Nullable<Material>;
  45616. /**
  45617. * Get a texture using its unique id
  45618. * @param uniqueId defines the texture's unique id
  45619. * @return the texture or null if none found.
  45620. */
  45621. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  45622. /**
  45623. * Gets a camera using its id
  45624. * @param id defines the id to look for
  45625. * @returns the camera or null if not found
  45626. */
  45627. getCameraByID(id: string): Nullable<Camera>;
  45628. /**
  45629. * Gets a camera using its unique id
  45630. * @param uniqueId defines the unique id to look for
  45631. * @returns the camera or null if not found
  45632. */
  45633. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  45634. /**
  45635. * Gets a camera using its name
  45636. * @param name defines the camera's name
  45637. * @return the camera or null if none found.
  45638. */
  45639. getCameraByName(name: string): Nullable<Camera>;
  45640. /**
  45641. * Gets a bone using its id
  45642. * @param id defines the bone's id
  45643. * @return the bone or null if not found
  45644. */
  45645. getBoneByID(id: string): Nullable<Bone>;
  45646. /**
  45647. * Gets a bone using its id
  45648. * @param name defines the bone's name
  45649. * @return the bone or null if not found
  45650. */
  45651. getBoneByName(name: string): Nullable<Bone>;
  45652. /**
  45653. * Gets a light node using its name
  45654. * @param name defines the the light's name
  45655. * @return the light or null if none found.
  45656. */
  45657. getLightByName(name: string): Nullable<Light>;
  45658. /**
  45659. * Gets a light node using its id
  45660. * @param id defines the light's id
  45661. * @return the light or null if none found.
  45662. */
  45663. getLightByID(id: string): Nullable<Light>;
  45664. /**
  45665. * Gets a light node using its scene-generated unique ID
  45666. * @param uniqueId defines the light's unique id
  45667. * @return the light or null if none found.
  45668. */
  45669. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  45670. /**
  45671. * Gets a particle system by id
  45672. * @param id defines the particle system id
  45673. * @return the corresponding system or null if none found
  45674. */
  45675. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  45676. /**
  45677. * Gets a geometry using its ID
  45678. * @param id defines the geometry's id
  45679. * @return the geometry or null if none found.
  45680. */
  45681. getGeometryByID(id: string): Nullable<Geometry>;
  45682. private _getGeometryByUniqueID;
  45683. /**
  45684. * Add a new geometry to this scene
  45685. * @param geometry defines the geometry to be added to the scene.
  45686. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  45687. * @return a boolean defining if the geometry was added or not
  45688. */
  45689. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  45690. /**
  45691. * Removes an existing geometry
  45692. * @param geometry defines the geometry to be removed from the scene
  45693. * @return a boolean defining if the geometry was removed or not
  45694. */
  45695. removeGeometry(geometry: Geometry): boolean;
  45696. /**
  45697. * Gets the list of geometries attached to the scene
  45698. * @returns an array of Geometry
  45699. */
  45700. getGeometries(): Geometry[];
  45701. /**
  45702. * Gets the first added mesh found of a given ID
  45703. * @param id defines the id to search for
  45704. * @return the mesh found or null if not found at all
  45705. */
  45706. getMeshByID(id: string): Nullable<AbstractMesh>;
  45707. /**
  45708. * Gets a list of meshes using their id
  45709. * @param id defines the id to search for
  45710. * @returns a list of meshes
  45711. */
  45712. getMeshesByID(id: string): Array<AbstractMesh>;
  45713. /**
  45714. * Gets the first added transform node found of a given ID
  45715. * @param id defines the id to search for
  45716. * @return the found transform node or null if not found at all.
  45717. */
  45718. getTransformNodeByID(id: string): Nullable<TransformNode>;
  45719. /**
  45720. * Gets a transform node with its auto-generated unique id
  45721. * @param uniqueId efines the unique id to search for
  45722. * @return the found transform node or null if not found at all.
  45723. */
  45724. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  45725. /**
  45726. * Gets a list of transform nodes using their id
  45727. * @param id defines the id to search for
  45728. * @returns a list of transform nodes
  45729. */
  45730. getTransformNodesByID(id: string): Array<TransformNode>;
  45731. /**
  45732. * Gets a mesh with its auto-generated unique id
  45733. * @param uniqueId defines the unique id to search for
  45734. * @return the found mesh or null if not found at all.
  45735. */
  45736. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  45737. /**
  45738. * Gets a the last added mesh using a given id
  45739. * @param id defines the id to search for
  45740. * @return the found mesh or null if not found at all.
  45741. */
  45742. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  45743. /**
  45744. * Gets a the last added node (Mesh, Camera, Light) using a given id
  45745. * @param id defines the id to search for
  45746. * @return the found node or null if not found at all
  45747. */
  45748. getLastEntryByID(id: string): Nullable<Node>;
  45749. /**
  45750. * Gets a node (Mesh, Camera, Light) using a given id
  45751. * @param id defines the id to search for
  45752. * @return the found node or null if not found at all
  45753. */
  45754. getNodeByID(id: string): Nullable<Node>;
  45755. /**
  45756. * Gets a node (Mesh, Camera, Light) using a given name
  45757. * @param name defines the name to search for
  45758. * @return the found node or null if not found at all.
  45759. */
  45760. getNodeByName(name: string): Nullable<Node>;
  45761. /**
  45762. * Gets a mesh using a given name
  45763. * @param name defines the name to search for
  45764. * @return the found mesh or null if not found at all.
  45765. */
  45766. getMeshByName(name: string): Nullable<AbstractMesh>;
  45767. /**
  45768. * Gets a transform node using a given name
  45769. * @param name defines the name to search for
  45770. * @return the found transform node or null if not found at all.
  45771. */
  45772. getTransformNodeByName(name: string): Nullable<TransformNode>;
  45773. /**
  45774. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  45775. * @param id defines the id to search for
  45776. * @return the found skeleton or null if not found at all.
  45777. */
  45778. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  45779. /**
  45780. * Gets a skeleton using a given auto generated unique id
  45781. * @param uniqueId defines the unique id to search for
  45782. * @return the found skeleton or null if not found at all.
  45783. */
  45784. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  45785. /**
  45786. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  45787. * @param id defines the id to search for
  45788. * @return the found skeleton or null if not found at all.
  45789. */
  45790. getSkeletonById(id: string): Nullable<Skeleton>;
  45791. /**
  45792. * Gets a skeleton using a given name
  45793. * @param name defines the name to search for
  45794. * @return the found skeleton or null if not found at all.
  45795. */
  45796. getSkeletonByName(name: string): Nullable<Skeleton>;
  45797. /**
  45798. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  45799. * @param id defines the id to search for
  45800. * @return the found morph target manager or null if not found at all.
  45801. */
  45802. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  45803. /**
  45804. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  45805. * @param id defines the id to search for
  45806. * @return the found morph target or null if not found at all.
  45807. */
  45808. getMorphTargetById(id: string): Nullable<MorphTarget>;
  45809. /**
  45810. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  45811. * @param name defines the name to search for
  45812. * @return the found morph target or null if not found at all.
  45813. */
  45814. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  45815. /**
  45816. * Gets a post process using a given name (if many are found, this function will pick the first one)
  45817. * @param name defines the name to search for
  45818. * @return the found post process or null if not found at all.
  45819. */
  45820. getPostProcessByName(name: string): Nullable<PostProcess>;
  45821. /**
  45822. * Gets a boolean indicating if the given mesh is active
  45823. * @param mesh defines the mesh to look for
  45824. * @returns true if the mesh is in the active list
  45825. */
  45826. isActiveMesh(mesh: AbstractMesh): boolean;
  45827. /**
  45828. * Return a unique id as a string which can serve as an identifier for the scene
  45829. */
  45830. get uid(): string;
  45831. /**
  45832. * Add an externaly attached data from its key.
  45833. * This method call will fail and return false, if such key already exists.
  45834. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  45835. * @param key the unique key that identifies the data
  45836. * @param data the data object to associate to the key for this Engine instance
  45837. * @return true if no such key were already present and the data was added successfully, false otherwise
  45838. */
  45839. addExternalData<T>(key: string, data: T): boolean;
  45840. /**
  45841. * Get an externaly attached data from its key
  45842. * @param key the unique key that identifies the data
  45843. * @return the associated data, if present (can be null), or undefined if not present
  45844. */
  45845. getExternalData<T>(key: string): Nullable<T>;
  45846. /**
  45847. * Get an externaly attached data from its key, create it using a factory if it's not already present
  45848. * @param key the unique key that identifies the data
  45849. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  45850. * @return the associated data, can be null if the factory returned null.
  45851. */
  45852. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  45853. /**
  45854. * Remove an externaly attached data from the Engine instance
  45855. * @param key the unique key that identifies the data
  45856. * @return true if the data was successfully removed, false if it doesn't exist
  45857. */
  45858. removeExternalData(key: string): boolean;
  45859. private _evaluateSubMesh;
  45860. /**
  45861. * Clear the processed materials smart array preventing retention point in material dispose.
  45862. */
  45863. freeProcessedMaterials(): void;
  45864. private _preventFreeActiveMeshesAndRenderingGroups;
  45865. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  45866. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  45867. * when disposing several meshes in a row or a hierarchy of meshes.
  45868. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  45869. */
  45870. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  45871. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  45872. /**
  45873. * Clear the active meshes smart array preventing retention point in mesh dispose.
  45874. */
  45875. freeActiveMeshes(): void;
  45876. /**
  45877. * Clear the info related to rendering groups preventing retention points during dispose.
  45878. */
  45879. freeRenderingGroups(): void;
  45880. /** @hidden */
  45881. _isInIntermediateRendering(): boolean;
  45882. /**
  45883. * Lambda returning the list of potentially active meshes.
  45884. */
  45885. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  45886. /**
  45887. * Lambda returning the list of potentially active sub meshes.
  45888. */
  45889. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  45890. /**
  45891. * Lambda returning the list of potentially intersecting sub meshes.
  45892. */
  45893. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  45894. /**
  45895. * Lambda returning the list of potentially colliding sub meshes.
  45896. */
  45897. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  45898. private _activeMeshesFrozen;
  45899. private _skipEvaluateActiveMeshesCompletely;
  45900. /**
  45901. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  45902. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  45903. * @param onSuccess optional success callback
  45904. * @param onError optional error callback
  45905. * @returns the current scene
  45906. */
  45907. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  45908. /**
  45909. * Use this function to restart evaluating active meshes on every frame
  45910. * @returns the current scene
  45911. */
  45912. unfreezeActiveMeshes(): Scene;
  45913. private _evaluateActiveMeshes;
  45914. private _activeMesh;
  45915. /**
  45916. * Update the transform matrix to update from the current active camera
  45917. * @param force defines a boolean used to force the update even if cache is up to date
  45918. */
  45919. updateTransformMatrix(force?: boolean): void;
  45920. private _bindFrameBuffer;
  45921. /** @hidden */
  45922. _allowPostProcessClearColor: boolean;
  45923. /** @hidden */
  45924. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  45925. private _processSubCameras;
  45926. private _checkIntersections;
  45927. /** @hidden */
  45928. _advancePhysicsEngineStep(step: number): void;
  45929. /**
  45930. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  45931. */
  45932. getDeterministicFrameTime: () => number;
  45933. /** @hidden */
  45934. _animate(): void;
  45935. /** Execute all animations (for a frame) */
  45936. animate(): void;
  45937. /**
  45938. * Render the scene
  45939. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  45940. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  45941. */
  45942. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  45943. /**
  45944. * Freeze all materials
  45945. * A frozen material will not be updatable but should be faster to render
  45946. */
  45947. freezeMaterials(): void;
  45948. /**
  45949. * Unfreeze all materials
  45950. * A frozen material will not be updatable but should be faster to render
  45951. */
  45952. unfreezeMaterials(): void;
  45953. /**
  45954. * Releases all held ressources
  45955. */
  45956. dispose(): void;
  45957. /**
  45958. * Gets if the scene is already disposed
  45959. */
  45960. get isDisposed(): boolean;
  45961. /**
  45962. * Call this function to reduce memory footprint of the scene.
  45963. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  45964. */
  45965. clearCachedVertexData(): void;
  45966. /**
  45967. * This function will remove the local cached buffer data from texture.
  45968. * It will save memory but will prevent the texture from being rebuilt
  45969. */
  45970. cleanCachedTextureBuffer(): void;
  45971. /**
  45972. * Get the world extend vectors with an optional filter
  45973. *
  45974. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  45975. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  45976. */
  45977. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  45978. min: Vector3;
  45979. max: Vector3;
  45980. };
  45981. /**
  45982. * Creates a ray that can be used to pick in the scene
  45983. * @param x defines the x coordinate of the origin (on-screen)
  45984. * @param y defines the y coordinate of the origin (on-screen)
  45985. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45986. * @param camera defines the camera to use for the picking
  45987. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45988. * @returns a Ray
  45989. */
  45990. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  45991. /**
  45992. * Creates a ray that can be used to pick in the scene
  45993. * @param x defines the x coordinate of the origin (on-screen)
  45994. * @param y defines the y coordinate of the origin (on-screen)
  45995. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  45996. * @param result defines the ray where to store the picking ray
  45997. * @param camera defines the camera to use for the picking
  45998. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  45999. * @returns the current scene
  46000. */
  46001. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  46002. /**
  46003. * Creates a ray that can be used to pick in the scene
  46004. * @param x defines the x coordinate of the origin (on-screen)
  46005. * @param y defines the y coordinate of the origin (on-screen)
  46006. * @param camera defines the camera to use for the picking
  46007. * @returns a Ray
  46008. */
  46009. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  46010. /**
  46011. * Creates a ray that can be used to pick in the scene
  46012. * @param x defines the x coordinate of the origin (on-screen)
  46013. * @param y defines the y coordinate of the origin (on-screen)
  46014. * @param result defines the ray where to store the picking ray
  46015. * @param camera defines the camera to use for the picking
  46016. * @returns the current scene
  46017. */
  46018. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  46019. /** Launch a ray to try to pick a mesh in the scene
  46020. * @param x position on screen
  46021. * @param y position on screen
  46022. * @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
  46023. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46024. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46025. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46026. * @returns a PickingInfo
  46027. */
  46028. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  46029. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  46030. * @param x position on screen
  46031. * @param y position on screen
  46032. * @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
  46033. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46034. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46035. * @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)
  46036. */
  46037. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  46038. /** Use the given ray to pick a mesh in the scene
  46039. * @param ray The ray to use to pick meshes
  46040. * @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
  46041. * @param fastCheck defines if the first intersection will be used (and not the closest)
  46042. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46043. * @returns a PickingInfo
  46044. */
  46045. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  46046. /**
  46047. * Launch a ray to try to pick a mesh in the scene
  46048. * @param x X position on screen
  46049. * @param y Y position on screen
  46050. * @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
  46051. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  46052. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46053. * @returns an array of PickingInfo
  46054. */
  46055. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  46056. /**
  46057. * Launch a ray to try to pick a mesh in the scene
  46058. * @param ray Ray to use
  46059. * @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
  46060. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  46061. * @returns an array of PickingInfo
  46062. */
  46063. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  46064. /**
  46065. * Force the value of meshUnderPointer
  46066. * @param mesh defines the mesh to use
  46067. * @param pointerId optional pointer id when using more than one pointer
  46068. */
  46069. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  46070. /**
  46071. * Gets the mesh under the pointer
  46072. * @returns a Mesh or null if no mesh is under the pointer
  46073. */
  46074. getPointerOverMesh(): Nullable<AbstractMesh>;
  46075. /** @hidden */
  46076. _rebuildGeometries(): void;
  46077. /** @hidden */
  46078. _rebuildTextures(): void;
  46079. private _getByTags;
  46080. /**
  46081. * Get a list of meshes by tags
  46082. * @param tagsQuery defines the tags query to use
  46083. * @param forEach defines a predicate used to filter results
  46084. * @returns an array of Mesh
  46085. */
  46086. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  46087. /**
  46088. * Get a list of cameras by tags
  46089. * @param tagsQuery defines the tags query to use
  46090. * @param forEach defines a predicate used to filter results
  46091. * @returns an array of Camera
  46092. */
  46093. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  46094. /**
  46095. * Get a list of lights by tags
  46096. * @param tagsQuery defines the tags query to use
  46097. * @param forEach defines a predicate used to filter results
  46098. * @returns an array of Light
  46099. */
  46100. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  46101. /**
  46102. * Get a list of materials by tags
  46103. * @param tagsQuery defines the tags query to use
  46104. * @param forEach defines a predicate used to filter results
  46105. * @returns an array of Material
  46106. */
  46107. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  46108. /**
  46109. * Get a list of transform nodes by tags
  46110. * @param tagsQuery defines the tags query to use
  46111. * @param forEach defines a predicate used to filter results
  46112. * @returns an array of TransformNode
  46113. */
  46114. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  46115. /**
  46116. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  46117. * This allowed control for front to back rendering or reversly depending of the special needs.
  46118. *
  46119. * @param renderingGroupId The rendering group id corresponding to its index
  46120. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  46121. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  46122. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  46123. */
  46124. 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;
  46125. /**
  46126. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  46127. *
  46128. * @param renderingGroupId The rendering group id corresponding to its index
  46129. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  46130. * @param depth Automatically clears depth between groups if true and autoClear is true.
  46131. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  46132. */
  46133. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  46134. /**
  46135. * Gets the current auto clear configuration for one rendering group of the rendering
  46136. * manager.
  46137. * @param index the rendering group index to get the information for
  46138. * @returns The auto clear setup for the requested rendering group
  46139. */
  46140. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  46141. private _blockMaterialDirtyMechanism;
  46142. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  46143. get blockMaterialDirtyMechanism(): boolean;
  46144. set blockMaterialDirtyMechanism(value: boolean);
  46145. /**
  46146. * Will flag all materials as dirty to trigger new shader compilation
  46147. * @param flag defines the flag used to specify which material part must be marked as dirty
  46148. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  46149. */
  46150. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  46151. /** @hidden */
  46152. _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;
  46153. /** @hidden */
  46154. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46155. /** @hidden */
  46156. _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;
  46157. /** @hidden */
  46158. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  46159. /** @hidden */
  46160. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  46161. /** @hidden */
  46162. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  46163. }
  46164. }
  46165. declare module "babylonjs/assetContainer" {
  46166. import { AbstractScene } from "babylonjs/abstractScene";
  46167. import { Scene } from "babylonjs/scene";
  46168. import { Mesh } from "babylonjs/Meshes/mesh";
  46169. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46170. import { Skeleton } from "babylonjs/Bones/skeleton";
  46171. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46172. import { Animatable } from "babylonjs/Animations/animatable";
  46173. import { Nullable } from "babylonjs/types";
  46174. import { Node } from "babylonjs/node";
  46175. /**
  46176. * Set of assets to keep when moving a scene into an asset container.
  46177. */
  46178. export class KeepAssets extends AbstractScene {
  46179. }
  46180. /**
  46181. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  46182. */
  46183. export class InstantiatedEntries {
  46184. /**
  46185. * List of new root nodes (eg. nodes with no parent)
  46186. */
  46187. rootNodes: TransformNode[];
  46188. /**
  46189. * List of new skeletons
  46190. */
  46191. skeletons: Skeleton[];
  46192. /**
  46193. * List of new animation groups
  46194. */
  46195. animationGroups: AnimationGroup[];
  46196. }
  46197. /**
  46198. * Container with a set of assets that can be added or removed from a scene.
  46199. */
  46200. export class AssetContainer extends AbstractScene {
  46201. private _wasAddedToScene;
  46202. /**
  46203. * The scene the AssetContainer belongs to.
  46204. */
  46205. scene: Scene;
  46206. /**
  46207. * Instantiates an AssetContainer.
  46208. * @param scene The scene the AssetContainer belongs to.
  46209. */
  46210. constructor(scene: Scene);
  46211. /**
  46212. * Instantiate or clone all meshes and add the new ones to the scene.
  46213. * Skeletons and animation groups will all be cloned
  46214. * @param nameFunction defines an optional function used to get new names for clones
  46215. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  46216. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  46217. */
  46218. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  46219. /**
  46220. * Adds all the assets from the container to the scene.
  46221. */
  46222. addAllToScene(): void;
  46223. /**
  46224. * Removes all the assets in the container from the scene
  46225. */
  46226. removeAllFromScene(): void;
  46227. /**
  46228. * Disposes all the assets in the container
  46229. */
  46230. dispose(): void;
  46231. private _moveAssets;
  46232. /**
  46233. * Removes all the assets contained in the scene and adds them to the container.
  46234. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  46235. */
  46236. moveAllFromScene(keepAssets?: KeepAssets): void;
  46237. /**
  46238. * 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.
  46239. * @returns the root mesh
  46240. */
  46241. createRootMesh(): Mesh;
  46242. /**
  46243. * Merge animations (direct and animation groups) from this asset container into a scene
  46244. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  46245. * @param animatables set of animatables to retarget to a node from the scene
  46246. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  46247. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  46248. */
  46249. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  46250. }
  46251. }
  46252. declare module "babylonjs/abstractScene" {
  46253. import { Scene } from "babylonjs/scene";
  46254. import { Nullable } from "babylonjs/types";
  46255. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46256. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46257. import { Geometry } from "babylonjs/Meshes/geometry";
  46258. import { Skeleton } from "babylonjs/Bones/skeleton";
  46259. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  46260. import { AssetContainer } from "babylonjs/assetContainer";
  46261. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  46262. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  46263. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46264. import { Material } from "babylonjs/Materials/material";
  46265. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  46266. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  46267. import { Camera } from "babylonjs/Cameras/camera";
  46268. import { Light } from "babylonjs/Lights/light";
  46269. import { Node } from "babylonjs/node";
  46270. import { Animation } from "babylonjs/Animations/animation";
  46271. /**
  46272. * Defines how the parser contract is defined.
  46273. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  46274. */
  46275. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  46276. /**
  46277. * Defines how the individual parser contract is defined.
  46278. * These parser can parse an individual asset
  46279. */
  46280. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  46281. /**
  46282. * Base class of the scene acting as a container for the different elements composing a scene.
  46283. * This class is dynamically extended by the different components of the scene increasing
  46284. * flexibility and reducing coupling
  46285. */
  46286. export abstract class AbstractScene {
  46287. /**
  46288. * Stores the list of available parsers in the application.
  46289. */
  46290. private static _BabylonFileParsers;
  46291. /**
  46292. * Stores the list of available individual parsers in the application.
  46293. */
  46294. private static _IndividualBabylonFileParsers;
  46295. /**
  46296. * Adds a parser in the list of available ones
  46297. * @param name Defines the name of the parser
  46298. * @param parser Defines the parser to add
  46299. */
  46300. static AddParser(name: string, parser: BabylonFileParser): void;
  46301. /**
  46302. * Gets a general parser from the list of avaialble ones
  46303. * @param name Defines the name of the parser
  46304. * @returns the requested parser or null
  46305. */
  46306. static GetParser(name: string): Nullable<BabylonFileParser>;
  46307. /**
  46308. * Adds n individual parser in the list of available ones
  46309. * @param name Defines the name of the parser
  46310. * @param parser Defines the parser to add
  46311. */
  46312. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  46313. /**
  46314. * Gets an individual parser from the list of avaialble ones
  46315. * @param name Defines the name of the parser
  46316. * @returns the requested parser or null
  46317. */
  46318. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  46319. /**
  46320. * Parser json data and populate both a scene and its associated container object
  46321. * @param jsonData Defines the data to parse
  46322. * @param scene Defines the scene to parse the data for
  46323. * @param container Defines the container attached to the parsing sequence
  46324. * @param rootUrl Defines the root url of the data
  46325. */
  46326. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  46327. /**
  46328. * Gets the list of root nodes (ie. nodes with no parent)
  46329. */
  46330. rootNodes: Node[];
  46331. /** All of the cameras added to this scene
  46332. * @see https://doc.babylonjs.com/babylon101/cameras
  46333. */
  46334. cameras: Camera[];
  46335. /**
  46336. * All of the lights added to this scene
  46337. * @see https://doc.babylonjs.com/babylon101/lights
  46338. */
  46339. lights: Light[];
  46340. /**
  46341. * All of the (abstract) meshes added to this scene
  46342. */
  46343. meshes: AbstractMesh[];
  46344. /**
  46345. * The list of skeletons added to the scene
  46346. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  46347. */
  46348. skeletons: Skeleton[];
  46349. /**
  46350. * All of the particle systems added to this scene
  46351. * @see https://doc.babylonjs.com/babylon101/particles
  46352. */
  46353. particleSystems: IParticleSystem[];
  46354. /**
  46355. * Gets a list of Animations associated with the scene
  46356. */
  46357. animations: Animation[];
  46358. /**
  46359. * All of the animation groups added to this scene
  46360. * @see https://doc.babylonjs.com/how_to/group
  46361. */
  46362. animationGroups: AnimationGroup[];
  46363. /**
  46364. * All of the multi-materials added to this scene
  46365. * @see https://doc.babylonjs.com/how_to/multi_materials
  46366. */
  46367. multiMaterials: MultiMaterial[];
  46368. /**
  46369. * All of the materials added to this scene
  46370. * In the context of a Scene, it is not supposed to be modified manually.
  46371. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  46372. * Note also that the order of the Material within the array is not significant and might change.
  46373. * @see https://doc.babylonjs.com/babylon101/materials
  46374. */
  46375. materials: Material[];
  46376. /**
  46377. * The list of morph target managers added to the scene
  46378. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  46379. */
  46380. morphTargetManagers: MorphTargetManager[];
  46381. /**
  46382. * The list of geometries used in the scene.
  46383. */
  46384. geometries: Geometry[];
  46385. /**
  46386. * All of the tranform nodes added to this scene
  46387. * In the context of a Scene, it is not supposed to be modified manually.
  46388. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  46389. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  46390. * @see https://doc.babylonjs.com/how_to/transformnode
  46391. */
  46392. transformNodes: TransformNode[];
  46393. /**
  46394. * ActionManagers available on the scene.
  46395. */
  46396. actionManagers: AbstractActionManager[];
  46397. /**
  46398. * Textures to keep.
  46399. */
  46400. textures: BaseTexture[];
  46401. /** @hidden */
  46402. protected _environmentTexture: Nullable<BaseTexture>;
  46403. /**
  46404. * Texture used in all pbr material as the reflection texture.
  46405. * As in the majority of the scene they are the same (exception for multi room and so on),
  46406. * this is easier to reference from here than from all the materials.
  46407. */
  46408. get environmentTexture(): Nullable<BaseTexture>;
  46409. set environmentTexture(value: Nullable<BaseTexture>);
  46410. /**
  46411. * The list of postprocesses added to the scene
  46412. */
  46413. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  46414. /**
  46415. * @returns all meshes, lights, cameras, transformNodes and bones
  46416. */
  46417. getNodes(): Array<Node>;
  46418. }
  46419. }
  46420. declare module "babylonjs/Audio/sound" {
  46421. import { Observable } from "babylonjs/Misc/observable";
  46422. import { Vector3 } from "babylonjs/Maths/math.vector";
  46423. import { Nullable } from "babylonjs/types";
  46424. import { Scene } from "babylonjs/scene";
  46425. import { TransformNode } from "babylonjs/Meshes/transformNode";
  46426. /**
  46427. * Interface used to define options for Sound class
  46428. */
  46429. export interface ISoundOptions {
  46430. /**
  46431. * Does the sound autoplay once loaded.
  46432. */
  46433. autoplay?: boolean;
  46434. /**
  46435. * Does the sound loop after it finishes playing once.
  46436. */
  46437. loop?: boolean;
  46438. /**
  46439. * Sound's volume
  46440. */
  46441. volume?: number;
  46442. /**
  46443. * Is it a spatial sound?
  46444. */
  46445. spatialSound?: boolean;
  46446. /**
  46447. * Maximum distance to hear that sound
  46448. */
  46449. maxDistance?: number;
  46450. /**
  46451. * Uses user defined attenuation function
  46452. */
  46453. useCustomAttenuation?: boolean;
  46454. /**
  46455. * Define the roll off factor of spatial sounds.
  46456. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46457. */
  46458. rolloffFactor?: number;
  46459. /**
  46460. * Define the reference distance the sound should be heard perfectly.
  46461. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46462. */
  46463. refDistance?: number;
  46464. /**
  46465. * Define the distance attenuation model the sound will follow.
  46466. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46467. */
  46468. distanceModel?: string;
  46469. /**
  46470. * Defines the playback speed (1 by default)
  46471. */
  46472. playbackRate?: number;
  46473. /**
  46474. * Defines if the sound is from a streaming source
  46475. */
  46476. streaming?: boolean;
  46477. /**
  46478. * Defines an optional length (in seconds) inside the sound file
  46479. */
  46480. length?: number;
  46481. /**
  46482. * Defines an optional offset (in seconds) inside the sound file
  46483. */
  46484. offset?: number;
  46485. /**
  46486. * If true, URLs will not be required to state the audio file codec to use.
  46487. */
  46488. skipCodecCheck?: boolean;
  46489. }
  46490. /**
  46491. * Defines a sound that can be played in the application.
  46492. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  46493. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  46494. */
  46495. export class Sound {
  46496. /**
  46497. * The name of the sound in the scene.
  46498. */
  46499. name: string;
  46500. /**
  46501. * Does the sound autoplay once loaded.
  46502. */
  46503. autoplay: boolean;
  46504. /**
  46505. * Does the sound loop after it finishes playing once.
  46506. */
  46507. loop: boolean;
  46508. /**
  46509. * Does the sound use a custom attenuation curve to simulate the falloff
  46510. * happening when the source gets further away from the camera.
  46511. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46512. */
  46513. useCustomAttenuation: boolean;
  46514. /**
  46515. * The sound track id this sound belongs to.
  46516. */
  46517. soundTrackId: number;
  46518. /**
  46519. * Is this sound currently played.
  46520. */
  46521. isPlaying: boolean;
  46522. /**
  46523. * Is this sound currently paused.
  46524. */
  46525. isPaused: boolean;
  46526. /**
  46527. * Does this sound enables spatial sound.
  46528. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46529. */
  46530. spatialSound: boolean;
  46531. /**
  46532. * Define the reference distance the sound should be heard perfectly.
  46533. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46534. */
  46535. refDistance: number;
  46536. /**
  46537. * Define the roll off factor of spatial sounds.
  46538. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46539. */
  46540. rolloffFactor: number;
  46541. /**
  46542. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  46543. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46544. */
  46545. maxDistance: number;
  46546. /**
  46547. * Define the distance attenuation model the sound will follow.
  46548. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46549. */
  46550. distanceModel: string;
  46551. /**
  46552. * @hidden
  46553. * Back Compat
  46554. **/
  46555. onended: () => any;
  46556. /**
  46557. * Gets or sets an object used to store user defined information for the sound.
  46558. */
  46559. metadata: any;
  46560. /**
  46561. * Observable event when the current playing sound finishes.
  46562. */
  46563. onEndedObservable: Observable<Sound>;
  46564. private _panningModel;
  46565. private _playbackRate;
  46566. private _streaming;
  46567. private _startTime;
  46568. private _startOffset;
  46569. private _position;
  46570. /** @hidden */
  46571. _positionInEmitterSpace: boolean;
  46572. private _localDirection;
  46573. private _volume;
  46574. private _isReadyToPlay;
  46575. private _isDirectional;
  46576. private _readyToPlayCallback;
  46577. private _audioBuffer;
  46578. private _soundSource;
  46579. private _streamingSource;
  46580. private _soundPanner;
  46581. private _soundGain;
  46582. private _inputAudioNode;
  46583. private _outputAudioNode;
  46584. private _coneInnerAngle;
  46585. private _coneOuterAngle;
  46586. private _coneOuterGain;
  46587. private _scene;
  46588. private _connectedTransformNode;
  46589. private _customAttenuationFunction;
  46590. private _registerFunc;
  46591. private _isOutputConnected;
  46592. private _htmlAudioElement;
  46593. private _urlType;
  46594. private _length?;
  46595. private _offset?;
  46596. /** @hidden */
  46597. static _SceneComponentInitialization: (scene: Scene) => void;
  46598. /**
  46599. * Create a sound and attach it to a scene
  46600. * @param name Name of your sound
  46601. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  46602. * @param scene defines the scene the sound belongs to
  46603. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  46604. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  46605. */
  46606. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  46607. /**
  46608. * Release the sound and its associated resources
  46609. */
  46610. dispose(): void;
  46611. /**
  46612. * Gets if the sounds is ready to be played or not.
  46613. * @returns true if ready, otherwise false
  46614. */
  46615. isReady(): boolean;
  46616. private _soundLoaded;
  46617. /**
  46618. * Sets the data of the sound from an audiobuffer
  46619. * @param audioBuffer The audioBuffer containing the data
  46620. */
  46621. setAudioBuffer(audioBuffer: AudioBuffer): void;
  46622. /**
  46623. * Updates the current sounds options such as maxdistance, loop...
  46624. * @param options A JSON object containing values named as the object properties
  46625. */
  46626. updateOptions(options: ISoundOptions): void;
  46627. private _createSpatialParameters;
  46628. private _updateSpatialParameters;
  46629. /**
  46630. * Switch the panning model to HRTF:
  46631. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46632. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46633. */
  46634. switchPanningModelToHRTF(): void;
  46635. /**
  46636. * Switch the panning model to Equal Power:
  46637. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46638. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46639. */
  46640. switchPanningModelToEqualPower(): void;
  46641. private _switchPanningModel;
  46642. /**
  46643. * Connect this sound to a sound track audio node like gain...
  46644. * @param soundTrackAudioNode the sound track audio node to connect to
  46645. */
  46646. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  46647. /**
  46648. * Transform this sound into a directional source
  46649. * @param coneInnerAngle Size of the inner cone in degree
  46650. * @param coneOuterAngle Size of the outer cone in degree
  46651. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  46652. */
  46653. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  46654. /**
  46655. * Gets or sets the inner angle for the directional cone.
  46656. */
  46657. get directionalConeInnerAngle(): number;
  46658. /**
  46659. * Gets or sets the inner angle for the directional cone.
  46660. */
  46661. set directionalConeInnerAngle(value: number);
  46662. /**
  46663. * Gets or sets the outer angle for the directional cone.
  46664. */
  46665. get directionalConeOuterAngle(): number;
  46666. /**
  46667. * Gets or sets the outer angle for the directional cone.
  46668. */
  46669. set directionalConeOuterAngle(value: number);
  46670. /**
  46671. * Sets the position of the emitter if spatial sound is enabled
  46672. * @param newPosition Defines the new posisiton
  46673. */
  46674. setPosition(newPosition: Vector3): void;
  46675. /**
  46676. * Sets the local direction of the emitter if spatial sound is enabled
  46677. * @param newLocalDirection Defines the new local direction
  46678. */
  46679. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  46680. private _updateDirection;
  46681. /** @hidden */
  46682. updateDistanceFromListener(): void;
  46683. /**
  46684. * Sets a new custom attenuation function for the sound.
  46685. * @param callback Defines the function used for the attenuation
  46686. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  46687. */
  46688. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  46689. /**
  46690. * Play the sound
  46691. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  46692. * @param offset (optional) Start the sound at a specific time in seconds
  46693. * @param length (optional) Sound duration (in seconds)
  46694. */
  46695. play(time?: number, offset?: number, length?: number): void;
  46696. private _onended;
  46697. /**
  46698. * Stop the sound
  46699. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  46700. */
  46701. stop(time?: number): void;
  46702. /**
  46703. * Put the sound in pause
  46704. */
  46705. pause(): void;
  46706. /**
  46707. * Sets a dedicated volume for this sounds
  46708. * @param newVolume Define the new volume of the sound
  46709. * @param time Define time for gradual change to new volume
  46710. */
  46711. setVolume(newVolume: number, time?: number): void;
  46712. /**
  46713. * Set the sound play back rate
  46714. * @param newPlaybackRate Define the playback rate the sound should be played at
  46715. */
  46716. setPlaybackRate(newPlaybackRate: number): void;
  46717. /**
  46718. * Gets the volume of the sound.
  46719. * @returns the volume of the sound
  46720. */
  46721. getVolume(): number;
  46722. /**
  46723. * Attach the sound to a dedicated mesh
  46724. * @param transformNode The transform node to connect the sound with
  46725. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46726. */
  46727. attachToMesh(transformNode: TransformNode): void;
  46728. /**
  46729. * Detach the sound from the previously attached mesh
  46730. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  46731. */
  46732. detachFromMesh(): void;
  46733. private _onRegisterAfterWorldMatrixUpdate;
  46734. /**
  46735. * Clone the current sound in the scene.
  46736. * @returns the new sound clone
  46737. */
  46738. clone(): Nullable<Sound>;
  46739. /**
  46740. * Gets the current underlying audio buffer containing the data
  46741. * @returns the audio buffer
  46742. */
  46743. getAudioBuffer(): Nullable<AudioBuffer>;
  46744. /**
  46745. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  46746. * @returns the source node
  46747. */
  46748. getSoundSource(): Nullable<AudioBufferSourceNode>;
  46749. /**
  46750. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  46751. * @returns the gain node
  46752. */
  46753. getSoundGain(): Nullable<GainNode>;
  46754. /**
  46755. * Serializes the Sound in a JSON representation
  46756. * @returns the JSON representation of the sound
  46757. */
  46758. serialize(): any;
  46759. /**
  46760. * Parse a JSON representation of a sound to innstantiate in a given scene
  46761. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  46762. * @param scene Define the scene the new parsed sound should be created in
  46763. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  46764. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  46765. * @returns the newly parsed sound
  46766. */
  46767. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  46768. }
  46769. }
  46770. declare module "babylonjs/Actions/directAudioActions" {
  46771. import { Action } from "babylonjs/Actions/action";
  46772. import { Condition } from "babylonjs/Actions/condition";
  46773. import { Sound } from "babylonjs/Audio/sound";
  46774. /**
  46775. * This defines an action helpful to play a defined sound on a triggered action.
  46776. */
  46777. export class PlaySoundAction extends Action {
  46778. private _sound;
  46779. /**
  46780. * Instantiate the action
  46781. * @param triggerOptions defines the trigger options
  46782. * @param sound defines the sound to play
  46783. * @param condition defines the trigger related conditions
  46784. */
  46785. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46786. /** @hidden */
  46787. _prepare(): void;
  46788. /**
  46789. * Execute the action and play the sound.
  46790. */
  46791. execute(): void;
  46792. /**
  46793. * Serializes the actions and its related information.
  46794. * @param parent defines the object to serialize in
  46795. * @returns the serialized object
  46796. */
  46797. serialize(parent: any): any;
  46798. }
  46799. /**
  46800. * This defines an action helpful to stop a defined sound on a triggered action.
  46801. */
  46802. export class StopSoundAction extends Action {
  46803. private _sound;
  46804. /**
  46805. * Instantiate the action
  46806. * @param triggerOptions defines the trigger options
  46807. * @param sound defines the sound to stop
  46808. * @param condition defines the trigger related conditions
  46809. */
  46810. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  46811. /** @hidden */
  46812. _prepare(): void;
  46813. /**
  46814. * Execute the action and stop the sound.
  46815. */
  46816. execute(): void;
  46817. /**
  46818. * Serializes the actions and its related information.
  46819. * @param parent defines the object to serialize in
  46820. * @returns the serialized object
  46821. */
  46822. serialize(parent: any): any;
  46823. }
  46824. }
  46825. declare module "babylonjs/Actions/interpolateValueAction" {
  46826. import { Action } from "babylonjs/Actions/action";
  46827. import { Condition } from "babylonjs/Actions/condition";
  46828. import { Observable } from "babylonjs/Misc/observable";
  46829. /**
  46830. * This defines an action responsible to change the value of a property
  46831. * by interpolating between its current value and the newly set one once triggered.
  46832. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  46833. */
  46834. export class InterpolateValueAction extends Action {
  46835. /**
  46836. * Defines the path of the property where the value should be interpolated
  46837. */
  46838. propertyPath: string;
  46839. /**
  46840. * Defines the target value at the end of the interpolation.
  46841. */
  46842. value: any;
  46843. /**
  46844. * Defines the time it will take for the property to interpolate to the value.
  46845. */
  46846. duration: number;
  46847. /**
  46848. * Defines if the other scene animations should be stopped when the action has been triggered
  46849. */
  46850. stopOtherAnimations?: boolean;
  46851. /**
  46852. * Defines a callback raised once the interpolation animation has been done.
  46853. */
  46854. onInterpolationDone?: () => void;
  46855. /**
  46856. * Observable triggered once the interpolation animation has been done.
  46857. */
  46858. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  46859. private _target;
  46860. private _effectiveTarget;
  46861. private _property;
  46862. /**
  46863. * Instantiate the action
  46864. * @param triggerOptions defines the trigger options
  46865. * @param target defines the object containing the value to interpolate
  46866. * @param propertyPath defines the path to the property in the target object
  46867. * @param value defines the target value at the end of the interpolation
  46868. * @param duration deines the time it will take for the property to interpolate to the value.
  46869. * @param condition defines the trigger related conditions
  46870. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  46871. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  46872. */
  46873. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  46874. /** @hidden */
  46875. _prepare(): void;
  46876. /**
  46877. * Execute the action starts the value interpolation.
  46878. */
  46879. execute(): void;
  46880. /**
  46881. * Serializes the actions and its related information.
  46882. * @param parent defines the object to serialize in
  46883. * @returns the serialized object
  46884. */
  46885. serialize(parent: any): any;
  46886. }
  46887. }
  46888. declare module "babylonjs/Actions/index" {
  46889. export * from "babylonjs/Actions/abstractActionManager";
  46890. export * from "babylonjs/Actions/action";
  46891. export * from "babylonjs/Actions/actionEvent";
  46892. export * from "babylonjs/Actions/actionManager";
  46893. export * from "babylonjs/Actions/condition";
  46894. export * from "babylonjs/Actions/directActions";
  46895. export * from "babylonjs/Actions/directAudioActions";
  46896. export * from "babylonjs/Actions/interpolateValueAction";
  46897. }
  46898. declare module "babylonjs/Animations/index" {
  46899. export * from "babylonjs/Animations/animatable";
  46900. export * from "babylonjs/Animations/animation";
  46901. export * from "babylonjs/Animations/animationGroup";
  46902. export * from "babylonjs/Animations/animationPropertiesOverride";
  46903. export * from "babylonjs/Animations/easing";
  46904. export * from "babylonjs/Animations/runtimeAnimation";
  46905. export * from "babylonjs/Animations/animationEvent";
  46906. export * from "babylonjs/Animations/animationGroup";
  46907. export * from "babylonjs/Animations/animationKey";
  46908. export * from "babylonjs/Animations/animationRange";
  46909. export * from "babylonjs/Animations/animatable.interface";
  46910. }
  46911. declare module "babylonjs/Audio/soundTrack" {
  46912. import { Sound } from "babylonjs/Audio/sound";
  46913. import { Analyser } from "babylonjs/Audio/analyser";
  46914. import { Scene } from "babylonjs/scene";
  46915. /**
  46916. * Options allowed during the creation of a sound track.
  46917. */
  46918. export interface ISoundTrackOptions {
  46919. /**
  46920. * The volume the sound track should take during creation
  46921. */
  46922. volume?: number;
  46923. /**
  46924. * Define if the sound track is the main sound track of the scene
  46925. */
  46926. mainTrack?: boolean;
  46927. }
  46928. /**
  46929. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  46930. * It will be also used in a future release to apply effects on a specific track.
  46931. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46932. */
  46933. export class SoundTrack {
  46934. /**
  46935. * The unique identifier of the sound track in the scene.
  46936. */
  46937. id: number;
  46938. /**
  46939. * The list of sounds included in the sound track.
  46940. */
  46941. soundCollection: Array<Sound>;
  46942. private _outputAudioNode;
  46943. private _scene;
  46944. private _connectedAnalyser;
  46945. private _options;
  46946. private _isInitialized;
  46947. /**
  46948. * Creates a new sound track.
  46949. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  46950. * @param scene Define the scene the sound track belongs to
  46951. * @param options
  46952. */
  46953. constructor(scene: Scene, options?: ISoundTrackOptions);
  46954. private _initializeSoundTrackAudioGraph;
  46955. /**
  46956. * Release the sound track and its associated resources
  46957. */
  46958. dispose(): void;
  46959. /**
  46960. * Adds a sound to this sound track
  46961. * @param sound define the cound to add
  46962. * @ignoreNaming
  46963. */
  46964. AddSound(sound: Sound): void;
  46965. /**
  46966. * Removes a sound to this sound track
  46967. * @param sound define the cound to remove
  46968. * @ignoreNaming
  46969. */
  46970. RemoveSound(sound: Sound): void;
  46971. /**
  46972. * Set a global volume for the full sound track.
  46973. * @param newVolume Define the new volume of the sound track
  46974. */
  46975. setVolume(newVolume: number): void;
  46976. /**
  46977. * Switch the panning model to HRTF:
  46978. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  46979. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46980. */
  46981. switchPanningModelToHRTF(): void;
  46982. /**
  46983. * Switch the panning model to Equal Power:
  46984. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  46985. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  46986. */
  46987. switchPanningModelToEqualPower(): void;
  46988. /**
  46989. * Connect the sound track to an audio analyser allowing some amazing
  46990. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  46991. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  46992. * @param analyser The analyser to connect to the engine
  46993. */
  46994. connectToAnalyser(analyser: Analyser): void;
  46995. }
  46996. }
  46997. declare module "babylonjs/Audio/audioSceneComponent" {
  46998. import { Sound } from "babylonjs/Audio/sound";
  46999. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  47000. import { Nullable } from "babylonjs/types";
  47001. import { Vector3 } from "babylonjs/Maths/math.vector";
  47002. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  47003. import { Scene } from "babylonjs/scene";
  47004. import { AbstractScene } from "babylonjs/abstractScene";
  47005. import "babylonjs/Audio/audioEngine";
  47006. module "babylonjs/abstractScene" {
  47007. interface AbstractScene {
  47008. /**
  47009. * The list of sounds used in the scene.
  47010. */
  47011. sounds: Nullable<Array<Sound>>;
  47012. }
  47013. }
  47014. module "babylonjs/scene" {
  47015. interface Scene {
  47016. /**
  47017. * @hidden
  47018. * Backing field
  47019. */
  47020. _mainSoundTrack: SoundTrack;
  47021. /**
  47022. * The main sound track played by the scene.
  47023. * It cotains your primary collection of sounds.
  47024. */
  47025. mainSoundTrack: SoundTrack;
  47026. /**
  47027. * The list of sound tracks added to the scene
  47028. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47029. */
  47030. soundTracks: Nullable<Array<SoundTrack>>;
  47031. /**
  47032. * Gets a sound using a given name
  47033. * @param name defines the name to search for
  47034. * @return the found sound or null if not found at all.
  47035. */
  47036. getSoundByName(name: string): Nullable<Sound>;
  47037. /**
  47038. * Gets or sets if audio support is enabled
  47039. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47040. */
  47041. audioEnabled: boolean;
  47042. /**
  47043. * Gets or sets if audio will be output to headphones
  47044. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47045. */
  47046. headphone: boolean;
  47047. /**
  47048. * Gets or sets custom audio listener position provider
  47049. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  47050. */
  47051. audioListenerPositionProvider: Nullable<() => Vector3>;
  47052. /**
  47053. * Gets or sets a refresh rate when using 3D audio positioning
  47054. */
  47055. audioPositioningRefreshRate: number;
  47056. }
  47057. }
  47058. /**
  47059. * Defines the sound scene component responsible to manage any sounds
  47060. * in a given scene.
  47061. */
  47062. export class AudioSceneComponent implements ISceneSerializableComponent {
  47063. private static _CameraDirectionLH;
  47064. private static _CameraDirectionRH;
  47065. /**
  47066. * The component name helpfull to identify the component in the list of scene components.
  47067. */
  47068. readonly name: string;
  47069. /**
  47070. * The scene the component belongs to.
  47071. */
  47072. scene: Scene;
  47073. private _audioEnabled;
  47074. /**
  47075. * Gets whether audio is enabled or not.
  47076. * Please use related enable/disable method to switch state.
  47077. */
  47078. get audioEnabled(): boolean;
  47079. private _headphone;
  47080. /**
  47081. * Gets whether audio is outputing to headphone or not.
  47082. * Please use the according Switch methods to change output.
  47083. */
  47084. get headphone(): boolean;
  47085. /**
  47086. * Gets or sets a refresh rate when using 3D audio positioning
  47087. */
  47088. audioPositioningRefreshRate: number;
  47089. private _audioListenerPositionProvider;
  47090. /**
  47091. * Gets the current audio listener position provider
  47092. */
  47093. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  47094. /**
  47095. * Sets a custom listener position for all sounds in the scene
  47096. * By default, this is the position of the first active camera
  47097. */
  47098. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  47099. /**
  47100. * Creates a new instance of the component for the given scene
  47101. * @param scene Defines the scene to register the component in
  47102. */
  47103. constructor(scene: Scene);
  47104. /**
  47105. * Registers the component in a given scene
  47106. */
  47107. register(): void;
  47108. /**
  47109. * Rebuilds the elements related to this component in case of
  47110. * context lost for instance.
  47111. */
  47112. rebuild(): void;
  47113. /**
  47114. * Serializes the component data to the specified json object
  47115. * @param serializationObject The object to serialize to
  47116. */
  47117. serialize(serializationObject: any): void;
  47118. /**
  47119. * Adds all the elements from the container to the scene
  47120. * @param container the container holding the elements
  47121. */
  47122. addFromContainer(container: AbstractScene): void;
  47123. /**
  47124. * Removes all the elements in the container from the scene
  47125. * @param container contains the elements to remove
  47126. * @param dispose if the removed element should be disposed (default: false)
  47127. */
  47128. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47129. /**
  47130. * Disposes the component and the associated ressources.
  47131. */
  47132. dispose(): void;
  47133. /**
  47134. * Disables audio in the associated scene.
  47135. */
  47136. disableAudio(): void;
  47137. /**
  47138. * Enables audio in the associated scene.
  47139. */
  47140. enableAudio(): void;
  47141. /**
  47142. * Switch audio to headphone output.
  47143. */
  47144. switchAudioModeForHeadphones(): void;
  47145. /**
  47146. * Switch audio to normal speakers.
  47147. */
  47148. switchAudioModeForNormalSpeakers(): void;
  47149. private _cachedCameraDirection;
  47150. private _cachedCameraPosition;
  47151. private _lastCheck;
  47152. private _afterRender;
  47153. }
  47154. }
  47155. declare module "babylonjs/Audio/weightedsound" {
  47156. import { Sound } from "babylonjs/Audio/sound";
  47157. /**
  47158. * Wraps one or more Sound objects and selects one with random weight for playback.
  47159. */
  47160. export class WeightedSound {
  47161. /** When true a Sound will be selected and played when the current playing Sound completes. */
  47162. loop: boolean;
  47163. private _coneInnerAngle;
  47164. private _coneOuterAngle;
  47165. private _volume;
  47166. /** A Sound is currently playing. */
  47167. isPlaying: boolean;
  47168. /** A Sound is currently paused. */
  47169. isPaused: boolean;
  47170. private _sounds;
  47171. private _weights;
  47172. private _currentIndex?;
  47173. /**
  47174. * Creates a new WeightedSound from the list of sounds given.
  47175. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  47176. * @param sounds Array of Sounds that will be selected from.
  47177. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  47178. */
  47179. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  47180. /**
  47181. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  47182. */
  47183. get directionalConeInnerAngle(): number;
  47184. /**
  47185. * The size of cone in degress for a directional sound in which there will be no attenuation.
  47186. */
  47187. set directionalConeInnerAngle(value: number);
  47188. /**
  47189. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47190. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47191. */
  47192. get directionalConeOuterAngle(): number;
  47193. /**
  47194. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  47195. * Listener angles between innerAngle and outerAngle will falloff linearly.
  47196. */
  47197. set directionalConeOuterAngle(value: number);
  47198. /**
  47199. * Playback volume.
  47200. */
  47201. get volume(): number;
  47202. /**
  47203. * Playback volume.
  47204. */
  47205. set volume(value: number);
  47206. private _onended;
  47207. /**
  47208. * Suspend playback
  47209. */
  47210. pause(): void;
  47211. /**
  47212. * Stop playback
  47213. */
  47214. stop(): void;
  47215. /**
  47216. * Start playback.
  47217. * @param startOffset Position the clip head at a specific time in seconds.
  47218. */
  47219. play(startOffset?: number): void;
  47220. }
  47221. }
  47222. declare module "babylonjs/Audio/index" {
  47223. export * from "babylonjs/Audio/analyser";
  47224. export * from "babylonjs/Audio/audioEngine";
  47225. export * from "babylonjs/Audio/audioSceneComponent";
  47226. export * from "babylonjs/Audio/sound";
  47227. export * from "babylonjs/Audio/soundTrack";
  47228. export * from "babylonjs/Audio/weightedsound";
  47229. }
  47230. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  47231. import { Behavior } from "babylonjs/Behaviors/behavior";
  47232. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47233. import { BackEase } from "babylonjs/Animations/easing";
  47234. /**
  47235. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  47236. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  47237. */
  47238. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  47239. /**
  47240. * Gets the name of the behavior.
  47241. */
  47242. get name(): string;
  47243. /**
  47244. * The easing function used by animations
  47245. */
  47246. static EasingFunction: BackEase;
  47247. /**
  47248. * The easing mode used by animations
  47249. */
  47250. static EasingMode: number;
  47251. /**
  47252. * The duration of the animation, in milliseconds
  47253. */
  47254. transitionDuration: number;
  47255. /**
  47256. * Length of the distance animated by the transition when lower radius is reached
  47257. */
  47258. lowerRadiusTransitionRange: number;
  47259. /**
  47260. * Length of the distance animated by the transition when upper radius is reached
  47261. */
  47262. upperRadiusTransitionRange: number;
  47263. private _autoTransitionRange;
  47264. /**
  47265. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47266. */
  47267. get autoTransitionRange(): boolean;
  47268. /**
  47269. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  47270. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  47271. */
  47272. set autoTransitionRange(value: boolean);
  47273. private _attachedCamera;
  47274. private _onAfterCheckInputsObserver;
  47275. private _onMeshTargetChangedObserver;
  47276. /**
  47277. * Initializes the behavior.
  47278. */
  47279. init(): void;
  47280. /**
  47281. * Attaches the behavior to its arc rotate camera.
  47282. * @param camera Defines the camera to attach the behavior to
  47283. */
  47284. attach(camera: ArcRotateCamera): void;
  47285. /**
  47286. * Detaches the behavior from its current arc rotate camera.
  47287. */
  47288. detach(): void;
  47289. private _radiusIsAnimating;
  47290. private _radiusBounceTransition;
  47291. private _animatables;
  47292. private _cachedWheelPrecision;
  47293. /**
  47294. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  47295. * @param radiusLimit The limit to check against.
  47296. * @return Bool to indicate if at limit.
  47297. */
  47298. private _isRadiusAtLimit;
  47299. /**
  47300. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  47301. * @param radiusDelta The delta by which to animate to. Can be negative.
  47302. */
  47303. private _applyBoundRadiusAnimation;
  47304. /**
  47305. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  47306. */
  47307. protected _clearAnimationLocks(): void;
  47308. /**
  47309. * Stops and removes all animations that have been applied to the camera
  47310. */
  47311. stopAllAnimations(): void;
  47312. }
  47313. }
  47314. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  47315. import { Behavior } from "babylonjs/Behaviors/behavior";
  47316. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47317. import { ExponentialEase } from "babylonjs/Animations/easing";
  47318. import { Nullable } from "babylonjs/types";
  47319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47320. import { Vector3 } from "babylonjs/Maths/math.vector";
  47321. /**
  47322. * 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.
  47323. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  47324. */
  47325. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  47326. /**
  47327. * Gets the name of the behavior.
  47328. */
  47329. get name(): string;
  47330. private _mode;
  47331. private _radiusScale;
  47332. private _positionScale;
  47333. private _defaultElevation;
  47334. private _elevationReturnTime;
  47335. private _elevationReturnWaitTime;
  47336. private _zoomStopsAnimation;
  47337. private _framingTime;
  47338. /**
  47339. * The easing function used by animations
  47340. */
  47341. static EasingFunction: ExponentialEase;
  47342. /**
  47343. * The easing mode used by animations
  47344. */
  47345. static EasingMode: number;
  47346. /**
  47347. * Sets the current mode used by the behavior
  47348. */
  47349. set mode(mode: number);
  47350. /**
  47351. * Gets current mode used by the behavior.
  47352. */
  47353. get mode(): number;
  47354. /**
  47355. * Sets the scale applied to the radius (1 by default)
  47356. */
  47357. set radiusScale(radius: number);
  47358. /**
  47359. * Gets the scale applied to the radius
  47360. */
  47361. get radiusScale(): number;
  47362. /**
  47363. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47364. */
  47365. set positionScale(scale: number);
  47366. /**
  47367. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  47368. */
  47369. get positionScale(): number;
  47370. /**
  47371. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47372. * behaviour is triggered, in radians.
  47373. */
  47374. set defaultElevation(elevation: number);
  47375. /**
  47376. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  47377. * behaviour is triggered, in radians.
  47378. */
  47379. get defaultElevation(): number;
  47380. /**
  47381. * Sets the time (in milliseconds) taken to return to the default beta position.
  47382. * Negative value indicates camera should not return to default.
  47383. */
  47384. set elevationReturnTime(speed: number);
  47385. /**
  47386. * Gets the time (in milliseconds) taken to return to the default beta position.
  47387. * Negative value indicates camera should not return to default.
  47388. */
  47389. get elevationReturnTime(): number;
  47390. /**
  47391. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47392. */
  47393. set elevationReturnWaitTime(time: number);
  47394. /**
  47395. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  47396. */
  47397. get elevationReturnWaitTime(): number;
  47398. /**
  47399. * Sets the flag that indicates if user zooming should stop animation.
  47400. */
  47401. set zoomStopsAnimation(flag: boolean);
  47402. /**
  47403. * Gets the flag that indicates if user zooming should stop animation.
  47404. */
  47405. get zoomStopsAnimation(): boolean;
  47406. /**
  47407. * Sets the transition time when framing the mesh, in milliseconds
  47408. */
  47409. set framingTime(time: number);
  47410. /**
  47411. * Gets the transition time when framing the mesh, in milliseconds
  47412. */
  47413. get framingTime(): number;
  47414. /**
  47415. * Define if the behavior should automatically change the configured
  47416. * camera limits and sensibilities.
  47417. */
  47418. autoCorrectCameraLimitsAndSensibility: boolean;
  47419. private _onPrePointerObservableObserver;
  47420. private _onAfterCheckInputsObserver;
  47421. private _onMeshTargetChangedObserver;
  47422. private _attachedCamera;
  47423. private _isPointerDown;
  47424. private _lastInteractionTime;
  47425. /**
  47426. * Initializes the behavior.
  47427. */
  47428. init(): void;
  47429. /**
  47430. * Attaches the behavior to its arc rotate camera.
  47431. * @param camera Defines the camera to attach the behavior to
  47432. */
  47433. attach(camera: ArcRotateCamera): void;
  47434. /**
  47435. * Detaches the behavior from its current arc rotate camera.
  47436. */
  47437. detach(): void;
  47438. private _animatables;
  47439. private _betaIsAnimating;
  47440. private _betaTransition;
  47441. private _radiusTransition;
  47442. private _vectorTransition;
  47443. /**
  47444. * Targets the given mesh and updates zoom level accordingly.
  47445. * @param mesh The mesh to target.
  47446. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47447. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47448. */
  47449. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47450. /**
  47451. * Targets the given mesh with its children and updates zoom level accordingly.
  47452. * @param mesh The mesh to target.
  47453. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47454. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47455. */
  47456. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47457. /**
  47458. * Targets the given meshes with their children and updates zoom level accordingly.
  47459. * @param meshes The mesh to target.
  47460. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47461. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47462. */
  47463. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47464. /**
  47465. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  47466. * @param minimumWorld Determines the smaller position of the bounding box extend
  47467. * @param maximumWorld Determines the bigger position of the bounding box extend
  47468. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  47469. * @param onAnimationEnd Callback triggered at the end of the framing animation
  47470. */
  47471. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  47472. /**
  47473. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  47474. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  47475. * frustum width.
  47476. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  47477. * to fully enclose the mesh in the viewing frustum.
  47478. */
  47479. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  47480. /**
  47481. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  47482. * is automatically returned to its default position (expected to be above ground plane).
  47483. */
  47484. private _maintainCameraAboveGround;
  47485. /**
  47486. * Returns the frustum slope based on the canvas ratio and camera FOV
  47487. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  47488. */
  47489. private _getFrustumSlope;
  47490. /**
  47491. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  47492. */
  47493. private _clearAnimationLocks;
  47494. /**
  47495. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  47496. */
  47497. private _applyUserInteraction;
  47498. /**
  47499. * Stops and removes all animations that have been applied to the camera
  47500. */
  47501. stopAllAnimations(): void;
  47502. /**
  47503. * Gets a value indicating if the user is moving the camera
  47504. */
  47505. get isUserIsMoving(): boolean;
  47506. /**
  47507. * The camera can move all the way towards the mesh.
  47508. */
  47509. static IgnoreBoundsSizeMode: number;
  47510. /**
  47511. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  47512. */
  47513. static FitFrustumSidesMode: number;
  47514. }
  47515. }
  47516. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  47517. import { Nullable } from "babylonjs/types";
  47518. import { Camera } from "babylonjs/Cameras/camera";
  47519. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47520. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47521. /**
  47522. * Base class for Camera Pointer Inputs.
  47523. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  47524. * for example usage.
  47525. */
  47526. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  47527. /**
  47528. * Defines the camera the input is attached to.
  47529. */
  47530. abstract camera: Camera;
  47531. /**
  47532. * Whether keyboard modifier keys are pressed at time of last mouse event.
  47533. */
  47534. protected _altKey: boolean;
  47535. protected _ctrlKey: boolean;
  47536. protected _metaKey: boolean;
  47537. protected _shiftKey: boolean;
  47538. /**
  47539. * Which mouse buttons were pressed at time of last mouse event.
  47540. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  47541. */
  47542. protected _buttonsPressed: number;
  47543. /**
  47544. * Defines the buttons associated with the input to handle camera move.
  47545. */
  47546. buttons: number[];
  47547. /**
  47548. * Attach the input controls to a specific dom element to get the input from.
  47549. * @param element Defines the element the controls should be listened from
  47550. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47551. */
  47552. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47553. /**
  47554. * Detach the current controls from the specified dom element.
  47555. * @param element Defines the element to stop listening the inputs from
  47556. */
  47557. detachControl(element: Nullable<HTMLElement>): void;
  47558. /**
  47559. * Gets the class name of the current input.
  47560. * @returns the class name
  47561. */
  47562. getClassName(): string;
  47563. /**
  47564. * Get the friendly name associated with the input class.
  47565. * @returns the input friendly name
  47566. */
  47567. getSimpleName(): string;
  47568. /**
  47569. * Called on pointer POINTERDOUBLETAP event.
  47570. * Override this method to provide functionality on POINTERDOUBLETAP event.
  47571. */
  47572. protected onDoubleTap(type: string): void;
  47573. /**
  47574. * Called on pointer POINTERMOVE event if only a single touch is active.
  47575. * Override this method to provide functionality.
  47576. */
  47577. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47578. /**
  47579. * Called on pointer POINTERMOVE event if multiple touches are active.
  47580. * Override this method to provide functionality.
  47581. */
  47582. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47583. /**
  47584. * Called on JS contextmenu event.
  47585. * Override this method to provide functionality.
  47586. */
  47587. protected onContextMenu(evt: PointerEvent): void;
  47588. /**
  47589. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47590. * press.
  47591. * Override this method to provide functionality.
  47592. */
  47593. protected onButtonDown(evt: PointerEvent): void;
  47594. /**
  47595. * Called each time a new POINTERUP event occurs. Ie, for each button
  47596. * release.
  47597. * Override this method to provide functionality.
  47598. */
  47599. protected onButtonUp(evt: PointerEvent): void;
  47600. /**
  47601. * Called when window becomes inactive.
  47602. * Override this method to provide functionality.
  47603. */
  47604. protected onLostFocus(): void;
  47605. private _pointerInput;
  47606. private _observer;
  47607. private _onLostFocus;
  47608. private pointA;
  47609. private pointB;
  47610. }
  47611. }
  47612. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  47613. import { Nullable } from "babylonjs/types";
  47614. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47615. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  47616. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  47617. /**
  47618. * Manage the pointers inputs to control an arc rotate camera.
  47619. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47620. */
  47621. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  47622. /**
  47623. * Defines the camera the input is attached to.
  47624. */
  47625. camera: ArcRotateCamera;
  47626. /**
  47627. * Gets the class name of the current input.
  47628. * @returns the class name
  47629. */
  47630. getClassName(): string;
  47631. /**
  47632. * Defines the buttons associated with the input to handle camera move.
  47633. */
  47634. buttons: number[];
  47635. /**
  47636. * Defines the pointer angular sensibility along the X axis or how fast is
  47637. * the camera rotating.
  47638. */
  47639. angularSensibilityX: number;
  47640. /**
  47641. * Defines the pointer angular sensibility along the Y axis or how fast is
  47642. * the camera rotating.
  47643. */
  47644. angularSensibilityY: number;
  47645. /**
  47646. * Defines the pointer pinch precision or how fast is the camera zooming.
  47647. */
  47648. pinchPrecision: number;
  47649. /**
  47650. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47651. * from 0.
  47652. * It defines the percentage of current camera.radius to use as delta when
  47653. * pinch zoom is used.
  47654. */
  47655. pinchDeltaPercentage: number;
  47656. /**
  47657. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  47658. * that any object in the plane at the camera's target point will scale
  47659. * perfectly with finger motion.
  47660. * Overrides pinchDeltaPercentage and pinchPrecision.
  47661. */
  47662. useNaturalPinchZoom: boolean;
  47663. /**
  47664. * Defines the pointer panning sensibility or how fast is the camera moving.
  47665. */
  47666. panningSensibility: number;
  47667. /**
  47668. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  47669. */
  47670. multiTouchPanning: boolean;
  47671. /**
  47672. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  47673. * zoom (pinch) through multitouch.
  47674. */
  47675. multiTouchPanAndZoom: boolean;
  47676. /**
  47677. * Revers pinch action direction.
  47678. */
  47679. pinchInwards: boolean;
  47680. private _isPanClick;
  47681. private _twoFingerActivityCount;
  47682. private _isPinching;
  47683. /**
  47684. * Called on pointer POINTERMOVE event if only a single touch is active.
  47685. */
  47686. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47687. /**
  47688. * Called on pointer POINTERDOUBLETAP event.
  47689. */
  47690. protected onDoubleTap(type: string): void;
  47691. /**
  47692. * Called on pointer POINTERMOVE event if multiple touches are active.
  47693. */
  47694. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47695. /**
  47696. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  47697. * press.
  47698. */
  47699. protected onButtonDown(evt: PointerEvent): void;
  47700. /**
  47701. * Called each time a new POINTERUP event occurs. Ie, for each button
  47702. * release.
  47703. */
  47704. protected onButtonUp(evt: PointerEvent): void;
  47705. /**
  47706. * Called when window becomes inactive.
  47707. */
  47708. protected onLostFocus(): void;
  47709. }
  47710. }
  47711. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  47712. import { Nullable } from "babylonjs/types";
  47713. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47714. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47715. /**
  47716. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  47717. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47718. */
  47719. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  47720. /**
  47721. * Defines the camera the input is attached to.
  47722. */
  47723. camera: ArcRotateCamera;
  47724. /**
  47725. * Defines the list of key codes associated with the up action (increase alpha)
  47726. */
  47727. keysUp: number[];
  47728. /**
  47729. * Defines the list of key codes associated with the down action (decrease alpha)
  47730. */
  47731. keysDown: number[];
  47732. /**
  47733. * Defines the list of key codes associated with the left action (increase beta)
  47734. */
  47735. keysLeft: number[];
  47736. /**
  47737. * Defines the list of key codes associated with the right action (decrease beta)
  47738. */
  47739. keysRight: number[];
  47740. /**
  47741. * Defines the list of key codes associated with the reset action.
  47742. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  47743. */
  47744. keysReset: number[];
  47745. /**
  47746. * Defines the panning sensibility of the inputs.
  47747. * (How fast is the camera panning)
  47748. */
  47749. panningSensibility: number;
  47750. /**
  47751. * Defines the zooming sensibility of the inputs.
  47752. * (How fast is the camera zooming)
  47753. */
  47754. zoomingSensibility: number;
  47755. /**
  47756. * Defines whether maintaining the alt key down switch the movement mode from
  47757. * orientation to zoom.
  47758. */
  47759. useAltToZoom: boolean;
  47760. /**
  47761. * Rotation speed of the camera
  47762. */
  47763. angularSpeed: number;
  47764. private _keys;
  47765. private _ctrlPressed;
  47766. private _altPressed;
  47767. private _onCanvasBlurObserver;
  47768. private _onKeyboardObserver;
  47769. private _engine;
  47770. private _scene;
  47771. /**
  47772. * Attach the input controls to a specific dom element to get the input from.
  47773. * @param element Defines the element the controls should be listened from
  47774. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47775. */
  47776. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47777. /**
  47778. * Detach the current controls from the specified dom element.
  47779. * @param element Defines the element to stop listening the inputs from
  47780. */
  47781. detachControl(element: Nullable<HTMLElement>): void;
  47782. /**
  47783. * Update the current camera state depending on the inputs that have been used this frame.
  47784. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47785. */
  47786. checkInputs(): void;
  47787. /**
  47788. * Gets the class name of the current intput.
  47789. * @returns the class name
  47790. */
  47791. getClassName(): string;
  47792. /**
  47793. * Get the friendly name associated with the input class.
  47794. * @returns the input friendly name
  47795. */
  47796. getSimpleName(): string;
  47797. }
  47798. }
  47799. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  47800. import { Nullable } from "babylonjs/types";
  47801. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47802. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47803. /**
  47804. * Manage the mouse wheel inputs to control an arc rotate camera.
  47805. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47806. */
  47807. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  47808. /**
  47809. * Defines the camera the input is attached to.
  47810. */
  47811. camera: ArcRotateCamera;
  47812. /**
  47813. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  47814. */
  47815. wheelPrecision: number;
  47816. /**
  47817. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47818. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47819. */
  47820. wheelDeltaPercentage: number;
  47821. private _wheel;
  47822. private _observer;
  47823. private computeDeltaFromMouseWheelLegacyEvent;
  47824. /**
  47825. * Attach the input controls to a specific dom element to get the input from.
  47826. * @param element Defines the element the controls should be listened from
  47827. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47828. */
  47829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47830. /**
  47831. * Detach the current controls from the specified dom element.
  47832. * @param element Defines the element to stop listening the inputs from
  47833. */
  47834. detachControl(element: Nullable<HTMLElement>): void;
  47835. /**
  47836. * Gets the class name of the current intput.
  47837. * @returns the class name
  47838. */
  47839. getClassName(): string;
  47840. /**
  47841. * Get the friendly name associated with the input class.
  47842. * @returns the input friendly name
  47843. */
  47844. getSimpleName(): string;
  47845. }
  47846. }
  47847. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47848. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47849. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  47850. /**
  47851. * Default Inputs manager for the ArcRotateCamera.
  47852. * It groups all the default supported inputs for ease of use.
  47853. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47854. */
  47855. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  47856. /**
  47857. * Instantiates a new ArcRotateCameraInputsManager.
  47858. * @param camera Defines the camera the inputs belong to
  47859. */
  47860. constructor(camera: ArcRotateCamera);
  47861. /**
  47862. * Add mouse wheel input support to the input manager.
  47863. * @returns the current input manager
  47864. */
  47865. addMouseWheel(): ArcRotateCameraInputsManager;
  47866. /**
  47867. * Add pointers input support to the input manager.
  47868. * @returns the current input manager
  47869. */
  47870. addPointers(): ArcRotateCameraInputsManager;
  47871. /**
  47872. * Add keyboard input support to the input manager.
  47873. * @returns the current input manager
  47874. */
  47875. addKeyboard(): ArcRotateCameraInputsManager;
  47876. }
  47877. }
  47878. declare module "babylonjs/Cameras/arcRotateCamera" {
  47879. import { Observable } from "babylonjs/Misc/observable";
  47880. import { Nullable } from "babylonjs/types";
  47881. import { Scene } from "babylonjs/scene";
  47882. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  47883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47884. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  47885. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  47886. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  47887. import { Camera } from "babylonjs/Cameras/camera";
  47888. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  47889. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47890. import { Collider } from "babylonjs/Collisions/collider";
  47891. /**
  47892. * This represents an orbital type of camera.
  47893. *
  47894. * 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.
  47895. * 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.
  47896. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  47897. */
  47898. export class ArcRotateCamera extends TargetCamera {
  47899. /**
  47900. * Defines the rotation angle of the camera along the longitudinal axis.
  47901. */
  47902. alpha: number;
  47903. /**
  47904. * Defines the rotation angle of the camera along the latitudinal axis.
  47905. */
  47906. beta: number;
  47907. /**
  47908. * Defines the radius of the camera from it s target point.
  47909. */
  47910. radius: number;
  47911. protected _target: Vector3;
  47912. protected _targetHost: Nullable<AbstractMesh>;
  47913. /**
  47914. * Defines the target point of the camera.
  47915. * The camera looks towards it form the radius distance.
  47916. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  47917. */
  47918. get target(): Vector3;
  47919. set target(value: Vector3);
  47920. /**
  47921. * Define the current local position of the camera in the scene
  47922. */
  47923. get position(): Vector3;
  47924. set position(newPosition: Vector3);
  47925. protected _upToYMatrix: Matrix;
  47926. protected _YToUpMatrix: Matrix;
  47927. /**
  47928. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  47929. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  47930. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  47931. */
  47932. set upVector(vec: Vector3);
  47933. get upVector(): Vector3;
  47934. /**
  47935. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  47936. */
  47937. setMatUp(): void;
  47938. /**
  47939. * Current inertia value on the longitudinal axis.
  47940. * The bigger this number the longer it will take for the camera to stop.
  47941. */
  47942. inertialAlphaOffset: number;
  47943. /**
  47944. * Current inertia value on the latitudinal axis.
  47945. * The bigger this number the longer it will take for the camera to stop.
  47946. */
  47947. inertialBetaOffset: number;
  47948. /**
  47949. * Current inertia value on the radius axis.
  47950. * The bigger this number the longer it will take for the camera to stop.
  47951. */
  47952. inertialRadiusOffset: number;
  47953. /**
  47954. * Minimum allowed angle on the longitudinal axis.
  47955. * This can help limiting how the Camera is able to move in the scene.
  47956. */
  47957. lowerAlphaLimit: Nullable<number>;
  47958. /**
  47959. * Maximum allowed angle on the longitudinal axis.
  47960. * This can help limiting how the Camera is able to move in the scene.
  47961. */
  47962. upperAlphaLimit: Nullable<number>;
  47963. /**
  47964. * Minimum allowed angle on the latitudinal axis.
  47965. * This can help limiting how the Camera is able to move in the scene.
  47966. */
  47967. lowerBetaLimit: number;
  47968. /**
  47969. * Maximum allowed angle on the latitudinal axis.
  47970. * This can help limiting how the Camera is able to move in the scene.
  47971. */
  47972. upperBetaLimit: number;
  47973. /**
  47974. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  47975. * This can help limiting how the Camera is able to move in the scene.
  47976. */
  47977. lowerRadiusLimit: Nullable<number>;
  47978. /**
  47979. * Maximum allowed distance of the camera to the target (The camera can not get further).
  47980. * This can help limiting how the Camera is able to move in the scene.
  47981. */
  47982. upperRadiusLimit: Nullable<number>;
  47983. /**
  47984. * Defines the current inertia value used during panning of the camera along the X axis.
  47985. */
  47986. inertialPanningX: number;
  47987. /**
  47988. * Defines the current inertia value used during panning of the camera along the Y axis.
  47989. */
  47990. inertialPanningY: number;
  47991. /**
  47992. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  47993. * Basically if your fingers moves away from more than this distance you will be considered
  47994. * in pinch mode.
  47995. */
  47996. pinchToPanMaxDistance: number;
  47997. /**
  47998. * Defines the maximum distance the camera can pan.
  47999. * This could help keeping the cammera always in your scene.
  48000. */
  48001. panningDistanceLimit: Nullable<number>;
  48002. /**
  48003. * Defines the target of the camera before paning.
  48004. */
  48005. panningOriginTarget: Vector3;
  48006. /**
  48007. * Defines the value of the inertia used during panning.
  48008. * 0 would mean stop inertia and one would mean no decelleration at all.
  48009. */
  48010. panningInertia: number;
  48011. /**
  48012. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  48013. */
  48014. get angularSensibilityX(): number;
  48015. set angularSensibilityX(value: number);
  48016. /**
  48017. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  48018. */
  48019. get angularSensibilityY(): number;
  48020. set angularSensibilityY(value: number);
  48021. /**
  48022. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  48023. */
  48024. get pinchPrecision(): number;
  48025. set pinchPrecision(value: number);
  48026. /**
  48027. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  48028. * It will be used instead of pinchDeltaPrecision if different from 0.
  48029. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48030. */
  48031. get pinchDeltaPercentage(): number;
  48032. set pinchDeltaPercentage(value: number);
  48033. /**
  48034. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  48035. * and pinch delta percentage.
  48036. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  48037. * that any object in the plane at the camera's target point will scale
  48038. * perfectly with finger motion.
  48039. */
  48040. get useNaturalPinchZoom(): boolean;
  48041. set useNaturalPinchZoom(value: boolean);
  48042. /**
  48043. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  48044. */
  48045. get panningSensibility(): number;
  48046. set panningSensibility(value: number);
  48047. /**
  48048. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  48049. */
  48050. get keysUp(): number[];
  48051. set keysUp(value: number[]);
  48052. /**
  48053. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  48054. */
  48055. get keysDown(): number[];
  48056. set keysDown(value: number[]);
  48057. /**
  48058. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  48059. */
  48060. get keysLeft(): number[];
  48061. set keysLeft(value: number[]);
  48062. /**
  48063. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  48064. */
  48065. get keysRight(): number[];
  48066. set keysRight(value: number[]);
  48067. /**
  48068. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  48069. */
  48070. get wheelPrecision(): number;
  48071. set wheelPrecision(value: number);
  48072. /**
  48073. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  48074. * It will be used instead of pinchDeltaPrecision if different from 0.
  48075. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  48076. */
  48077. get wheelDeltaPercentage(): number;
  48078. set wheelDeltaPercentage(value: number);
  48079. /**
  48080. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  48081. */
  48082. zoomOnFactor: number;
  48083. /**
  48084. * Defines a screen offset for the camera position.
  48085. */
  48086. targetScreenOffset: Vector2;
  48087. /**
  48088. * Allows the camera to be completely reversed.
  48089. * If false the camera can not arrive upside down.
  48090. */
  48091. allowUpsideDown: boolean;
  48092. /**
  48093. * Define if double tap/click is used to restore the previously saved state of the camera.
  48094. */
  48095. useInputToRestoreState: boolean;
  48096. /** @hidden */
  48097. _viewMatrix: Matrix;
  48098. /** @hidden */
  48099. _useCtrlForPanning: boolean;
  48100. /** @hidden */
  48101. _panningMouseButton: number;
  48102. /**
  48103. * Defines the input associated to the camera.
  48104. */
  48105. inputs: ArcRotateCameraInputsManager;
  48106. /** @hidden */
  48107. _reset: () => void;
  48108. /**
  48109. * Defines the allowed panning axis.
  48110. */
  48111. panningAxis: Vector3;
  48112. protected _localDirection: Vector3;
  48113. protected _transformedDirection: Vector3;
  48114. private _bouncingBehavior;
  48115. /**
  48116. * Gets the bouncing behavior of the camera if it has been enabled.
  48117. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48118. */
  48119. get bouncingBehavior(): Nullable<BouncingBehavior>;
  48120. /**
  48121. * Defines if the bouncing behavior of the camera is enabled on the camera.
  48122. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  48123. */
  48124. get useBouncingBehavior(): boolean;
  48125. set useBouncingBehavior(value: boolean);
  48126. private _framingBehavior;
  48127. /**
  48128. * Gets the framing behavior of the camera if it has been enabled.
  48129. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48130. */
  48131. get framingBehavior(): Nullable<FramingBehavior>;
  48132. /**
  48133. * Defines if the framing behavior of the camera is enabled on the camera.
  48134. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  48135. */
  48136. get useFramingBehavior(): boolean;
  48137. set useFramingBehavior(value: boolean);
  48138. private _autoRotationBehavior;
  48139. /**
  48140. * Gets the auto rotation behavior of the camera if it has been enabled.
  48141. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48142. */
  48143. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  48144. /**
  48145. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  48146. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48147. */
  48148. get useAutoRotationBehavior(): boolean;
  48149. set useAutoRotationBehavior(value: boolean);
  48150. /**
  48151. * Observable triggered when the mesh target has been changed on the camera.
  48152. */
  48153. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  48154. /**
  48155. * Event raised when the camera is colliding with a mesh.
  48156. */
  48157. onCollide: (collidedMesh: AbstractMesh) => void;
  48158. /**
  48159. * Defines whether the camera should check collision with the objects oh the scene.
  48160. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  48161. */
  48162. checkCollisions: boolean;
  48163. /**
  48164. * Defines the collision radius of the camera.
  48165. * This simulates a sphere around the camera.
  48166. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  48167. */
  48168. collisionRadius: Vector3;
  48169. protected _collider: Collider;
  48170. protected _previousPosition: Vector3;
  48171. protected _collisionVelocity: Vector3;
  48172. protected _newPosition: Vector3;
  48173. protected _previousAlpha: number;
  48174. protected _previousBeta: number;
  48175. protected _previousRadius: number;
  48176. protected _collisionTriggered: boolean;
  48177. protected _targetBoundingCenter: Nullable<Vector3>;
  48178. private _computationVector;
  48179. /**
  48180. * Instantiates a new ArcRotateCamera in a given scene
  48181. * @param name Defines the name of the camera
  48182. * @param alpha Defines the camera rotation along the logitudinal axis
  48183. * @param beta Defines the camera rotation along the latitudinal axis
  48184. * @param radius Defines the camera distance from its target
  48185. * @param target Defines the camera target
  48186. * @param scene Defines the scene the camera belongs to
  48187. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  48188. */
  48189. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  48190. /** @hidden */
  48191. _initCache(): void;
  48192. /** @hidden */
  48193. _updateCache(ignoreParentClass?: boolean): void;
  48194. protected _getTargetPosition(): Vector3;
  48195. private _storedAlpha;
  48196. private _storedBeta;
  48197. private _storedRadius;
  48198. private _storedTarget;
  48199. private _storedTargetScreenOffset;
  48200. /**
  48201. * Stores the current state of the camera (alpha, beta, radius and target)
  48202. * @returns the camera itself
  48203. */
  48204. storeState(): Camera;
  48205. /**
  48206. * @hidden
  48207. * Restored camera state. You must call storeState() first
  48208. */
  48209. _restoreStateValues(): boolean;
  48210. /** @hidden */
  48211. _isSynchronizedViewMatrix(): boolean;
  48212. /**
  48213. * Attached controls to the current camera.
  48214. * @param element Defines the element the controls should be listened from
  48215. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48216. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  48217. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  48218. */
  48219. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  48220. /**
  48221. * Detach the current controls from the camera.
  48222. * The camera will stop reacting to inputs.
  48223. * @param element Defines the element to stop listening the inputs from
  48224. */
  48225. detachControl(element: HTMLElement): void;
  48226. /** @hidden */
  48227. _checkInputs(): void;
  48228. protected _checkLimits(): void;
  48229. /**
  48230. * Rebuilds angles (alpha, beta) and radius from the give position and target
  48231. */
  48232. rebuildAnglesAndRadius(): void;
  48233. /**
  48234. * Use a position to define the current camera related information like alpha, beta and radius
  48235. * @param position Defines the position to set the camera at
  48236. */
  48237. setPosition(position: Vector3): void;
  48238. /**
  48239. * Defines the target the camera should look at.
  48240. * This will automatically adapt alpha beta and radius to fit within the new target.
  48241. * @param target Defines the new target as a Vector or a mesh
  48242. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  48243. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  48244. */
  48245. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  48246. /** @hidden */
  48247. _getViewMatrix(): Matrix;
  48248. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  48249. /**
  48250. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  48251. * @param meshes Defines the mesh to zoom on
  48252. * @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)
  48253. */
  48254. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  48255. /**
  48256. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  48257. * The target will be changed but the radius
  48258. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  48259. * @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)
  48260. */
  48261. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  48262. min: Vector3;
  48263. max: Vector3;
  48264. distance: number;
  48265. }, doNotUpdateMaxZ?: boolean): void;
  48266. /**
  48267. * @override
  48268. * Override Camera.createRigCamera
  48269. */
  48270. createRigCamera(name: string, cameraIndex: number): Camera;
  48271. /**
  48272. * @hidden
  48273. * @override
  48274. * Override Camera._updateRigCameras
  48275. */
  48276. _updateRigCameras(): void;
  48277. /**
  48278. * Destroy the camera and release the current resources hold by it.
  48279. */
  48280. dispose(): void;
  48281. /**
  48282. * Gets the current object class name.
  48283. * @return the class name
  48284. */
  48285. getClassName(): string;
  48286. }
  48287. }
  48288. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  48289. import { Behavior } from "babylonjs/Behaviors/behavior";
  48290. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48291. /**
  48292. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  48293. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  48294. */
  48295. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  48296. /**
  48297. * Gets the name of the behavior.
  48298. */
  48299. get name(): string;
  48300. private _zoomStopsAnimation;
  48301. private _idleRotationSpeed;
  48302. private _idleRotationWaitTime;
  48303. private _idleRotationSpinupTime;
  48304. /**
  48305. * Sets the flag that indicates if user zooming should stop animation.
  48306. */
  48307. set zoomStopsAnimation(flag: boolean);
  48308. /**
  48309. * Gets the flag that indicates if user zooming should stop animation.
  48310. */
  48311. get zoomStopsAnimation(): boolean;
  48312. /**
  48313. * Sets the default speed at which the camera rotates around the model.
  48314. */
  48315. set idleRotationSpeed(speed: number);
  48316. /**
  48317. * Gets the default speed at which the camera rotates around the model.
  48318. */
  48319. get idleRotationSpeed(): number;
  48320. /**
  48321. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  48322. */
  48323. set idleRotationWaitTime(time: number);
  48324. /**
  48325. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  48326. */
  48327. get idleRotationWaitTime(): number;
  48328. /**
  48329. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48330. */
  48331. set idleRotationSpinupTime(time: number);
  48332. /**
  48333. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  48334. */
  48335. get idleRotationSpinupTime(): number;
  48336. /**
  48337. * Gets a value indicating if the camera is currently rotating because of this behavior
  48338. */
  48339. get rotationInProgress(): boolean;
  48340. private _onPrePointerObservableObserver;
  48341. private _onAfterCheckInputsObserver;
  48342. private _attachedCamera;
  48343. private _isPointerDown;
  48344. private _lastFrameTime;
  48345. private _lastInteractionTime;
  48346. private _cameraRotationSpeed;
  48347. /**
  48348. * Initializes the behavior.
  48349. */
  48350. init(): void;
  48351. /**
  48352. * Attaches the behavior to its arc rotate camera.
  48353. * @param camera Defines the camera to attach the behavior to
  48354. */
  48355. attach(camera: ArcRotateCamera): void;
  48356. /**
  48357. * Detaches the behavior from its current arc rotate camera.
  48358. */
  48359. detach(): void;
  48360. /**
  48361. * Returns true if user is scrolling.
  48362. * @return true if user is scrolling.
  48363. */
  48364. private _userIsZooming;
  48365. private _lastFrameRadius;
  48366. private _shouldAnimationStopForInteraction;
  48367. /**
  48368. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  48369. */
  48370. private _applyUserInteraction;
  48371. private _userIsMoving;
  48372. }
  48373. }
  48374. declare module "babylonjs/Behaviors/Cameras/index" {
  48375. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  48376. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  48377. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  48378. }
  48379. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  48380. import { Mesh } from "babylonjs/Meshes/mesh";
  48381. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48382. import { Behavior } from "babylonjs/Behaviors/behavior";
  48383. /**
  48384. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  48385. */
  48386. export class AttachToBoxBehavior implements Behavior<Mesh> {
  48387. private ui;
  48388. /**
  48389. * The name of the behavior
  48390. */
  48391. name: string;
  48392. /**
  48393. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  48394. */
  48395. distanceAwayFromFace: number;
  48396. /**
  48397. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  48398. */
  48399. distanceAwayFromBottomOfFace: number;
  48400. private _faceVectors;
  48401. private _target;
  48402. private _scene;
  48403. private _onRenderObserver;
  48404. private _tmpMatrix;
  48405. private _tmpVector;
  48406. /**
  48407. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  48408. * @param ui The transform node that should be attched to the mesh
  48409. */
  48410. constructor(ui: TransformNode);
  48411. /**
  48412. * Initializes the behavior
  48413. */
  48414. init(): void;
  48415. private _closestFace;
  48416. private _zeroVector;
  48417. private _lookAtTmpMatrix;
  48418. private _lookAtToRef;
  48419. /**
  48420. * Attaches the AttachToBoxBehavior to the passed in mesh
  48421. * @param target The mesh that the specified node will be attached to
  48422. */
  48423. attach(target: Mesh): void;
  48424. /**
  48425. * Detaches the behavior from the mesh
  48426. */
  48427. detach(): void;
  48428. }
  48429. }
  48430. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  48431. import { Behavior } from "babylonjs/Behaviors/behavior";
  48432. import { Mesh } from "babylonjs/Meshes/mesh";
  48433. /**
  48434. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  48435. */
  48436. export class FadeInOutBehavior implements Behavior<Mesh> {
  48437. /**
  48438. * Time in milliseconds to delay before fading in (Default: 0)
  48439. */
  48440. delay: number;
  48441. /**
  48442. * Time in milliseconds for the mesh to fade in (Default: 300)
  48443. */
  48444. fadeInTime: number;
  48445. private _millisecondsPerFrame;
  48446. private _hovered;
  48447. private _hoverValue;
  48448. private _ownerNode;
  48449. /**
  48450. * Instatiates the FadeInOutBehavior
  48451. */
  48452. constructor();
  48453. /**
  48454. * The name of the behavior
  48455. */
  48456. get name(): string;
  48457. /**
  48458. * Initializes the behavior
  48459. */
  48460. init(): void;
  48461. /**
  48462. * Attaches the fade behavior on the passed in mesh
  48463. * @param ownerNode The mesh that will be faded in/out once attached
  48464. */
  48465. attach(ownerNode: Mesh): void;
  48466. /**
  48467. * Detaches the behavior from the mesh
  48468. */
  48469. detach(): void;
  48470. /**
  48471. * Triggers the mesh to begin fading in or out
  48472. * @param value if the object should fade in or out (true to fade in)
  48473. */
  48474. fadeIn(value: boolean): void;
  48475. private _update;
  48476. private _setAllVisibility;
  48477. }
  48478. }
  48479. declare module "babylonjs/Misc/pivotTools" {
  48480. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48481. /**
  48482. * Class containing a set of static utilities functions for managing Pivots
  48483. * @hidden
  48484. */
  48485. export class PivotTools {
  48486. private static _PivotCached;
  48487. private static _OldPivotPoint;
  48488. private static _PivotTranslation;
  48489. private static _PivotTmpVector;
  48490. private static _PivotPostMultiplyPivotMatrix;
  48491. /** @hidden */
  48492. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  48493. /** @hidden */
  48494. static _RestorePivotPoint(mesh: AbstractMesh): void;
  48495. }
  48496. }
  48497. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  48498. import { Scene } from "babylonjs/scene";
  48499. import { Vector4 } from "babylonjs/Maths/math.vector";
  48500. import { Mesh } from "babylonjs/Meshes/mesh";
  48501. import { Nullable } from "babylonjs/types";
  48502. import { Plane } from "babylonjs/Maths/math.plane";
  48503. /**
  48504. * Class containing static functions to help procedurally build meshes
  48505. */
  48506. export class PlaneBuilder {
  48507. /**
  48508. * Creates a plane mesh
  48509. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  48510. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  48511. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  48512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48513. * * 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
  48514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48515. * @param name defines the name of the mesh
  48516. * @param options defines the options used to create the mesh
  48517. * @param scene defines the hosting scene
  48518. * @returns the plane mesh
  48519. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  48520. */
  48521. static CreatePlane(name: string, options: {
  48522. size?: number;
  48523. width?: number;
  48524. height?: number;
  48525. sideOrientation?: number;
  48526. frontUVs?: Vector4;
  48527. backUVs?: Vector4;
  48528. updatable?: boolean;
  48529. sourcePlane?: Plane;
  48530. }, scene?: Nullable<Scene>): Mesh;
  48531. }
  48532. }
  48533. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  48534. import { Behavior } from "babylonjs/Behaviors/behavior";
  48535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48536. import { Observable } from "babylonjs/Misc/observable";
  48537. import { Vector3 } from "babylonjs/Maths/math.vector";
  48538. import { Ray } from "babylonjs/Culling/ray";
  48539. import "babylonjs/Meshes/Builders/planeBuilder";
  48540. /**
  48541. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  48542. */
  48543. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  48544. private static _AnyMouseID;
  48545. /**
  48546. * Abstract mesh the behavior is set on
  48547. */
  48548. attachedNode: AbstractMesh;
  48549. private _dragPlane;
  48550. private _scene;
  48551. private _pointerObserver;
  48552. private _beforeRenderObserver;
  48553. private static _planeScene;
  48554. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  48555. /**
  48556. * 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)
  48557. */
  48558. maxDragAngle: number;
  48559. /**
  48560. * @hidden
  48561. */
  48562. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  48563. /**
  48564. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48565. */
  48566. currentDraggingPointerID: number;
  48567. /**
  48568. * The last position where the pointer hit the drag plane in world space
  48569. */
  48570. lastDragPosition: Vector3;
  48571. /**
  48572. * If the behavior is currently in a dragging state
  48573. */
  48574. dragging: boolean;
  48575. /**
  48576. * 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)
  48577. */
  48578. dragDeltaRatio: number;
  48579. /**
  48580. * If the drag plane orientation should be updated during the dragging (Default: true)
  48581. */
  48582. updateDragPlane: boolean;
  48583. private _debugMode;
  48584. private _moving;
  48585. /**
  48586. * Fires each time the attached mesh is dragged with the pointer
  48587. * * delta between last drag position and current drag position in world space
  48588. * * dragDistance along the drag axis
  48589. * * dragPlaneNormal normal of the current drag plane used during the drag
  48590. * * dragPlanePoint in world space where the drag intersects the drag plane
  48591. */
  48592. onDragObservable: Observable<{
  48593. delta: Vector3;
  48594. dragPlanePoint: Vector3;
  48595. dragPlaneNormal: Vector3;
  48596. dragDistance: number;
  48597. pointerId: number;
  48598. }>;
  48599. /**
  48600. * Fires each time a drag begins (eg. mouse down on mesh)
  48601. */
  48602. onDragStartObservable: Observable<{
  48603. dragPlanePoint: Vector3;
  48604. pointerId: number;
  48605. }>;
  48606. /**
  48607. * Fires each time a drag ends (eg. mouse release after drag)
  48608. */
  48609. onDragEndObservable: Observable<{
  48610. dragPlanePoint: Vector3;
  48611. pointerId: number;
  48612. }>;
  48613. /**
  48614. * If the attached mesh should be moved when dragged
  48615. */
  48616. moveAttached: boolean;
  48617. /**
  48618. * If the drag behavior will react to drag events (Default: true)
  48619. */
  48620. enabled: boolean;
  48621. /**
  48622. * If pointer events should start and release the drag (Default: true)
  48623. */
  48624. startAndReleaseDragOnPointerEvents: boolean;
  48625. /**
  48626. * If camera controls should be detached during the drag
  48627. */
  48628. detachCameraControls: boolean;
  48629. /**
  48630. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  48631. */
  48632. useObjectOrientationForDragging: boolean;
  48633. private _options;
  48634. /**
  48635. * Gets the options used by the behavior
  48636. */
  48637. get options(): {
  48638. dragAxis?: Vector3;
  48639. dragPlaneNormal?: Vector3;
  48640. };
  48641. /**
  48642. * Sets the options used by the behavior
  48643. */
  48644. set options(options: {
  48645. dragAxis?: Vector3;
  48646. dragPlaneNormal?: Vector3;
  48647. });
  48648. /**
  48649. * Creates a pointer drag behavior that can be attached to a mesh
  48650. * @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)
  48651. */
  48652. constructor(options?: {
  48653. dragAxis?: Vector3;
  48654. dragPlaneNormal?: Vector3;
  48655. });
  48656. /**
  48657. * Predicate to determine if it is valid to move the object to a new position when it is moved
  48658. */
  48659. validateDrag: (targetPosition: Vector3) => boolean;
  48660. /**
  48661. * The name of the behavior
  48662. */
  48663. get name(): string;
  48664. /**
  48665. * Initializes the behavior
  48666. */
  48667. init(): void;
  48668. private _tmpVector;
  48669. private _alternatePickedPoint;
  48670. private _worldDragAxis;
  48671. private _targetPosition;
  48672. private _attachedElement;
  48673. /**
  48674. * Attaches the drag behavior the passed in mesh
  48675. * @param ownerNode The mesh that will be dragged around once attached
  48676. * @param predicate Predicate to use for pick filtering
  48677. */
  48678. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  48679. /**
  48680. * Force relase the drag action by code.
  48681. */
  48682. releaseDrag(): void;
  48683. private _startDragRay;
  48684. private _lastPointerRay;
  48685. /**
  48686. * Simulates the start of a pointer drag event on the behavior
  48687. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  48688. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  48689. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  48690. */
  48691. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48692. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  48693. private _dragDelta;
  48694. protected _moveDrag(ray: Ray): void;
  48695. private _pickWithRayOnDragPlane;
  48696. private _pointA;
  48697. private _pointC;
  48698. private _localAxis;
  48699. private _lookAt;
  48700. private _updateDragPlanePosition;
  48701. /**
  48702. * Detaches the behavior from the mesh
  48703. */
  48704. detach(): void;
  48705. }
  48706. }
  48707. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  48708. import { Mesh } from "babylonjs/Meshes/mesh";
  48709. import { Behavior } from "babylonjs/Behaviors/behavior";
  48710. /**
  48711. * A behavior that when attached to a mesh will allow the mesh to be scaled
  48712. */
  48713. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  48714. private _dragBehaviorA;
  48715. private _dragBehaviorB;
  48716. private _startDistance;
  48717. private _initialScale;
  48718. private _targetScale;
  48719. private _ownerNode;
  48720. private _sceneRenderObserver;
  48721. /**
  48722. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  48723. */
  48724. constructor();
  48725. /**
  48726. * The name of the behavior
  48727. */
  48728. get name(): string;
  48729. /**
  48730. * Initializes the behavior
  48731. */
  48732. init(): void;
  48733. private _getCurrentDistance;
  48734. /**
  48735. * Attaches the scale behavior the passed in mesh
  48736. * @param ownerNode The mesh that will be scaled around once attached
  48737. */
  48738. attach(ownerNode: Mesh): void;
  48739. /**
  48740. * Detaches the behavior from the mesh
  48741. */
  48742. detach(): void;
  48743. }
  48744. }
  48745. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  48746. import { Behavior } from "babylonjs/Behaviors/behavior";
  48747. import { Mesh } from "babylonjs/Meshes/mesh";
  48748. import { Observable } from "babylonjs/Misc/observable";
  48749. /**
  48750. * 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
  48751. */
  48752. export class SixDofDragBehavior implements Behavior<Mesh> {
  48753. private static _virtualScene;
  48754. private _ownerNode;
  48755. private _sceneRenderObserver;
  48756. private _scene;
  48757. private _targetPosition;
  48758. private _virtualOriginMesh;
  48759. private _virtualDragMesh;
  48760. private _pointerObserver;
  48761. private _moving;
  48762. private _startingOrientation;
  48763. private _attachedElement;
  48764. /**
  48765. * 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)
  48766. */
  48767. private zDragFactor;
  48768. /**
  48769. * If the object should rotate to face the drag origin
  48770. */
  48771. rotateDraggedObject: boolean;
  48772. /**
  48773. * If the behavior is currently in a dragging state
  48774. */
  48775. dragging: boolean;
  48776. /**
  48777. * 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)
  48778. */
  48779. dragDeltaRatio: number;
  48780. /**
  48781. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  48782. */
  48783. currentDraggingPointerID: number;
  48784. /**
  48785. * If camera controls should be detached during the drag
  48786. */
  48787. detachCameraControls: boolean;
  48788. /**
  48789. * Fires each time a drag starts
  48790. */
  48791. onDragStartObservable: Observable<{}>;
  48792. /**
  48793. * Fires each time a drag ends (eg. mouse release after drag)
  48794. */
  48795. onDragEndObservable: Observable<{}>;
  48796. /**
  48797. * 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
  48798. */
  48799. constructor();
  48800. /**
  48801. * The name of the behavior
  48802. */
  48803. get name(): string;
  48804. /**
  48805. * Initializes the behavior
  48806. */
  48807. init(): void;
  48808. /**
  48809. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  48810. */
  48811. private get _pointerCamera();
  48812. /**
  48813. * Attaches the scale behavior the passed in mesh
  48814. * @param ownerNode The mesh that will be scaled around once attached
  48815. */
  48816. attach(ownerNode: Mesh): void;
  48817. /**
  48818. * Detaches the behavior from the mesh
  48819. */
  48820. detach(): void;
  48821. }
  48822. }
  48823. declare module "babylonjs/Behaviors/Meshes/index" {
  48824. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  48825. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  48826. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  48827. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48828. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  48829. }
  48830. declare module "babylonjs/Behaviors/index" {
  48831. export * from "babylonjs/Behaviors/behavior";
  48832. export * from "babylonjs/Behaviors/Cameras/index";
  48833. export * from "babylonjs/Behaviors/Meshes/index";
  48834. }
  48835. declare module "babylonjs/Bones/boneIKController" {
  48836. import { Bone } from "babylonjs/Bones/bone";
  48837. import { Vector3 } from "babylonjs/Maths/math.vector";
  48838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48839. import { Nullable } from "babylonjs/types";
  48840. /**
  48841. * Class used to apply inverse kinematics to bones
  48842. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  48843. */
  48844. export class BoneIKController {
  48845. private static _tmpVecs;
  48846. private static _tmpQuat;
  48847. private static _tmpMats;
  48848. /**
  48849. * Gets or sets the target mesh
  48850. */
  48851. targetMesh: AbstractMesh;
  48852. /** Gets or sets the mesh used as pole */
  48853. poleTargetMesh: AbstractMesh;
  48854. /**
  48855. * Gets or sets the bone used as pole
  48856. */
  48857. poleTargetBone: Nullable<Bone>;
  48858. /**
  48859. * Gets or sets the target position
  48860. */
  48861. targetPosition: Vector3;
  48862. /**
  48863. * Gets or sets the pole target position
  48864. */
  48865. poleTargetPosition: Vector3;
  48866. /**
  48867. * Gets or sets the pole target local offset
  48868. */
  48869. poleTargetLocalOffset: Vector3;
  48870. /**
  48871. * Gets or sets the pole angle
  48872. */
  48873. poleAngle: number;
  48874. /**
  48875. * Gets or sets the mesh associated with the controller
  48876. */
  48877. mesh: AbstractMesh;
  48878. /**
  48879. * 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)
  48880. */
  48881. slerpAmount: number;
  48882. private _bone1Quat;
  48883. private _bone1Mat;
  48884. private _bone2Ang;
  48885. private _bone1;
  48886. private _bone2;
  48887. private _bone1Length;
  48888. private _bone2Length;
  48889. private _maxAngle;
  48890. private _maxReach;
  48891. private _rightHandedSystem;
  48892. private _bendAxis;
  48893. private _slerping;
  48894. private _adjustRoll;
  48895. /**
  48896. * Gets or sets maximum allowed angle
  48897. */
  48898. get maxAngle(): number;
  48899. set maxAngle(value: number);
  48900. /**
  48901. * Creates a new BoneIKController
  48902. * @param mesh defines the mesh to control
  48903. * @param bone defines the bone to control
  48904. * @param options defines options to set up the controller
  48905. */
  48906. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  48907. targetMesh?: AbstractMesh;
  48908. poleTargetMesh?: AbstractMesh;
  48909. poleTargetBone?: Bone;
  48910. poleTargetLocalOffset?: Vector3;
  48911. poleAngle?: number;
  48912. bendAxis?: Vector3;
  48913. maxAngle?: number;
  48914. slerpAmount?: number;
  48915. });
  48916. private _setMaxAngle;
  48917. /**
  48918. * Force the controller to update the bones
  48919. */
  48920. update(): void;
  48921. }
  48922. }
  48923. declare module "babylonjs/Bones/boneLookController" {
  48924. import { Vector3 } from "babylonjs/Maths/math.vector";
  48925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48926. import { Bone } from "babylonjs/Bones/bone";
  48927. import { Space } from "babylonjs/Maths/math.axis";
  48928. /**
  48929. * Class used to make a bone look toward a point in space
  48930. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  48931. */
  48932. export class BoneLookController {
  48933. private static _tmpVecs;
  48934. private static _tmpQuat;
  48935. private static _tmpMats;
  48936. /**
  48937. * The target Vector3 that the bone will look at
  48938. */
  48939. target: Vector3;
  48940. /**
  48941. * The mesh that the bone is attached to
  48942. */
  48943. mesh: AbstractMesh;
  48944. /**
  48945. * The bone that will be looking to the target
  48946. */
  48947. bone: Bone;
  48948. /**
  48949. * The up axis of the coordinate system that is used when the bone is rotated
  48950. */
  48951. upAxis: Vector3;
  48952. /**
  48953. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  48954. */
  48955. upAxisSpace: Space;
  48956. /**
  48957. * Used to make an adjustment to the yaw of the bone
  48958. */
  48959. adjustYaw: number;
  48960. /**
  48961. * Used to make an adjustment to the pitch of the bone
  48962. */
  48963. adjustPitch: number;
  48964. /**
  48965. * Used to make an adjustment to the roll of the bone
  48966. */
  48967. adjustRoll: number;
  48968. /**
  48969. * 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)
  48970. */
  48971. slerpAmount: number;
  48972. private _minYaw;
  48973. private _maxYaw;
  48974. private _minPitch;
  48975. private _maxPitch;
  48976. private _minYawSin;
  48977. private _minYawCos;
  48978. private _maxYawSin;
  48979. private _maxYawCos;
  48980. private _midYawConstraint;
  48981. private _minPitchTan;
  48982. private _maxPitchTan;
  48983. private _boneQuat;
  48984. private _slerping;
  48985. private _transformYawPitch;
  48986. private _transformYawPitchInv;
  48987. private _firstFrameSkipped;
  48988. private _yawRange;
  48989. private _fowardAxis;
  48990. /**
  48991. * Gets or sets the minimum yaw angle that the bone can look to
  48992. */
  48993. get minYaw(): number;
  48994. set minYaw(value: number);
  48995. /**
  48996. * Gets or sets the maximum yaw angle that the bone can look to
  48997. */
  48998. get maxYaw(): number;
  48999. set maxYaw(value: number);
  49000. /**
  49001. * Gets or sets the minimum pitch angle that the bone can look to
  49002. */
  49003. get minPitch(): number;
  49004. set minPitch(value: number);
  49005. /**
  49006. * Gets or sets the maximum pitch angle that the bone can look to
  49007. */
  49008. get maxPitch(): number;
  49009. set maxPitch(value: number);
  49010. /**
  49011. * Create a BoneLookController
  49012. * @param mesh the mesh that the bone belongs to
  49013. * @param bone the bone that will be looking to the target
  49014. * @param target the target Vector3 to look at
  49015. * @param options optional settings:
  49016. * * maxYaw: the maximum angle the bone will yaw to
  49017. * * minYaw: the minimum angle the bone will yaw to
  49018. * * maxPitch: the maximum angle the bone will pitch to
  49019. * * minPitch: the minimum angle the bone will yaw to
  49020. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  49021. * * upAxis: the up axis of the coordinate system
  49022. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  49023. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  49024. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  49025. * * adjustYaw: used to make an adjustment to the yaw of the bone
  49026. * * adjustPitch: used to make an adjustment to the pitch of the bone
  49027. * * adjustRoll: used to make an adjustment to the roll of the bone
  49028. **/
  49029. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  49030. maxYaw?: number;
  49031. minYaw?: number;
  49032. maxPitch?: number;
  49033. minPitch?: number;
  49034. slerpAmount?: number;
  49035. upAxis?: Vector3;
  49036. upAxisSpace?: Space;
  49037. yawAxis?: Vector3;
  49038. pitchAxis?: Vector3;
  49039. adjustYaw?: number;
  49040. adjustPitch?: number;
  49041. adjustRoll?: number;
  49042. });
  49043. /**
  49044. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  49045. */
  49046. update(): void;
  49047. private _getAngleDiff;
  49048. private _getAngleBetween;
  49049. private _isAngleBetween;
  49050. }
  49051. }
  49052. declare module "babylonjs/Bones/index" {
  49053. export * from "babylonjs/Bones/bone";
  49054. export * from "babylonjs/Bones/boneIKController";
  49055. export * from "babylonjs/Bones/boneLookController";
  49056. export * from "babylonjs/Bones/skeleton";
  49057. }
  49058. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  49059. import { Nullable } from "babylonjs/types";
  49060. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49061. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49062. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  49063. /**
  49064. * Manage the gamepad inputs to control an arc rotate camera.
  49065. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49066. */
  49067. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  49068. /**
  49069. * Defines the camera the input is attached to.
  49070. */
  49071. camera: ArcRotateCamera;
  49072. /**
  49073. * Defines the gamepad the input is gathering event from.
  49074. */
  49075. gamepad: Nullable<Gamepad>;
  49076. /**
  49077. * Defines the gamepad rotation sensiblity.
  49078. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  49079. */
  49080. gamepadRotationSensibility: number;
  49081. /**
  49082. * Defines the gamepad move sensiblity.
  49083. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  49084. */
  49085. gamepadMoveSensibility: number;
  49086. private _yAxisScale;
  49087. /**
  49088. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  49089. */
  49090. get invertYAxis(): boolean;
  49091. set invertYAxis(value: boolean);
  49092. private _onGamepadConnectedObserver;
  49093. private _onGamepadDisconnectedObserver;
  49094. /**
  49095. * Attach the input controls to a specific dom element to get the input from.
  49096. * @param element Defines the element the controls should be listened from
  49097. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49098. */
  49099. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49100. /**
  49101. * Detach the current controls from the specified dom element.
  49102. * @param element Defines the element to stop listening the inputs from
  49103. */
  49104. detachControl(element: Nullable<HTMLElement>): void;
  49105. /**
  49106. * Update the current camera state depending on the inputs that have been used this frame.
  49107. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49108. */
  49109. checkInputs(): void;
  49110. /**
  49111. * Gets the class name of the current intput.
  49112. * @returns the class name
  49113. */
  49114. getClassName(): string;
  49115. /**
  49116. * Get the friendly name associated with the input class.
  49117. * @returns the input friendly name
  49118. */
  49119. getSimpleName(): string;
  49120. }
  49121. }
  49122. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  49123. import { Nullable } from "babylonjs/types";
  49124. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  49125. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49126. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  49127. interface ArcRotateCameraInputsManager {
  49128. /**
  49129. * Add orientation input support to the input manager.
  49130. * @returns the current input manager
  49131. */
  49132. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  49133. }
  49134. }
  49135. /**
  49136. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  49137. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49138. */
  49139. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  49140. /**
  49141. * Defines the camera the input is attached to.
  49142. */
  49143. camera: ArcRotateCamera;
  49144. /**
  49145. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  49146. */
  49147. alphaCorrection: number;
  49148. /**
  49149. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  49150. */
  49151. gammaCorrection: number;
  49152. private _alpha;
  49153. private _gamma;
  49154. private _dirty;
  49155. private _deviceOrientationHandler;
  49156. /**
  49157. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  49158. */
  49159. constructor();
  49160. /**
  49161. * Attach the input controls to a specific dom element to get the input from.
  49162. * @param element Defines the element the controls should be listened from
  49163. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49164. */
  49165. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49166. /** @hidden */
  49167. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  49168. /**
  49169. * Update the current camera state depending on the inputs that have been used this frame.
  49170. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49171. */
  49172. checkInputs(): void;
  49173. /**
  49174. * Detach the current controls from the specified dom element.
  49175. * @param element Defines the element to stop listening the inputs from
  49176. */
  49177. detachControl(element: Nullable<HTMLElement>): void;
  49178. /**
  49179. * Gets the class name of the current intput.
  49180. * @returns the class name
  49181. */
  49182. getClassName(): string;
  49183. /**
  49184. * Get the friendly name associated with the input class.
  49185. * @returns the input friendly name
  49186. */
  49187. getSimpleName(): string;
  49188. }
  49189. }
  49190. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  49191. import { Nullable } from "babylonjs/types";
  49192. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49193. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49194. /**
  49195. * Listen to mouse events to control the camera.
  49196. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49197. */
  49198. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  49199. /**
  49200. * Defines the camera the input is attached to.
  49201. */
  49202. camera: FlyCamera;
  49203. /**
  49204. * Defines if touch is enabled. (Default is true.)
  49205. */
  49206. touchEnabled: boolean;
  49207. /**
  49208. * Defines the buttons associated with the input to handle camera rotation.
  49209. */
  49210. buttons: number[];
  49211. /**
  49212. * Assign buttons for Yaw control.
  49213. */
  49214. buttonsYaw: number[];
  49215. /**
  49216. * Assign buttons for Pitch control.
  49217. */
  49218. buttonsPitch: number[];
  49219. /**
  49220. * Assign buttons for Roll control.
  49221. */
  49222. buttonsRoll: number[];
  49223. /**
  49224. * Detect if any button is being pressed while mouse is moved.
  49225. * -1 = Mouse locked.
  49226. * 0 = Left button.
  49227. * 1 = Middle Button.
  49228. * 2 = Right Button.
  49229. */
  49230. activeButton: number;
  49231. /**
  49232. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  49233. * Higher values reduce its sensitivity.
  49234. */
  49235. angularSensibility: number;
  49236. private _observer;
  49237. private _rollObserver;
  49238. private previousPosition;
  49239. private noPreventDefault;
  49240. private element;
  49241. /**
  49242. * Listen to mouse events to control the camera.
  49243. * @param touchEnabled Define if touch is enabled. (Default is true.)
  49244. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49245. */
  49246. constructor(touchEnabled?: boolean);
  49247. /**
  49248. * Attach the mouse control to the HTML DOM element.
  49249. * @param element Defines the element that listens to the input events.
  49250. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  49251. */
  49252. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49253. /**
  49254. * Detach the current controls from the specified dom element.
  49255. * @param element Defines the element to stop listening the inputs from
  49256. */
  49257. detachControl(element: Nullable<HTMLElement>): void;
  49258. /**
  49259. * Gets the class name of the current input.
  49260. * @returns the class name.
  49261. */
  49262. getClassName(): string;
  49263. /**
  49264. * Get the friendly name associated with the input class.
  49265. * @returns the input's friendly name.
  49266. */
  49267. getSimpleName(): string;
  49268. private _pointerInput;
  49269. private _onMouseMove;
  49270. /**
  49271. * Rotate camera by mouse offset.
  49272. */
  49273. private rotateCamera;
  49274. }
  49275. }
  49276. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  49277. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49278. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49279. /**
  49280. * Default Inputs manager for the FlyCamera.
  49281. * It groups all the default supported inputs for ease of use.
  49282. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49283. */
  49284. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  49285. /**
  49286. * Instantiates a new FlyCameraInputsManager.
  49287. * @param camera Defines the camera the inputs belong to.
  49288. */
  49289. constructor(camera: FlyCamera);
  49290. /**
  49291. * Add keyboard input support to the input manager.
  49292. * @returns the new FlyCameraKeyboardMoveInput().
  49293. */
  49294. addKeyboard(): FlyCameraInputsManager;
  49295. /**
  49296. * Add mouse input support to the input manager.
  49297. * @param touchEnabled Enable touch screen support.
  49298. * @returns the new FlyCameraMouseInput().
  49299. */
  49300. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  49301. }
  49302. }
  49303. declare module "babylonjs/Cameras/flyCamera" {
  49304. import { Scene } from "babylonjs/scene";
  49305. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  49306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49307. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49308. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  49309. /**
  49310. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49311. * such as in a 3D Space Shooter or a Flight Simulator.
  49312. */
  49313. export class FlyCamera extends TargetCamera {
  49314. /**
  49315. * Define the collision ellipsoid of the camera.
  49316. * This is helpful for simulating a camera body, like a player's body.
  49317. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  49318. */
  49319. ellipsoid: Vector3;
  49320. /**
  49321. * Define an offset for the position of the ellipsoid around the camera.
  49322. * This can be helpful if the camera is attached away from the player's body center,
  49323. * such as at its head.
  49324. */
  49325. ellipsoidOffset: Vector3;
  49326. /**
  49327. * Enable or disable collisions of the camera with the rest of the scene objects.
  49328. */
  49329. checkCollisions: boolean;
  49330. /**
  49331. * Enable or disable gravity on the camera.
  49332. */
  49333. applyGravity: boolean;
  49334. /**
  49335. * Define the current direction the camera is moving to.
  49336. */
  49337. cameraDirection: Vector3;
  49338. /**
  49339. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  49340. * This overrides and empties cameraRotation.
  49341. */
  49342. rotationQuaternion: Quaternion;
  49343. /**
  49344. * Track Roll to maintain the wanted Rolling when looking around.
  49345. */
  49346. _trackRoll: number;
  49347. /**
  49348. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  49349. */
  49350. rollCorrect: number;
  49351. /**
  49352. * Mimic a banked turn, Rolling the camera when Yawing.
  49353. * It's recommended to use rollCorrect = 10 for faster banking correction.
  49354. */
  49355. bankedTurn: boolean;
  49356. /**
  49357. * Limit in radians for how much Roll banking will add. (Default: 90°)
  49358. */
  49359. bankedTurnLimit: number;
  49360. /**
  49361. * Value of 0 disables the banked Roll.
  49362. * Value of 1 is equal to the Yaw angle in radians.
  49363. */
  49364. bankedTurnMultiplier: number;
  49365. /**
  49366. * The inputs manager loads all the input sources, such as keyboard and mouse.
  49367. */
  49368. inputs: FlyCameraInputsManager;
  49369. /**
  49370. * Gets the input sensibility for mouse input.
  49371. * Higher values reduce sensitivity.
  49372. */
  49373. get angularSensibility(): number;
  49374. /**
  49375. * Sets the input sensibility for a mouse input.
  49376. * Higher values reduce sensitivity.
  49377. */
  49378. set angularSensibility(value: number);
  49379. /**
  49380. * Get the keys for camera movement forward.
  49381. */
  49382. get keysForward(): number[];
  49383. /**
  49384. * Set the keys for camera movement forward.
  49385. */
  49386. set keysForward(value: number[]);
  49387. /**
  49388. * Get the keys for camera movement backward.
  49389. */
  49390. get keysBackward(): number[];
  49391. set keysBackward(value: number[]);
  49392. /**
  49393. * Get the keys for camera movement up.
  49394. */
  49395. get keysUp(): number[];
  49396. /**
  49397. * Set the keys for camera movement up.
  49398. */
  49399. set keysUp(value: number[]);
  49400. /**
  49401. * Get the keys for camera movement down.
  49402. */
  49403. get keysDown(): number[];
  49404. /**
  49405. * Set the keys for camera movement down.
  49406. */
  49407. set keysDown(value: number[]);
  49408. /**
  49409. * Get the keys for camera movement left.
  49410. */
  49411. get keysLeft(): number[];
  49412. /**
  49413. * Set the keys for camera movement left.
  49414. */
  49415. set keysLeft(value: number[]);
  49416. /**
  49417. * Set the keys for camera movement right.
  49418. */
  49419. get keysRight(): number[];
  49420. /**
  49421. * Set the keys for camera movement right.
  49422. */
  49423. set keysRight(value: number[]);
  49424. /**
  49425. * Event raised when the camera collides with a mesh in the scene.
  49426. */
  49427. onCollide: (collidedMesh: AbstractMesh) => void;
  49428. private _collider;
  49429. private _needMoveForGravity;
  49430. private _oldPosition;
  49431. private _diffPosition;
  49432. private _newPosition;
  49433. /** @hidden */
  49434. _localDirection: Vector3;
  49435. /** @hidden */
  49436. _transformedDirection: Vector3;
  49437. /**
  49438. * Instantiates a FlyCamera.
  49439. * This is a flying camera, designed for 3D movement and rotation in all directions,
  49440. * such as in a 3D Space Shooter or a Flight Simulator.
  49441. * @param name Define the name of the camera in the scene.
  49442. * @param position Define the starting position of the camera in the scene.
  49443. * @param scene Define the scene the camera belongs to.
  49444. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  49445. */
  49446. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  49447. /**
  49448. * Attach a control to the HTML DOM element.
  49449. * @param element Defines the element that listens to the input events.
  49450. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  49451. */
  49452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49453. /**
  49454. * Detach a control from the HTML DOM element.
  49455. * The camera will stop reacting to that input.
  49456. * @param element Defines the element that listens to the input events.
  49457. */
  49458. detachControl(element: HTMLElement): void;
  49459. private _collisionMask;
  49460. /**
  49461. * Get the mask that the camera ignores in collision events.
  49462. */
  49463. get collisionMask(): number;
  49464. /**
  49465. * Set the mask that the camera ignores in collision events.
  49466. */
  49467. set collisionMask(mask: number);
  49468. /** @hidden */
  49469. _collideWithWorld(displacement: Vector3): void;
  49470. /** @hidden */
  49471. private _onCollisionPositionChange;
  49472. /** @hidden */
  49473. _checkInputs(): void;
  49474. /** @hidden */
  49475. _decideIfNeedsToMove(): boolean;
  49476. /** @hidden */
  49477. _updatePosition(): void;
  49478. /**
  49479. * Restore the Roll to its target value at the rate specified.
  49480. * @param rate - Higher means slower restoring.
  49481. * @hidden
  49482. */
  49483. restoreRoll(rate: number): void;
  49484. /**
  49485. * Destroy the camera and release the current resources held by it.
  49486. */
  49487. dispose(): void;
  49488. /**
  49489. * Get the current object class name.
  49490. * @returns the class name.
  49491. */
  49492. getClassName(): string;
  49493. }
  49494. }
  49495. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  49496. import { Nullable } from "babylonjs/types";
  49497. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49498. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  49499. /**
  49500. * Listen to keyboard events to control the camera.
  49501. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49502. */
  49503. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  49504. /**
  49505. * Defines the camera the input is attached to.
  49506. */
  49507. camera: FlyCamera;
  49508. /**
  49509. * The list of keyboard keys used to control the forward move of the camera.
  49510. */
  49511. keysForward: number[];
  49512. /**
  49513. * The list of keyboard keys used to control the backward move of the camera.
  49514. */
  49515. keysBackward: number[];
  49516. /**
  49517. * The list of keyboard keys used to control the forward move of the camera.
  49518. */
  49519. keysUp: number[];
  49520. /**
  49521. * The list of keyboard keys used to control the backward move of the camera.
  49522. */
  49523. keysDown: number[];
  49524. /**
  49525. * The list of keyboard keys used to control the right strafe move of the camera.
  49526. */
  49527. keysRight: number[];
  49528. /**
  49529. * The list of keyboard keys used to control the left strafe move of the camera.
  49530. */
  49531. keysLeft: number[];
  49532. private _keys;
  49533. private _onCanvasBlurObserver;
  49534. private _onKeyboardObserver;
  49535. private _engine;
  49536. private _scene;
  49537. /**
  49538. * Attach the input controls to a specific dom element to get the input from.
  49539. * @param element Defines the element the controls should be listened from
  49540. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49541. */
  49542. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49543. /**
  49544. * Detach the current controls from the specified dom element.
  49545. * @param element Defines the element to stop listening the inputs from
  49546. */
  49547. detachControl(element: Nullable<HTMLElement>): void;
  49548. /**
  49549. * Gets the class name of the current intput.
  49550. * @returns the class name
  49551. */
  49552. getClassName(): string;
  49553. /** @hidden */
  49554. _onLostFocus(e: FocusEvent): void;
  49555. /**
  49556. * Get the friendly name associated with the input class.
  49557. * @returns the input friendly name
  49558. */
  49559. getSimpleName(): string;
  49560. /**
  49561. * Update the current camera state depending on the inputs that have been used this frame.
  49562. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  49563. */
  49564. checkInputs(): void;
  49565. }
  49566. }
  49567. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  49568. import { Nullable } from "babylonjs/types";
  49569. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49570. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49571. /**
  49572. * Manage the mouse wheel inputs to control a follow camera.
  49573. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49574. */
  49575. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  49576. /**
  49577. * Defines the camera the input is attached to.
  49578. */
  49579. camera: FollowCamera;
  49580. /**
  49581. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  49582. */
  49583. axisControlRadius: boolean;
  49584. /**
  49585. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  49586. */
  49587. axisControlHeight: boolean;
  49588. /**
  49589. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  49590. */
  49591. axisControlRotation: boolean;
  49592. /**
  49593. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  49594. * relation to mouseWheel events.
  49595. */
  49596. wheelPrecision: number;
  49597. /**
  49598. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  49599. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  49600. */
  49601. wheelDeltaPercentage: number;
  49602. private _wheel;
  49603. private _observer;
  49604. /**
  49605. * Attach the input controls to a specific dom element to get the input from.
  49606. * @param element Defines the element the controls should be listened from
  49607. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49608. */
  49609. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49610. /**
  49611. * Detach the current controls from the specified dom element.
  49612. * @param element Defines the element to stop listening the inputs from
  49613. */
  49614. detachControl(element: Nullable<HTMLElement>): void;
  49615. /**
  49616. * Gets the class name of the current intput.
  49617. * @returns the class name
  49618. */
  49619. getClassName(): string;
  49620. /**
  49621. * Get the friendly name associated with the input class.
  49622. * @returns the input friendly name
  49623. */
  49624. getSimpleName(): string;
  49625. }
  49626. }
  49627. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  49628. import { Nullable } from "babylonjs/types";
  49629. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49630. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  49631. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  49632. /**
  49633. * Manage the pointers inputs to control an follow camera.
  49634. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49635. */
  49636. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  49637. /**
  49638. * Defines the camera the input is attached to.
  49639. */
  49640. camera: FollowCamera;
  49641. /**
  49642. * Gets the class name of the current input.
  49643. * @returns the class name
  49644. */
  49645. getClassName(): string;
  49646. /**
  49647. * Defines the pointer angular sensibility along the X axis or how fast is
  49648. * the camera rotating.
  49649. * A negative number will reverse the axis direction.
  49650. */
  49651. angularSensibilityX: number;
  49652. /**
  49653. * Defines the pointer angular sensibility along the Y axis or how fast is
  49654. * the camera rotating.
  49655. * A negative number will reverse the axis direction.
  49656. */
  49657. angularSensibilityY: number;
  49658. /**
  49659. * Defines the pointer pinch precision or how fast is the camera zooming.
  49660. * A negative number will reverse the axis direction.
  49661. */
  49662. pinchPrecision: number;
  49663. /**
  49664. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  49665. * from 0.
  49666. * It defines the percentage of current camera.radius to use as delta when
  49667. * pinch zoom is used.
  49668. */
  49669. pinchDeltaPercentage: number;
  49670. /**
  49671. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  49672. */
  49673. axisXControlRadius: boolean;
  49674. /**
  49675. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  49676. */
  49677. axisXControlHeight: boolean;
  49678. /**
  49679. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  49680. */
  49681. axisXControlRotation: boolean;
  49682. /**
  49683. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  49684. */
  49685. axisYControlRadius: boolean;
  49686. /**
  49687. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  49688. */
  49689. axisYControlHeight: boolean;
  49690. /**
  49691. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  49692. */
  49693. axisYControlRotation: boolean;
  49694. /**
  49695. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  49696. */
  49697. axisPinchControlRadius: boolean;
  49698. /**
  49699. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  49700. */
  49701. axisPinchControlHeight: boolean;
  49702. /**
  49703. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  49704. */
  49705. axisPinchControlRotation: boolean;
  49706. /**
  49707. * Log error messages if basic misconfiguration has occurred.
  49708. */
  49709. warningEnable: boolean;
  49710. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  49711. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  49712. private _warningCounter;
  49713. private _warning;
  49714. }
  49715. }
  49716. declare module "babylonjs/Cameras/followCameraInputsManager" {
  49717. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  49718. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49719. /**
  49720. * Default Inputs manager for the FollowCamera.
  49721. * It groups all the default supported inputs for ease of use.
  49722. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49723. */
  49724. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  49725. /**
  49726. * Instantiates a new FollowCameraInputsManager.
  49727. * @param camera Defines the camera the inputs belong to
  49728. */
  49729. constructor(camera: FollowCamera);
  49730. /**
  49731. * Add keyboard input support to the input manager.
  49732. * @returns the current input manager
  49733. */
  49734. addKeyboard(): FollowCameraInputsManager;
  49735. /**
  49736. * Add mouse wheel input support to the input manager.
  49737. * @returns the current input manager
  49738. */
  49739. addMouseWheel(): FollowCameraInputsManager;
  49740. /**
  49741. * Add pointers input support to the input manager.
  49742. * @returns the current input manager
  49743. */
  49744. addPointers(): FollowCameraInputsManager;
  49745. /**
  49746. * Add orientation input support to the input manager.
  49747. * @returns the current input manager
  49748. */
  49749. addVRDeviceOrientation(): FollowCameraInputsManager;
  49750. }
  49751. }
  49752. declare module "babylonjs/Cameras/followCamera" {
  49753. import { Nullable } from "babylonjs/types";
  49754. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  49755. import { Scene } from "babylonjs/scene";
  49756. import { Vector3 } from "babylonjs/Maths/math.vector";
  49757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49758. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  49759. /**
  49760. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  49761. * an arc rotate version arcFollowCamera are available.
  49762. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49763. */
  49764. export class FollowCamera extends TargetCamera {
  49765. /**
  49766. * Distance the follow camera should follow an object at
  49767. */
  49768. radius: number;
  49769. /**
  49770. * Minimum allowed distance of the camera to the axis of rotation
  49771. * (The camera can not get closer).
  49772. * This can help limiting how the Camera is able to move in the scene.
  49773. */
  49774. lowerRadiusLimit: Nullable<number>;
  49775. /**
  49776. * Maximum allowed distance of the camera to the axis of rotation
  49777. * (The camera can not get further).
  49778. * This can help limiting how the Camera is able to move in the scene.
  49779. */
  49780. upperRadiusLimit: Nullable<number>;
  49781. /**
  49782. * Define a rotation offset between the camera and the object it follows
  49783. */
  49784. rotationOffset: number;
  49785. /**
  49786. * Minimum allowed angle to camera position relative to target object.
  49787. * This can help limiting how the Camera is able to move in the scene.
  49788. */
  49789. lowerRotationOffsetLimit: Nullable<number>;
  49790. /**
  49791. * Maximum allowed angle to camera position relative to target object.
  49792. * This can help limiting how the Camera is able to move in the scene.
  49793. */
  49794. upperRotationOffsetLimit: Nullable<number>;
  49795. /**
  49796. * Define a height offset between the camera and the object it follows.
  49797. * It can help following an object from the top (like a car chaing a plane)
  49798. */
  49799. heightOffset: number;
  49800. /**
  49801. * Minimum allowed height of camera position relative to target object.
  49802. * This can help limiting how the Camera is able to move in the scene.
  49803. */
  49804. lowerHeightOffsetLimit: Nullable<number>;
  49805. /**
  49806. * Maximum allowed height of camera position relative to target object.
  49807. * This can help limiting how the Camera is able to move in the scene.
  49808. */
  49809. upperHeightOffsetLimit: Nullable<number>;
  49810. /**
  49811. * Define how fast the camera can accelerate to follow it s target.
  49812. */
  49813. cameraAcceleration: number;
  49814. /**
  49815. * Define the speed limit of the camera following an object.
  49816. */
  49817. maxCameraSpeed: number;
  49818. /**
  49819. * Define the target of the camera.
  49820. */
  49821. lockedTarget: Nullable<AbstractMesh>;
  49822. /**
  49823. * Defines the input associated with the camera.
  49824. */
  49825. inputs: FollowCameraInputsManager;
  49826. /**
  49827. * Instantiates the follow camera.
  49828. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49829. * @param name Define the name of the camera in the scene
  49830. * @param position Define the position of the camera
  49831. * @param scene Define the scene the camera belong to
  49832. * @param lockedTarget Define the target of the camera
  49833. */
  49834. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  49835. private _follow;
  49836. /**
  49837. * Attached controls to the current camera.
  49838. * @param element Defines the element the controls should be listened from
  49839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49840. */
  49841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  49842. /**
  49843. * Detach the current controls from the camera.
  49844. * The camera will stop reacting to inputs.
  49845. * @param element Defines the element to stop listening the inputs from
  49846. */
  49847. detachControl(element: HTMLElement): void;
  49848. /** @hidden */
  49849. _checkInputs(): void;
  49850. private _checkLimits;
  49851. /**
  49852. * Gets the camera class name.
  49853. * @returns the class name
  49854. */
  49855. getClassName(): string;
  49856. }
  49857. /**
  49858. * Arc Rotate version of the follow camera.
  49859. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  49860. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49861. */
  49862. export class ArcFollowCamera extends TargetCamera {
  49863. /** The longitudinal angle of the camera */
  49864. alpha: number;
  49865. /** The latitudinal angle of the camera */
  49866. beta: number;
  49867. /** The radius of the camera from its target */
  49868. radius: number;
  49869. private _cartesianCoordinates;
  49870. /** Define the camera target (the mesh it should follow) */
  49871. private _meshTarget;
  49872. /**
  49873. * Instantiates a new ArcFollowCamera
  49874. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  49875. * @param name Define the name of the camera
  49876. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  49877. * @param beta Define the rotation angle of the camera around the elevation axis
  49878. * @param radius Define the radius of the camera from its target point
  49879. * @param target Define the target of the camera
  49880. * @param scene Define the scene the camera belongs to
  49881. */
  49882. constructor(name: string,
  49883. /** The longitudinal angle of the camera */
  49884. alpha: number,
  49885. /** The latitudinal angle of the camera */
  49886. beta: number,
  49887. /** The radius of the camera from its target */
  49888. radius: number,
  49889. /** Define the camera target (the mesh it should follow) */
  49890. target: Nullable<AbstractMesh>, scene: Scene);
  49891. private _follow;
  49892. /** @hidden */
  49893. _checkInputs(): void;
  49894. /**
  49895. * Returns the class name of the object.
  49896. * It is mostly used internally for serialization purposes.
  49897. */
  49898. getClassName(): string;
  49899. }
  49900. }
  49901. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  49902. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  49903. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  49904. import { Nullable } from "babylonjs/types";
  49905. /**
  49906. * Manage the keyboard inputs to control the movement of a follow camera.
  49907. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  49908. */
  49909. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  49910. /**
  49911. * Defines the camera the input is attached to.
  49912. */
  49913. camera: FollowCamera;
  49914. /**
  49915. * Defines the list of key codes associated with the up action (increase heightOffset)
  49916. */
  49917. keysHeightOffsetIncr: number[];
  49918. /**
  49919. * Defines the list of key codes associated with the down action (decrease heightOffset)
  49920. */
  49921. keysHeightOffsetDecr: number[];
  49922. /**
  49923. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  49924. */
  49925. keysHeightOffsetModifierAlt: boolean;
  49926. /**
  49927. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  49928. */
  49929. keysHeightOffsetModifierCtrl: boolean;
  49930. /**
  49931. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  49932. */
  49933. keysHeightOffsetModifierShift: boolean;
  49934. /**
  49935. * Defines the list of key codes associated with the left action (increase rotationOffset)
  49936. */
  49937. keysRotationOffsetIncr: number[];
  49938. /**
  49939. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  49940. */
  49941. keysRotationOffsetDecr: number[];
  49942. /**
  49943. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  49944. */
  49945. keysRotationOffsetModifierAlt: boolean;
  49946. /**
  49947. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  49948. */
  49949. keysRotationOffsetModifierCtrl: boolean;
  49950. /**
  49951. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  49952. */
  49953. keysRotationOffsetModifierShift: boolean;
  49954. /**
  49955. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  49956. */
  49957. keysRadiusIncr: number[];
  49958. /**
  49959. * Defines the list of key codes associated with the zoom-out action (increase radius)
  49960. */
  49961. keysRadiusDecr: number[];
  49962. /**
  49963. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  49964. */
  49965. keysRadiusModifierAlt: boolean;
  49966. /**
  49967. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  49968. */
  49969. keysRadiusModifierCtrl: boolean;
  49970. /**
  49971. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  49972. */
  49973. keysRadiusModifierShift: boolean;
  49974. /**
  49975. * Defines the rate of change of heightOffset.
  49976. */
  49977. heightSensibility: number;
  49978. /**
  49979. * Defines the rate of change of rotationOffset.
  49980. */
  49981. rotationSensibility: number;
  49982. /**
  49983. * Defines the rate of change of radius.
  49984. */
  49985. radiusSensibility: number;
  49986. private _keys;
  49987. private _ctrlPressed;
  49988. private _altPressed;
  49989. private _shiftPressed;
  49990. private _onCanvasBlurObserver;
  49991. private _onKeyboardObserver;
  49992. private _engine;
  49993. private _scene;
  49994. /**
  49995. * Attach the input controls to a specific dom element to get the input from.
  49996. * @param element Defines the element the controls should be listened from
  49997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  49998. */
  49999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  50000. /**
  50001. * Detach the current controls from the specified dom element.
  50002. * @param element Defines the element to stop listening the inputs from
  50003. */
  50004. detachControl(element: Nullable<HTMLElement>): void;
  50005. /**
  50006. * Update the current camera state depending on the inputs that have been used this frame.
  50007. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50008. */
  50009. checkInputs(): void;
  50010. /**
  50011. * Gets the class name of the current input.
  50012. * @returns the class name
  50013. */
  50014. getClassName(): string;
  50015. /**
  50016. * Get the friendly name associated with the input class.
  50017. * @returns the input friendly name
  50018. */
  50019. getSimpleName(): string;
  50020. /**
  50021. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50022. * allow modification of the heightOffset value.
  50023. */
  50024. private _modifierHeightOffset;
  50025. /**
  50026. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50027. * allow modification of the rotationOffset value.
  50028. */
  50029. private _modifierRotationOffset;
  50030. /**
  50031. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  50032. * allow modification of the radius value.
  50033. */
  50034. private _modifierRadius;
  50035. }
  50036. }
  50037. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  50038. import { Nullable } from "babylonjs/types";
  50039. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50040. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50041. import { Observable } from "babylonjs/Misc/observable";
  50042. module "babylonjs/Cameras/freeCameraInputsManager" {
  50043. interface FreeCameraInputsManager {
  50044. /**
  50045. * @hidden
  50046. */
  50047. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  50048. /**
  50049. * Add orientation input support to the input manager.
  50050. * @returns the current input manager
  50051. */
  50052. addDeviceOrientation(): FreeCameraInputsManager;
  50053. }
  50054. }
  50055. /**
  50056. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  50057. * Screen rotation is taken into account.
  50058. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50059. */
  50060. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  50061. private _camera;
  50062. private _screenOrientationAngle;
  50063. private _constantTranform;
  50064. private _screenQuaternion;
  50065. private _alpha;
  50066. private _beta;
  50067. private _gamma;
  50068. /**
  50069. * Can be used to detect if a device orientation sensor is available on a device
  50070. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  50071. * @returns a promise that will resolve on orientation change
  50072. */
  50073. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  50074. /**
  50075. * @hidden
  50076. */
  50077. _onDeviceOrientationChangedObservable: Observable<void>;
  50078. /**
  50079. * Instantiates a new input
  50080. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50081. */
  50082. constructor();
  50083. /**
  50084. * Define the camera controlled by the input.
  50085. */
  50086. get camera(): FreeCamera;
  50087. set camera(camera: FreeCamera);
  50088. /**
  50089. * Attach the input controls to a specific dom element to get the input from.
  50090. * @param element Defines the element the controls should be listened from
  50091. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50092. */
  50093. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  50094. private _orientationChanged;
  50095. private _deviceOrientation;
  50096. /**
  50097. * Detach the current controls from the specified dom element.
  50098. * @param element Defines the element to stop listening the inputs from
  50099. */
  50100. detachControl(element: Nullable<HTMLElement>): void;
  50101. /**
  50102. * Update the current camera state depending on the inputs that have been used this frame.
  50103. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50104. */
  50105. checkInputs(): void;
  50106. /**
  50107. * Gets the class name of the current intput.
  50108. * @returns the class name
  50109. */
  50110. getClassName(): string;
  50111. /**
  50112. * Get the friendly name associated with the input class.
  50113. * @returns the input friendly name
  50114. */
  50115. getSimpleName(): string;
  50116. }
  50117. }
  50118. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  50119. import { Nullable } from "babylonjs/types";
  50120. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50121. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50122. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50123. /**
  50124. * Manage the gamepad inputs to control a free camera.
  50125. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50126. */
  50127. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  50128. /**
  50129. * Define the camera the input is attached to.
  50130. */
  50131. camera: FreeCamera;
  50132. /**
  50133. * Define the Gamepad controlling the input
  50134. */
  50135. gamepad: Nullable<Gamepad>;
  50136. /**
  50137. * Defines the gamepad rotation sensiblity.
  50138. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  50139. */
  50140. gamepadAngularSensibility: number;
  50141. /**
  50142. * Defines the gamepad move sensiblity.
  50143. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  50144. */
  50145. gamepadMoveSensibility: number;
  50146. private _yAxisScale;
  50147. /**
  50148. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  50149. */
  50150. get invertYAxis(): boolean;
  50151. set invertYAxis(value: boolean);
  50152. private _onGamepadConnectedObserver;
  50153. private _onGamepadDisconnectedObserver;
  50154. private _cameraTransform;
  50155. private _deltaTransform;
  50156. private _vector3;
  50157. private _vector2;
  50158. /**
  50159. * Attach the input controls to a specific dom element to get the input from.
  50160. * @param element Defines the element the controls should be listened from
  50161. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50162. */
  50163. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  50164. /**
  50165. * Detach the current controls from the specified dom element.
  50166. * @param element Defines the element to stop listening the inputs from
  50167. */
  50168. detachControl(element: Nullable<HTMLElement>): void;
  50169. /**
  50170. * Update the current camera state depending on the inputs that have been used this frame.
  50171. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50172. */
  50173. checkInputs(): void;
  50174. /**
  50175. * Gets the class name of the current intput.
  50176. * @returns the class name
  50177. */
  50178. getClassName(): string;
  50179. /**
  50180. * Get the friendly name associated with the input class.
  50181. * @returns the input friendly name
  50182. */
  50183. getSimpleName(): string;
  50184. }
  50185. }
  50186. declare module "babylonjs/Misc/virtualJoystick" {
  50187. import { Nullable } from "babylonjs/types";
  50188. import { Vector3 } from "babylonjs/Maths/math.vector";
  50189. /**
  50190. * Defines the potential axis of a Joystick
  50191. */
  50192. export enum JoystickAxis {
  50193. /** X axis */
  50194. X = 0,
  50195. /** Y axis */
  50196. Y = 1,
  50197. /** Z axis */
  50198. Z = 2
  50199. }
  50200. /**
  50201. * Represents the different customization options available
  50202. * for VirtualJoystick
  50203. */
  50204. interface VirtualJoystickCustomizations {
  50205. /**
  50206. * Size of the joystick's puck
  50207. */
  50208. puckSize: number;
  50209. /**
  50210. * Size of the joystick's container
  50211. */
  50212. containerSize: number;
  50213. /**
  50214. * Color of the joystick && puck
  50215. */
  50216. color: string;
  50217. /**
  50218. * Image URL for the joystick's puck
  50219. */
  50220. puckImage?: string;
  50221. /**
  50222. * Image URL for the joystick's container
  50223. */
  50224. containerImage?: string;
  50225. /**
  50226. * Defines the unmoving position of the joystick container
  50227. */
  50228. position?: {
  50229. x: number;
  50230. y: number;
  50231. };
  50232. /**
  50233. * Defines whether or not the joystick container is always visible
  50234. */
  50235. alwaysVisible: boolean;
  50236. /**
  50237. * Defines whether or not to limit the movement of the puck to the joystick's container
  50238. */
  50239. limitToContainer: boolean;
  50240. }
  50241. /**
  50242. * Class used to define virtual joystick (used in touch mode)
  50243. */
  50244. export class VirtualJoystick {
  50245. /**
  50246. * Gets or sets a boolean indicating that left and right values must be inverted
  50247. */
  50248. reverseLeftRight: boolean;
  50249. /**
  50250. * Gets or sets a boolean indicating that up and down values must be inverted
  50251. */
  50252. reverseUpDown: boolean;
  50253. /**
  50254. * Gets the offset value for the position (ie. the change of the position value)
  50255. */
  50256. deltaPosition: Vector3;
  50257. /**
  50258. * Gets a boolean indicating if the virtual joystick was pressed
  50259. */
  50260. pressed: boolean;
  50261. /**
  50262. * Canvas the virtual joystick will render onto, default z-index of this is 5
  50263. */
  50264. static Canvas: Nullable<HTMLCanvasElement>;
  50265. /**
  50266. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  50267. */
  50268. limitToContainer: boolean;
  50269. private static _globalJoystickIndex;
  50270. private static _alwaysVisibleSticks;
  50271. private static vjCanvasContext;
  50272. private static vjCanvasWidth;
  50273. private static vjCanvasHeight;
  50274. private static halfWidth;
  50275. private static _GetDefaultOptions;
  50276. private _action;
  50277. private _axisTargetedByLeftAndRight;
  50278. private _axisTargetedByUpAndDown;
  50279. private _joystickSensibility;
  50280. private _inversedSensibility;
  50281. private _joystickPointerID;
  50282. private _joystickColor;
  50283. private _joystickPointerPos;
  50284. private _joystickPreviousPointerPos;
  50285. private _joystickPointerStartPos;
  50286. private _deltaJoystickVector;
  50287. private _leftJoystick;
  50288. private _touches;
  50289. private _joystickPosition;
  50290. private _alwaysVisible;
  50291. private _puckImage;
  50292. private _containerImage;
  50293. private _joystickPuckSize;
  50294. private _joystickContainerSize;
  50295. private _clearPuckSize;
  50296. private _clearContainerSize;
  50297. private _clearPuckSizeOffset;
  50298. private _clearContainerSizeOffset;
  50299. private _onPointerDownHandlerRef;
  50300. private _onPointerMoveHandlerRef;
  50301. private _onPointerUpHandlerRef;
  50302. private _onResize;
  50303. /**
  50304. * Creates a new virtual joystick
  50305. * @param leftJoystick defines that the joystick is for left hand (false by default)
  50306. * @param customizations Defines the options we want to customize the VirtualJoystick
  50307. */
  50308. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  50309. /**
  50310. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  50311. * @param newJoystickSensibility defines the new sensibility
  50312. */
  50313. setJoystickSensibility(newJoystickSensibility: number): void;
  50314. private _onPointerDown;
  50315. private _onPointerMove;
  50316. private _onPointerUp;
  50317. /**
  50318. * Change the color of the virtual joystick
  50319. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  50320. */
  50321. setJoystickColor(newColor: string): void;
  50322. /**
  50323. * Size of the joystick's container
  50324. */
  50325. set containerSize(newSize: number);
  50326. get containerSize(): number;
  50327. /**
  50328. * Size of the joystick's puck
  50329. */
  50330. set puckSize(newSize: number);
  50331. get puckSize(): number;
  50332. /**
  50333. * Clears the set position of the joystick
  50334. */
  50335. clearPosition(): void;
  50336. /**
  50337. * Defines whether or not the joystick container is always visible
  50338. */
  50339. set alwaysVisible(value: boolean);
  50340. get alwaysVisible(): boolean;
  50341. /**
  50342. * Sets the constant position of the Joystick container
  50343. * @param x X axis coordinate
  50344. * @param y Y axis coordinate
  50345. */
  50346. setPosition(x: number, y: number): void;
  50347. /**
  50348. * Defines a callback to call when the joystick is touched
  50349. * @param action defines the callback
  50350. */
  50351. setActionOnTouch(action: () => any): void;
  50352. /**
  50353. * Defines which axis you'd like to control for left & right
  50354. * @param axis defines the axis to use
  50355. */
  50356. setAxisForLeftRight(axis: JoystickAxis): void;
  50357. /**
  50358. * Defines which axis you'd like to control for up & down
  50359. * @param axis defines the axis to use
  50360. */
  50361. setAxisForUpDown(axis: JoystickAxis): void;
  50362. /**
  50363. * Clears the canvas from the previous puck / container draw
  50364. */
  50365. private _clearPreviousDraw;
  50366. /**
  50367. * Loads `urlPath` to be used for the container's image
  50368. * @param urlPath defines the urlPath of an image to use
  50369. */
  50370. setContainerImage(urlPath: string): void;
  50371. /**
  50372. * Loads `urlPath` to be used for the puck's image
  50373. * @param urlPath defines the urlPath of an image to use
  50374. */
  50375. setPuckImage(urlPath: string): void;
  50376. /**
  50377. * Draws the Virtual Joystick's container
  50378. */
  50379. private _drawContainer;
  50380. /**
  50381. * Draws the Virtual Joystick's puck
  50382. */
  50383. private _drawPuck;
  50384. private _drawVirtualJoystick;
  50385. /**
  50386. * Release internal HTML canvas
  50387. */
  50388. releaseCanvas(): void;
  50389. }
  50390. }
  50391. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  50392. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  50393. import { Nullable } from "babylonjs/types";
  50394. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  50395. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50396. module "babylonjs/Cameras/freeCameraInputsManager" {
  50397. interface FreeCameraInputsManager {
  50398. /**
  50399. * Add virtual joystick input support to the input manager.
  50400. * @returns the current input manager
  50401. */
  50402. addVirtualJoystick(): FreeCameraInputsManager;
  50403. }
  50404. }
  50405. /**
  50406. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  50407. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  50408. */
  50409. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  50410. /**
  50411. * Defines the camera the input is attached to.
  50412. */
  50413. camera: FreeCamera;
  50414. private _leftjoystick;
  50415. private _rightjoystick;
  50416. /**
  50417. * Gets the left stick of the virtual joystick.
  50418. * @returns The virtual Joystick
  50419. */
  50420. getLeftJoystick(): VirtualJoystick;
  50421. /**
  50422. * Gets the right stick of the virtual joystick.
  50423. * @returns The virtual Joystick
  50424. */
  50425. getRightJoystick(): VirtualJoystick;
  50426. /**
  50427. * Update the current camera state depending on the inputs that have been used this frame.
  50428. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  50429. */
  50430. checkInputs(): void;
  50431. /**
  50432. * Attach the input controls to a specific dom element to get the input from.
  50433. * @param element Defines the element the controls should be listened from
  50434. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  50435. */
  50436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  50437. /**
  50438. * Detach the current controls from the specified dom element.
  50439. * @param element Defines the element to stop listening the inputs from
  50440. */
  50441. detachControl(element: Nullable<HTMLElement>): void;
  50442. /**
  50443. * Gets the class name of the current intput.
  50444. * @returns the class name
  50445. */
  50446. getClassName(): string;
  50447. /**
  50448. * Get the friendly name associated with the input class.
  50449. * @returns the input friendly name
  50450. */
  50451. getSimpleName(): string;
  50452. }
  50453. }
  50454. declare module "babylonjs/Cameras/Inputs/index" {
  50455. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  50456. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  50457. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  50458. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  50459. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  50460. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  50461. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  50462. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  50463. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  50464. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  50465. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50466. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  50467. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  50468. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  50469. export * from "babylonjs/Cameras/Inputs/freeCameraMouseWheelInput";
  50470. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  50471. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  50472. }
  50473. declare module "babylonjs/Cameras/touchCamera" {
  50474. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50475. import { Scene } from "babylonjs/scene";
  50476. import { Vector3 } from "babylonjs/Maths/math.vector";
  50477. /**
  50478. * This represents a FPS type of camera controlled by touch.
  50479. * This is like a universal camera minus the Gamepad controls.
  50480. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50481. */
  50482. export class TouchCamera extends FreeCamera {
  50483. /**
  50484. * Defines the touch sensibility for rotation.
  50485. * The higher the faster.
  50486. */
  50487. get touchAngularSensibility(): number;
  50488. set touchAngularSensibility(value: number);
  50489. /**
  50490. * Defines the touch sensibility for move.
  50491. * The higher the faster.
  50492. */
  50493. get touchMoveSensibility(): number;
  50494. set touchMoveSensibility(value: number);
  50495. /**
  50496. * Instantiates a new touch camera.
  50497. * This represents a FPS type of camera controlled by touch.
  50498. * This is like a universal camera minus the Gamepad controls.
  50499. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  50500. * @param name Define the name of the camera in the scene
  50501. * @param position Define the start position of the camera in the scene
  50502. * @param scene Define the scene the camera belongs to
  50503. */
  50504. constructor(name: string, position: Vector3, scene: Scene);
  50505. /**
  50506. * Gets the current object class name.
  50507. * @return the class name
  50508. */
  50509. getClassName(): string;
  50510. /** @hidden */
  50511. _setupInputs(): void;
  50512. }
  50513. }
  50514. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  50515. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  50516. import { Scene } from "babylonjs/scene";
  50517. import { Vector3 } from "babylonjs/Maths/math.vector";
  50518. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  50519. import { Axis } from "babylonjs/Maths/math.axis";
  50520. /**
  50521. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  50522. * being tilted forward or back and left or right.
  50523. */
  50524. export class DeviceOrientationCamera extends FreeCamera {
  50525. private _initialQuaternion;
  50526. private _quaternionCache;
  50527. private _tmpDragQuaternion;
  50528. private _disablePointerInputWhenUsingDeviceOrientation;
  50529. /**
  50530. * Creates a new device orientation camera
  50531. * @param name The name of the camera
  50532. * @param position The start position camera
  50533. * @param scene The scene the camera belongs to
  50534. */
  50535. constructor(name: string, position: Vector3, scene: Scene);
  50536. /**
  50537. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  50538. */
  50539. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  50540. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  50541. private _dragFactor;
  50542. /**
  50543. * Enabled turning on the y axis when the orientation sensor is active
  50544. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  50545. */
  50546. enableHorizontalDragging(dragFactor?: number): void;
  50547. /**
  50548. * Gets the current instance class name ("DeviceOrientationCamera").
  50549. * This helps avoiding instanceof at run time.
  50550. * @returns the class name
  50551. */
  50552. getClassName(): string;
  50553. /**
  50554. * @hidden
  50555. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  50556. */
  50557. _checkInputs(): void;
  50558. /**
  50559. * Reset the camera to its default orientation on the specified axis only.
  50560. * @param axis The axis to reset
  50561. */
  50562. resetToCurrentRotation(axis?: Axis): void;
  50563. }
  50564. }
  50565. declare module "babylonjs/Gamepads/xboxGamepad" {
  50566. import { Observable } from "babylonjs/Misc/observable";
  50567. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50568. /**
  50569. * Defines supported buttons for XBox360 compatible gamepads
  50570. */
  50571. export enum Xbox360Button {
  50572. /** A */
  50573. A = 0,
  50574. /** B */
  50575. B = 1,
  50576. /** X */
  50577. X = 2,
  50578. /** Y */
  50579. Y = 3,
  50580. /** Left button */
  50581. LB = 4,
  50582. /** Right button */
  50583. RB = 5,
  50584. /** Back */
  50585. Back = 8,
  50586. /** Start */
  50587. Start = 9,
  50588. /** Left stick */
  50589. LeftStick = 10,
  50590. /** Right stick */
  50591. RightStick = 11
  50592. }
  50593. /** Defines values for XBox360 DPad */
  50594. export enum Xbox360Dpad {
  50595. /** Up */
  50596. Up = 12,
  50597. /** Down */
  50598. Down = 13,
  50599. /** Left */
  50600. Left = 14,
  50601. /** Right */
  50602. Right = 15
  50603. }
  50604. /**
  50605. * Defines a XBox360 gamepad
  50606. */
  50607. export class Xbox360Pad extends Gamepad {
  50608. private _leftTrigger;
  50609. private _rightTrigger;
  50610. private _onlefttriggerchanged;
  50611. private _onrighttriggerchanged;
  50612. private _onbuttondown;
  50613. private _onbuttonup;
  50614. private _ondpaddown;
  50615. private _ondpadup;
  50616. /** Observable raised when a button is pressed */
  50617. onButtonDownObservable: Observable<Xbox360Button>;
  50618. /** Observable raised when a button is released */
  50619. onButtonUpObservable: Observable<Xbox360Button>;
  50620. /** Observable raised when a pad is pressed */
  50621. onPadDownObservable: Observable<Xbox360Dpad>;
  50622. /** Observable raised when a pad is released */
  50623. onPadUpObservable: Observable<Xbox360Dpad>;
  50624. private _buttonA;
  50625. private _buttonB;
  50626. private _buttonX;
  50627. private _buttonY;
  50628. private _buttonBack;
  50629. private _buttonStart;
  50630. private _buttonLB;
  50631. private _buttonRB;
  50632. private _buttonLeftStick;
  50633. private _buttonRightStick;
  50634. private _dPadUp;
  50635. private _dPadDown;
  50636. private _dPadLeft;
  50637. private _dPadRight;
  50638. private _isXboxOnePad;
  50639. /**
  50640. * Creates a new XBox360 gamepad object
  50641. * @param id defines the id of this gamepad
  50642. * @param index defines its index
  50643. * @param gamepad defines the internal HTML gamepad object
  50644. * @param xboxOne defines if it is a XBox One gamepad
  50645. */
  50646. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  50647. /**
  50648. * Defines the callback to call when left trigger is pressed
  50649. * @param callback defines the callback to use
  50650. */
  50651. onlefttriggerchanged(callback: (value: number) => void): void;
  50652. /**
  50653. * Defines the callback to call when right trigger is pressed
  50654. * @param callback defines the callback to use
  50655. */
  50656. onrighttriggerchanged(callback: (value: number) => void): void;
  50657. /**
  50658. * Gets the left trigger value
  50659. */
  50660. get leftTrigger(): number;
  50661. /**
  50662. * Sets the left trigger value
  50663. */
  50664. set leftTrigger(newValue: number);
  50665. /**
  50666. * Gets the right trigger value
  50667. */
  50668. get rightTrigger(): number;
  50669. /**
  50670. * Sets the right trigger value
  50671. */
  50672. set rightTrigger(newValue: number);
  50673. /**
  50674. * Defines the callback to call when a button is pressed
  50675. * @param callback defines the callback to use
  50676. */
  50677. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  50678. /**
  50679. * Defines the callback to call when a button is released
  50680. * @param callback defines the callback to use
  50681. */
  50682. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  50683. /**
  50684. * Defines the callback to call when a pad is pressed
  50685. * @param callback defines the callback to use
  50686. */
  50687. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  50688. /**
  50689. * Defines the callback to call when a pad is released
  50690. * @param callback defines the callback to use
  50691. */
  50692. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  50693. private _setButtonValue;
  50694. private _setDPadValue;
  50695. /**
  50696. * Gets the value of the `A` button
  50697. */
  50698. get buttonA(): number;
  50699. /**
  50700. * Sets the value of the `A` button
  50701. */
  50702. set buttonA(value: number);
  50703. /**
  50704. * Gets the value of the `B` button
  50705. */
  50706. get buttonB(): number;
  50707. /**
  50708. * Sets the value of the `B` button
  50709. */
  50710. set buttonB(value: number);
  50711. /**
  50712. * Gets the value of the `X` button
  50713. */
  50714. get buttonX(): number;
  50715. /**
  50716. * Sets the value of the `X` button
  50717. */
  50718. set buttonX(value: number);
  50719. /**
  50720. * Gets the value of the `Y` button
  50721. */
  50722. get buttonY(): number;
  50723. /**
  50724. * Sets the value of the `Y` button
  50725. */
  50726. set buttonY(value: number);
  50727. /**
  50728. * Gets the value of the `Start` button
  50729. */
  50730. get buttonStart(): number;
  50731. /**
  50732. * Sets the value of the `Start` button
  50733. */
  50734. set buttonStart(value: number);
  50735. /**
  50736. * Gets the value of the `Back` button
  50737. */
  50738. get buttonBack(): number;
  50739. /**
  50740. * Sets the value of the `Back` button
  50741. */
  50742. set buttonBack(value: number);
  50743. /**
  50744. * Gets the value of the `Left` button
  50745. */
  50746. get buttonLB(): number;
  50747. /**
  50748. * Sets the value of the `Left` button
  50749. */
  50750. set buttonLB(value: number);
  50751. /**
  50752. * Gets the value of the `Right` button
  50753. */
  50754. get buttonRB(): number;
  50755. /**
  50756. * Sets the value of the `Right` button
  50757. */
  50758. set buttonRB(value: number);
  50759. /**
  50760. * Gets the value of the Left joystick
  50761. */
  50762. get buttonLeftStick(): number;
  50763. /**
  50764. * Sets the value of the Left joystick
  50765. */
  50766. set buttonLeftStick(value: number);
  50767. /**
  50768. * Gets the value of the Right joystick
  50769. */
  50770. get buttonRightStick(): number;
  50771. /**
  50772. * Sets the value of the Right joystick
  50773. */
  50774. set buttonRightStick(value: number);
  50775. /**
  50776. * Gets the value of D-pad up
  50777. */
  50778. get dPadUp(): number;
  50779. /**
  50780. * Sets the value of D-pad up
  50781. */
  50782. set dPadUp(value: number);
  50783. /**
  50784. * Gets the value of D-pad down
  50785. */
  50786. get dPadDown(): number;
  50787. /**
  50788. * Sets the value of D-pad down
  50789. */
  50790. set dPadDown(value: number);
  50791. /**
  50792. * Gets the value of D-pad left
  50793. */
  50794. get dPadLeft(): number;
  50795. /**
  50796. * Sets the value of D-pad left
  50797. */
  50798. set dPadLeft(value: number);
  50799. /**
  50800. * Gets the value of D-pad right
  50801. */
  50802. get dPadRight(): number;
  50803. /**
  50804. * Sets the value of D-pad right
  50805. */
  50806. set dPadRight(value: number);
  50807. /**
  50808. * Force the gamepad to synchronize with device values
  50809. */
  50810. update(): void;
  50811. /**
  50812. * Disposes the gamepad
  50813. */
  50814. dispose(): void;
  50815. }
  50816. }
  50817. declare module "babylonjs/Gamepads/dualShockGamepad" {
  50818. import { Observable } from "babylonjs/Misc/observable";
  50819. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  50820. /**
  50821. * Defines supported buttons for DualShock compatible gamepads
  50822. */
  50823. export enum DualShockButton {
  50824. /** Cross */
  50825. Cross = 0,
  50826. /** Circle */
  50827. Circle = 1,
  50828. /** Square */
  50829. Square = 2,
  50830. /** Triangle */
  50831. Triangle = 3,
  50832. /** L1 */
  50833. L1 = 4,
  50834. /** R1 */
  50835. R1 = 5,
  50836. /** Share */
  50837. Share = 8,
  50838. /** Options */
  50839. Options = 9,
  50840. /** Left stick */
  50841. LeftStick = 10,
  50842. /** Right stick */
  50843. RightStick = 11
  50844. }
  50845. /** Defines values for DualShock DPad */
  50846. export enum DualShockDpad {
  50847. /** Up */
  50848. Up = 12,
  50849. /** Down */
  50850. Down = 13,
  50851. /** Left */
  50852. Left = 14,
  50853. /** Right */
  50854. Right = 15
  50855. }
  50856. /**
  50857. * Defines a DualShock gamepad
  50858. */
  50859. export class DualShockPad extends Gamepad {
  50860. private _leftTrigger;
  50861. private _rightTrigger;
  50862. private _onlefttriggerchanged;
  50863. private _onrighttriggerchanged;
  50864. private _onbuttondown;
  50865. private _onbuttonup;
  50866. private _ondpaddown;
  50867. private _ondpadup;
  50868. /** Observable raised when a button is pressed */
  50869. onButtonDownObservable: Observable<DualShockButton>;
  50870. /** Observable raised when a button is released */
  50871. onButtonUpObservable: Observable<DualShockButton>;
  50872. /** Observable raised when a pad is pressed */
  50873. onPadDownObservable: Observable<DualShockDpad>;
  50874. /** Observable raised when a pad is released */
  50875. onPadUpObservable: Observable<DualShockDpad>;
  50876. private _buttonCross;
  50877. private _buttonCircle;
  50878. private _buttonSquare;
  50879. private _buttonTriangle;
  50880. private _buttonShare;
  50881. private _buttonOptions;
  50882. private _buttonL1;
  50883. private _buttonR1;
  50884. private _buttonLeftStick;
  50885. private _buttonRightStick;
  50886. private _dPadUp;
  50887. private _dPadDown;
  50888. private _dPadLeft;
  50889. private _dPadRight;
  50890. /**
  50891. * Creates a new DualShock gamepad object
  50892. * @param id defines the id of this gamepad
  50893. * @param index defines its index
  50894. * @param gamepad defines the internal HTML gamepad object
  50895. */
  50896. constructor(id: string, index: number, gamepad: any);
  50897. /**
  50898. * Defines the callback to call when left trigger is pressed
  50899. * @param callback defines the callback to use
  50900. */
  50901. onlefttriggerchanged(callback: (value: number) => void): void;
  50902. /**
  50903. * Defines the callback to call when right trigger is pressed
  50904. * @param callback defines the callback to use
  50905. */
  50906. onrighttriggerchanged(callback: (value: number) => void): void;
  50907. /**
  50908. * Gets the left trigger value
  50909. */
  50910. get leftTrigger(): number;
  50911. /**
  50912. * Sets the left trigger value
  50913. */
  50914. set leftTrigger(newValue: number);
  50915. /**
  50916. * Gets the right trigger value
  50917. */
  50918. get rightTrigger(): number;
  50919. /**
  50920. * Sets the right trigger value
  50921. */
  50922. set rightTrigger(newValue: number);
  50923. /**
  50924. * Defines the callback to call when a button is pressed
  50925. * @param callback defines the callback to use
  50926. */
  50927. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  50928. /**
  50929. * Defines the callback to call when a button is released
  50930. * @param callback defines the callback to use
  50931. */
  50932. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  50933. /**
  50934. * Defines the callback to call when a pad is pressed
  50935. * @param callback defines the callback to use
  50936. */
  50937. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  50938. /**
  50939. * Defines the callback to call when a pad is released
  50940. * @param callback defines the callback to use
  50941. */
  50942. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  50943. private _setButtonValue;
  50944. private _setDPadValue;
  50945. /**
  50946. * Gets the value of the `Cross` button
  50947. */
  50948. get buttonCross(): number;
  50949. /**
  50950. * Sets the value of the `Cross` button
  50951. */
  50952. set buttonCross(value: number);
  50953. /**
  50954. * Gets the value of the `Circle` button
  50955. */
  50956. get buttonCircle(): number;
  50957. /**
  50958. * Sets the value of the `Circle` button
  50959. */
  50960. set buttonCircle(value: number);
  50961. /**
  50962. * Gets the value of the `Square` button
  50963. */
  50964. get buttonSquare(): number;
  50965. /**
  50966. * Sets the value of the `Square` button
  50967. */
  50968. set buttonSquare(value: number);
  50969. /**
  50970. * Gets the value of the `Triangle` button
  50971. */
  50972. get buttonTriangle(): number;
  50973. /**
  50974. * Sets the value of the `Triangle` button
  50975. */
  50976. set buttonTriangle(value: number);
  50977. /**
  50978. * Gets the value of the `Options` button
  50979. */
  50980. get buttonOptions(): number;
  50981. /**
  50982. * Sets the value of the `Options` button
  50983. */
  50984. set buttonOptions(value: number);
  50985. /**
  50986. * Gets the value of the `Share` button
  50987. */
  50988. get buttonShare(): number;
  50989. /**
  50990. * Sets the value of the `Share` button
  50991. */
  50992. set buttonShare(value: number);
  50993. /**
  50994. * Gets the value of the `L1` button
  50995. */
  50996. get buttonL1(): number;
  50997. /**
  50998. * Sets the value of the `L1` button
  50999. */
  51000. set buttonL1(value: number);
  51001. /**
  51002. * Gets the value of the `R1` button
  51003. */
  51004. get buttonR1(): number;
  51005. /**
  51006. * Sets the value of the `R1` button
  51007. */
  51008. set buttonR1(value: number);
  51009. /**
  51010. * Gets the value of the Left joystick
  51011. */
  51012. get buttonLeftStick(): number;
  51013. /**
  51014. * Sets the value of the Left joystick
  51015. */
  51016. set buttonLeftStick(value: number);
  51017. /**
  51018. * Gets the value of the Right joystick
  51019. */
  51020. get buttonRightStick(): number;
  51021. /**
  51022. * Sets the value of the Right joystick
  51023. */
  51024. set buttonRightStick(value: number);
  51025. /**
  51026. * Gets the value of D-pad up
  51027. */
  51028. get dPadUp(): number;
  51029. /**
  51030. * Sets the value of D-pad up
  51031. */
  51032. set dPadUp(value: number);
  51033. /**
  51034. * Gets the value of D-pad down
  51035. */
  51036. get dPadDown(): number;
  51037. /**
  51038. * Sets the value of D-pad down
  51039. */
  51040. set dPadDown(value: number);
  51041. /**
  51042. * Gets the value of D-pad left
  51043. */
  51044. get dPadLeft(): number;
  51045. /**
  51046. * Sets the value of D-pad left
  51047. */
  51048. set dPadLeft(value: number);
  51049. /**
  51050. * Gets the value of D-pad right
  51051. */
  51052. get dPadRight(): number;
  51053. /**
  51054. * Sets the value of D-pad right
  51055. */
  51056. set dPadRight(value: number);
  51057. /**
  51058. * Force the gamepad to synchronize with device values
  51059. */
  51060. update(): void;
  51061. /**
  51062. * Disposes the gamepad
  51063. */
  51064. dispose(): void;
  51065. }
  51066. }
  51067. declare module "babylonjs/Gamepads/gamepadManager" {
  51068. import { Observable } from "babylonjs/Misc/observable";
  51069. import { Nullable } from "babylonjs/types";
  51070. import { Scene } from "babylonjs/scene";
  51071. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  51072. /**
  51073. * Manager for handling gamepads
  51074. */
  51075. export class GamepadManager {
  51076. private _scene?;
  51077. private _babylonGamepads;
  51078. private _oneGamepadConnected;
  51079. /** @hidden */
  51080. _isMonitoring: boolean;
  51081. private _gamepadEventSupported;
  51082. private _gamepadSupport?;
  51083. /**
  51084. * observable to be triggered when the gamepad controller has been connected
  51085. */
  51086. onGamepadConnectedObservable: Observable<Gamepad>;
  51087. /**
  51088. * observable to be triggered when the gamepad controller has been disconnected
  51089. */
  51090. onGamepadDisconnectedObservable: Observable<Gamepad>;
  51091. private _onGamepadConnectedEvent;
  51092. private _onGamepadDisconnectedEvent;
  51093. /**
  51094. * Initializes the gamepad manager
  51095. * @param _scene BabylonJS scene
  51096. */
  51097. constructor(_scene?: Scene | undefined);
  51098. /**
  51099. * The gamepads in the game pad manager
  51100. */
  51101. get gamepads(): Gamepad[];
  51102. /**
  51103. * Get the gamepad controllers based on type
  51104. * @param type The type of gamepad controller
  51105. * @returns Nullable gamepad
  51106. */
  51107. getGamepadByType(type?: number): Nullable<Gamepad>;
  51108. /**
  51109. * Disposes the gamepad manager
  51110. */
  51111. dispose(): void;
  51112. private _addNewGamepad;
  51113. private _startMonitoringGamepads;
  51114. private _stopMonitoringGamepads;
  51115. /** @hidden */
  51116. _checkGamepadsStatus(): void;
  51117. private _updateGamepadObjects;
  51118. }
  51119. }
  51120. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  51121. import { Nullable } from "babylonjs/types";
  51122. import { Scene } from "babylonjs/scene";
  51123. import { ISceneComponent } from "babylonjs/sceneComponent";
  51124. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  51125. module "babylonjs/scene" {
  51126. interface Scene {
  51127. /** @hidden */
  51128. _gamepadManager: Nullable<GamepadManager>;
  51129. /**
  51130. * Gets the gamepad manager associated with the scene
  51131. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  51132. */
  51133. gamepadManager: GamepadManager;
  51134. }
  51135. }
  51136. module "babylonjs/Cameras/freeCameraInputsManager" {
  51137. /**
  51138. * Interface representing a free camera inputs manager
  51139. */
  51140. interface FreeCameraInputsManager {
  51141. /**
  51142. * Adds gamepad input support to the FreeCameraInputsManager.
  51143. * @returns the FreeCameraInputsManager
  51144. */
  51145. addGamepad(): FreeCameraInputsManager;
  51146. }
  51147. }
  51148. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  51149. /**
  51150. * Interface representing an arc rotate camera inputs manager
  51151. */
  51152. interface ArcRotateCameraInputsManager {
  51153. /**
  51154. * Adds gamepad input support to the ArcRotateCamera InputManager.
  51155. * @returns the camera inputs manager
  51156. */
  51157. addGamepad(): ArcRotateCameraInputsManager;
  51158. }
  51159. }
  51160. /**
  51161. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  51162. */
  51163. export class GamepadSystemSceneComponent implements ISceneComponent {
  51164. /**
  51165. * The component name helpfull to identify the component in the list of scene components.
  51166. */
  51167. readonly name: string;
  51168. /**
  51169. * The scene the component belongs to.
  51170. */
  51171. scene: Scene;
  51172. /**
  51173. * Creates a new instance of the component for the given scene
  51174. * @param scene Defines the scene to register the component in
  51175. */
  51176. constructor(scene: Scene);
  51177. /**
  51178. * Registers the component in a given scene
  51179. */
  51180. register(): void;
  51181. /**
  51182. * Rebuilds the elements related to this component in case of
  51183. * context lost for instance.
  51184. */
  51185. rebuild(): void;
  51186. /**
  51187. * Disposes the component and the associated ressources
  51188. */
  51189. dispose(): void;
  51190. private _beforeCameraUpdate;
  51191. }
  51192. }
  51193. declare module "babylonjs/Cameras/universalCamera" {
  51194. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  51195. import { Scene } from "babylonjs/scene";
  51196. import { Vector3 } from "babylonjs/Maths/math.vector";
  51197. import "babylonjs/Gamepads/gamepadSceneComponent";
  51198. /**
  51199. * 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,
  51200. * which still works and will still be found in many Playgrounds.
  51201. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51202. */
  51203. export class UniversalCamera extends TouchCamera {
  51204. /**
  51205. * Defines the gamepad rotation sensiblity.
  51206. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  51207. */
  51208. get gamepadAngularSensibility(): number;
  51209. set gamepadAngularSensibility(value: number);
  51210. /**
  51211. * Defines the gamepad move sensiblity.
  51212. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  51213. */
  51214. get gamepadMoveSensibility(): number;
  51215. set gamepadMoveSensibility(value: number);
  51216. /**
  51217. * 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,
  51218. * which still works and will still be found in many Playgrounds.
  51219. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51220. * @param name Define the name of the camera in the scene
  51221. * @param position Define the start position of the camera in the scene
  51222. * @param scene Define the scene the camera belongs to
  51223. */
  51224. constructor(name: string, position: Vector3, scene: Scene);
  51225. /**
  51226. * Gets the current object class name.
  51227. * @return the class name
  51228. */
  51229. getClassName(): string;
  51230. }
  51231. }
  51232. declare module "babylonjs/Cameras/gamepadCamera" {
  51233. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51234. import { Scene } from "babylonjs/scene";
  51235. import { Vector3 } from "babylonjs/Maths/math.vector";
  51236. /**
  51237. * This represents a FPS type of camera. This is only here for back compat purpose.
  51238. * Please use the UniversalCamera instead as both are identical.
  51239. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51240. */
  51241. export class GamepadCamera extends UniversalCamera {
  51242. /**
  51243. * Instantiates a new Gamepad Camera
  51244. * This represents a FPS type of camera. This is only here for back compat purpose.
  51245. * Please use the UniversalCamera instead as both are identical.
  51246. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  51247. * @param name Define the name of the camera in the scene
  51248. * @param position Define the start position of the camera in the scene
  51249. * @param scene Define the scene the camera belongs to
  51250. */
  51251. constructor(name: string, position: Vector3, scene: Scene);
  51252. /**
  51253. * Gets the current object class name.
  51254. * @return the class name
  51255. */
  51256. getClassName(): string;
  51257. }
  51258. }
  51259. declare module "babylonjs/Shaders/pass.fragment" {
  51260. /** @hidden */
  51261. export var passPixelShader: {
  51262. name: string;
  51263. shader: string;
  51264. };
  51265. }
  51266. declare module "babylonjs/Shaders/passCube.fragment" {
  51267. /** @hidden */
  51268. export var passCubePixelShader: {
  51269. name: string;
  51270. shader: string;
  51271. };
  51272. }
  51273. declare module "babylonjs/PostProcesses/passPostProcess" {
  51274. import { Nullable } from "babylonjs/types";
  51275. import { Camera } from "babylonjs/Cameras/camera";
  51276. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51277. import { Engine } from "babylonjs/Engines/engine";
  51278. import "babylonjs/Shaders/pass.fragment";
  51279. import "babylonjs/Shaders/passCube.fragment";
  51280. import { Scene } from "babylonjs/scene";
  51281. /**
  51282. * PassPostProcess which produces an output the same as it's input
  51283. */
  51284. export class PassPostProcess extends PostProcess {
  51285. /**
  51286. * Gets a string identifying the name of the class
  51287. * @returns "PassPostProcess" string
  51288. */
  51289. getClassName(): string;
  51290. /**
  51291. * Creates the PassPostProcess
  51292. * @param name The name of the effect.
  51293. * @param options The required width/height ratio to downsize to before computing the render pass.
  51294. * @param camera The camera to apply the render pass to.
  51295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51296. * @param engine The engine which the post process will be applied. (default: current engine)
  51297. * @param reusable If the post process can be reused on the same frame. (default: false)
  51298. * @param textureType The type of texture to be used when performing the post processing.
  51299. * @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)
  51300. */
  51301. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51302. /** @hidden */
  51303. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  51304. }
  51305. /**
  51306. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  51307. */
  51308. export class PassCubePostProcess extends PostProcess {
  51309. private _face;
  51310. /**
  51311. * Gets or sets the cube face to display.
  51312. * * 0 is +X
  51313. * * 1 is -X
  51314. * * 2 is +Y
  51315. * * 3 is -Y
  51316. * * 4 is +Z
  51317. * * 5 is -Z
  51318. */
  51319. get face(): number;
  51320. set face(value: number);
  51321. /**
  51322. * Gets a string identifying the name of the class
  51323. * @returns "PassCubePostProcess" string
  51324. */
  51325. getClassName(): string;
  51326. /**
  51327. * Creates the PassCubePostProcess
  51328. * @param name The name of the effect.
  51329. * @param options The required width/height ratio to downsize to before computing the render pass.
  51330. * @param camera The camera to apply the render pass to.
  51331. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  51332. * @param engine The engine which the post process will be applied. (default: current engine)
  51333. * @param reusable If the post process can be reused on the same frame. (default: false)
  51334. * @param textureType The type of texture to be used when performing the post processing.
  51335. * @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)
  51336. */
  51337. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  51338. /** @hidden */
  51339. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  51340. }
  51341. }
  51342. declare module "babylonjs/Shaders/anaglyph.fragment" {
  51343. /** @hidden */
  51344. export var anaglyphPixelShader: {
  51345. name: string;
  51346. shader: string;
  51347. };
  51348. }
  51349. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  51350. import { Engine } from "babylonjs/Engines/engine";
  51351. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  51352. import { Camera } from "babylonjs/Cameras/camera";
  51353. import "babylonjs/Shaders/anaglyph.fragment";
  51354. /**
  51355. * Postprocess used to generate anaglyphic rendering
  51356. */
  51357. export class AnaglyphPostProcess extends PostProcess {
  51358. private _passedProcess;
  51359. /**
  51360. * Gets a string identifying the name of the class
  51361. * @returns "AnaglyphPostProcess" string
  51362. */
  51363. getClassName(): string;
  51364. /**
  51365. * Creates a new AnaglyphPostProcess
  51366. * @param name defines postprocess name
  51367. * @param options defines creation options or target ratio scale
  51368. * @param rigCameras defines cameras using this postprocess
  51369. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  51370. * @param engine defines hosting engine
  51371. * @param reusable defines if the postprocess will be reused multiple times per frame
  51372. */
  51373. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  51374. }
  51375. }
  51376. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  51377. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  51378. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51379. import { Scene } from "babylonjs/scene";
  51380. import { Vector3 } from "babylonjs/Maths/math.vector";
  51381. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51382. /**
  51383. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  51384. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51385. */
  51386. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  51387. /**
  51388. * Creates a new AnaglyphArcRotateCamera
  51389. * @param name defines camera name
  51390. * @param alpha defines alpha angle (in radians)
  51391. * @param beta defines beta angle (in radians)
  51392. * @param radius defines radius
  51393. * @param target defines camera target
  51394. * @param interaxialDistance defines distance between each color axis
  51395. * @param scene defines the hosting scene
  51396. */
  51397. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  51398. /**
  51399. * Gets camera class name
  51400. * @returns AnaglyphArcRotateCamera
  51401. */
  51402. getClassName(): string;
  51403. }
  51404. }
  51405. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  51406. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51407. import { Scene } from "babylonjs/scene";
  51408. import { Vector3 } from "babylonjs/Maths/math.vector";
  51409. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51410. /**
  51411. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  51412. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51413. */
  51414. export class AnaglyphFreeCamera extends FreeCamera {
  51415. /**
  51416. * Creates a new AnaglyphFreeCamera
  51417. * @param name defines camera name
  51418. * @param position defines initial position
  51419. * @param interaxialDistance defines distance between each color axis
  51420. * @param scene defines the hosting scene
  51421. */
  51422. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51423. /**
  51424. * Gets camera class name
  51425. * @returns AnaglyphFreeCamera
  51426. */
  51427. getClassName(): string;
  51428. }
  51429. }
  51430. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  51431. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51432. import { Scene } from "babylonjs/scene";
  51433. import { Vector3 } from "babylonjs/Maths/math.vector";
  51434. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51435. /**
  51436. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  51437. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51438. */
  51439. export class AnaglyphGamepadCamera extends GamepadCamera {
  51440. /**
  51441. * Creates a new AnaglyphGamepadCamera
  51442. * @param name defines camera name
  51443. * @param position defines initial position
  51444. * @param interaxialDistance defines distance between each color axis
  51445. * @param scene defines the hosting scene
  51446. */
  51447. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51448. /**
  51449. * Gets camera class name
  51450. * @returns AnaglyphGamepadCamera
  51451. */
  51452. getClassName(): string;
  51453. }
  51454. }
  51455. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  51456. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51457. import { Scene } from "babylonjs/scene";
  51458. import { Vector3 } from "babylonjs/Maths/math.vector";
  51459. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51460. /**
  51461. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  51462. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  51463. */
  51464. export class AnaglyphUniversalCamera extends UniversalCamera {
  51465. /**
  51466. * Creates a new AnaglyphUniversalCamera
  51467. * @param name defines camera name
  51468. * @param position defines initial position
  51469. * @param interaxialDistance defines distance between each color axis
  51470. * @param scene defines the hosting scene
  51471. */
  51472. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  51473. /**
  51474. * Gets camera class name
  51475. * @returns AnaglyphUniversalCamera
  51476. */
  51477. getClassName(): string;
  51478. }
  51479. }
  51480. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  51481. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  51482. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51483. import { Scene } from "babylonjs/scene";
  51484. import { Vector3 } from "babylonjs/Maths/math.vector";
  51485. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51486. /**
  51487. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  51488. * @see https://doc.babylonjs.com/features/cameras
  51489. */
  51490. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  51491. /**
  51492. * Creates a new StereoscopicArcRotateCamera
  51493. * @param name defines camera name
  51494. * @param alpha defines alpha angle (in radians)
  51495. * @param beta defines beta angle (in radians)
  51496. * @param radius defines radius
  51497. * @param target defines camera target
  51498. * @param interaxialDistance defines distance between each color axis
  51499. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51500. * @param scene defines the hosting scene
  51501. */
  51502. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51503. /**
  51504. * Gets camera class name
  51505. * @returns StereoscopicArcRotateCamera
  51506. */
  51507. getClassName(): string;
  51508. }
  51509. }
  51510. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  51511. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51512. import { Scene } from "babylonjs/scene";
  51513. import { Vector3 } from "babylonjs/Maths/math.vector";
  51514. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51515. /**
  51516. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  51517. * @see https://doc.babylonjs.com/features/cameras
  51518. */
  51519. export class StereoscopicFreeCamera extends FreeCamera {
  51520. /**
  51521. * Creates a new StereoscopicFreeCamera
  51522. * @param name defines camera name
  51523. * @param position defines initial position
  51524. * @param interaxialDistance defines distance between each color axis
  51525. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51526. * @param scene defines the hosting scene
  51527. */
  51528. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51529. /**
  51530. * Gets camera class name
  51531. * @returns StereoscopicFreeCamera
  51532. */
  51533. getClassName(): string;
  51534. }
  51535. }
  51536. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  51537. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  51538. import { Scene } from "babylonjs/scene";
  51539. import { Vector3 } from "babylonjs/Maths/math.vector";
  51540. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51541. /**
  51542. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  51543. * @see https://doc.babylonjs.com/features/cameras
  51544. */
  51545. export class StereoscopicGamepadCamera extends GamepadCamera {
  51546. /**
  51547. * Creates a new StereoscopicGamepadCamera
  51548. * @param name defines camera name
  51549. * @param position defines initial position
  51550. * @param interaxialDistance defines distance between each color axis
  51551. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51552. * @param scene defines the hosting scene
  51553. */
  51554. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51555. /**
  51556. * Gets camera class name
  51557. * @returns StereoscopicGamepadCamera
  51558. */
  51559. getClassName(): string;
  51560. }
  51561. }
  51562. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  51563. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  51564. import { Scene } from "babylonjs/scene";
  51565. import { Vector3 } from "babylonjs/Maths/math.vector";
  51566. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51567. /**
  51568. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  51569. * @see https://doc.babylonjs.com/features/cameras
  51570. */
  51571. export class StereoscopicUniversalCamera extends UniversalCamera {
  51572. /**
  51573. * Creates a new StereoscopicUniversalCamera
  51574. * @param name defines camera name
  51575. * @param position defines initial position
  51576. * @param interaxialDistance defines distance between each color axis
  51577. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  51578. * @param scene defines the hosting scene
  51579. */
  51580. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  51581. /**
  51582. * Gets camera class name
  51583. * @returns StereoscopicUniversalCamera
  51584. */
  51585. getClassName(): string;
  51586. }
  51587. }
  51588. declare module "babylonjs/Cameras/Stereoscopic/index" {
  51589. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  51590. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  51591. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  51592. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  51593. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  51594. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  51595. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  51596. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  51597. }
  51598. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  51599. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  51600. import { Scene } from "babylonjs/scene";
  51601. import { Vector3 } from "babylonjs/Maths/math.vector";
  51602. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  51603. /**
  51604. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  51605. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51606. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51607. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51608. */
  51609. export class VirtualJoysticksCamera extends FreeCamera {
  51610. /**
  51611. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  51612. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  51613. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  51614. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  51615. * @param name Define the name of the camera in the scene
  51616. * @param position Define the start position of the camera in the scene
  51617. * @param scene Define the scene the camera belongs to
  51618. */
  51619. constructor(name: string, position: Vector3, scene: Scene);
  51620. /**
  51621. * Gets the current object class name.
  51622. * @return the class name
  51623. */
  51624. getClassName(): string;
  51625. }
  51626. }
  51627. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  51628. import { Matrix } from "babylonjs/Maths/math.vector";
  51629. /**
  51630. * This represents all the required metrics to create a VR camera.
  51631. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  51632. */
  51633. export class VRCameraMetrics {
  51634. /**
  51635. * Define the horizontal resolution off the screen.
  51636. */
  51637. hResolution: number;
  51638. /**
  51639. * Define the vertical resolution off the screen.
  51640. */
  51641. vResolution: number;
  51642. /**
  51643. * Define the horizontal screen size.
  51644. */
  51645. hScreenSize: number;
  51646. /**
  51647. * Define the vertical screen size.
  51648. */
  51649. vScreenSize: number;
  51650. /**
  51651. * Define the vertical screen center position.
  51652. */
  51653. vScreenCenter: number;
  51654. /**
  51655. * Define the distance of the eyes to the screen.
  51656. */
  51657. eyeToScreenDistance: number;
  51658. /**
  51659. * Define the distance between both lenses
  51660. */
  51661. lensSeparationDistance: number;
  51662. /**
  51663. * Define the distance between both viewer's eyes.
  51664. */
  51665. interpupillaryDistance: number;
  51666. /**
  51667. * Define the distortion factor of the VR postprocess.
  51668. * Please, touch with care.
  51669. */
  51670. distortionK: number[];
  51671. /**
  51672. * Define the chromatic aberration correction factors for the VR post process.
  51673. */
  51674. chromaAbCorrection: number[];
  51675. /**
  51676. * Define the scale factor of the post process.
  51677. * The smaller the better but the slower.
  51678. */
  51679. postProcessScaleFactor: number;
  51680. /**
  51681. * Define an offset for the lens center.
  51682. */
  51683. lensCenterOffset: number;
  51684. /**
  51685. * Define if the current vr camera should compensate the distortion of the lense or not.
  51686. */
  51687. compensateDistortion: boolean;
  51688. /**
  51689. * Defines if multiview should be enabled when rendering (Default: false)
  51690. */
  51691. multiviewEnabled: boolean;
  51692. /**
  51693. * Gets the rendering aspect ratio based on the provided resolutions.
  51694. */
  51695. get aspectRatio(): number;
  51696. /**
  51697. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  51698. */
  51699. get aspectRatioFov(): number;
  51700. /**
  51701. * @hidden
  51702. */
  51703. get leftHMatrix(): Matrix;
  51704. /**
  51705. * @hidden
  51706. */
  51707. get rightHMatrix(): Matrix;
  51708. /**
  51709. * @hidden
  51710. */
  51711. get leftPreViewMatrix(): Matrix;
  51712. /**
  51713. * @hidden
  51714. */
  51715. get rightPreViewMatrix(): Matrix;
  51716. /**
  51717. * Get the default VRMetrics based on the most generic setup.
  51718. * @returns the default vr metrics
  51719. */
  51720. static GetDefault(): VRCameraMetrics;
  51721. }
  51722. }
  51723. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  51724. /** @hidden */
  51725. export var vrDistortionCorrectionPixelShader: {
  51726. name: string;
  51727. shader: string;
  51728. };
  51729. }
  51730. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  51731. import { Camera } from "babylonjs/Cameras/camera";
  51732. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51733. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51734. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  51735. /**
  51736. * VRDistortionCorrectionPostProcess used for mobile VR
  51737. */
  51738. export class VRDistortionCorrectionPostProcess extends PostProcess {
  51739. private _isRightEye;
  51740. private _distortionFactors;
  51741. private _postProcessScaleFactor;
  51742. private _lensCenterOffset;
  51743. private _scaleIn;
  51744. private _scaleFactor;
  51745. private _lensCenter;
  51746. /**
  51747. * Gets a string identifying the name of the class
  51748. * @returns "VRDistortionCorrectionPostProcess" string
  51749. */
  51750. getClassName(): string;
  51751. /**
  51752. * Initializes the VRDistortionCorrectionPostProcess
  51753. * @param name The name of the effect.
  51754. * @param camera The camera to apply the render pass to.
  51755. * @param isRightEye If this is for the right eye distortion
  51756. * @param vrMetrics All the required metrics for the VR camera
  51757. */
  51758. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  51759. }
  51760. }
  51761. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  51762. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  51763. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  51764. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51765. import { Scene } from "babylonjs/scene";
  51766. import { Vector3 } from "babylonjs/Maths/math.vector";
  51767. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  51768. import "babylonjs/Cameras/RigModes/vrRigMode";
  51769. /**
  51770. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  51771. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51772. */
  51773. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  51774. /**
  51775. * Creates a new VRDeviceOrientationArcRotateCamera
  51776. * @param name defines camera name
  51777. * @param alpha defines the camera rotation along the logitudinal axis
  51778. * @param beta defines the camera rotation along the latitudinal axis
  51779. * @param radius defines the camera distance from its target
  51780. * @param target defines the camera target
  51781. * @param scene defines the scene the camera belongs to
  51782. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51783. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51784. */
  51785. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51786. /**
  51787. * Gets camera class name
  51788. * @returns VRDeviceOrientationArcRotateCamera
  51789. */
  51790. getClassName(): string;
  51791. }
  51792. }
  51793. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  51794. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51795. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51796. import { Scene } from "babylonjs/scene";
  51797. import { Vector3 } from "babylonjs/Maths/math.vector";
  51798. import "babylonjs/Cameras/RigModes/vrRigMode";
  51799. /**
  51800. * Camera used to simulate VR rendering (based on FreeCamera)
  51801. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51802. */
  51803. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  51804. /**
  51805. * Creates a new VRDeviceOrientationFreeCamera
  51806. * @param name defines camera name
  51807. * @param position defines the start position of the camera
  51808. * @param scene defines the scene the camera belongs to
  51809. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51810. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51811. */
  51812. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51813. /**
  51814. * Gets camera class name
  51815. * @returns VRDeviceOrientationFreeCamera
  51816. */
  51817. getClassName(): string;
  51818. }
  51819. }
  51820. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  51821. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51822. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51823. import { Scene } from "babylonjs/scene";
  51824. import { Vector3 } from "babylonjs/Maths/math.vector";
  51825. import "babylonjs/Gamepads/gamepadSceneComponent";
  51826. /**
  51827. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  51828. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  51829. */
  51830. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  51831. /**
  51832. * Creates a new VRDeviceOrientationGamepadCamera
  51833. * @param name defines camera name
  51834. * @param position defines the start position of the camera
  51835. * @param scene defines the scene the camera belongs to
  51836. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  51837. * @param vrCameraMetrics defines the vr metrics associated to the camera
  51838. */
  51839. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  51840. /**
  51841. * Gets camera class name
  51842. * @returns VRDeviceOrientationGamepadCamera
  51843. */
  51844. getClassName(): string;
  51845. }
  51846. }
  51847. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  51848. import { Scene } from "babylonjs/scene";
  51849. import { Texture } from "babylonjs/Materials/Textures/texture";
  51850. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  51851. /**
  51852. * A class extending Texture allowing drawing on a texture
  51853. * @see https://doc.babylonjs.com/how_to/dynamictexture
  51854. */
  51855. export class DynamicTexture extends Texture {
  51856. private _generateMipMaps;
  51857. private _canvas;
  51858. private _context;
  51859. /**
  51860. * Creates a DynamicTexture
  51861. * @param name defines the name of the texture
  51862. * @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
  51863. * @param scene defines the scene where you want the texture
  51864. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  51865. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  51866. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  51867. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  51868. */
  51869. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  51870. /**
  51871. * Get the current class name of the texture useful for serialization or dynamic coding.
  51872. * @returns "DynamicTexture"
  51873. */
  51874. getClassName(): string;
  51875. /**
  51876. * Gets the current state of canRescale
  51877. */
  51878. get canRescale(): boolean;
  51879. private _recreate;
  51880. /**
  51881. * Scales the texture
  51882. * @param ratio the scale factor to apply to both width and height
  51883. */
  51884. scale(ratio: number): void;
  51885. /**
  51886. * Resizes the texture
  51887. * @param width the new width
  51888. * @param height the new height
  51889. */
  51890. scaleTo(width: number, height: number): void;
  51891. /**
  51892. * Gets the context of the canvas used by the texture
  51893. * @returns the canvas context of the dynamic texture
  51894. */
  51895. getContext(): CanvasRenderingContext2D;
  51896. /**
  51897. * Clears the texture
  51898. */
  51899. clear(): void;
  51900. /**
  51901. * Updates the texture
  51902. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51903. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  51904. */
  51905. update(invertY?: boolean, premulAlpha?: boolean): void;
  51906. /**
  51907. * Draws text onto the texture
  51908. * @param text defines the text to be drawn
  51909. * @param x defines the placement of the text from the left
  51910. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  51911. * @param font defines the font to be used with font-style, font-size, font-name
  51912. * @param color defines the color used for the text
  51913. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  51914. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  51915. * @param update defines whether texture is immediately update (default is true)
  51916. */
  51917. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  51918. /**
  51919. * Clones the texture
  51920. * @returns the clone of the texture.
  51921. */
  51922. clone(): DynamicTexture;
  51923. /**
  51924. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  51925. * @returns a serialized dynamic texture object
  51926. */
  51927. serialize(): any;
  51928. private _IsCanvasElement;
  51929. /** @hidden */
  51930. _rebuild(): void;
  51931. }
  51932. }
  51933. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  51934. import { Scene } from "babylonjs/scene";
  51935. import { Color3 } from "babylonjs/Maths/math.color";
  51936. import { Mesh } from "babylonjs/Meshes/mesh";
  51937. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  51938. import { Nullable } from "babylonjs/types";
  51939. /**
  51940. * Class containing static functions to help procedurally build meshes
  51941. */
  51942. export class GroundBuilder {
  51943. /**
  51944. * Creates a ground mesh
  51945. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  51946. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  51947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51948. * @param name defines the name of the mesh
  51949. * @param options defines the options used to create the mesh
  51950. * @param scene defines the hosting scene
  51951. * @returns the ground mesh
  51952. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  51953. */
  51954. static CreateGround(name: string, options: {
  51955. width?: number;
  51956. height?: number;
  51957. subdivisions?: number;
  51958. subdivisionsX?: number;
  51959. subdivisionsY?: number;
  51960. updatable?: boolean;
  51961. }, scene: any): Mesh;
  51962. /**
  51963. * Creates a tiled ground mesh
  51964. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  51965. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  51966. * * 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
  51967. * * 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
  51968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51969. * @param name defines the name of the mesh
  51970. * @param options defines the options used to create the mesh
  51971. * @param scene defines the hosting scene
  51972. * @returns the tiled ground mesh
  51973. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  51974. */
  51975. static CreateTiledGround(name: string, options: {
  51976. xmin: number;
  51977. zmin: number;
  51978. xmax: number;
  51979. zmax: number;
  51980. subdivisions?: {
  51981. w: number;
  51982. h: number;
  51983. };
  51984. precision?: {
  51985. w: number;
  51986. h: number;
  51987. };
  51988. updatable?: boolean;
  51989. }, scene?: Nullable<Scene>): Mesh;
  51990. /**
  51991. * Creates a ground mesh from a height map
  51992. * * The parameter `url` sets the URL of the height map image resource.
  51993. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  51994. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  51995. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  51996. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  51997. * * 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.
  51998. * * 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).
  51999. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52000. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52001. * @param name defines the name of the mesh
  52002. * @param url defines the url to the height map
  52003. * @param options defines the options used to create the mesh
  52004. * @param scene defines the hosting scene
  52005. * @returns the ground mesh
  52006. * @see https://doc.babylonjs.com/babylon101/height_map
  52007. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52008. */
  52009. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52010. width?: number;
  52011. height?: number;
  52012. subdivisions?: number;
  52013. minHeight?: number;
  52014. maxHeight?: number;
  52015. colorFilter?: Color3;
  52016. alphaFilter?: number;
  52017. updatable?: boolean;
  52018. onReady?: (mesh: GroundMesh) => void;
  52019. }, scene?: Nullable<Scene>): GroundMesh;
  52020. }
  52021. }
  52022. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  52023. import { Vector4 } from "babylonjs/Maths/math.vector";
  52024. import { Mesh } from "babylonjs/Meshes/mesh";
  52025. /**
  52026. * Class containing static functions to help procedurally build meshes
  52027. */
  52028. export class TorusBuilder {
  52029. /**
  52030. * Creates a torus mesh
  52031. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52032. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52033. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52034. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52035. * * 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
  52036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52037. * @param name defines the name of the mesh
  52038. * @param options defines the options used to create the mesh
  52039. * @param scene defines the hosting scene
  52040. * @returns the torus mesh
  52041. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52042. */
  52043. static CreateTorus(name: string, options: {
  52044. diameter?: number;
  52045. thickness?: number;
  52046. tessellation?: number;
  52047. updatable?: boolean;
  52048. sideOrientation?: number;
  52049. frontUVs?: Vector4;
  52050. backUVs?: Vector4;
  52051. }, scene: any): Mesh;
  52052. }
  52053. }
  52054. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  52055. import { Vector4 } from "babylonjs/Maths/math.vector";
  52056. import { Color4 } from "babylonjs/Maths/math.color";
  52057. import { Mesh } from "babylonjs/Meshes/mesh";
  52058. /**
  52059. * Class containing static functions to help procedurally build meshes
  52060. */
  52061. export class CylinderBuilder {
  52062. /**
  52063. * Creates a cylinder or a cone mesh
  52064. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52065. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52066. * * 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.
  52067. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52068. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52069. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52070. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52071. * * 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).
  52072. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52073. * * 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).
  52074. * * 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
  52075. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52076. * * 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
  52077. * * 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.
  52078. * * If `enclose` is false, a ring surface is one element.
  52079. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52080. * * 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
  52081. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52082. * * 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
  52083. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52084. * @param name defines the name of the mesh
  52085. * @param options defines the options used to create the mesh
  52086. * @param scene defines the hosting scene
  52087. * @returns the cylinder mesh
  52088. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52089. */
  52090. static CreateCylinder(name: string, options: {
  52091. height?: number;
  52092. diameterTop?: number;
  52093. diameterBottom?: number;
  52094. diameter?: number;
  52095. tessellation?: number;
  52096. subdivisions?: number;
  52097. arc?: number;
  52098. faceColors?: Color4[];
  52099. faceUV?: Vector4[];
  52100. updatable?: boolean;
  52101. hasRings?: boolean;
  52102. enclose?: boolean;
  52103. cap?: number;
  52104. sideOrientation?: number;
  52105. frontUVs?: Vector4;
  52106. backUVs?: Vector4;
  52107. }, scene: any): Mesh;
  52108. }
  52109. }
  52110. declare module "babylonjs/XR/webXRTypes" {
  52111. import { Nullable } from "babylonjs/types";
  52112. import { IDisposable } from "babylonjs/scene";
  52113. /**
  52114. * States of the webXR experience
  52115. */
  52116. export enum WebXRState {
  52117. /**
  52118. * Transitioning to being in XR mode
  52119. */
  52120. ENTERING_XR = 0,
  52121. /**
  52122. * Transitioning to non XR mode
  52123. */
  52124. EXITING_XR = 1,
  52125. /**
  52126. * In XR mode and presenting
  52127. */
  52128. IN_XR = 2,
  52129. /**
  52130. * Not entered XR mode
  52131. */
  52132. NOT_IN_XR = 3
  52133. }
  52134. /**
  52135. * The state of the XR camera's tracking
  52136. */
  52137. export enum WebXRTrackingState {
  52138. /**
  52139. * No transformation received, device is not being tracked
  52140. */
  52141. NOT_TRACKING = 0,
  52142. /**
  52143. * Tracking lost - using emulated position
  52144. */
  52145. TRACKING_LOST = 1,
  52146. /**
  52147. * Transformation tracking works normally
  52148. */
  52149. TRACKING = 2
  52150. }
  52151. /**
  52152. * Abstraction of the XR render target
  52153. */
  52154. export interface WebXRRenderTarget extends IDisposable {
  52155. /**
  52156. * xrpresent context of the canvas which can be used to display/mirror xr content
  52157. */
  52158. canvasContext: WebGLRenderingContext;
  52159. /**
  52160. * xr layer for the canvas
  52161. */
  52162. xrLayer: Nullable<XRWebGLLayer>;
  52163. /**
  52164. * Initializes the xr layer for the session
  52165. * @param xrSession xr session
  52166. * @returns a promise that will resolve once the XR Layer has been created
  52167. */
  52168. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52169. }
  52170. }
  52171. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  52172. import { Nullable } from "babylonjs/types";
  52173. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  52174. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52175. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52176. import { Observable } from "babylonjs/Misc/observable";
  52177. /**
  52178. * COnfiguration object for WebXR output canvas
  52179. */
  52180. export class WebXRManagedOutputCanvasOptions {
  52181. /**
  52182. * An optional canvas in case you wish to create it yourself and provide it here.
  52183. * If not provided, a new canvas will be created
  52184. */
  52185. canvasElement?: HTMLCanvasElement;
  52186. /**
  52187. * Options for this XR Layer output
  52188. */
  52189. canvasOptions?: XRWebGLLayerOptions;
  52190. /**
  52191. * CSS styling for a newly created canvas (if not provided)
  52192. */
  52193. newCanvasCssStyle?: string;
  52194. /**
  52195. * Get the default values of the configuration object
  52196. * @param engine defines the engine to use (can be null)
  52197. * @returns default values of this configuration object
  52198. */
  52199. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  52200. }
  52201. /**
  52202. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  52203. */
  52204. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  52205. private _options;
  52206. private _canvas;
  52207. private _engine;
  52208. private _originalCanvasSize;
  52209. /**
  52210. * Rendering context of the canvas which can be used to display/mirror xr content
  52211. */
  52212. canvasContext: WebGLRenderingContext;
  52213. /**
  52214. * xr layer for the canvas
  52215. */
  52216. xrLayer: Nullable<XRWebGLLayer>;
  52217. /**
  52218. * Obseervers registered here will be triggered when the xr layer was initialized
  52219. */
  52220. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  52221. /**
  52222. * Initializes the canvas to be added/removed upon entering/exiting xr
  52223. * @param _xrSessionManager The XR Session manager
  52224. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  52225. */
  52226. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  52227. /**
  52228. * Disposes of the object
  52229. */
  52230. dispose(): void;
  52231. /**
  52232. * Initializes the xr layer for the session
  52233. * @param xrSession xr session
  52234. * @returns a promise that will resolve once the XR Layer has been created
  52235. */
  52236. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  52237. private _addCanvas;
  52238. private _removeCanvas;
  52239. private _setCanvasSize;
  52240. private _setManagedOutputCanvas;
  52241. }
  52242. }
  52243. declare module "babylonjs/XR/webXRSessionManager" {
  52244. import { Observable } from "babylonjs/Misc/observable";
  52245. import { Nullable } from "babylonjs/types";
  52246. import { IDisposable, Scene } from "babylonjs/scene";
  52247. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52248. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52249. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  52250. /**
  52251. * Manages an XRSession to work with Babylon's engine
  52252. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  52253. */
  52254. export class WebXRSessionManager implements IDisposable {
  52255. /** The scene which the session should be created for */
  52256. scene: Scene;
  52257. private _referenceSpace;
  52258. private _rttProvider;
  52259. private _sessionEnded;
  52260. private _xrNavigator;
  52261. private baseLayer;
  52262. /**
  52263. * The base reference space from which the session started. good if you want to reset your
  52264. * reference space
  52265. */
  52266. baseReferenceSpace: XRReferenceSpace;
  52267. /**
  52268. * Current XR frame
  52269. */
  52270. currentFrame: Nullable<XRFrame>;
  52271. /** WebXR timestamp updated every frame */
  52272. currentTimestamp: number;
  52273. /**
  52274. * Used just in case of a failure to initialize an immersive session.
  52275. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  52276. */
  52277. defaultHeightCompensation: number;
  52278. /**
  52279. * Fires every time a new xrFrame arrives which can be used to update the camera
  52280. */
  52281. onXRFrameObservable: Observable<XRFrame>;
  52282. /**
  52283. * Fires when the reference space changed
  52284. */
  52285. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  52286. /**
  52287. * Fires when the xr session is ended either by the device or manually done
  52288. */
  52289. onXRSessionEnded: Observable<any>;
  52290. /**
  52291. * Fires when the xr session is ended either by the device or manually done
  52292. */
  52293. onXRSessionInit: Observable<XRSession>;
  52294. /**
  52295. * Underlying xr session
  52296. */
  52297. session: XRSession;
  52298. /**
  52299. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  52300. * or get the offset the player is currently at.
  52301. */
  52302. viewerReferenceSpace: XRReferenceSpace;
  52303. /**
  52304. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  52305. * @param scene The scene which the session should be created for
  52306. */
  52307. constructor(
  52308. /** The scene which the session should be created for */
  52309. scene: Scene);
  52310. /**
  52311. * The current reference space used in this session. This reference space can constantly change!
  52312. * It is mainly used to offset the camera's position.
  52313. */
  52314. get referenceSpace(): XRReferenceSpace;
  52315. /**
  52316. * Set a new reference space and triggers the observable
  52317. */
  52318. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  52319. /**
  52320. * Disposes of the session manager
  52321. */
  52322. dispose(): void;
  52323. /**
  52324. * Stops the xrSession and restores the render loop
  52325. * @returns Promise which resolves after it exits XR
  52326. */
  52327. exitXRAsync(): Promise<void>;
  52328. /**
  52329. * Gets the correct render target texture to be rendered this frame for this eye
  52330. * @param eye the eye for which to get the render target
  52331. * @returns the render target for the specified eye
  52332. */
  52333. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  52334. /**
  52335. * Creates a WebXRRenderTarget object for the XR session
  52336. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  52337. * @param options optional options to provide when creating a new render target
  52338. * @returns a WebXR render target to which the session can render
  52339. */
  52340. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  52341. /**
  52342. * Initializes the manager
  52343. * After initialization enterXR can be called to start an XR session
  52344. * @returns Promise which resolves after it is initialized
  52345. */
  52346. initializeAsync(): Promise<void>;
  52347. /**
  52348. * Initializes an xr session
  52349. * @param xrSessionMode mode to initialize
  52350. * @param xrSessionInit defines optional and required values to pass to the session builder
  52351. * @returns a promise which will resolve once the session has been initialized
  52352. */
  52353. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  52354. /**
  52355. * Checks if a session would be supported for the creation options specified
  52356. * @param sessionMode session mode to check if supported eg. immersive-vr
  52357. * @returns A Promise that resolves to true if supported and false if not
  52358. */
  52359. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52360. /**
  52361. * Resets the reference space to the one started the session
  52362. */
  52363. resetReferenceSpace(): void;
  52364. /**
  52365. * Starts rendering to the xr layer
  52366. */
  52367. runXRRenderLoop(): void;
  52368. /**
  52369. * Sets the reference space on the xr session
  52370. * @param referenceSpaceType space to set
  52371. * @returns a promise that will resolve once the reference space has been set
  52372. */
  52373. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  52374. /**
  52375. * Updates the render state of the session
  52376. * @param state state to set
  52377. * @returns a promise that resolves once the render state has been updated
  52378. */
  52379. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  52380. /**
  52381. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  52382. * @param sessionMode defines the session to test
  52383. * @returns a promise with boolean as final value
  52384. */
  52385. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  52386. private _createRenderTargetTexture;
  52387. }
  52388. }
  52389. declare module "babylonjs/XR/webXRCamera" {
  52390. import { Vector3 } from "babylonjs/Maths/math.vector";
  52391. import { Scene } from "babylonjs/scene";
  52392. import { Camera } from "babylonjs/Cameras/camera";
  52393. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  52394. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52395. import { Observable } from "babylonjs/Misc/observable";
  52396. import { WebXRTrackingState } from "babylonjs/XR/webXRTypes";
  52397. /**
  52398. * WebXR Camera which holds the views for the xrSession
  52399. * @see https://doc.babylonjs.com/how_to/webxr_camera
  52400. */
  52401. export class WebXRCamera extends FreeCamera {
  52402. private _xrSessionManager;
  52403. private _firstFrame;
  52404. private _referenceQuaternion;
  52405. private _referencedPosition;
  52406. private _xrInvPositionCache;
  52407. private _xrInvQuaternionCache;
  52408. private _trackingState;
  52409. /**
  52410. * Observable raised before camera teleportation
  52411. */
  52412. onBeforeCameraTeleport: Observable<Vector3>;
  52413. /**
  52414. * Observable raised after camera teleportation
  52415. */
  52416. onAfterCameraTeleport: Observable<Vector3>;
  52417. /**
  52418. * Notifies when the camera's tracking state has changed.
  52419. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  52420. */
  52421. onTrackingStateChanged: Observable<WebXRTrackingState>;
  52422. /**
  52423. * Should position compensation execute on first frame.
  52424. * This is used when copying the position from a native (non XR) camera
  52425. */
  52426. compensateOnFirstFrame: boolean;
  52427. /**
  52428. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  52429. * @param name the name of the camera
  52430. * @param scene the scene to add the camera to
  52431. * @param _xrSessionManager a constructed xr session manager
  52432. */
  52433. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  52434. /**
  52435. * Get the current XR tracking state of the camera
  52436. */
  52437. get trackingState(): WebXRTrackingState;
  52438. private _setTrackingState;
  52439. /**
  52440. * Return the user's height, unrelated to the current ground.
  52441. * This will be the y position of this camera, when ground level is 0.
  52442. */
  52443. get realWorldHeight(): number;
  52444. /** @hidden */
  52445. _updateForDualEyeDebugging(): void;
  52446. /**
  52447. * Sets this camera's transformation based on a non-vr camera
  52448. * @param otherCamera the non-vr camera to copy the transformation from
  52449. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  52450. */
  52451. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  52452. /**
  52453. * Gets the current instance class name ("WebXRCamera").
  52454. * @returns the class name
  52455. */
  52456. getClassName(): string;
  52457. private _rotate180;
  52458. private _updateFromXRSession;
  52459. private _updateNumberOfRigCameras;
  52460. private _updateReferenceSpace;
  52461. private _updateReferenceSpaceOffset;
  52462. }
  52463. }
  52464. declare module "babylonjs/XR/webXRFeaturesManager" {
  52465. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52466. import { IDisposable } from "babylonjs/scene";
  52467. /**
  52468. * Defining the interface required for a (webxr) feature
  52469. */
  52470. export interface IWebXRFeature extends IDisposable {
  52471. /**
  52472. * Is this feature attached
  52473. */
  52474. attached: boolean;
  52475. /**
  52476. * Should auto-attach be disabled?
  52477. */
  52478. disableAutoAttach: boolean;
  52479. /**
  52480. * Attach the feature to the session
  52481. * Will usually be called by the features manager
  52482. *
  52483. * @param force should attachment be forced (even when already attached)
  52484. * @returns true if successful.
  52485. */
  52486. attach(force?: boolean): boolean;
  52487. /**
  52488. * Detach the feature from the session
  52489. * Will usually be called by the features manager
  52490. *
  52491. * @returns true if successful.
  52492. */
  52493. detach(): boolean;
  52494. /**
  52495. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  52496. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  52497. *
  52498. * @returns whether or not the feature is compatible in this environment
  52499. */
  52500. isCompatible(): boolean;
  52501. /**
  52502. * Was this feature disposed;
  52503. */
  52504. isDisposed: boolean;
  52505. /**
  52506. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  52507. */
  52508. xrNativeFeatureName?: string;
  52509. /**
  52510. * A list of (Babylon WebXR) features this feature depends on
  52511. */
  52512. dependsOn?: string[];
  52513. }
  52514. /**
  52515. * A list of the currently available features without referencing them
  52516. */
  52517. export class WebXRFeatureName {
  52518. /**
  52519. * The name of the anchor system feature
  52520. */
  52521. static readonly ANCHOR_SYSTEM: string;
  52522. /**
  52523. * The name of the background remover feature
  52524. */
  52525. static readonly BACKGROUND_REMOVER: string;
  52526. /**
  52527. * The name of the hit test feature
  52528. */
  52529. static readonly HIT_TEST: string;
  52530. /**
  52531. * physics impostors for xr controllers feature
  52532. */
  52533. static readonly PHYSICS_CONTROLLERS: string;
  52534. /**
  52535. * The name of the plane detection feature
  52536. */
  52537. static readonly PLANE_DETECTION: string;
  52538. /**
  52539. * The name of the pointer selection feature
  52540. */
  52541. static readonly POINTER_SELECTION: string;
  52542. /**
  52543. * The name of the teleportation feature
  52544. */
  52545. static readonly TELEPORTATION: string;
  52546. /**
  52547. * The name of the feature points feature.
  52548. */
  52549. static readonly FEATURE_POINTS: string;
  52550. /**
  52551. * The name of the hand tracking feature.
  52552. */
  52553. static readonly HAND_TRACKING: string;
  52554. }
  52555. /**
  52556. * Defining the constructor of a feature. Used to register the modules.
  52557. */
  52558. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  52559. /**
  52560. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  52561. * It is mainly used in AR sessions.
  52562. *
  52563. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  52564. */
  52565. export class WebXRFeaturesManager implements IDisposable {
  52566. private _xrSessionManager;
  52567. private static readonly _AvailableFeatures;
  52568. private _features;
  52569. /**
  52570. * constructs a new features manages.
  52571. *
  52572. * @param _xrSessionManager an instance of WebXRSessionManager
  52573. */
  52574. constructor(_xrSessionManager: WebXRSessionManager);
  52575. /**
  52576. * Used to register a module. After calling this function a developer can use this feature in the scene.
  52577. * Mainly used internally.
  52578. *
  52579. * @param featureName the name of the feature to register
  52580. * @param constructorFunction the function used to construct the module
  52581. * @param version the (babylon) version of the module
  52582. * @param stable is that a stable version of this module
  52583. */
  52584. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  52585. /**
  52586. * Returns a constructor of a specific feature.
  52587. *
  52588. * @param featureName the name of the feature to construct
  52589. * @param version the version of the feature to load
  52590. * @param xrSessionManager the xrSessionManager. Used to construct the module
  52591. * @param options optional options provided to the module.
  52592. * @returns a function that, when called, will return a new instance of this feature
  52593. */
  52594. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  52595. /**
  52596. * Can be used to return the list of features currently registered
  52597. *
  52598. * @returns an Array of available features
  52599. */
  52600. static GetAvailableFeatures(): string[];
  52601. /**
  52602. * Gets the versions available for a specific feature
  52603. * @param featureName the name of the feature
  52604. * @returns an array with the available versions
  52605. */
  52606. static GetAvailableVersions(featureName: string): string[];
  52607. /**
  52608. * Return the latest unstable version of this feature
  52609. * @param featureName the name of the feature to search
  52610. * @returns the version number. if not found will return -1
  52611. */
  52612. static GetLatestVersionOfFeature(featureName: string): number;
  52613. /**
  52614. * Return the latest stable version of this feature
  52615. * @param featureName the name of the feature to search
  52616. * @returns the version number. if not found will return -1
  52617. */
  52618. static GetStableVersionOfFeature(featureName: string): number;
  52619. /**
  52620. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  52621. * Can be used during a session to start a feature
  52622. * @param featureName the name of feature to attach
  52623. */
  52624. attachFeature(featureName: string): void;
  52625. /**
  52626. * Can be used inside a session or when the session ends to detach a specific feature
  52627. * @param featureName the name of the feature to detach
  52628. */
  52629. detachFeature(featureName: string): void;
  52630. /**
  52631. * Used to disable an already-enabled feature
  52632. * The feature will be disposed and will be recreated once enabled.
  52633. * @param featureName the feature to disable
  52634. * @returns true if disable was successful
  52635. */
  52636. disableFeature(featureName: string | {
  52637. Name: string;
  52638. }): boolean;
  52639. /**
  52640. * dispose this features manager
  52641. */
  52642. dispose(): void;
  52643. /**
  52644. * 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.
  52645. * 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.
  52646. *
  52647. * @param featureName the name of the feature to load or the class of the feature
  52648. * @param version optional version to load. if not provided the latest version will be enabled
  52649. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  52650. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  52651. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  52652. * @returns a new constructed feature or throws an error if feature not found.
  52653. */
  52654. enableFeature(featureName: string | {
  52655. Name: string;
  52656. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  52657. /**
  52658. * get the implementation of an enabled feature.
  52659. * @param featureName the name of the feature to load
  52660. * @returns the feature class, if found
  52661. */
  52662. getEnabledFeature(featureName: string): IWebXRFeature;
  52663. /**
  52664. * Get the list of enabled features
  52665. * @returns an array of enabled features
  52666. */
  52667. getEnabledFeatures(): string[];
  52668. /**
  52669. * This function will exten the session creation configuration object with enabled features.
  52670. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  52671. * according to the defined "required" variable, provided during enableFeature call
  52672. * @param xrSessionInit the xr Session init object to extend
  52673. *
  52674. * @returns an extended XRSessionInit object
  52675. */
  52676. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  52677. }
  52678. }
  52679. declare module "babylonjs/XR/webXRExperienceHelper" {
  52680. import { Observable } from "babylonjs/Misc/observable";
  52681. import { IDisposable, Scene } from "babylonjs/scene";
  52682. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  52683. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  52684. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  52685. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  52686. /**
  52687. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  52688. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  52689. */
  52690. export class WebXRExperienceHelper implements IDisposable {
  52691. private scene;
  52692. private _nonVRCamera;
  52693. private _originalSceneAutoClear;
  52694. private _supported;
  52695. /**
  52696. * Camera used to render xr content
  52697. */
  52698. camera: WebXRCamera;
  52699. /** A features manager for this xr session */
  52700. featuresManager: WebXRFeaturesManager;
  52701. /**
  52702. * Observers registered here will be triggered after the camera's initial transformation is set
  52703. * This can be used to set a different ground level or an extra rotation.
  52704. *
  52705. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  52706. * to the position set after this observable is done executing.
  52707. */
  52708. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  52709. /**
  52710. * Fires when the state of the experience helper has changed
  52711. */
  52712. onStateChangedObservable: Observable<WebXRState>;
  52713. /** Session manager used to keep track of xr session */
  52714. sessionManager: WebXRSessionManager;
  52715. /**
  52716. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  52717. */
  52718. state: WebXRState;
  52719. /**
  52720. * Creates a WebXRExperienceHelper
  52721. * @param scene The scene the helper should be created in
  52722. */
  52723. private constructor();
  52724. /**
  52725. * Creates the experience helper
  52726. * @param scene the scene to attach the experience helper to
  52727. * @returns a promise for the experience helper
  52728. */
  52729. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  52730. /**
  52731. * Disposes of the experience helper
  52732. */
  52733. dispose(): void;
  52734. /**
  52735. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  52736. * @param sessionMode options for the XR session
  52737. * @param referenceSpaceType frame of reference of the XR session
  52738. * @param renderTarget the output canvas that will be used to enter XR mode
  52739. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  52740. * @returns promise that resolves after xr mode has entered
  52741. */
  52742. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  52743. /**
  52744. * Exits XR mode and returns the scene to its original state
  52745. * @returns promise that resolves after xr mode has exited
  52746. */
  52747. exitXRAsync(): Promise<void>;
  52748. private _nonXRToXRCamera;
  52749. private _setState;
  52750. }
  52751. }
  52752. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  52753. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  52754. import { Observable } from "babylonjs/Misc/observable";
  52755. import { IDisposable } from "babylonjs/scene";
  52756. /**
  52757. * X-Y values for axes in WebXR
  52758. */
  52759. export interface IWebXRMotionControllerAxesValue {
  52760. /**
  52761. * The value of the x axis
  52762. */
  52763. x: number;
  52764. /**
  52765. * The value of the y-axis
  52766. */
  52767. y: number;
  52768. }
  52769. /**
  52770. * changed / previous values for the values of this component
  52771. */
  52772. export interface IWebXRMotionControllerComponentChangesValues<T> {
  52773. /**
  52774. * current (this frame) value
  52775. */
  52776. current: T;
  52777. /**
  52778. * previous (last change) value
  52779. */
  52780. previous: T;
  52781. }
  52782. /**
  52783. * Represents changes in the component between current frame and last values recorded
  52784. */
  52785. export interface IWebXRMotionControllerComponentChanges {
  52786. /**
  52787. * will be populated with previous and current values if axes changed
  52788. */
  52789. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  52790. /**
  52791. * will be populated with previous and current values if pressed changed
  52792. */
  52793. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52794. /**
  52795. * will be populated with previous and current values if touched changed
  52796. */
  52797. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  52798. /**
  52799. * will be populated with previous and current values if value changed
  52800. */
  52801. value?: IWebXRMotionControllerComponentChangesValues<number>;
  52802. }
  52803. /**
  52804. * This class represents a single component (for example button or thumbstick) of a motion controller
  52805. */
  52806. export class WebXRControllerComponent implements IDisposable {
  52807. /**
  52808. * the id of this component
  52809. */
  52810. id: string;
  52811. /**
  52812. * the type of the component
  52813. */
  52814. type: MotionControllerComponentType;
  52815. private _buttonIndex;
  52816. private _axesIndices;
  52817. private _axes;
  52818. private _changes;
  52819. private _currentValue;
  52820. private _hasChanges;
  52821. private _pressed;
  52822. private _touched;
  52823. /**
  52824. * button component type
  52825. */
  52826. static BUTTON_TYPE: MotionControllerComponentType;
  52827. /**
  52828. * squeeze component type
  52829. */
  52830. static SQUEEZE_TYPE: MotionControllerComponentType;
  52831. /**
  52832. * Thumbstick component type
  52833. */
  52834. static THUMBSTICK_TYPE: MotionControllerComponentType;
  52835. /**
  52836. * Touchpad component type
  52837. */
  52838. static TOUCHPAD_TYPE: MotionControllerComponentType;
  52839. /**
  52840. * trigger component type
  52841. */
  52842. static TRIGGER_TYPE: MotionControllerComponentType;
  52843. /**
  52844. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  52845. * the axes data changes
  52846. */
  52847. onAxisValueChangedObservable: Observable<{
  52848. x: number;
  52849. y: number;
  52850. }>;
  52851. /**
  52852. * Observers registered here will be triggered when the state of a button changes
  52853. * State change is either pressed / touched / value
  52854. */
  52855. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  52856. /**
  52857. * Creates a new component for a motion controller.
  52858. * It is created by the motion controller itself
  52859. *
  52860. * @param id the id of this component
  52861. * @param type the type of the component
  52862. * @param _buttonIndex index in the buttons array of the gamepad
  52863. * @param _axesIndices indices of the values in the axes array of the gamepad
  52864. */
  52865. constructor(
  52866. /**
  52867. * the id of this component
  52868. */
  52869. id: string,
  52870. /**
  52871. * the type of the component
  52872. */
  52873. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  52874. /**
  52875. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  52876. */
  52877. get axes(): IWebXRMotionControllerAxesValue;
  52878. /**
  52879. * Get the changes. Elements will be populated only if they changed with their previous and current value
  52880. */
  52881. get changes(): IWebXRMotionControllerComponentChanges;
  52882. /**
  52883. * Return whether or not the component changed the last frame
  52884. */
  52885. get hasChanges(): boolean;
  52886. /**
  52887. * is the button currently pressed
  52888. */
  52889. get pressed(): boolean;
  52890. /**
  52891. * is the button currently touched
  52892. */
  52893. get touched(): boolean;
  52894. /**
  52895. * Get the current value of this component
  52896. */
  52897. get value(): number;
  52898. /**
  52899. * Dispose this component
  52900. */
  52901. dispose(): void;
  52902. /**
  52903. * Are there axes correlating to this component
  52904. * @return true is axes data is available
  52905. */
  52906. isAxes(): boolean;
  52907. /**
  52908. * Is this component a button (hence - pressable)
  52909. * @returns true if can be pressed
  52910. */
  52911. isButton(): boolean;
  52912. /**
  52913. * update this component using the gamepad object it is in. Called on every frame
  52914. * @param nativeController the native gamepad controller object
  52915. */
  52916. update(nativeController: IMinimalMotionControllerObject): void;
  52917. }
  52918. }
  52919. declare module "babylonjs/Loading/sceneLoader" {
  52920. import { Observable } from "babylonjs/Misc/observable";
  52921. import { Nullable } from "babylonjs/types";
  52922. import { Scene } from "babylonjs/scene";
  52923. import { Engine } from "babylonjs/Engines/engine";
  52924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52925. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  52926. import { AssetContainer } from "babylonjs/assetContainer";
  52927. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  52928. import { Skeleton } from "babylonjs/Bones/skeleton";
  52929. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  52930. import { WebRequest } from "babylonjs/Misc/webRequest";
  52931. /**
  52932. * Interface used to represent data loading progression
  52933. */
  52934. export interface ISceneLoaderProgressEvent {
  52935. /**
  52936. * Defines if data length to load can be evaluated
  52937. */
  52938. readonly lengthComputable: boolean;
  52939. /**
  52940. * Defines the loaded data length
  52941. */
  52942. readonly loaded: number;
  52943. /**
  52944. * Defines the data length to load
  52945. */
  52946. readonly total: number;
  52947. }
  52948. /**
  52949. * Interface used by SceneLoader plugins to define supported file extensions
  52950. */
  52951. export interface ISceneLoaderPluginExtensions {
  52952. /**
  52953. * Defines the list of supported extensions
  52954. */
  52955. [extension: string]: {
  52956. isBinary: boolean;
  52957. };
  52958. }
  52959. /**
  52960. * Interface used by SceneLoader plugin factory
  52961. */
  52962. export interface ISceneLoaderPluginFactory {
  52963. /**
  52964. * Defines the name of the factory
  52965. */
  52966. name: string;
  52967. /**
  52968. * Function called to create a new plugin
  52969. * @return the new plugin
  52970. */
  52971. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  52972. /**
  52973. * The callback that returns true if the data can be directly loaded.
  52974. * @param data string containing the file data
  52975. * @returns if the data can be loaded directly
  52976. */
  52977. canDirectLoad?(data: string): boolean;
  52978. }
  52979. /**
  52980. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  52981. */
  52982. export interface ISceneLoaderPluginBase {
  52983. /**
  52984. * The friendly name of this plugin.
  52985. */
  52986. name: string;
  52987. /**
  52988. * The file extensions supported by this plugin.
  52989. */
  52990. extensions: string | ISceneLoaderPluginExtensions;
  52991. /**
  52992. * The callback called when loading from a url.
  52993. * @param scene scene loading this url
  52994. * @param url url to load
  52995. * @param onSuccess callback called when the file successfully loads
  52996. * @param onProgress callback called while file is loading (if the server supports this mode)
  52997. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  52998. * @param onError callback called when the file fails to load
  52999. * @returns a file request object
  53000. */
  53001. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53002. /**
  53003. * The callback called when loading from a file object.
  53004. * @param scene scene loading this file
  53005. * @param file defines the file to load
  53006. * @param onSuccess defines the callback to call when data is loaded
  53007. * @param onProgress defines the callback to call during loading process
  53008. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  53009. * @param onError defines the callback to call when an error occurs
  53010. * @returns a file request object
  53011. */
  53012. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  53013. /**
  53014. * The callback that returns true if the data can be directly loaded.
  53015. * @param data string containing the file data
  53016. * @returns if the data can be loaded directly
  53017. */
  53018. canDirectLoad?(data: string): boolean;
  53019. /**
  53020. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  53021. * @param scene scene loading this data
  53022. * @param data string containing the data
  53023. * @returns data to pass to the plugin
  53024. */
  53025. directLoad?(scene: Scene, data: string): any;
  53026. /**
  53027. * The callback that allows custom handling of the root url based on the response url.
  53028. * @param rootUrl the original root url
  53029. * @param responseURL the response url if available
  53030. * @returns the new root url
  53031. */
  53032. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  53033. }
  53034. /**
  53035. * Interface used to define a SceneLoader plugin
  53036. */
  53037. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  53038. /**
  53039. * Import meshes into a scene.
  53040. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53041. * @param scene The scene to import into
  53042. * @param data The data to import
  53043. * @param rootUrl The root url for scene and resources
  53044. * @param meshes The meshes array to import into
  53045. * @param particleSystems The particle systems array to import into
  53046. * @param skeletons The skeletons array to import into
  53047. * @param onError The callback when import fails
  53048. * @returns True if successful or false otherwise
  53049. */
  53050. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  53051. /**
  53052. * Load into a scene.
  53053. * @param scene The scene to load into
  53054. * @param data The data to import
  53055. * @param rootUrl The root url for scene and resources
  53056. * @param onError The callback when import fails
  53057. * @returns True if successful or false otherwise
  53058. */
  53059. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  53060. /**
  53061. * Load into an asset container.
  53062. * @param scene The scene to load into
  53063. * @param data The data to import
  53064. * @param rootUrl The root url for scene and resources
  53065. * @param onError The callback when import fails
  53066. * @returns The loaded asset container
  53067. */
  53068. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  53069. }
  53070. /**
  53071. * Interface used to define an async SceneLoader plugin
  53072. */
  53073. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  53074. /**
  53075. * Import meshes into a scene.
  53076. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53077. * @param scene The scene to import into
  53078. * @param data The data to import
  53079. * @param rootUrl The root url for scene and resources
  53080. * @param onProgress The callback when the load progresses
  53081. * @param fileName Defines the name of the file to load
  53082. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  53083. */
  53084. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  53085. meshes: AbstractMesh[];
  53086. particleSystems: IParticleSystem[];
  53087. skeletons: Skeleton[];
  53088. animationGroups: AnimationGroup[];
  53089. }>;
  53090. /**
  53091. * Load into a scene.
  53092. * @param scene The scene to load into
  53093. * @param data The data to import
  53094. * @param rootUrl The root url for scene and resources
  53095. * @param onProgress The callback when the load progresses
  53096. * @param fileName Defines the name of the file to load
  53097. * @returns Nothing
  53098. */
  53099. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  53100. /**
  53101. * Load into an asset container.
  53102. * @param scene The scene to load into
  53103. * @param data The data to import
  53104. * @param rootUrl The root url for scene and resources
  53105. * @param onProgress The callback when the load progresses
  53106. * @param fileName Defines the name of the file to load
  53107. * @returns The loaded asset container
  53108. */
  53109. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  53110. }
  53111. /**
  53112. * Mode that determines how to handle old animation groups before loading new ones.
  53113. */
  53114. export enum SceneLoaderAnimationGroupLoadingMode {
  53115. /**
  53116. * Reset all old animations to initial state then dispose them.
  53117. */
  53118. Clean = 0,
  53119. /**
  53120. * Stop all old animations.
  53121. */
  53122. Stop = 1,
  53123. /**
  53124. * Restart old animations from first frame.
  53125. */
  53126. Sync = 2,
  53127. /**
  53128. * Old animations remains untouched.
  53129. */
  53130. NoSync = 3
  53131. }
  53132. /**
  53133. * Defines a plugin registered by the SceneLoader
  53134. */
  53135. interface IRegisteredPlugin {
  53136. /**
  53137. * Defines the plugin to use
  53138. */
  53139. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53140. /**
  53141. * Defines if the plugin supports binary data
  53142. */
  53143. isBinary: boolean;
  53144. }
  53145. /**
  53146. * Class used to load scene from various file formats using registered plugins
  53147. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  53148. */
  53149. export class SceneLoader {
  53150. /**
  53151. * No logging while loading
  53152. */
  53153. static readonly NO_LOGGING: number;
  53154. /**
  53155. * Minimal logging while loading
  53156. */
  53157. static readonly MINIMAL_LOGGING: number;
  53158. /**
  53159. * Summary logging while loading
  53160. */
  53161. static readonly SUMMARY_LOGGING: number;
  53162. /**
  53163. * Detailled logging while loading
  53164. */
  53165. static readonly DETAILED_LOGGING: number;
  53166. /**
  53167. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  53168. */
  53169. static get ForceFullSceneLoadingForIncremental(): boolean;
  53170. static set ForceFullSceneLoadingForIncremental(value: boolean);
  53171. /**
  53172. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  53173. */
  53174. static get ShowLoadingScreen(): boolean;
  53175. static set ShowLoadingScreen(value: boolean);
  53176. /**
  53177. * Defines the current logging level (while loading the scene)
  53178. * @ignorenaming
  53179. */
  53180. static get loggingLevel(): number;
  53181. static set loggingLevel(value: number);
  53182. /**
  53183. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  53184. */
  53185. static get CleanBoneMatrixWeights(): boolean;
  53186. static set CleanBoneMatrixWeights(value: boolean);
  53187. /**
  53188. * Event raised when a plugin is used to load a scene
  53189. */
  53190. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  53191. private static _registeredPlugins;
  53192. private static _showingLoadingScreen;
  53193. /**
  53194. * Gets the default plugin (used to load Babylon files)
  53195. * @returns the .babylon plugin
  53196. */
  53197. static GetDefaultPlugin(): IRegisteredPlugin;
  53198. private static _GetPluginForExtension;
  53199. private static _GetPluginForDirectLoad;
  53200. private static _GetPluginForFilename;
  53201. private static _GetDirectLoad;
  53202. private static _LoadData;
  53203. private static _GetFileInfo;
  53204. /**
  53205. * Gets a plugin that can load the given extension
  53206. * @param extension defines the extension to load
  53207. * @returns a plugin or null if none works
  53208. */
  53209. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  53210. /**
  53211. * Gets a boolean indicating that the given extension can be loaded
  53212. * @param extension defines the extension to load
  53213. * @returns true if the extension is supported
  53214. */
  53215. static IsPluginForExtensionAvailable(extension: string): boolean;
  53216. /**
  53217. * Adds a new plugin to the list of registered plugins
  53218. * @param plugin defines the plugin to add
  53219. */
  53220. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  53221. /**
  53222. * Import meshes into a scene
  53223. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53224. * @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)
  53225. * @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)
  53226. * @param scene the instance of BABYLON.Scene to append to
  53227. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  53228. * @param onProgress a callback with a progress event for each file being loaded
  53229. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53230. * @param pluginExtension the extension used to determine the plugin
  53231. * @returns The loaded plugin
  53232. */
  53233. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  53234. /**
  53235. * Import meshes into a scene
  53236. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  53237. * @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)
  53238. * @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)
  53239. * @param scene the instance of BABYLON.Scene to append to
  53240. * @param onProgress a callback with a progress event for each file being loaded
  53241. * @param pluginExtension the extension used to determine the plugin
  53242. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  53243. */
  53244. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  53245. meshes: AbstractMesh[];
  53246. particleSystems: IParticleSystem[];
  53247. skeletons: Skeleton[];
  53248. animationGroups: AnimationGroup[];
  53249. }>;
  53250. /**
  53251. * Load a scene
  53252. * @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)
  53253. * @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)
  53254. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53255. * @param onSuccess a callback with the scene when import succeeds
  53256. * @param onProgress a callback with a progress event for each file being loaded
  53257. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53258. * @param pluginExtension the extension used to determine the plugin
  53259. * @returns The loaded plugin
  53260. */
  53261. 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>;
  53262. /**
  53263. * Load a scene
  53264. * @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)
  53265. * @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)
  53266. * @param engine is the instance of BABYLON.Engine to use to create the scene
  53267. * @param onProgress a callback with a progress event for each file being loaded
  53268. * @param pluginExtension the extension used to determine the plugin
  53269. * @returns The loaded scene
  53270. */
  53271. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53272. /**
  53273. * Append a scene
  53274. * @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)
  53275. * @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)
  53276. * @param scene is the instance of BABYLON.Scene to append to
  53277. * @param onSuccess a callback with the scene when import succeeds
  53278. * @param onProgress a callback with a progress event for each file being loaded
  53279. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53280. * @param pluginExtension the extension used to determine the plugin
  53281. * @returns The loaded plugin
  53282. */
  53283. 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>;
  53284. /**
  53285. * Append a scene
  53286. * @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)
  53287. * @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)
  53288. * @param scene is the instance of BABYLON.Scene to append to
  53289. * @param onProgress a callback with a progress event for each file being loaded
  53290. * @param pluginExtension the extension used to determine the plugin
  53291. * @returns The given scene
  53292. */
  53293. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  53294. /**
  53295. * Load a scene into an asset container
  53296. * @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)
  53297. * @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)
  53298. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53299. * @param onSuccess a callback with the scene when import succeeds
  53300. * @param onProgress a callback with a progress event for each file being loaded
  53301. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53302. * @param pluginExtension the extension used to determine the plugin
  53303. * @returns The loaded plugin
  53304. */
  53305. 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>;
  53306. /**
  53307. * Load a scene into an asset container
  53308. * @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)
  53309. * @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)
  53310. * @param scene is the instance of Scene to append to
  53311. * @param onProgress a callback with a progress event for each file being loaded
  53312. * @param pluginExtension the extension used to determine the plugin
  53313. * @returns The loaded asset container
  53314. */
  53315. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  53316. /**
  53317. * Import animations from a file into a scene
  53318. * @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)
  53319. * @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)
  53320. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53321. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53322. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53323. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53324. * @param onSuccess a callback with the scene when import succeeds
  53325. * @param onProgress a callback with a progress event for each file being loaded
  53326. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53327. * @param pluginExtension the extension used to determine the plugin
  53328. */
  53329. 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;
  53330. /**
  53331. * Import animations from a file into a scene
  53332. * @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)
  53333. * @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)
  53334. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  53335. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  53336. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  53337. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  53338. * @param onSuccess a callback with the scene when import succeeds
  53339. * @param onProgress a callback with a progress event for each file being loaded
  53340. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  53341. * @param pluginExtension the extension used to determine the plugin
  53342. * @returns the updated scene with imported animations
  53343. */
  53344. 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>;
  53345. }
  53346. }
  53347. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  53348. import { IDisposable, Scene } from "babylonjs/scene";
  53349. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  53350. import { Observable } from "babylonjs/Misc/observable";
  53351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53352. import { Nullable } from "babylonjs/types";
  53353. /**
  53354. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  53355. */
  53356. export type MotionControllerHandedness = "none" | "left" | "right";
  53357. /**
  53358. * The type of components available in motion controllers.
  53359. * This is not the name of the component.
  53360. */
  53361. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  53362. /**
  53363. * The state of a controller component
  53364. */
  53365. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  53366. /**
  53367. * The schema of motion controller layout.
  53368. * No object will be initialized using this interface
  53369. * This is used just to define the profile.
  53370. */
  53371. export interface IMotionControllerLayout {
  53372. /**
  53373. * Path to load the assets. Usually relative to the base path
  53374. */
  53375. assetPath: string;
  53376. /**
  53377. * Available components (unsorted)
  53378. */
  53379. components: {
  53380. /**
  53381. * A map of component Ids
  53382. */
  53383. [componentId: string]: {
  53384. /**
  53385. * The type of input the component outputs
  53386. */
  53387. type: MotionControllerComponentType;
  53388. /**
  53389. * The indices of this component in the gamepad object
  53390. */
  53391. gamepadIndices: {
  53392. /**
  53393. * Index of button
  53394. */
  53395. button?: number;
  53396. /**
  53397. * If available, index of x-axis
  53398. */
  53399. xAxis?: number;
  53400. /**
  53401. * If available, index of y-axis
  53402. */
  53403. yAxis?: number;
  53404. };
  53405. /**
  53406. * The mesh's root node name
  53407. */
  53408. rootNodeName: string;
  53409. /**
  53410. * Animation definitions for this model
  53411. */
  53412. visualResponses: {
  53413. [stateKey: string]: {
  53414. /**
  53415. * What property will be animated
  53416. */
  53417. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  53418. /**
  53419. * What states influence this visual response
  53420. */
  53421. states: MotionControllerComponentStateType[];
  53422. /**
  53423. * Type of animation - movement or visibility
  53424. */
  53425. valueNodeProperty: "transform" | "visibility";
  53426. /**
  53427. * Base node name to move. Its position will be calculated according to the min and max nodes
  53428. */
  53429. valueNodeName?: string;
  53430. /**
  53431. * Minimum movement node
  53432. */
  53433. minNodeName?: string;
  53434. /**
  53435. * Max movement node
  53436. */
  53437. maxNodeName?: string;
  53438. };
  53439. };
  53440. /**
  53441. * If touch enabled, what is the name of node to display user feedback
  53442. */
  53443. touchPointNodeName?: string;
  53444. };
  53445. };
  53446. /**
  53447. * Is it xr standard mapping or not
  53448. */
  53449. gamepadMapping: "" | "xr-standard";
  53450. /**
  53451. * Base root node of this entire model
  53452. */
  53453. rootNodeName: string;
  53454. /**
  53455. * Defines the main button component id
  53456. */
  53457. selectComponentId: string;
  53458. }
  53459. /**
  53460. * A definition for the layout map in the input profile
  53461. */
  53462. export interface IMotionControllerLayoutMap {
  53463. /**
  53464. * Layouts with handedness type as a key
  53465. */
  53466. [handedness: string]: IMotionControllerLayout;
  53467. }
  53468. /**
  53469. * The XR Input profile schema
  53470. * Profiles can be found here:
  53471. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  53472. */
  53473. export interface IMotionControllerProfile {
  53474. /**
  53475. * fallback profiles for this profileId
  53476. */
  53477. fallbackProfileIds: string[];
  53478. /**
  53479. * The layout map, with handedness as key
  53480. */
  53481. layouts: IMotionControllerLayoutMap;
  53482. /**
  53483. * The id of this profile
  53484. * correlates to the profile(s) in the xrInput.profiles array
  53485. */
  53486. profileId: string;
  53487. }
  53488. /**
  53489. * A helper-interface for the 3 meshes needed for controller button animation
  53490. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  53491. */
  53492. export interface IMotionControllerButtonMeshMap {
  53493. /**
  53494. * the mesh that defines the pressed value mesh position.
  53495. * This is used to find the max-position of this button
  53496. */
  53497. pressedMesh: AbstractMesh;
  53498. /**
  53499. * the mesh that defines the unpressed value mesh position.
  53500. * This is used to find the min (or initial) position of this button
  53501. */
  53502. unpressedMesh: AbstractMesh;
  53503. /**
  53504. * The mesh that will be changed when value changes
  53505. */
  53506. valueMesh: AbstractMesh;
  53507. }
  53508. /**
  53509. * A helper-interface for the 3 meshes needed for controller axis animation.
  53510. * This will be expanded when touchpad animations are fully supported
  53511. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  53512. */
  53513. export interface IMotionControllerMeshMap {
  53514. /**
  53515. * the mesh that defines the maximum value mesh position.
  53516. */
  53517. maxMesh?: AbstractMesh;
  53518. /**
  53519. * the mesh that defines the minimum value mesh position.
  53520. */
  53521. minMesh?: AbstractMesh;
  53522. /**
  53523. * The mesh that will be changed when axis value changes
  53524. */
  53525. valueMesh?: AbstractMesh;
  53526. }
  53527. /**
  53528. * The elements needed for change-detection of the gamepad objects in motion controllers
  53529. */
  53530. export interface IMinimalMotionControllerObject {
  53531. /**
  53532. * Available axes of this controller
  53533. */
  53534. axes: number[];
  53535. /**
  53536. * An array of available buttons
  53537. */
  53538. buttons: Array<{
  53539. /**
  53540. * Value of the button/trigger
  53541. */
  53542. value: number;
  53543. /**
  53544. * If the button/trigger is currently touched
  53545. */
  53546. touched: boolean;
  53547. /**
  53548. * If the button/trigger is currently pressed
  53549. */
  53550. pressed: boolean;
  53551. }>;
  53552. /**
  53553. * EXPERIMENTAL haptic support.
  53554. */
  53555. hapticActuators?: Array<{
  53556. pulse: (value: number, duration: number) => Promise<boolean>;
  53557. }>;
  53558. }
  53559. /**
  53560. * An Abstract Motion controller
  53561. * This class receives an xrInput and a profile layout and uses those to initialize the components
  53562. * Each component has an observable to check for changes in value and state
  53563. */
  53564. export abstract class WebXRAbstractMotionController implements IDisposable {
  53565. protected scene: Scene;
  53566. protected layout: IMotionControllerLayout;
  53567. /**
  53568. * The gamepad object correlating to this controller
  53569. */
  53570. gamepadObject: IMinimalMotionControllerObject;
  53571. /**
  53572. * handedness (left/right/none) of this controller
  53573. */
  53574. handedness: MotionControllerHandedness;
  53575. private _initComponent;
  53576. private _modelReady;
  53577. /**
  53578. * A map of components (WebXRControllerComponent) in this motion controller
  53579. * Components have a ComponentType and can also have both button and axis definitions
  53580. */
  53581. readonly components: {
  53582. [id: string]: WebXRControllerComponent;
  53583. };
  53584. /**
  53585. * Disable the model's animation. Can be set at any time.
  53586. */
  53587. disableAnimation: boolean;
  53588. /**
  53589. * Observers registered here will be triggered when the model of this controller is done loading
  53590. */
  53591. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  53592. /**
  53593. * The profile id of this motion controller
  53594. */
  53595. abstract profileId: string;
  53596. /**
  53597. * The root mesh of the model. It is null if the model was not yet initialized
  53598. */
  53599. rootMesh: Nullable<AbstractMesh>;
  53600. /**
  53601. * constructs a new abstract motion controller
  53602. * @param scene the scene to which the model of the controller will be added
  53603. * @param layout The profile layout to load
  53604. * @param gamepadObject The gamepad object correlating to this controller
  53605. * @param handedness handedness (left/right/none) of this controller
  53606. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  53607. */
  53608. constructor(scene: Scene, layout: IMotionControllerLayout,
  53609. /**
  53610. * The gamepad object correlating to this controller
  53611. */
  53612. gamepadObject: IMinimalMotionControllerObject,
  53613. /**
  53614. * handedness (left/right/none) of this controller
  53615. */
  53616. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  53617. /**
  53618. * Dispose this controller, the model mesh and all its components
  53619. */
  53620. dispose(): void;
  53621. /**
  53622. * Returns all components of specific type
  53623. * @param type the type to search for
  53624. * @return an array of components with this type
  53625. */
  53626. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  53627. /**
  53628. * get a component based an its component id as defined in layout.components
  53629. * @param id the id of the component
  53630. * @returns the component correlates to the id or undefined if not found
  53631. */
  53632. getComponent(id: string): WebXRControllerComponent;
  53633. /**
  53634. * Get the list of components available in this motion controller
  53635. * @returns an array of strings correlating to available components
  53636. */
  53637. getComponentIds(): string[];
  53638. /**
  53639. * Get the first component of specific type
  53640. * @param type type of component to find
  53641. * @return a controller component or null if not found
  53642. */
  53643. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  53644. /**
  53645. * Get the main (Select) component of this controller as defined in the layout
  53646. * @returns the main component of this controller
  53647. */
  53648. getMainComponent(): WebXRControllerComponent;
  53649. /**
  53650. * Loads the model correlating to this controller
  53651. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  53652. * @returns A promise fulfilled with the result of the model loading
  53653. */
  53654. loadModel(): Promise<boolean>;
  53655. /**
  53656. * Update this model using the current XRFrame
  53657. * @param xrFrame the current xr frame to use and update the model
  53658. */
  53659. updateFromXRFrame(xrFrame: XRFrame): void;
  53660. /**
  53661. * Backwards compatibility due to a deeply-integrated typo
  53662. */
  53663. get handness(): XREye;
  53664. /**
  53665. * Pulse (vibrate) this controller
  53666. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  53667. * Consecutive calls to this function will cancel the last pulse call
  53668. *
  53669. * @param value the strength of the pulse in 0.0...1.0 range
  53670. * @param duration Duration of the pulse in milliseconds
  53671. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  53672. * @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
  53673. */
  53674. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  53675. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53676. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  53677. /**
  53678. * Moves the axis on the controller mesh based on its current state
  53679. * @param axis the index of the axis
  53680. * @param axisValue the value of the axis which determines the meshes new position
  53681. * @hidden
  53682. */
  53683. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  53684. /**
  53685. * Update the model itself with the current frame data
  53686. * @param xrFrame the frame to use for updating the model mesh
  53687. */
  53688. protected updateModel(xrFrame: XRFrame): void;
  53689. /**
  53690. * Get the filename and path for this controller's model
  53691. * @returns a map of filename and path
  53692. */
  53693. protected abstract _getFilenameAndPath(): {
  53694. filename: string;
  53695. path: string;
  53696. };
  53697. /**
  53698. * This function is called before the mesh is loaded. It checks for loading constraints.
  53699. * For example, this function can check if the GLB loader is available
  53700. * If this function returns false, the generic controller will be loaded instead
  53701. * @returns Is the client ready to load the mesh
  53702. */
  53703. protected abstract _getModelLoadingConstraints(): boolean;
  53704. /**
  53705. * This function will be called after the model was successfully loaded and can be used
  53706. * for mesh transformations before it is available for the user
  53707. * @param meshes the loaded meshes
  53708. */
  53709. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  53710. /**
  53711. * Set the root mesh for this controller. Important for the WebXR controller class
  53712. * @param meshes the loaded meshes
  53713. */
  53714. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  53715. /**
  53716. * A function executed each frame that updates the mesh (if needed)
  53717. * @param xrFrame the current xrFrame
  53718. */
  53719. protected abstract _updateModel(xrFrame: XRFrame): void;
  53720. private _getGenericFilenameAndPath;
  53721. private _getGenericParentMesh;
  53722. }
  53723. }
  53724. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  53725. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53727. import { Scene } from "babylonjs/scene";
  53728. /**
  53729. * A generic trigger-only motion controller for WebXR
  53730. */
  53731. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  53732. /**
  53733. * Static version of the profile id of this controller
  53734. */
  53735. static ProfileId: string;
  53736. profileId: string;
  53737. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  53738. protected _getFilenameAndPath(): {
  53739. filename: string;
  53740. path: string;
  53741. };
  53742. protected _getModelLoadingConstraints(): boolean;
  53743. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  53744. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53745. protected _updateModel(): void;
  53746. }
  53747. }
  53748. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  53749. import { Vector4 } from "babylonjs/Maths/math.vector";
  53750. import { Mesh } from "babylonjs/Meshes/mesh";
  53751. import { Scene } from "babylonjs/scene";
  53752. import { Nullable } from "babylonjs/types";
  53753. /**
  53754. * Class containing static functions to help procedurally build meshes
  53755. */
  53756. export class SphereBuilder {
  53757. /**
  53758. * Creates a sphere mesh
  53759. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53760. * * 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`)
  53761. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53762. * * 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
  53763. * * 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)
  53764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53765. * * 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
  53766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53767. * @param name defines the name of the mesh
  53768. * @param options defines the options used to create the mesh
  53769. * @param scene defines the hosting scene
  53770. * @returns the sphere mesh
  53771. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53772. */
  53773. static CreateSphere(name: string, options: {
  53774. segments?: number;
  53775. diameter?: number;
  53776. diameterX?: number;
  53777. diameterY?: number;
  53778. diameterZ?: number;
  53779. arc?: number;
  53780. slice?: number;
  53781. sideOrientation?: number;
  53782. frontUVs?: Vector4;
  53783. backUVs?: Vector4;
  53784. updatable?: boolean;
  53785. }, scene?: Nullable<Scene>): Mesh;
  53786. }
  53787. }
  53788. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  53789. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53790. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53791. import { Scene } from "babylonjs/scene";
  53792. /**
  53793. * A profiled motion controller has its profile loaded from an online repository.
  53794. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  53795. */
  53796. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  53797. private _repositoryUrl;
  53798. private _buttonMeshMapping;
  53799. private _touchDots;
  53800. /**
  53801. * The profile ID of this controller. Will be populated when the controller initializes.
  53802. */
  53803. profileId: string;
  53804. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  53805. dispose(): void;
  53806. protected _getFilenameAndPath(): {
  53807. filename: string;
  53808. path: string;
  53809. };
  53810. protected _getModelLoadingConstraints(): boolean;
  53811. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  53812. protected _setRootMesh(meshes: AbstractMesh[]): void;
  53813. protected _updateModel(_xrFrame: XRFrame): void;
  53814. }
  53815. }
  53816. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  53817. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53818. import { Scene } from "babylonjs/scene";
  53819. /**
  53820. * A construction function type to create a new controller based on an xrInput object
  53821. */
  53822. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  53823. /**
  53824. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  53825. *
  53826. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  53827. * it should be replaced with auto-loaded controllers.
  53828. *
  53829. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  53830. */
  53831. export class WebXRMotionControllerManager {
  53832. private static _AvailableControllers;
  53833. private static _Fallbacks;
  53834. private static _ProfileLoadingPromises;
  53835. private static _ProfilesList;
  53836. /**
  53837. * The base URL of the online controller repository. Can be changed at any time.
  53838. */
  53839. static BaseRepositoryUrl: string;
  53840. /**
  53841. * Which repository gets priority - local or online
  53842. */
  53843. static PrioritizeOnlineRepository: boolean;
  53844. /**
  53845. * Use the online repository, or use only locally-defined controllers
  53846. */
  53847. static UseOnlineRepository: boolean;
  53848. /**
  53849. * Clear the cache used for profile loading and reload when requested again
  53850. */
  53851. static ClearProfilesCache(): void;
  53852. /**
  53853. * Register the default fallbacks.
  53854. * This function is called automatically when this file is imported.
  53855. */
  53856. static DefaultFallbacks(): void;
  53857. /**
  53858. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  53859. * @param profileId the profile to which a fallback needs to be found
  53860. * @return an array with corresponding fallback profiles
  53861. */
  53862. static FindFallbackWithProfileId(profileId: string): string[];
  53863. /**
  53864. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  53865. * The order of search:
  53866. *
  53867. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  53868. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  53869. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  53870. * 4) return the generic trigger controller if none were found
  53871. *
  53872. * @param xrInput the xrInput to which a new controller is initialized
  53873. * @param scene the scene to which the model will be added
  53874. * @param forceProfile force a certain profile for this controller
  53875. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  53876. */
  53877. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  53878. /**
  53879. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  53880. *
  53881. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  53882. *
  53883. * @param type the profile type to register
  53884. * @param constructFunction the function to be called when loading this profile
  53885. */
  53886. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  53887. /**
  53888. * Register a fallback to a specific profile.
  53889. * @param profileId the profileId that will receive the fallbacks
  53890. * @param fallbacks A list of fallback profiles
  53891. */
  53892. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  53893. /**
  53894. * Will update the list of profiles available in the repository
  53895. * @return a promise that resolves to a map of profiles available online
  53896. */
  53897. static UpdateProfilesList(): Promise<{
  53898. [profile: string]: string;
  53899. }>;
  53900. private static _LoadProfileFromRepository;
  53901. private static _LoadProfilesFromAvailableControllers;
  53902. }
  53903. }
  53904. declare module "babylonjs/XR/webXRInputSource" {
  53905. import { Observable } from "babylonjs/Misc/observable";
  53906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53907. import { Ray } from "babylonjs/Culling/ray";
  53908. import { Scene } from "babylonjs/scene";
  53909. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  53910. /**
  53911. * Configuration options for the WebXR controller creation
  53912. */
  53913. export interface IWebXRControllerOptions {
  53914. /**
  53915. * Should the controller mesh be animated when a user interacts with it
  53916. * The pressed buttons / thumbstick and touchpad animations will be disabled
  53917. */
  53918. disableMotionControllerAnimation?: boolean;
  53919. /**
  53920. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  53921. */
  53922. doNotLoadControllerMesh?: boolean;
  53923. /**
  53924. * Force a specific controller type for this controller.
  53925. * This can be used when creating your own profile or when testing different controllers
  53926. */
  53927. forceControllerProfile?: string;
  53928. /**
  53929. * Defines a rendering group ID for meshes that will be loaded.
  53930. * This is for the default controllers only.
  53931. */
  53932. renderingGroupId?: number;
  53933. }
  53934. /**
  53935. * Represents an XR controller
  53936. */
  53937. export class WebXRInputSource {
  53938. private _scene;
  53939. /** The underlying input source for the controller */
  53940. inputSource: XRInputSource;
  53941. private _options;
  53942. private _tmpVector;
  53943. private _uniqueId;
  53944. private _disposed;
  53945. /**
  53946. * 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
  53947. */
  53948. grip?: AbstractMesh;
  53949. /**
  53950. * If available, this is the gamepad object related to this controller.
  53951. * Using this object it is possible to get click events and trackpad changes of the
  53952. * webxr controller that is currently being used.
  53953. */
  53954. motionController?: WebXRAbstractMotionController;
  53955. /**
  53956. * Event that fires when the controller is removed/disposed.
  53957. * The object provided as event data is this controller, after associated assets were disposed.
  53958. * uniqueId is still available.
  53959. */
  53960. onDisposeObservable: Observable<WebXRInputSource>;
  53961. /**
  53962. * Will be triggered when the mesh associated with the motion controller is done loading.
  53963. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  53964. * A shortened version of controller -> motion controller -> on mesh loaded.
  53965. */
  53966. onMeshLoadedObservable: Observable<AbstractMesh>;
  53967. /**
  53968. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  53969. */
  53970. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  53971. /**
  53972. * Pointer which can be used to select objects or attach a visible laser to
  53973. */
  53974. pointer: AbstractMesh;
  53975. /**
  53976. * Creates the input source object
  53977. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  53978. * @param _scene the scene which the controller should be associated to
  53979. * @param inputSource the underlying input source for the controller
  53980. * @param _options options for this controller creation
  53981. */
  53982. constructor(_scene: Scene,
  53983. /** The underlying input source for the controller */
  53984. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  53985. /**
  53986. * Get this controllers unique id
  53987. */
  53988. get uniqueId(): string;
  53989. /**
  53990. * Disposes of the object
  53991. */
  53992. dispose(): void;
  53993. /**
  53994. * Gets a world space ray coming from the pointer or grip
  53995. * @param result the resulting ray
  53996. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  53997. */
  53998. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  53999. /**
  54000. * Updates the controller pose based on the given XRFrame
  54001. * @param xrFrame xr frame to update the pose with
  54002. * @param referenceSpace reference space to use
  54003. */
  54004. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  54005. }
  54006. }
  54007. declare module "babylonjs/XR/webXRInput" {
  54008. import { Observable } from "babylonjs/Misc/observable";
  54009. import { IDisposable } from "babylonjs/scene";
  54010. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  54011. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54012. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54013. /**
  54014. * The schema for initialization options of the XR Input class
  54015. */
  54016. export interface IWebXRInputOptions {
  54017. /**
  54018. * If set to true no model will be automatically loaded
  54019. */
  54020. doNotLoadControllerMeshes?: boolean;
  54021. /**
  54022. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  54023. * If not found, the xr input profile data will be used.
  54024. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  54025. */
  54026. forceInputProfile?: string;
  54027. /**
  54028. * Do not send a request to the controller repository to load the profile.
  54029. *
  54030. * Instead, use the controllers available in babylon itself.
  54031. */
  54032. disableOnlineControllerRepository?: boolean;
  54033. /**
  54034. * A custom URL for the controllers repository
  54035. */
  54036. customControllersRepositoryURL?: string;
  54037. /**
  54038. * Should the controller model's components not move according to the user input
  54039. */
  54040. disableControllerAnimation?: boolean;
  54041. /**
  54042. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  54043. */
  54044. controllerOptions?: IWebXRControllerOptions;
  54045. }
  54046. /**
  54047. * XR input used to track XR inputs such as controllers/rays
  54048. */
  54049. export class WebXRInput implements IDisposable {
  54050. /**
  54051. * the xr session manager for this session
  54052. */
  54053. xrSessionManager: WebXRSessionManager;
  54054. /**
  54055. * the WebXR camera for this session. Mainly used for teleportation
  54056. */
  54057. xrCamera: WebXRCamera;
  54058. private readonly options;
  54059. /**
  54060. * XR controllers being tracked
  54061. */
  54062. controllers: Array<WebXRInputSource>;
  54063. private _frameObserver;
  54064. private _sessionEndedObserver;
  54065. private _sessionInitObserver;
  54066. /**
  54067. * Event when a controller has been connected/added
  54068. */
  54069. onControllerAddedObservable: Observable<WebXRInputSource>;
  54070. /**
  54071. * Event when a controller has been removed/disconnected
  54072. */
  54073. onControllerRemovedObservable: Observable<WebXRInputSource>;
  54074. /**
  54075. * Initializes the WebXRInput
  54076. * @param xrSessionManager the xr session manager for this session
  54077. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  54078. * @param options = initialization options for this xr input
  54079. */
  54080. constructor(
  54081. /**
  54082. * the xr session manager for this session
  54083. */
  54084. xrSessionManager: WebXRSessionManager,
  54085. /**
  54086. * the WebXR camera for this session. Mainly used for teleportation
  54087. */
  54088. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  54089. private _onInputSourcesChange;
  54090. private _addAndRemoveControllers;
  54091. /**
  54092. * Disposes of the object
  54093. */
  54094. dispose(): void;
  54095. }
  54096. }
  54097. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  54098. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54099. import { Observable, EventState } from "babylonjs/Misc/observable";
  54100. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54101. /**
  54102. * This is the base class for all WebXR features.
  54103. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  54104. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  54105. */
  54106. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  54107. protected _xrSessionManager: WebXRSessionManager;
  54108. private _attached;
  54109. private _removeOnDetach;
  54110. /**
  54111. * Is this feature disposed?
  54112. */
  54113. isDisposed: boolean;
  54114. /**
  54115. * Should auto-attach be disabled?
  54116. */
  54117. disableAutoAttach: boolean;
  54118. /**
  54119. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  54120. */
  54121. xrNativeFeatureName: string;
  54122. /**
  54123. * Construct a new (abstract) WebXR feature
  54124. * @param _xrSessionManager the xr session manager for this feature
  54125. */
  54126. constructor(_xrSessionManager: WebXRSessionManager);
  54127. /**
  54128. * Is this feature attached
  54129. */
  54130. get attached(): boolean;
  54131. /**
  54132. * attach this feature
  54133. *
  54134. * @param force should attachment be forced (even when already attached)
  54135. * @returns true if successful, false is failed or already attached
  54136. */
  54137. attach(force?: boolean): boolean;
  54138. /**
  54139. * detach this feature.
  54140. *
  54141. * @returns true if successful, false if failed or already detached
  54142. */
  54143. detach(): boolean;
  54144. /**
  54145. * Dispose this feature and all of the resources attached
  54146. */
  54147. dispose(): void;
  54148. /**
  54149. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  54150. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  54151. *
  54152. * @returns whether or not the feature is compatible in this environment
  54153. */
  54154. isCompatible(): boolean;
  54155. /**
  54156. * This is used to register callbacks that will automatically be removed when detach is called.
  54157. * @param observable the observable to which the observer will be attached
  54158. * @param callback the callback to register
  54159. */
  54160. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  54161. /**
  54162. * Code in this function will be executed on each xrFrame received from the browser.
  54163. * This function will not execute after the feature is detached.
  54164. * @param _xrFrame the current frame
  54165. */
  54166. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  54167. }
  54168. }
  54169. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  54170. import { IDisposable, Scene } from "babylonjs/scene";
  54171. import { Nullable } from "babylonjs/types";
  54172. import { Observable } from "babylonjs/Misc/observable";
  54173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54174. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  54175. import { Camera } from "babylonjs/Cameras/camera";
  54176. /**
  54177. * Renders a layer on top of an existing scene
  54178. */
  54179. export class UtilityLayerRenderer implements IDisposable {
  54180. /** the original scene that will be rendered on top of */
  54181. originalScene: Scene;
  54182. private _pointerCaptures;
  54183. private _lastPointerEvents;
  54184. private static _DefaultUtilityLayer;
  54185. private static _DefaultKeepDepthUtilityLayer;
  54186. private _sharedGizmoLight;
  54187. private _renderCamera;
  54188. /**
  54189. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  54190. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  54191. * @returns the camera that is used when rendering the utility layer
  54192. */
  54193. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  54194. /**
  54195. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  54196. * @param cam the camera that should be used when rendering the utility layer
  54197. */
  54198. setRenderCamera(cam: Nullable<Camera>): void;
  54199. /**
  54200. * @hidden
  54201. * Light which used by gizmos to get light shading
  54202. */
  54203. _getSharedGizmoLight(): HemisphericLight;
  54204. /**
  54205. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  54206. */
  54207. pickUtilitySceneFirst: boolean;
  54208. /**
  54209. * 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)
  54210. */
  54211. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  54212. /**
  54213. * 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)
  54214. */
  54215. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  54216. /**
  54217. * The scene that is rendered on top of the original scene
  54218. */
  54219. utilityLayerScene: Scene;
  54220. /**
  54221. * If the utility layer should automatically be rendered on top of existing scene
  54222. */
  54223. shouldRender: boolean;
  54224. /**
  54225. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  54226. */
  54227. onlyCheckPointerDownEvents: boolean;
  54228. /**
  54229. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  54230. */
  54231. processAllEvents: boolean;
  54232. /**
  54233. * Observable raised when the pointer move from the utility layer scene to the main scene
  54234. */
  54235. onPointerOutObservable: Observable<number>;
  54236. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  54237. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  54238. private _afterRenderObserver;
  54239. private _sceneDisposeObserver;
  54240. private _originalPointerObserver;
  54241. /**
  54242. * Instantiates a UtilityLayerRenderer
  54243. * @param originalScene the original scene that will be rendered on top of
  54244. * @param handleEvents boolean indicating if the utility layer should handle events
  54245. */
  54246. constructor(
  54247. /** the original scene that will be rendered on top of */
  54248. originalScene: Scene, handleEvents?: boolean);
  54249. private _notifyObservers;
  54250. /**
  54251. * Renders the utility layers scene on top of the original scene
  54252. */
  54253. render(): void;
  54254. /**
  54255. * Disposes of the renderer
  54256. */
  54257. dispose(): void;
  54258. private _updateCamera;
  54259. }
  54260. }
  54261. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  54262. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54264. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54265. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  54266. import { Scene } from "babylonjs/scene";
  54267. import { Nullable } from "babylonjs/types";
  54268. import { Color3 } from "babylonjs/Maths/math.color";
  54269. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54270. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  54271. /**
  54272. * Options interface for the pointer selection module
  54273. */
  54274. export interface IWebXRControllerPointerSelectionOptions {
  54275. /**
  54276. * if provided, this scene will be used to render meshes.
  54277. */
  54278. customUtilityLayerScene?: Scene;
  54279. /**
  54280. * 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)
  54281. * If not disabled, the last picked point will be used to execute a pointer up event
  54282. * If disabled, pointer up event will be triggered right after the pointer down event.
  54283. * Used in screen and gaze target ray mode only
  54284. */
  54285. disablePointerUpOnTouchOut: boolean;
  54286. /**
  54287. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  54288. */
  54289. forceGazeMode: boolean;
  54290. /**
  54291. * 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
  54292. * to start a new countdown to the pointer down event.
  54293. * Defaults to 1.
  54294. */
  54295. gazeModePointerMovedFactor?: number;
  54296. /**
  54297. * Different button type to use instead of the main component
  54298. */
  54299. overrideButtonId?: string;
  54300. /**
  54301. * use this rendering group id for the meshes (optional)
  54302. */
  54303. renderingGroupId?: number;
  54304. /**
  54305. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  54306. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  54307. * 3000 means 3 seconds between pointing at something and selecting it
  54308. */
  54309. timeToSelect?: number;
  54310. /**
  54311. * Should meshes created here be added to a utility layer or the main scene
  54312. */
  54313. useUtilityLayer?: boolean;
  54314. /**
  54315. * Optional WebXR camera to be used for gaze selection
  54316. */
  54317. gazeCamera?: WebXRCamera;
  54318. /**
  54319. * the xr input to use with this pointer selection
  54320. */
  54321. xrInput: WebXRInput;
  54322. /**
  54323. * Should the scene pointerX and pointerY update be disabled
  54324. * This is required for fullscreen AR GUI, but might slow down other experiences.
  54325. * Disable in VR, if not needed.
  54326. * The first rig camera (left eye) will be used to calculate the projection
  54327. */
  54328. disableScenePointerVectorUpdate: boolean;
  54329. /**
  54330. * Enable pointer selection on all controllers instead of switching between them
  54331. */
  54332. enablePointerSelectionOnAllControllers?: boolean;
  54333. /**
  54334. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  54335. * If switch is enabled, it will still allow the user to switch between the different controllers
  54336. */
  54337. preferredHandedness?: XRHandedness;
  54338. /**
  54339. * Disable switching the pointer selection from one controller to the other.
  54340. * 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
  54341. */
  54342. disableSwitchOnClick?: boolean;
  54343. /**
  54344. * The maximum distance of the pointer selection feature. Defaults to 100.
  54345. */
  54346. maxPointerDistance?: number;
  54347. }
  54348. /**
  54349. * A module that will enable pointer selection for motion controllers of XR Input Sources
  54350. */
  54351. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  54352. private readonly _options;
  54353. private static _idCounter;
  54354. private _attachController;
  54355. private _controllers;
  54356. private _scene;
  54357. private _tmpVectorForPickCompare;
  54358. private _attachedController;
  54359. /**
  54360. * The module's name
  54361. */
  54362. static readonly Name: string;
  54363. /**
  54364. * The (Babylon) version of this module.
  54365. * This is an integer representing the implementation version.
  54366. * This number does not correspond to the WebXR specs version
  54367. */
  54368. static readonly Version: number;
  54369. /**
  54370. * Disable lighting on the laser pointer (so it will always be visible)
  54371. */
  54372. disablePointerLighting: boolean;
  54373. /**
  54374. * Disable lighting on the selection mesh (so it will always be visible)
  54375. */
  54376. disableSelectionMeshLighting: boolean;
  54377. /**
  54378. * Should the laser pointer be displayed
  54379. */
  54380. displayLaserPointer: boolean;
  54381. /**
  54382. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  54383. */
  54384. displaySelectionMesh: boolean;
  54385. /**
  54386. * This color will be set to the laser pointer when selection is triggered
  54387. */
  54388. laserPointerPickedColor: Color3;
  54389. /**
  54390. * Default color of the laser pointer
  54391. */
  54392. laserPointerDefaultColor: Color3;
  54393. /**
  54394. * default color of the selection ring
  54395. */
  54396. selectionMeshDefaultColor: Color3;
  54397. /**
  54398. * This color will be applied to the selection ring when selection is triggered
  54399. */
  54400. selectionMeshPickedColor: Color3;
  54401. /**
  54402. * Optional filter to be used for ray selection. This predicate shares behavior with
  54403. * scene.pointerMovePredicate which takes priority if it is also assigned.
  54404. */
  54405. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  54406. /**
  54407. * constructs a new background remover module
  54408. * @param _xrSessionManager the session manager for this module
  54409. * @param _options read-only options to be used in this module
  54410. */
  54411. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  54412. /**
  54413. * attach this feature
  54414. * Will usually be called by the features manager
  54415. *
  54416. * @returns true if successful.
  54417. */
  54418. attach(): boolean;
  54419. /**
  54420. * detach this feature.
  54421. * Will usually be called by the features manager
  54422. *
  54423. * @returns true if successful.
  54424. */
  54425. detach(): boolean;
  54426. /**
  54427. * Will get the mesh under a specific pointer.
  54428. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  54429. * @param controllerId the controllerId to check
  54430. * @returns The mesh under pointer or null if no mesh is under the pointer
  54431. */
  54432. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  54433. /**
  54434. * Get the xr controller that correlates to the pointer id in the pointer event
  54435. *
  54436. * @param id the pointer id to search for
  54437. * @returns the controller that correlates to this id or null if not found
  54438. */
  54439. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  54440. private _identityMatrix;
  54441. private _screenCoordinatesRef;
  54442. private _viewportRef;
  54443. protected _onXRFrame(_xrFrame: XRFrame): void;
  54444. private _attachGazeMode;
  54445. private _attachScreenRayMode;
  54446. private _attachTrackedPointerRayMode;
  54447. private _convertNormalToDirectionOfRay;
  54448. private _detachController;
  54449. private _generateNewMeshPair;
  54450. private _pickingMoved;
  54451. private _updatePointerDistance;
  54452. /** @hidden */
  54453. get lasterPointerDefaultColor(): Color3;
  54454. }
  54455. }
  54456. declare module "babylonjs/XR/webXREnterExitUI" {
  54457. import { Nullable } from "babylonjs/types";
  54458. import { Observable } from "babylonjs/Misc/observable";
  54459. import { IDisposable, Scene } from "babylonjs/scene";
  54460. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  54461. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  54462. /**
  54463. * Button which can be used to enter a different mode of XR
  54464. */
  54465. export class WebXREnterExitUIButton {
  54466. /** button element */
  54467. element: HTMLElement;
  54468. /** XR initialization options for the button */
  54469. sessionMode: XRSessionMode;
  54470. /** Reference space type */
  54471. referenceSpaceType: XRReferenceSpaceType;
  54472. /**
  54473. * Creates a WebXREnterExitUIButton
  54474. * @param element button element
  54475. * @param sessionMode XR initialization session mode
  54476. * @param referenceSpaceType the type of reference space to be used
  54477. */
  54478. constructor(
  54479. /** button element */
  54480. element: HTMLElement,
  54481. /** XR initialization options for the button */
  54482. sessionMode: XRSessionMode,
  54483. /** Reference space type */
  54484. referenceSpaceType: XRReferenceSpaceType);
  54485. /**
  54486. * Extendable function which can be used to update the button's visuals when the state changes
  54487. * @param activeButton the current active button in the UI
  54488. */
  54489. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  54490. }
  54491. /**
  54492. * Options to create the webXR UI
  54493. */
  54494. export class WebXREnterExitUIOptions {
  54495. /**
  54496. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  54497. */
  54498. customButtons?: Array<WebXREnterExitUIButton>;
  54499. /**
  54500. * A reference space type to use when creating the default button.
  54501. * Default is local-floor
  54502. */
  54503. referenceSpaceType?: XRReferenceSpaceType;
  54504. /**
  54505. * Context to enter xr with
  54506. */
  54507. renderTarget?: Nullable<WebXRRenderTarget>;
  54508. /**
  54509. * A session mode to use when creating the default button.
  54510. * Default is immersive-vr
  54511. */
  54512. sessionMode?: XRSessionMode;
  54513. /**
  54514. * A list of optional features to init the session with
  54515. */
  54516. optionalFeatures?: string[];
  54517. /**
  54518. * A list of optional features to init the session with
  54519. */
  54520. requiredFeatures?: string[];
  54521. }
  54522. /**
  54523. * UI to allow the user to enter/exit XR mode
  54524. */
  54525. export class WebXREnterExitUI implements IDisposable {
  54526. private scene;
  54527. /** version of the options passed to this UI */
  54528. options: WebXREnterExitUIOptions;
  54529. private _activeButton;
  54530. private _buttons;
  54531. /**
  54532. * The HTML Div Element to which buttons are added.
  54533. */
  54534. readonly overlay: HTMLDivElement;
  54535. /**
  54536. * Fired every time the active button is changed.
  54537. *
  54538. * When xr is entered via a button that launches xr that button will be the callback parameter
  54539. *
  54540. * When exiting xr the callback parameter will be null)
  54541. */
  54542. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  54543. /**
  54544. *
  54545. * @param scene babylon scene object to use
  54546. * @param options (read-only) version of the options passed to this UI
  54547. */
  54548. private constructor();
  54549. /**
  54550. * Creates UI to allow the user to enter/exit XR mode
  54551. * @param scene the scene to add the ui to
  54552. * @param helper the xr experience helper to enter/exit xr with
  54553. * @param options options to configure the UI
  54554. * @returns the created ui
  54555. */
  54556. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  54557. /**
  54558. * Disposes of the XR UI component
  54559. */
  54560. dispose(): void;
  54561. private _updateButtons;
  54562. }
  54563. }
  54564. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  54565. import { Vector3 } from "babylonjs/Maths/math.vector";
  54566. import { Color4 } from "babylonjs/Maths/math.color";
  54567. import { Nullable } from "babylonjs/types";
  54568. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54569. import { Scene } from "babylonjs/scene";
  54570. /**
  54571. * Class containing static functions to help procedurally build meshes
  54572. */
  54573. export class LinesBuilder {
  54574. /**
  54575. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54576. * * 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
  54577. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54578. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54579. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54580. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54581. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54582. * * 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
  54583. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54586. * @param name defines the name of the new line system
  54587. * @param options defines the options used to create the line system
  54588. * @param scene defines the hosting scene
  54589. * @returns a new line system mesh
  54590. */
  54591. static CreateLineSystem(name: string, options: {
  54592. lines: Vector3[][];
  54593. updatable?: boolean;
  54594. instance?: Nullable<LinesMesh>;
  54595. colors?: Nullable<Color4[][]>;
  54596. useVertexAlpha?: boolean;
  54597. }, scene: Nullable<Scene>): LinesMesh;
  54598. /**
  54599. * Creates a line mesh
  54600. * 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
  54601. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54602. * * The parameter `points` is an array successive Vector3
  54603. * * 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
  54604. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54605. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54606. * * When updating an instance, remember that only point positions can change, not the number of points
  54607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54609. * @param name defines the name of the new line system
  54610. * @param options defines the options used to create the line system
  54611. * @param scene defines the hosting scene
  54612. * @returns a new line mesh
  54613. */
  54614. static CreateLines(name: string, options: {
  54615. points: Vector3[];
  54616. updatable?: boolean;
  54617. instance?: Nullable<LinesMesh>;
  54618. colors?: Color4[];
  54619. useVertexAlpha?: boolean;
  54620. }, scene?: Nullable<Scene>): LinesMesh;
  54621. /**
  54622. * Creates a dashed line mesh
  54623. * * 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
  54624. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54625. * * The parameter `points` is an array successive Vector3
  54626. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  54627. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  54628. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  54629. * * 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
  54630. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54631. * * When updating an instance, remember that only point positions can change, not the number of points
  54632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54633. * @param name defines the name of the mesh
  54634. * @param options defines the options used to create the mesh
  54635. * @param scene defines the hosting scene
  54636. * @returns the dashed line mesh
  54637. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  54638. */
  54639. static CreateDashedLines(name: string, options: {
  54640. points: Vector3[];
  54641. dashSize?: number;
  54642. gapSize?: number;
  54643. dashNb?: number;
  54644. updatable?: boolean;
  54645. instance?: LinesMesh;
  54646. useVertexAlpha?: boolean;
  54647. }, scene?: Nullable<Scene>): LinesMesh;
  54648. }
  54649. }
  54650. declare module "babylonjs/Misc/timer" {
  54651. import { Observable, Observer } from "babylonjs/Misc/observable";
  54652. import { Nullable } from "babylonjs/types";
  54653. import { IDisposable } from "babylonjs/scene";
  54654. /**
  54655. * Construction options for a timer
  54656. */
  54657. export interface ITimerOptions<T> {
  54658. /**
  54659. * Time-to-end
  54660. */
  54661. timeout: number;
  54662. /**
  54663. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  54664. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  54665. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  54666. */
  54667. contextObservable: Observable<T>;
  54668. /**
  54669. * Optional parameters when adding an observer to the observable
  54670. */
  54671. observableParameters?: {
  54672. mask?: number;
  54673. insertFirst?: boolean;
  54674. scope?: any;
  54675. };
  54676. /**
  54677. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  54678. */
  54679. breakCondition?: (data?: ITimerData<T>) => boolean;
  54680. /**
  54681. * Will be triggered when the time condition has met
  54682. */
  54683. onEnded?: (data: ITimerData<any>) => void;
  54684. /**
  54685. * Will be triggered when the break condition has met (prematurely ended)
  54686. */
  54687. onAborted?: (data: ITimerData<any>) => void;
  54688. /**
  54689. * Optional function to execute on each tick (or count)
  54690. */
  54691. onTick?: (data: ITimerData<any>) => void;
  54692. }
  54693. /**
  54694. * An interface defining the data sent by the timer
  54695. */
  54696. export interface ITimerData<T> {
  54697. /**
  54698. * When did it start
  54699. */
  54700. startTime: number;
  54701. /**
  54702. * Time now
  54703. */
  54704. currentTime: number;
  54705. /**
  54706. * Time passed since started
  54707. */
  54708. deltaTime: number;
  54709. /**
  54710. * How much is completed, in [0.0...1.0].
  54711. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  54712. */
  54713. completeRate: number;
  54714. /**
  54715. * What the registered observable sent in the last count
  54716. */
  54717. payload: T;
  54718. }
  54719. /**
  54720. * The current state of the timer
  54721. */
  54722. export enum TimerState {
  54723. /**
  54724. * Timer initialized, not yet started
  54725. */
  54726. INIT = 0,
  54727. /**
  54728. * Timer started and counting
  54729. */
  54730. STARTED = 1,
  54731. /**
  54732. * Timer ended (whether aborted or time reached)
  54733. */
  54734. ENDED = 2
  54735. }
  54736. /**
  54737. * A simple version of the timer. Will take options and start the timer immediately after calling it
  54738. *
  54739. * @param options options with which to initialize this timer
  54740. */
  54741. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  54742. /**
  54743. * An advanced implementation of a timer class
  54744. */
  54745. export class AdvancedTimer<T = any> implements IDisposable {
  54746. /**
  54747. * Will notify each time the timer calculates the remaining time
  54748. */
  54749. onEachCountObservable: Observable<ITimerData<T>>;
  54750. /**
  54751. * Will trigger when the timer was aborted due to the break condition
  54752. */
  54753. onTimerAbortedObservable: Observable<ITimerData<T>>;
  54754. /**
  54755. * Will trigger when the timer ended successfully
  54756. */
  54757. onTimerEndedObservable: Observable<ITimerData<T>>;
  54758. /**
  54759. * Will trigger when the timer state has changed
  54760. */
  54761. onStateChangedObservable: Observable<TimerState>;
  54762. private _observer;
  54763. private _contextObservable;
  54764. private _observableParameters;
  54765. private _startTime;
  54766. private _timer;
  54767. private _state;
  54768. private _breakCondition;
  54769. private _timeToEnd;
  54770. private _breakOnNextTick;
  54771. /**
  54772. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  54773. * @param options construction options for this advanced timer
  54774. */
  54775. constructor(options: ITimerOptions<T>);
  54776. /**
  54777. * set a breaking condition for this timer. Default is to never break during count
  54778. * @param predicate the new break condition. Returns true to break, false otherwise
  54779. */
  54780. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  54781. /**
  54782. * Reset ALL associated observables in this advanced timer
  54783. */
  54784. clearObservables(): void;
  54785. /**
  54786. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  54787. *
  54788. * @param timeToEnd how much time to measure until timer ended
  54789. */
  54790. start(timeToEnd?: number): void;
  54791. /**
  54792. * Will force a stop on the next tick.
  54793. */
  54794. stop(): void;
  54795. /**
  54796. * Dispose this timer, clearing all resources
  54797. */
  54798. dispose(): void;
  54799. private _setState;
  54800. private _tick;
  54801. private _stop;
  54802. }
  54803. }
  54804. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  54805. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  54806. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  54807. import { Nullable } from "babylonjs/types";
  54808. import { WebXRInput } from "babylonjs/XR/webXRInput";
  54809. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54810. import { Vector3 } from "babylonjs/Maths/math.vector";
  54811. import { Material } from "babylonjs/Materials/material";
  54812. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  54813. import { Scene } from "babylonjs/scene";
  54814. /**
  54815. * The options container for the teleportation module
  54816. */
  54817. export interface IWebXRTeleportationOptions {
  54818. /**
  54819. * if provided, this scene will be used to render meshes.
  54820. */
  54821. customUtilityLayerScene?: Scene;
  54822. /**
  54823. * Values to configure the default target mesh
  54824. */
  54825. defaultTargetMeshOptions?: {
  54826. /**
  54827. * Fill color of the teleportation area
  54828. */
  54829. teleportationFillColor?: string;
  54830. /**
  54831. * Border color for the teleportation area
  54832. */
  54833. teleportationBorderColor?: string;
  54834. /**
  54835. * Disable the mesh's animation sequence
  54836. */
  54837. disableAnimation?: boolean;
  54838. /**
  54839. * Disable lighting on the material or the ring and arrow
  54840. */
  54841. disableLighting?: boolean;
  54842. /**
  54843. * Override the default material of the torus and arrow
  54844. */
  54845. torusArrowMaterial?: Material;
  54846. };
  54847. /**
  54848. * A list of meshes to use as floor meshes.
  54849. * Meshes can be added and removed after initializing the feature using the
  54850. * addFloorMesh and removeFloorMesh functions
  54851. * If empty, rotation will still work
  54852. */
  54853. floorMeshes?: AbstractMesh[];
  54854. /**
  54855. * use this rendering group id for the meshes (optional)
  54856. */
  54857. renderingGroupId?: number;
  54858. /**
  54859. * Should teleportation move only to snap points
  54860. */
  54861. snapPointsOnly?: boolean;
  54862. /**
  54863. * An array of points to which the teleportation will snap to.
  54864. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  54865. */
  54866. snapPositions?: Vector3[];
  54867. /**
  54868. * How close should the teleportation ray be in order to snap to position.
  54869. * Default to 0.8 units (meters)
  54870. */
  54871. snapToPositionRadius?: number;
  54872. /**
  54873. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  54874. * If you want to support rotation, make sure your mesh has a direction indicator.
  54875. *
  54876. * When left untouched, the default mesh will be initialized.
  54877. */
  54878. teleportationTargetMesh?: AbstractMesh;
  54879. /**
  54880. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  54881. */
  54882. timeToTeleport?: number;
  54883. /**
  54884. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  54885. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  54886. */
  54887. useMainComponentOnly?: boolean;
  54888. /**
  54889. * Should meshes created here be added to a utility layer or the main scene
  54890. */
  54891. useUtilityLayer?: boolean;
  54892. /**
  54893. * Babylon XR Input class for controller
  54894. */
  54895. xrInput: WebXRInput;
  54896. /**
  54897. * Meshes that the teleportation ray cannot go through
  54898. */
  54899. pickBlockerMeshes?: AbstractMesh[];
  54900. }
  54901. /**
  54902. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  54903. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  54904. * the input of the attached controllers.
  54905. */
  54906. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  54907. private _options;
  54908. private _controllers;
  54909. private _currentTeleportationControllerId;
  54910. private _floorMeshes;
  54911. private _quadraticBezierCurve;
  54912. private _selectionFeature;
  54913. private _snapToPositions;
  54914. private _snappedToPoint;
  54915. private _teleportationRingMaterial?;
  54916. private _tmpRay;
  54917. private _tmpVector;
  54918. private _tmpQuaternion;
  54919. /**
  54920. * The module's name
  54921. */
  54922. static readonly Name: string;
  54923. /**
  54924. * The (Babylon) version of this module.
  54925. * This is an integer representing the implementation version.
  54926. * This number does not correspond to the webxr specs version
  54927. */
  54928. static readonly Version: number;
  54929. /**
  54930. * Is movement backwards enabled
  54931. */
  54932. backwardsMovementEnabled: boolean;
  54933. /**
  54934. * Distance to travel when moving backwards
  54935. */
  54936. backwardsTeleportationDistance: number;
  54937. /**
  54938. * The distance from the user to the inspection point in the direction of the controller
  54939. * A higher number will allow the user to move further
  54940. * defaults to 5 (meters, in xr units)
  54941. */
  54942. parabolicCheckRadius: number;
  54943. /**
  54944. * Should the module support parabolic ray on top of direct ray
  54945. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  54946. * Very helpful when moving between floors / different heights
  54947. */
  54948. parabolicRayEnabled: boolean;
  54949. /**
  54950. * How much rotation should be applied when rotating right and left
  54951. */
  54952. rotationAngle: number;
  54953. /**
  54954. * Is rotation enabled when moving forward?
  54955. * Disabling this feature will prevent the user from deciding the direction when teleporting
  54956. */
  54957. rotationEnabled: boolean;
  54958. /**
  54959. * constructs a new anchor system
  54960. * @param _xrSessionManager an instance of WebXRSessionManager
  54961. * @param _options configuration object for this feature
  54962. */
  54963. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  54964. /**
  54965. * Get the snapPointsOnly flag
  54966. */
  54967. get snapPointsOnly(): boolean;
  54968. /**
  54969. * Sets the snapPointsOnly flag
  54970. * @param snapToPoints should teleportation be exclusively to snap points
  54971. */
  54972. set snapPointsOnly(snapToPoints: boolean);
  54973. /**
  54974. * Add a new mesh to the floor meshes array
  54975. * @param mesh the mesh to use as floor mesh
  54976. */
  54977. addFloorMesh(mesh: AbstractMesh): void;
  54978. /**
  54979. * Add a new snap-to point to fix teleportation to this position
  54980. * @param newSnapPoint The new Snap-To point
  54981. */
  54982. addSnapPoint(newSnapPoint: Vector3): void;
  54983. attach(): boolean;
  54984. detach(): boolean;
  54985. dispose(): void;
  54986. /**
  54987. * Remove a mesh from the floor meshes array
  54988. * @param mesh the mesh to remove
  54989. */
  54990. removeFloorMesh(mesh: AbstractMesh): void;
  54991. /**
  54992. * Remove a mesh from the floor meshes array using its name
  54993. * @param name the mesh name to remove
  54994. */
  54995. removeFloorMeshByName(name: string): void;
  54996. /**
  54997. * 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
  54998. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  54999. * @returns was the point found and removed or not
  55000. */
  55001. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  55002. /**
  55003. * This function sets a selection feature that will be disabled when
  55004. * the forward ray is shown and will be reattached when hidden.
  55005. * This is used to remove the selection rays when moving.
  55006. * @param selectionFeature the feature to disable when forward movement is enabled
  55007. */
  55008. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  55009. protected _onXRFrame(_xrFrame: XRFrame): void;
  55010. private _attachController;
  55011. private _createDefaultTargetMesh;
  55012. private _detachController;
  55013. private _findClosestSnapPointWithRadius;
  55014. private _setTargetMeshPosition;
  55015. private _setTargetMeshVisibility;
  55016. private _showParabolicPath;
  55017. private _teleportForward;
  55018. }
  55019. }
  55020. declare module "babylonjs/XR/webXRDefaultExperience" {
  55021. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  55022. import { Scene } from "babylonjs/scene";
  55023. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  55024. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  55025. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  55026. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  55027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55028. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  55029. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  55030. /**
  55031. * Options for the default xr helper
  55032. */
  55033. export class WebXRDefaultExperienceOptions {
  55034. /**
  55035. * Enable or disable default UI to enter XR
  55036. */
  55037. disableDefaultUI?: boolean;
  55038. /**
  55039. * Should teleportation not initialize. defaults to false.
  55040. */
  55041. disableTeleportation?: boolean;
  55042. /**
  55043. * Floor meshes that will be used for teleport
  55044. */
  55045. floorMeshes?: Array<AbstractMesh>;
  55046. /**
  55047. * If set to true, the first frame will not be used to reset position
  55048. * The first frame is mainly used when copying transformation from the old camera
  55049. * Mainly used in AR
  55050. */
  55051. ignoreNativeCameraTransformation?: boolean;
  55052. /**
  55053. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  55054. */
  55055. inputOptions?: IWebXRInputOptions;
  55056. /**
  55057. * optional configuration for the output canvas
  55058. */
  55059. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  55060. /**
  55061. * optional UI options. This can be used among other to change session mode and reference space type
  55062. */
  55063. uiOptions?: WebXREnterExitUIOptions;
  55064. /**
  55065. * When loading teleportation and pointer select, use stable versions instead of latest.
  55066. */
  55067. useStablePlugins?: boolean;
  55068. /**
  55069. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  55070. */
  55071. renderingGroupId?: number;
  55072. /**
  55073. * A list of optional features to init the session with
  55074. * If set to true, all features we support will be added
  55075. */
  55076. optionalFeatures?: boolean | string[];
  55077. }
  55078. /**
  55079. * Default experience which provides a similar setup to the previous webVRExperience
  55080. */
  55081. export class WebXRDefaultExperience {
  55082. /**
  55083. * Base experience
  55084. */
  55085. baseExperience: WebXRExperienceHelper;
  55086. /**
  55087. * Enables ui for entering/exiting xr
  55088. */
  55089. enterExitUI: WebXREnterExitUI;
  55090. /**
  55091. * Input experience extension
  55092. */
  55093. input: WebXRInput;
  55094. /**
  55095. * Enables laser pointer and selection
  55096. */
  55097. pointerSelection: WebXRControllerPointerSelection;
  55098. /**
  55099. * Default target xr should render to
  55100. */
  55101. renderTarget: WebXRRenderTarget;
  55102. /**
  55103. * Enables teleportation
  55104. */
  55105. teleportation: WebXRMotionControllerTeleportation;
  55106. private constructor();
  55107. /**
  55108. * Creates the default xr experience
  55109. * @param scene scene
  55110. * @param options options for basic configuration
  55111. * @returns resulting WebXRDefaultExperience
  55112. */
  55113. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55114. /**
  55115. * DIsposes of the experience helper
  55116. */
  55117. dispose(): void;
  55118. }
  55119. }
  55120. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  55121. import { Observable } from "babylonjs/Misc/observable";
  55122. import { Nullable } from "babylonjs/types";
  55123. import { Camera } from "babylonjs/Cameras/camera";
  55124. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  55125. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55126. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  55127. import { Scene } from "babylonjs/scene";
  55128. import { Vector3 } from "babylonjs/Maths/math.vector";
  55129. import { Color3 } from "babylonjs/Maths/math.color";
  55130. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55132. import { Mesh } from "babylonjs/Meshes/mesh";
  55133. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  55134. import { EasingFunction } from "babylonjs/Animations/easing";
  55135. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  55136. import "babylonjs/Meshes/Builders/groundBuilder";
  55137. import "babylonjs/Meshes/Builders/torusBuilder";
  55138. import "babylonjs/Meshes/Builders/cylinderBuilder";
  55139. import "babylonjs/Gamepads/gamepadSceneComponent";
  55140. import "babylonjs/Animations/animatable";
  55141. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  55142. /**
  55143. * Options to modify the vr teleportation behavior.
  55144. */
  55145. export interface VRTeleportationOptions {
  55146. /**
  55147. * The name of the mesh which should be used as the teleportation floor. (default: null)
  55148. */
  55149. floorMeshName?: string;
  55150. /**
  55151. * A list of meshes to be used as the teleportation floor. (default: empty)
  55152. */
  55153. floorMeshes?: Mesh[];
  55154. /**
  55155. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  55156. */
  55157. teleportationMode?: number;
  55158. /**
  55159. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  55160. */
  55161. teleportationTime?: number;
  55162. /**
  55163. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  55164. */
  55165. teleportationSpeed?: number;
  55166. /**
  55167. * The easing function used in the animation or null for Linear. (default CircleEase)
  55168. */
  55169. easingFunction?: EasingFunction;
  55170. }
  55171. /**
  55172. * Options to modify the vr experience helper's behavior.
  55173. */
  55174. export interface VRExperienceHelperOptions extends WebVROptions {
  55175. /**
  55176. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  55177. */
  55178. createDeviceOrientationCamera?: boolean;
  55179. /**
  55180. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  55181. */
  55182. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  55183. /**
  55184. * Uses the main button on the controller to toggle the laser casted. (default: true)
  55185. */
  55186. laserToggle?: boolean;
  55187. /**
  55188. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  55189. */
  55190. floorMeshes?: Mesh[];
  55191. /**
  55192. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  55193. */
  55194. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  55195. /**
  55196. * Defines if WebXR should be used instead of WebVR (if available)
  55197. */
  55198. useXR?: boolean;
  55199. }
  55200. /**
  55201. * Event containing information after VR has been entered
  55202. */
  55203. export class OnAfterEnteringVRObservableEvent {
  55204. /**
  55205. * If entering vr was successful
  55206. */
  55207. success: boolean;
  55208. }
  55209. /**
  55210. * Helps to quickly add VR support to an existing scene.
  55211. * See https://doc.babylonjs.com/how_to/webvr_helper
  55212. */
  55213. export class VRExperienceHelper {
  55214. /** Options to modify the vr experience helper's behavior. */
  55215. webVROptions: VRExperienceHelperOptions;
  55216. private _scene;
  55217. private _position;
  55218. private _btnVR;
  55219. private _btnVRDisplayed;
  55220. private _webVRsupported;
  55221. private _webVRready;
  55222. private _webVRrequesting;
  55223. private _webVRpresenting;
  55224. private _hasEnteredVR;
  55225. private _fullscreenVRpresenting;
  55226. private _inputElement;
  55227. private _webVRCamera;
  55228. private _vrDeviceOrientationCamera;
  55229. private _deviceOrientationCamera;
  55230. private _existingCamera;
  55231. private _onKeyDown;
  55232. private _onVrDisplayPresentChange;
  55233. private _onVRDisplayChanged;
  55234. private _onVRRequestPresentStart;
  55235. private _onVRRequestPresentComplete;
  55236. /**
  55237. * 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)
  55238. */
  55239. enableGazeEvenWhenNoPointerLock: boolean;
  55240. /**
  55241. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  55242. */
  55243. exitVROnDoubleTap: boolean;
  55244. /**
  55245. * Observable raised right before entering VR.
  55246. */
  55247. onEnteringVRObservable: Observable<VRExperienceHelper>;
  55248. /**
  55249. * Observable raised when entering VR has completed.
  55250. */
  55251. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  55252. /**
  55253. * Observable raised when exiting VR.
  55254. */
  55255. onExitingVRObservable: Observable<VRExperienceHelper>;
  55256. /**
  55257. * Observable raised when controller mesh is loaded.
  55258. */
  55259. onControllerMeshLoadedObservable: Observable<WebVRController>;
  55260. /** Return this.onEnteringVRObservable
  55261. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  55262. */
  55263. get onEnteringVR(): Observable<VRExperienceHelper>;
  55264. /** Return this.onExitingVRObservable
  55265. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  55266. */
  55267. get onExitingVR(): Observable<VRExperienceHelper>;
  55268. /** Return this.onControllerMeshLoadedObservable
  55269. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  55270. */
  55271. get onControllerMeshLoaded(): Observable<WebVRController>;
  55272. private _rayLength;
  55273. private _useCustomVRButton;
  55274. private _teleportationRequested;
  55275. private _teleportActive;
  55276. private _floorMeshName;
  55277. private _floorMeshesCollection;
  55278. private _teleportationMode;
  55279. private _teleportationTime;
  55280. private _teleportationSpeed;
  55281. private _teleportationEasing;
  55282. private _rotationAllowed;
  55283. private _teleportBackwardsVector;
  55284. private _teleportationTarget;
  55285. private _isDefaultTeleportationTarget;
  55286. private _postProcessMove;
  55287. private _teleportationFillColor;
  55288. private _teleportationBorderColor;
  55289. private _rotationAngle;
  55290. private _haloCenter;
  55291. private _cameraGazer;
  55292. private _padSensibilityUp;
  55293. private _padSensibilityDown;
  55294. private _leftController;
  55295. private _rightController;
  55296. private _gazeColor;
  55297. private _laserColor;
  55298. private _pickedLaserColor;
  55299. private _pickedGazeColor;
  55300. /**
  55301. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  55302. */
  55303. onNewMeshSelected: Observable<AbstractMesh>;
  55304. /**
  55305. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  55306. * This observable will provide the mesh and the controller used to select the mesh
  55307. */
  55308. onMeshSelectedWithController: Observable<{
  55309. mesh: AbstractMesh;
  55310. controller: WebVRController;
  55311. }>;
  55312. /**
  55313. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  55314. */
  55315. onNewMeshPicked: Observable<PickingInfo>;
  55316. private _circleEase;
  55317. /**
  55318. * Observable raised before camera teleportation
  55319. */
  55320. onBeforeCameraTeleport: Observable<Vector3>;
  55321. /**
  55322. * Observable raised after camera teleportation
  55323. */
  55324. onAfterCameraTeleport: Observable<Vector3>;
  55325. /**
  55326. * Observable raised when current selected mesh gets unselected
  55327. */
  55328. onSelectedMeshUnselected: Observable<AbstractMesh>;
  55329. private _raySelectionPredicate;
  55330. /**
  55331. * To be optionaly changed by user to define custom ray selection
  55332. */
  55333. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  55334. /**
  55335. * To be optionaly changed by user to define custom selection logic (after ray selection)
  55336. */
  55337. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  55338. /**
  55339. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  55340. */
  55341. teleportationEnabled: boolean;
  55342. private _defaultHeight;
  55343. private _teleportationInitialized;
  55344. private _interactionsEnabled;
  55345. private _interactionsRequested;
  55346. private _displayGaze;
  55347. private _displayLaserPointer;
  55348. /**
  55349. * The mesh used to display where the user is going to teleport.
  55350. */
  55351. get teleportationTarget(): Mesh;
  55352. /**
  55353. * Sets the mesh to be used to display where the user is going to teleport.
  55354. */
  55355. set teleportationTarget(value: Mesh);
  55356. /**
  55357. * 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
  55358. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  55359. * See https://doc.babylonjs.com/resources/baking_transformations
  55360. */
  55361. get gazeTrackerMesh(): Mesh;
  55362. set gazeTrackerMesh(value: Mesh);
  55363. /**
  55364. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  55365. */
  55366. updateGazeTrackerScale: boolean;
  55367. /**
  55368. * If the gaze trackers color should be updated when selecting meshes
  55369. */
  55370. updateGazeTrackerColor: boolean;
  55371. /**
  55372. * If the controller laser color should be updated when selecting meshes
  55373. */
  55374. updateControllerLaserColor: boolean;
  55375. /**
  55376. * The gaze tracking mesh corresponding to the left controller
  55377. */
  55378. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  55379. /**
  55380. * The gaze tracking mesh corresponding to the right controller
  55381. */
  55382. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  55383. /**
  55384. * If the ray of the gaze should be displayed.
  55385. */
  55386. get displayGaze(): boolean;
  55387. /**
  55388. * Sets if the ray of the gaze should be displayed.
  55389. */
  55390. set displayGaze(value: boolean);
  55391. /**
  55392. * If the ray of the LaserPointer should be displayed.
  55393. */
  55394. get displayLaserPointer(): boolean;
  55395. /**
  55396. * Sets if the ray of the LaserPointer should be displayed.
  55397. */
  55398. set displayLaserPointer(value: boolean);
  55399. /**
  55400. * The deviceOrientationCamera used as the camera when not in VR.
  55401. */
  55402. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  55403. /**
  55404. * Based on the current WebVR support, returns the current VR camera used.
  55405. */
  55406. get currentVRCamera(): Nullable<Camera>;
  55407. /**
  55408. * The webVRCamera which is used when in VR.
  55409. */
  55410. get webVRCamera(): WebVRFreeCamera;
  55411. /**
  55412. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  55413. */
  55414. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  55415. /**
  55416. * The html button that is used to trigger entering into VR.
  55417. */
  55418. get vrButton(): Nullable<HTMLButtonElement>;
  55419. private get _teleportationRequestInitiated();
  55420. /**
  55421. * Defines whether or not Pointer lock should be requested when switching to
  55422. * full screen.
  55423. */
  55424. requestPointerLockOnFullScreen: boolean;
  55425. /**
  55426. * If asking to force XR, this will be populated with the default xr experience
  55427. */
  55428. xr: WebXRDefaultExperience;
  55429. /**
  55430. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  55431. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  55432. */
  55433. xrTestDone: boolean;
  55434. /**
  55435. * Instantiates a VRExperienceHelper.
  55436. * Helps to quickly add VR support to an existing scene.
  55437. * @param scene The scene the VRExperienceHelper belongs to.
  55438. * @param webVROptions Options to modify the vr experience helper's behavior.
  55439. */
  55440. constructor(scene: Scene,
  55441. /** Options to modify the vr experience helper's behavior. */
  55442. webVROptions?: VRExperienceHelperOptions);
  55443. private completeVRInit;
  55444. private _onDefaultMeshLoaded;
  55445. private _onResize;
  55446. private _onFullscreenChange;
  55447. /**
  55448. * Gets a value indicating if we are currently in VR mode.
  55449. */
  55450. get isInVRMode(): boolean;
  55451. private onVrDisplayPresentChange;
  55452. private onVRDisplayChanged;
  55453. private moveButtonToBottomRight;
  55454. private displayVRButton;
  55455. private updateButtonVisibility;
  55456. private _cachedAngularSensibility;
  55457. /**
  55458. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  55459. * Otherwise, will use the fullscreen API.
  55460. */
  55461. enterVR(): void;
  55462. /**
  55463. * Attempt to exit VR, or fullscreen.
  55464. */
  55465. exitVR(): void;
  55466. /**
  55467. * The position of the vr experience helper.
  55468. */
  55469. get position(): Vector3;
  55470. /**
  55471. * Sets the position of the vr experience helper.
  55472. */
  55473. set position(value: Vector3);
  55474. /**
  55475. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  55476. */
  55477. enableInteractions(): void;
  55478. private get _noControllerIsActive();
  55479. private beforeRender;
  55480. private _isTeleportationFloor;
  55481. /**
  55482. * Adds a floor mesh to be used for teleportation.
  55483. * @param floorMesh the mesh to be used for teleportation.
  55484. */
  55485. addFloorMesh(floorMesh: Mesh): void;
  55486. /**
  55487. * Removes a floor mesh from being used for teleportation.
  55488. * @param floorMesh the mesh to be removed.
  55489. */
  55490. removeFloorMesh(floorMesh: Mesh): void;
  55491. /**
  55492. * Enables interactions and teleportation using the VR controllers and gaze.
  55493. * @param vrTeleportationOptions options to modify teleportation behavior.
  55494. */
  55495. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  55496. private _onNewGamepadConnected;
  55497. private _tryEnableInteractionOnController;
  55498. private _onNewGamepadDisconnected;
  55499. private _enableInteractionOnController;
  55500. private _checkTeleportWithRay;
  55501. private _checkRotate;
  55502. private _checkTeleportBackwards;
  55503. private _enableTeleportationOnController;
  55504. private _createTeleportationCircles;
  55505. private _displayTeleportationTarget;
  55506. private _hideTeleportationTarget;
  55507. private _rotateCamera;
  55508. private _moveTeleportationSelectorTo;
  55509. private _workingVector;
  55510. private _workingQuaternion;
  55511. private _workingMatrix;
  55512. /**
  55513. * Time Constant Teleportation Mode
  55514. */
  55515. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  55516. /**
  55517. * Speed Constant Teleportation Mode
  55518. */
  55519. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  55520. /**
  55521. * Teleports the users feet to the desired location
  55522. * @param location The location where the user's feet should be placed
  55523. */
  55524. teleportCamera(location: Vector3): void;
  55525. private _convertNormalToDirectionOfRay;
  55526. private _castRayAndSelectObject;
  55527. private _notifySelectedMeshUnselected;
  55528. /**
  55529. * Permanently set new colors for the laser pointer
  55530. * @param color the new laser color
  55531. * @param pickedColor the new laser color when picked mesh detected
  55532. */
  55533. setLaserColor(color: Color3, pickedColor?: Color3): void;
  55534. /**
  55535. * Set lighting enabled / disabled on the laser pointer of both controllers
  55536. * @param enabled should the lighting be enabled on the laser pointer
  55537. */
  55538. setLaserLightingState(enabled?: boolean): void;
  55539. /**
  55540. * Permanently set new colors for the gaze pointer
  55541. * @param color the new gaze color
  55542. * @param pickedColor the new gaze color when picked mesh detected
  55543. */
  55544. setGazeColor(color: Color3, pickedColor?: Color3): void;
  55545. /**
  55546. * Sets the color of the laser ray from the vr controllers.
  55547. * @param color new color for the ray.
  55548. */
  55549. changeLaserColor(color: Color3): void;
  55550. /**
  55551. * Sets the color of the ray from the vr headsets gaze.
  55552. * @param color new color for the ray.
  55553. */
  55554. changeGazeColor(color: Color3): void;
  55555. /**
  55556. * Exits VR and disposes of the vr experience helper
  55557. */
  55558. dispose(): void;
  55559. /**
  55560. * Gets the name of the VRExperienceHelper class
  55561. * @returns "VRExperienceHelper"
  55562. */
  55563. getClassName(): string;
  55564. }
  55565. }
  55566. declare module "babylonjs/Cameras/VR/index" {
  55567. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  55568. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  55569. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  55570. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  55571. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  55572. export * from "babylonjs/Cameras/VR/webVRCamera";
  55573. }
  55574. declare module "babylonjs/Cameras/RigModes/index" {
  55575. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  55576. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  55577. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  55578. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  55579. }
  55580. declare module "babylonjs/Cameras/index" {
  55581. export * from "babylonjs/Cameras/Inputs/index";
  55582. export * from "babylonjs/Cameras/cameraInputsManager";
  55583. export * from "babylonjs/Cameras/camera";
  55584. export * from "babylonjs/Cameras/targetCamera";
  55585. export * from "babylonjs/Cameras/freeCamera";
  55586. export * from "babylonjs/Cameras/freeCameraInputsManager";
  55587. export * from "babylonjs/Cameras/touchCamera";
  55588. export * from "babylonjs/Cameras/arcRotateCamera";
  55589. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  55590. export * from "babylonjs/Cameras/deviceOrientationCamera";
  55591. export * from "babylonjs/Cameras/flyCamera";
  55592. export * from "babylonjs/Cameras/flyCameraInputsManager";
  55593. export * from "babylonjs/Cameras/followCamera";
  55594. export * from "babylonjs/Cameras/followCameraInputsManager";
  55595. export * from "babylonjs/Cameras/gamepadCamera";
  55596. export * from "babylonjs/Cameras/Stereoscopic/index";
  55597. export * from "babylonjs/Cameras/universalCamera";
  55598. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  55599. export * from "babylonjs/Cameras/VR/index";
  55600. export * from "babylonjs/Cameras/RigModes/index";
  55601. }
  55602. declare module "babylonjs/Collisions/index" {
  55603. export * from "babylonjs/Collisions/collider";
  55604. export * from "babylonjs/Collisions/collisionCoordinator";
  55605. export * from "babylonjs/Collisions/pickingInfo";
  55606. export * from "babylonjs/Collisions/intersectionInfo";
  55607. export * from "babylonjs/Collisions/meshCollisionData";
  55608. }
  55609. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  55610. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  55611. import { Vector3 } from "babylonjs/Maths/math.vector";
  55612. import { Ray } from "babylonjs/Culling/ray";
  55613. import { Plane } from "babylonjs/Maths/math.plane";
  55614. /**
  55615. * Contains an array of blocks representing the octree
  55616. */
  55617. export interface IOctreeContainer<T> {
  55618. /**
  55619. * Blocks within the octree
  55620. */
  55621. blocks: Array<OctreeBlock<T>>;
  55622. }
  55623. /**
  55624. * Class used to store a cell in an octree
  55625. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55626. */
  55627. export class OctreeBlock<T> {
  55628. /**
  55629. * Gets the content of the current block
  55630. */
  55631. entries: T[];
  55632. /**
  55633. * Gets the list of block children
  55634. */
  55635. blocks: Array<OctreeBlock<T>>;
  55636. private _depth;
  55637. private _maxDepth;
  55638. private _capacity;
  55639. private _minPoint;
  55640. private _maxPoint;
  55641. private _boundingVectors;
  55642. private _creationFunc;
  55643. /**
  55644. * Creates a new block
  55645. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  55646. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  55647. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55648. * @param depth defines the current depth of this block in the octree
  55649. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  55650. * @param creationFunc defines a callback to call when an element is added to the block
  55651. */
  55652. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  55653. /**
  55654. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  55655. */
  55656. get capacity(): number;
  55657. /**
  55658. * Gets the minimum vector (in world space) of the block's bounding box
  55659. */
  55660. get minPoint(): Vector3;
  55661. /**
  55662. * Gets the maximum vector (in world space) of the block's bounding box
  55663. */
  55664. get maxPoint(): Vector3;
  55665. /**
  55666. * Add a new element to this block
  55667. * @param entry defines the element to add
  55668. */
  55669. addEntry(entry: T): void;
  55670. /**
  55671. * Remove an element from this block
  55672. * @param entry defines the element to remove
  55673. */
  55674. removeEntry(entry: T): void;
  55675. /**
  55676. * Add an array of elements to this block
  55677. * @param entries defines the array of elements to add
  55678. */
  55679. addEntries(entries: T[]): void;
  55680. /**
  55681. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  55682. * @param frustumPlanes defines the frustum planes to test
  55683. * @param selection defines the array to store current content if selection is positive
  55684. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55685. */
  55686. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55687. /**
  55688. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  55689. * @param sphereCenter defines the bounding sphere center
  55690. * @param sphereRadius defines the bounding sphere radius
  55691. * @param selection defines the array to store current content if selection is positive
  55692. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55693. */
  55694. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  55695. /**
  55696. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  55697. * @param ray defines the ray to test with
  55698. * @param selection defines the array to store current content if selection is positive
  55699. */
  55700. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  55701. /**
  55702. * Subdivide the content into child blocks (this block will then be empty)
  55703. */
  55704. createInnerBlocks(): void;
  55705. /**
  55706. * @hidden
  55707. */
  55708. 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;
  55709. }
  55710. }
  55711. declare module "babylonjs/Culling/Octrees/octree" {
  55712. import { SmartArray } from "babylonjs/Misc/smartArray";
  55713. import { Vector3 } from "babylonjs/Maths/math.vector";
  55714. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55716. import { Ray } from "babylonjs/Culling/ray";
  55717. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  55718. import { Plane } from "babylonjs/Maths/math.plane";
  55719. /**
  55720. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  55721. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55722. */
  55723. export class Octree<T> {
  55724. /** 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.) */
  55725. maxDepth: number;
  55726. /**
  55727. * Blocks within the octree containing objects
  55728. */
  55729. blocks: Array<OctreeBlock<T>>;
  55730. /**
  55731. * Content stored in the octree
  55732. */
  55733. dynamicContent: T[];
  55734. private _maxBlockCapacity;
  55735. private _selectionContent;
  55736. private _creationFunc;
  55737. /**
  55738. * Creates a octree
  55739. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55740. * @param creationFunc function to be used to instatiate the octree
  55741. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  55742. * @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.)
  55743. */
  55744. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  55745. /** 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.) */
  55746. maxDepth?: number);
  55747. /**
  55748. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  55749. * @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);
  55750. * @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);
  55751. * @param entries meshes to be added to the octree blocks
  55752. */
  55753. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  55754. /**
  55755. * Adds a mesh to the octree
  55756. * @param entry Mesh to add to the octree
  55757. */
  55758. addMesh(entry: T): void;
  55759. /**
  55760. * Remove an element from the octree
  55761. * @param entry defines the element to remove
  55762. */
  55763. removeMesh(entry: T): void;
  55764. /**
  55765. * Selects an array of meshes within the frustum
  55766. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  55767. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  55768. * @returns array of meshes within the frustum
  55769. */
  55770. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  55771. /**
  55772. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  55773. * @param sphereCenter defines the bounding sphere center
  55774. * @param sphereRadius defines the bounding sphere radius
  55775. * @param allowDuplicate defines if the selection array can contains duplicated entries
  55776. * @returns an array of objects that intersect the sphere
  55777. */
  55778. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  55779. /**
  55780. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  55781. * @param ray defines the ray to test with
  55782. * @returns array of intersected objects
  55783. */
  55784. intersectsRay(ray: Ray): SmartArray<T>;
  55785. /**
  55786. * Adds a mesh into the octree block if it intersects the block
  55787. */
  55788. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  55789. /**
  55790. * Adds a submesh into the octree block if it intersects the block
  55791. */
  55792. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  55793. }
  55794. }
  55795. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  55796. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  55797. import { Scene } from "babylonjs/scene";
  55798. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55800. import { Ray } from "babylonjs/Culling/ray";
  55801. import { Octree } from "babylonjs/Culling/Octrees/octree";
  55802. import { Collider } from "babylonjs/Collisions/collider";
  55803. module "babylonjs/scene" {
  55804. interface Scene {
  55805. /**
  55806. * @hidden
  55807. * Backing Filed
  55808. */
  55809. _selectionOctree: Octree<AbstractMesh>;
  55810. /**
  55811. * Gets the octree used to boost mesh selection (picking)
  55812. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55813. */
  55814. selectionOctree: Octree<AbstractMesh>;
  55815. /**
  55816. * Creates or updates the octree used to boost selection (picking)
  55817. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55818. * @param maxCapacity defines the maximum capacity per leaf
  55819. * @param maxDepth defines the maximum depth of the octree
  55820. * @returns an octree of AbstractMesh
  55821. */
  55822. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  55823. }
  55824. }
  55825. module "babylonjs/Meshes/abstractMesh" {
  55826. interface AbstractMesh {
  55827. /**
  55828. * @hidden
  55829. * Backing Field
  55830. */
  55831. _submeshesOctree: Octree<SubMesh>;
  55832. /**
  55833. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  55834. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  55835. * @param maxCapacity defines the maximum size of each block (64 by default)
  55836. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  55837. * @returns the new octree
  55838. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  55839. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  55840. */
  55841. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  55842. }
  55843. }
  55844. /**
  55845. * Defines the octree scene component responsible to manage any octrees
  55846. * in a given scene.
  55847. */
  55848. export class OctreeSceneComponent {
  55849. /**
  55850. * The component name help to identify the component in the list of scene components.
  55851. */
  55852. readonly name: string;
  55853. /**
  55854. * The scene the component belongs to.
  55855. */
  55856. scene: Scene;
  55857. /**
  55858. * Indicates if the meshes have been checked to make sure they are isEnabled()
  55859. */
  55860. readonly checksIsEnabled: boolean;
  55861. /**
  55862. * Creates a new instance of the component for the given scene
  55863. * @param scene Defines the scene to register the component in
  55864. */
  55865. constructor(scene: Scene);
  55866. /**
  55867. * Registers the component in a given scene
  55868. */
  55869. register(): void;
  55870. /**
  55871. * Return the list of active meshes
  55872. * @returns the list of active meshes
  55873. */
  55874. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  55875. /**
  55876. * Return the list of active sub meshes
  55877. * @param mesh The mesh to get the candidates sub meshes from
  55878. * @returns the list of active sub meshes
  55879. */
  55880. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  55881. private _tempRay;
  55882. /**
  55883. * Return the list of sub meshes intersecting with a given local ray
  55884. * @param mesh defines the mesh to find the submesh for
  55885. * @param localRay defines the ray in local space
  55886. * @returns the list of intersecting sub meshes
  55887. */
  55888. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  55889. /**
  55890. * Return the list of sub meshes colliding with a collider
  55891. * @param mesh defines the mesh to find the submesh for
  55892. * @param collider defines the collider to evaluate the collision against
  55893. * @returns the list of colliding sub meshes
  55894. */
  55895. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  55896. /**
  55897. * Rebuilds the elements related to this component in case of
  55898. * context lost for instance.
  55899. */
  55900. rebuild(): void;
  55901. /**
  55902. * Disposes the component and the associated ressources.
  55903. */
  55904. dispose(): void;
  55905. }
  55906. }
  55907. declare module "babylonjs/Culling/Octrees/index" {
  55908. export * from "babylonjs/Culling/Octrees/octree";
  55909. export * from "babylonjs/Culling/Octrees/octreeBlock";
  55910. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  55911. }
  55912. declare module "babylonjs/Culling/index" {
  55913. export * from "babylonjs/Culling/boundingBox";
  55914. export * from "babylonjs/Culling/boundingInfo";
  55915. export * from "babylonjs/Culling/boundingSphere";
  55916. export * from "babylonjs/Culling/Octrees/index";
  55917. export * from "babylonjs/Culling/ray";
  55918. }
  55919. declare module "babylonjs/Gizmos/gizmo" {
  55920. import { Nullable } from "babylonjs/types";
  55921. import { IDisposable } from "babylonjs/scene";
  55922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55923. import { Mesh } from "babylonjs/Meshes/mesh";
  55924. import { Node } from "babylonjs/node";
  55925. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55926. /**
  55927. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  55928. */
  55929. export class Gizmo implements IDisposable {
  55930. /** The utility layer the gizmo will be added to */
  55931. gizmoLayer: UtilityLayerRenderer;
  55932. /**
  55933. * The root mesh of the gizmo
  55934. */
  55935. _rootMesh: Mesh;
  55936. private _attachedMesh;
  55937. private _attachedNode;
  55938. /**
  55939. * Ratio for the scale of the gizmo (Default: 1)
  55940. */
  55941. protected _scaleRatio: number;
  55942. /**
  55943. * boolean updated by pointermove when a gizmo mesh is hovered
  55944. */
  55945. protected _isHovered: boolean;
  55946. /**
  55947. * Ratio for the scale of the gizmo (Default: 1)
  55948. */
  55949. set scaleRatio(value: number);
  55950. get scaleRatio(): number;
  55951. /**
  55952. * True when the mouse pointer is hovered a gizmo mesh
  55953. */
  55954. get isHovered(): boolean;
  55955. /**
  55956. * If a custom mesh has been set (Default: false)
  55957. */
  55958. protected _customMeshSet: boolean;
  55959. /**
  55960. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  55961. * * When set, interactions will be enabled
  55962. */
  55963. get attachedMesh(): Nullable<AbstractMesh>;
  55964. set attachedMesh(value: Nullable<AbstractMesh>);
  55965. /**
  55966. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  55967. * * When set, interactions will be enabled
  55968. */
  55969. get attachedNode(): Nullable<Node>;
  55970. set attachedNode(value: Nullable<Node>);
  55971. /**
  55972. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  55973. * @param mesh The mesh to replace the default mesh of the gizmo
  55974. */
  55975. setCustomMesh(mesh: Mesh): void;
  55976. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  55977. /**
  55978. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  55979. */
  55980. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55981. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55982. /**
  55983. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  55984. */
  55985. updateGizmoPositionToMatchAttachedMesh: boolean;
  55986. /**
  55987. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  55988. */
  55989. updateScale: boolean;
  55990. protected _interactionsEnabled: boolean;
  55991. protected _attachedNodeChanged(value: Nullable<Node>): void;
  55992. private _beforeRenderObserver;
  55993. private _tempQuaternion;
  55994. private _tempVector;
  55995. private _tempVector2;
  55996. private _tempMatrix1;
  55997. private _tempMatrix2;
  55998. private _rightHandtoLeftHandMatrix;
  55999. /**
  56000. * Creates a gizmo
  56001. * @param gizmoLayer The utility layer the gizmo will be added to
  56002. */
  56003. constructor(
  56004. /** The utility layer the gizmo will be added to */
  56005. gizmoLayer?: UtilityLayerRenderer);
  56006. /**
  56007. * Updates the gizmo to match the attached mesh's position/rotation
  56008. */
  56009. protected _update(): void;
  56010. /**
  56011. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  56012. * @param value Node, TransformNode or mesh
  56013. */
  56014. protected _matrixChanged(): void;
  56015. /**
  56016. * Disposes of the gizmo
  56017. */
  56018. dispose(): void;
  56019. }
  56020. }
  56021. declare module "babylonjs/Gizmos/planeDragGizmo" {
  56022. import { Observable } from "babylonjs/Misc/observable";
  56023. import { Nullable } from "babylonjs/types";
  56024. import { Vector3 } from "babylonjs/Maths/math.vector";
  56025. import { Color3 } from "babylonjs/Maths/math.color";
  56026. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56027. import { Node } from "babylonjs/node";
  56028. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56029. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56030. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56031. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56032. import { Scene } from "babylonjs/scene";
  56033. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56034. /**
  56035. * Single plane drag gizmo
  56036. */
  56037. export class PlaneDragGizmo extends Gizmo {
  56038. /**
  56039. * Drag behavior responsible for the gizmos dragging interactions
  56040. */
  56041. dragBehavior: PointerDragBehavior;
  56042. private _pointerObserver;
  56043. /**
  56044. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56045. */
  56046. snapDistance: number;
  56047. /**
  56048. * Event that fires each time the gizmo snaps to a new location.
  56049. * * snapDistance is the the change in distance
  56050. */
  56051. onSnapObservable: Observable<{
  56052. snapDistance: number;
  56053. }>;
  56054. private _plane;
  56055. private _coloredMaterial;
  56056. private _hoverMaterial;
  56057. private _isEnabled;
  56058. private _parent;
  56059. /** @hidden */
  56060. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  56061. /** @hidden */
  56062. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  56063. /**
  56064. * Creates a PlaneDragGizmo
  56065. * @param gizmoLayer The utility layer the gizmo will be added to
  56066. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  56067. * @param color The color of the gizmo
  56068. */
  56069. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  56070. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56071. /**
  56072. * If the gizmo is enabled
  56073. */
  56074. set isEnabled(value: boolean);
  56075. get isEnabled(): boolean;
  56076. /**
  56077. * Disposes of the gizmo
  56078. */
  56079. dispose(): void;
  56080. }
  56081. }
  56082. declare module "babylonjs/Gizmos/positionGizmo" {
  56083. import { Observable } from "babylonjs/Misc/observable";
  56084. import { Nullable } from "babylonjs/types";
  56085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56086. import { Node } from "babylonjs/node";
  56087. import { Mesh } from "babylonjs/Meshes/mesh";
  56088. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56089. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  56090. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  56091. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56092. /**
  56093. * Gizmo that enables dragging a mesh along 3 axis
  56094. */
  56095. export class PositionGizmo extends Gizmo {
  56096. /**
  56097. * Internal gizmo used for interactions on the x axis
  56098. */
  56099. xGizmo: AxisDragGizmo;
  56100. /**
  56101. * Internal gizmo used for interactions on the y axis
  56102. */
  56103. yGizmo: AxisDragGizmo;
  56104. /**
  56105. * Internal gizmo used for interactions on the z axis
  56106. */
  56107. zGizmo: AxisDragGizmo;
  56108. /**
  56109. * Internal gizmo used for interactions on the yz plane
  56110. */
  56111. xPlaneGizmo: PlaneDragGizmo;
  56112. /**
  56113. * Internal gizmo used for interactions on the xz plane
  56114. */
  56115. yPlaneGizmo: PlaneDragGizmo;
  56116. /**
  56117. * Internal gizmo used for interactions on the xy plane
  56118. */
  56119. zPlaneGizmo: PlaneDragGizmo;
  56120. /**
  56121. * private variables
  56122. */
  56123. private _meshAttached;
  56124. private _nodeAttached;
  56125. private _snapDistance;
  56126. /** Fires an event when any of it's sub gizmos are dragged */
  56127. onDragStartObservable: Observable<unknown>;
  56128. /** Fires an event when any of it's sub gizmos are released from dragging */
  56129. onDragEndObservable: Observable<unknown>;
  56130. /**
  56131. * If set to true, planar drag is enabled
  56132. */
  56133. private _planarGizmoEnabled;
  56134. get attachedMesh(): Nullable<AbstractMesh>;
  56135. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56136. get attachedNode(): Nullable<Node>;
  56137. set attachedNode(node: Nullable<Node>);
  56138. /**
  56139. * True when the mouse pointer is hovering a gizmo mesh
  56140. */
  56141. get isHovered(): boolean;
  56142. /**
  56143. * Creates a PositionGizmo
  56144. * @param gizmoLayer The utility layer the gizmo will be added to
  56145. @param thickness display gizmo axis thickness
  56146. */
  56147. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56148. /**
  56149. * If the planar drag gizmo is enabled
  56150. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  56151. */
  56152. set planarGizmoEnabled(value: boolean);
  56153. get planarGizmoEnabled(): boolean;
  56154. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56155. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56156. /**
  56157. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56158. */
  56159. set snapDistance(value: number);
  56160. get snapDistance(): number;
  56161. /**
  56162. * Ratio for the scale of the gizmo (Default: 1)
  56163. */
  56164. set scaleRatio(value: number);
  56165. get scaleRatio(): number;
  56166. /**
  56167. * Disposes of the gizmo
  56168. */
  56169. dispose(): void;
  56170. /**
  56171. * CustomMeshes are not supported by this gizmo
  56172. * @param mesh The mesh to replace the default mesh of the gizmo
  56173. */
  56174. setCustomMesh(mesh: Mesh): void;
  56175. }
  56176. }
  56177. declare module "babylonjs/Gizmos/axisDragGizmo" {
  56178. import { Observable } from "babylonjs/Misc/observable";
  56179. import { Nullable } from "babylonjs/types";
  56180. import { Vector3 } from "babylonjs/Maths/math.vector";
  56181. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56182. import { Node } from "babylonjs/node";
  56183. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56184. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56185. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56186. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56187. import { Scene } from "babylonjs/scene";
  56188. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56189. import { Color3 } from "babylonjs/Maths/math.color";
  56190. /**
  56191. * Single axis drag gizmo
  56192. */
  56193. export class AxisDragGizmo extends Gizmo {
  56194. /**
  56195. * Drag behavior responsible for the gizmos dragging interactions
  56196. */
  56197. dragBehavior: PointerDragBehavior;
  56198. private _pointerObserver;
  56199. /**
  56200. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56201. */
  56202. snapDistance: number;
  56203. /**
  56204. * Event that fires each time the gizmo snaps to a new location.
  56205. * * snapDistance is the the change in distance
  56206. */
  56207. onSnapObservable: Observable<{
  56208. snapDistance: number;
  56209. }>;
  56210. private _isEnabled;
  56211. private _parent;
  56212. private _arrow;
  56213. private _coloredMaterial;
  56214. private _hoverMaterial;
  56215. /** @hidden */
  56216. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  56217. /** @hidden */
  56218. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  56219. /**
  56220. * Creates an AxisDragGizmo
  56221. * @param gizmoLayer The utility layer the gizmo will be added to
  56222. * @param dragAxis The axis which the gizmo will be able to drag on
  56223. * @param color The color of the gizmo
  56224. * @param thickness display gizmo axis thickness
  56225. */
  56226. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  56227. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56228. /**
  56229. * If the gizmo is enabled
  56230. */
  56231. set isEnabled(value: boolean);
  56232. get isEnabled(): boolean;
  56233. /**
  56234. * Disposes of the gizmo
  56235. */
  56236. dispose(): void;
  56237. }
  56238. }
  56239. declare module "babylonjs/Debug/axesViewer" {
  56240. import { Vector3 } from "babylonjs/Maths/math.vector";
  56241. import { Nullable } from "babylonjs/types";
  56242. import { Scene } from "babylonjs/scene";
  56243. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56244. /**
  56245. * The Axes viewer will show 3 axes in a specific point in space
  56246. */
  56247. export class AxesViewer {
  56248. private _xAxis;
  56249. private _yAxis;
  56250. private _zAxis;
  56251. private _scaleLinesFactor;
  56252. private _instanced;
  56253. /**
  56254. * Gets the hosting scene
  56255. */
  56256. scene: Nullable<Scene>;
  56257. /**
  56258. * Gets or sets a number used to scale line length
  56259. */
  56260. scaleLines: number;
  56261. /** Gets the node hierarchy used to render x-axis */
  56262. get xAxis(): TransformNode;
  56263. /** Gets the node hierarchy used to render y-axis */
  56264. get yAxis(): TransformNode;
  56265. /** Gets the node hierarchy used to render z-axis */
  56266. get zAxis(): TransformNode;
  56267. /**
  56268. * Creates a new AxesViewer
  56269. * @param scene defines the hosting scene
  56270. * @param scaleLines defines a number used to scale line length (1 by default)
  56271. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  56272. * @param xAxis defines the node hierarchy used to render the x-axis
  56273. * @param yAxis defines the node hierarchy used to render the y-axis
  56274. * @param zAxis defines the node hierarchy used to render the z-axis
  56275. */
  56276. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  56277. /**
  56278. * Force the viewer to update
  56279. * @param position defines the position of the viewer
  56280. * @param xaxis defines the x axis of the viewer
  56281. * @param yaxis defines the y axis of the viewer
  56282. * @param zaxis defines the z axis of the viewer
  56283. */
  56284. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  56285. /**
  56286. * Creates an instance of this axes viewer.
  56287. * @returns a new axes viewer with instanced meshes
  56288. */
  56289. createInstance(): AxesViewer;
  56290. /** Releases resources */
  56291. dispose(): void;
  56292. private static _SetRenderingGroupId;
  56293. }
  56294. }
  56295. declare module "babylonjs/Debug/boneAxesViewer" {
  56296. import { Nullable } from "babylonjs/types";
  56297. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  56298. import { Vector3 } from "babylonjs/Maths/math.vector";
  56299. import { Mesh } from "babylonjs/Meshes/mesh";
  56300. import { Bone } from "babylonjs/Bones/bone";
  56301. import { Scene } from "babylonjs/scene";
  56302. /**
  56303. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  56304. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  56305. */
  56306. export class BoneAxesViewer extends AxesViewer {
  56307. /**
  56308. * Gets or sets the target mesh where to display the axes viewer
  56309. */
  56310. mesh: Nullable<Mesh>;
  56311. /**
  56312. * Gets or sets the target bone where to display the axes viewer
  56313. */
  56314. bone: Nullable<Bone>;
  56315. /** Gets current position */
  56316. pos: Vector3;
  56317. /** Gets direction of X axis */
  56318. xaxis: Vector3;
  56319. /** Gets direction of Y axis */
  56320. yaxis: Vector3;
  56321. /** Gets direction of Z axis */
  56322. zaxis: Vector3;
  56323. /**
  56324. * Creates a new BoneAxesViewer
  56325. * @param scene defines the hosting scene
  56326. * @param bone defines the target bone
  56327. * @param mesh defines the target mesh
  56328. * @param scaleLines defines a scaling factor for line length (1 by default)
  56329. */
  56330. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  56331. /**
  56332. * Force the viewer to update
  56333. */
  56334. update(): void;
  56335. /** Releases resources */
  56336. dispose(): void;
  56337. }
  56338. }
  56339. declare module "babylonjs/Debug/debugLayer" {
  56340. import { Scene } from "babylonjs/scene";
  56341. /**
  56342. * Interface used to define scene explorer extensibility option
  56343. */
  56344. export interface IExplorerExtensibilityOption {
  56345. /**
  56346. * Define the option label
  56347. */
  56348. label: string;
  56349. /**
  56350. * Defines the action to execute on click
  56351. */
  56352. action: (entity: any) => void;
  56353. }
  56354. /**
  56355. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  56356. */
  56357. export interface IExplorerExtensibilityGroup {
  56358. /**
  56359. * Defines a predicate to test if a given type mut be extended
  56360. */
  56361. predicate: (entity: any) => boolean;
  56362. /**
  56363. * Gets the list of options added to a type
  56364. */
  56365. entries: IExplorerExtensibilityOption[];
  56366. }
  56367. /**
  56368. * Interface used to define the options to use to create the Inspector
  56369. */
  56370. export interface IInspectorOptions {
  56371. /**
  56372. * Display in overlay mode (default: false)
  56373. */
  56374. overlay?: boolean;
  56375. /**
  56376. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  56377. */
  56378. globalRoot?: HTMLElement;
  56379. /**
  56380. * Display the Scene explorer
  56381. */
  56382. showExplorer?: boolean;
  56383. /**
  56384. * Display the property inspector
  56385. */
  56386. showInspector?: boolean;
  56387. /**
  56388. * Display in embed mode (both panes on the right)
  56389. */
  56390. embedMode?: boolean;
  56391. /**
  56392. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  56393. */
  56394. handleResize?: boolean;
  56395. /**
  56396. * Allow the panes to popup (default: true)
  56397. */
  56398. enablePopup?: boolean;
  56399. /**
  56400. * Allow the panes to be closed by users (default: true)
  56401. */
  56402. enableClose?: boolean;
  56403. /**
  56404. * Optional list of extensibility entries
  56405. */
  56406. explorerExtensibility?: IExplorerExtensibilityGroup[];
  56407. /**
  56408. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  56409. */
  56410. inspectorURL?: string;
  56411. /**
  56412. * Optional initial tab (default to DebugLayerTab.Properties)
  56413. */
  56414. initialTab?: DebugLayerTab;
  56415. }
  56416. module "babylonjs/scene" {
  56417. interface Scene {
  56418. /**
  56419. * @hidden
  56420. * Backing field
  56421. */
  56422. _debugLayer: DebugLayer;
  56423. /**
  56424. * Gets the debug layer (aka Inspector) associated with the scene
  56425. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56426. */
  56427. debugLayer: DebugLayer;
  56428. }
  56429. }
  56430. /**
  56431. * Enum of inspector action tab
  56432. */
  56433. export enum DebugLayerTab {
  56434. /**
  56435. * Properties tag (default)
  56436. */
  56437. Properties = 0,
  56438. /**
  56439. * Debug tab
  56440. */
  56441. Debug = 1,
  56442. /**
  56443. * Statistics tab
  56444. */
  56445. Statistics = 2,
  56446. /**
  56447. * Tools tab
  56448. */
  56449. Tools = 3,
  56450. /**
  56451. * Settings tab
  56452. */
  56453. Settings = 4
  56454. }
  56455. /**
  56456. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56457. * what is happening in your scene
  56458. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56459. */
  56460. export class DebugLayer {
  56461. /**
  56462. * Define the url to get the inspector script from.
  56463. * By default it uses the babylonjs CDN.
  56464. * @ignoreNaming
  56465. */
  56466. static InspectorURL: string;
  56467. private _scene;
  56468. private BJSINSPECTOR;
  56469. private _onPropertyChangedObservable?;
  56470. /**
  56471. * Observable triggered when a property is changed through the inspector.
  56472. */
  56473. get onPropertyChangedObservable(): any;
  56474. /**
  56475. * Instantiates a new debug layer.
  56476. * The debug layer (aka Inspector) is the go to tool in order to better understand
  56477. * what is happening in your scene
  56478. * @see https://doc.babylonjs.com/features/playground_debuglayer
  56479. * @param scene Defines the scene to inspect
  56480. */
  56481. constructor(scene: Scene);
  56482. /** Creates the inspector window. */
  56483. private _createInspector;
  56484. /**
  56485. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  56486. * @param entity defines the entity to select
  56487. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  56488. */
  56489. select(entity: any, lineContainerTitles?: string | string[]): void;
  56490. /** Get the inspector from bundle or global */
  56491. private _getGlobalInspector;
  56492. /**
  56493. * Get if the inspector is visible or not.
  56494. * @returns true if visible otherwise, false
  56495. */
  56496. isVisible(): boolean;
  56497. /**
  56498. * Hide the inspector and close its window.
  56499. */
  56500. hide(): void;
  56501. /**
  56502. * Update the scene in the inspector
  56503. */
  56504. setAsActiveScene(): void;
  56505. /**
  56506. * Launch the debugLayer.
  56507. * @param config Define the configuration of the inspector
  56508. * @return a promise fulfilled when the debug layer is visible
  56509. */
  56510. show(config?: IInspectorOptions): Promise<DebugLayer>;
  56511. }
  56512. }
  56513. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  56514. import { Nullable } from "babylonjs/types";
  56515. import { Scene } from "babylonjs/scene";
  56516. import { Vector4 } from "babylonjs/Maths/math.vector";
  56517. import { Color4 } from "babylonjs/Maths/math.color";
  56518. import { Mesh } from "babylonjs/Meshes/mesh";
  56519. /**
  56520. * Class containing static functions to help procedurally build meshes
  56521. */
  56522. export class BoxBuilder {
  56523. /**
  56524. * Creates a box mesh
  56525. * * The parameter `size` sets the size (float) of each box side (default 1)
  56526. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  56527. * * 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)
  56528. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  56529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56530. * * 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
  56531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56532. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  56533. * @param name defines the name of the mesh
  56534. * @param options defines the options used to create the mesh
  56535. * @param scene defines the hosting scene
  56536. * @returns the box mesh
  56537. */
  56538. static CreateBox(name: string, options: {
  56539. size?: number;
  56540. width?: number;
  56541. height?: number;
  56542. depth?: number;
  56543. faceUV?: Vector4[];
  56544. faceColors?: Color4[];
  56545. sideOrientation?: number;
  56546. frontUVs?: Vector4;
  56547. backUVs?: Vector4;
  56548. wrap?: boolean;
  56549. topBaseAt?: number;
  56550. bottomBaseAt?: number;
  56551. updatable?: boolean;
  56552. }, scene?: Nullable<Scene>): Mesh;
  56553. }
  56554. }
  56555. declare module "babylonjs/Debug/physicsViewer" {
  56556. import { Nullable } from "babylonjs/types";
  56557. import { Scene } from "babylonjs/scene";
  56558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56559. import { Mesh } from "babylonjs/Meshes/mesh";
  56560. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56561. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56562. /**
  56563. * Used to show the physics impostor around the specific mesh
  56564. */
  56565. export class PhysicsViewer {
  56566. /** @hidden */
  56567. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  56568. /** @hidden */
  56569. protected _meshes: Array<Nullable<AbstractMesh>>;
  56570. /** @hidden */
  56571. protected _scene: Nullable<Scene>;
  56572. /** @hidden */
  56573. protected _numMeshes: number;
  56574. /** @hidden */
  56575. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  56576. private _renderFunction;
  56577. private _utilityLayer;
  56578. private _debugBoxMesh;
  56579. private _debugSphereMesh;
  56580. private _debugCylinderMesh;
  56581. private _debugMaterial;
  56582. private _debugMeshMeshes;
  56583. /**
  56584. * Creates a new PhysicsViewer
  56585. * @param scene defines the hosting scene
  56586. */
  56587. constructor(scene: Scene);
  56588. /** @hidden */
  56589. protected _updateDebugMeshes(): void;
  56590. /**
  56591. * Renders a specified physic impostor
  56592. * @param impostor defines the impostor to render
  56593. * @param targetMesh defines the mesh represented by the impostor
  56594. * @returns the new debug mesh used to render the impostor
  56595. */
  56596. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  56597. /**
  56598. * Hides a specified physic impostor
  56599. * @param impostor defines the impostor to hide
  56600. */
  56601. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  56602. private _getDebugMaterial;
  56603. private _getDebugBoxMesh;
  56604. private _getDebugSphereMesh;
  56605. private _getDebugCylinderMesh;
  56606. private _getDebugMeshMesh;
  56607. private _getDebugMesh;
  56608. /** Releases all resources */
  56609. dispose(): void;
  56610. }
  56611. }
  56612. declare module "babylonjs/Debug/rayHelper" {
  56613. import { Nullable } from "babylonjs/types";
  56614. import { Ray } from "babylonjs/Culling/ray";
  56615. import { Vector3 } from "babylonjs/Maths/math.vector";
  56616. import { Color3 } from "babylonjs/Maths/math.color";
  56617. import { Scene } from "babylonjs/scene";
  56618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56619. import "babylonjs/Meshes/Builders/linesBuilder";
  56620. /**
  56621. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56622. * in order to better appreciate the issue one might have.
  56623. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56624. */
  56625. export class RayHelper {
  56626. /**
  56627. * Defines the ray we are currently tryin to visualize.
  56628. */
  56629. ray: Nullable<Ray>;
  56630. private _renderPoints;
  56631. private _renderLine;
  56632. private _renderFunction;
  56633. private _scene;
  56634. private _onAfterRenderObserver;
  56635. private _onAfterStepObserver;
  56636. private _attachedToMesh;
  56637. private _meshSpaceDirection;
  56638. private _meshSpaceOrigin;
  56639. /**
  56640. * Helper function to create a colored helper in a scene in one line.
  56641. * @param ray Defines the ray we are currently tryin to visualize
  56642. * @param scene Defines the scene the ray is used in
  56643. * @param color Defines the color we want to see the ray in
  56644. * @returns The newly created ray helper.
  56645. */
  56646. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  56647. /**
  56648. * Instantiate a new ray helper.
  56649. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  56650. * in order to better appreciate the issue one might have.
  56651. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  56652. * @param ray Defines the ray we are currently tryin to visualize
  56653. */
  56654. constructor(ray: Ray);
  56655. /**
  56656. * Shows the ray we are willing to debug.
  56657. * @param scene Defines the scene the ray needs to be rendered in
  56658. * @param color Defines the color the ray needs to be rendered in
  56659. */
  56660. show(scene: Scene, color?: Color3): void;
  56661. /**
  56662. * Hides the ray we are debugging.
  56663. */
  56664. hide(): void;
  56665. private _render;
  56666. /**
  56667. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  56668. * @param mesh Defines the mesh we want the helper attached to
  56669. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  56670. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  56671. * @param length Defines the length of the ray
  56672. */
  56673. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  56674. /**
  56675. * Detach the ray helper from the mesh it has previously been attached to.
  56676. */
  56677. detachFromMesh(): void;
  56678. private _updateToMesh;
  56679. /**
  56680. * Dispose the helper and release its associated resources.
  56681. */
  56682. dispose(): void;
  56683. }
  56684. }
  56685. declare module "babylonjs/Debug/ISkeletonViewer" {
  56686. import { Skeleton } from "babylonjs/Bones/skeleton";
  56687. import { Color3 } from "babylonjs/Maths/math.color";
  56688. /**
  56689. * Defines the options associated with the creation of a SkeletonViewer.
  56690. */
  56691. export interface ISkeletonViewerOptions {
  56692. /** Should the system pause animations before building the Viewer? */
  56693. pauseAnimations: boolean;
  56694. /** Should the system return the skeleton to rest before building? */
  56695. returnToRest: boolean;
  56696. /** public Display Mode of the Viewer */
  56697. displayMode: number;
  56698. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56699. displayOptions: ISkeletonViewerDisplayOptions;
  56700. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  56701. computeBonesUsingShaders: boolean;
  56702. /** Flag ignore non weighted bones */
  56703. useAllBones: boolean;
  56704. }
  56705. /**
  56706. * Defines how to display the various bone meshes for the viewer.
  56707. */
  56708. export interface ISkeletonViewerDisplayOptions {
  56709. /** How far down to start tapering the bone spurs */
  56710. midStep?: number;
  56711. /** How big is the midStep? */
  56712. midStepFactor?: number;
  56713. /** Base for the Sphere Size */
  56714. sphereBaseSize?: number;
  56715. /** The ratio of the sphere to the longest bone in units */
  56716. sphereScaleUnit?: number;
  56717. /** Ratio for the Sphere Size */
  56718. sphereFactor?: number;
  56719. /** Whether a spur should attach its far end to the child bone position */
  56720. spurFollowsChild?: boolean;
  56721. /** Whether to show local axes or not */
  56722. showLocalAxes?: boolean;
  56723. /** Length of each local axis */
  56724. localAxesSize?: number;
  56725. }
  56726. /**
  56727. * Defines the constructor options for the BoneWeight Shader.
  56728. */
  56729. export interface IBoneWeightShaderOptions {
  56730. /** Skeleton to Map */
  56731. skeleton: Skeleton;
  56732. /** Colors for Uninfluenced bones */
  56733. colorBase?: Color3;
  56734. /** Colors for 0.0-0.25 Weight bones */
  56735. colorZero?: Color3;
  56736. /** Color for 0.25-0.5 Weight Influence */
  56737. colorQuarter?: Color3;
  56738. /** Color for 0.5-0.75 Weight Influence */
  56739. colorHalf?: Color3;
  56740. /** Color for 0.75-1 Weight Influence */
  56741. colorFull?: Color3;
  56742. /** Color for Zero Weight Influence */
  56743. targetBoneIndex?: number;
  56744. }
  56745. /**
  56746. * Simple structure of the gradient steps for the Color Map.
  56747. */
  56748. export interface ISkeletonMapShaderColorMapKnot {
  56749. /** Color of the Knot */
  56750. color: Color3;
  56751. /** Location of the Knot */
  56752. location: number;
  56753. }
  56754. /**
  56755. * Defines the constructor options for the SkeletonMap Shader.
  56756. */
  56757. export interface ISkeletonMapShaderOptions {
  56758. /** Skeleton to Map */
  56759. skeleton: Skeleton;
  56760. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  56761. colorMap?: ISkeletonMapShaderColorMapKnot[];
  56762. }
  56763. }
  56764. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  56765. import { Nullable } from "babylonjs/types";
  56766. import { Scene } from "babylonjs/scene";
  56767. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  56768. import { Color4 } from "babylonjs/Maths/math.color";
  56769. import { Mesh } from "babylonjs/Meshes/mesh";
  56770. /**
  56771. * Class containing static functions to help procedurally build meshes
  56772. */
  56773. export class RibbonBuilder {
  56774. /**
  56775. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  56776. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  56777. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  56778. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  56779. * * 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
  56780. * * 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
  56781. * * 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
  56782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56783. * * 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
  56784. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56785. * * 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
  56786. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  56787. * * 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
  56788. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  56789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56790. * @param name defines the name of the mesh
  56791. * @param options defines the options used to create the mesh
  56792. * @param scene defines the hosting scene
  56793. * @returns the ribbon mesh
  56794. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  56795. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56796. */
  56797. static CreateRibbon(name: string, options: {
  56798. pathArray: Vector3[][];
  56799. closeArray?: boolean;
  56800. closePath?: boolean;
  56801. offset?: number;
  56802. updatable?: boolean;
  56803. sideOrientation?: number;
  56804. frontUVs?: Vector4;
  56805. backUVs?: Vector4;
  56806. instance?: Mesh;
  56807. invertUV?: boolean;
  56808. uvs?: Vector2[];
  56809. colors?: Color4[];
  56810. }, scene?: Nullable<Scene>): Mesh;
  56811. }
  56812. }
  56813. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  56814. import { Nullable } from "babylonjs/types";
  56815. import { Scene } from "babylonjs/scene";
  56816. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  56817. import { Mesh } from "babylonjs/Meshes/mesh";
  56818. /**
  56819. * Class containing static functions to help procedurally build meshes
  56820. */
  56821. export class ShapeBuilder {
  56822. /**
  56823. * 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.
  56824. * * 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.
  56825. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56826. * * 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.
  56827. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  56828. * * 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
  56829. * * 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
  56830. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  56831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56832. * * 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
  56833. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  56834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  56835. * @param name defines the name of the mesh
  56836. * @param options defines the options used to create the mesh
  56837. * @param scene defines the hosting scene
  56838. * @returns the extruded shape mesh
  56839. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56840. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56841. */
  56842. static ExtrudeShape(name: string, options: {
  56843. shape: Vector3[];
  56844. path: Vector3[];
  56845. scale?: number;
  56846. rotation?: number;
  56847. cap?: number;
  56848. updatable?: boolean;
  56849. sideOrientation?: number;
  56850. frontUVs?: Vector4;
  56851. backUVs?: Vector4;
  56852. instance?: Mesh;
  56853. invertUV?: boolean;
  56854. }, scene?: Nullable<Scene>): Mesh;
  56855. /**
  56856. * Creates an custom extruded shape mesh.
  56857. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  56858. * * 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.
  56859. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  56860. * * 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
  56861. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  56862. * * 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
  56863. * * It must returns a float value that will be the scale value applied to the shape on each path point
  56864. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  56865. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  56866. * * 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
  56867. * * 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
  56868. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  56869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56870. * * 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
  56871. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  56872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56873. * @param name defines the name of the mesh
  56874. * @param options defines the options used to create the mesh
  56875. * @param scene defines the hosting scene
  56876. * @returns the custom extruded shape mesh
  56877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  56878. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  56879. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  56880. */
  56881. static ExtrudeShapeCustom(name: string, options: {
  56882. shape: Vector3[];
  56883. path: Vector3[];
  56884. scaleFunction?: any;
  56885. rotationFunction?: any;
  56886. ribbonCloseArray?: boolean;
  56887. ribbonClosePath?: boolean;
  56888. cap?: number;
  56889. updatable?: boolean;
  56890. sideOrientation?: number;
  56891. frontUVs?: Vector4;
  56892. backUVs?: Vector4;
  56893. instance?: Mesh;
  56894. invertUV?: boolean;
  56895. }, scene?: Nullable<Scene>): Mesh;
  56896. private static _ExtrudeShapeGeneric;
  56897. }
  56898. }
  56899. declare module "babylonjs/Debug/skeletonViewer" {
  56900. import { Color3 } from "babylonjs/Maths/math.color";
  56901. import { Scene } from "babylonjs/scene";
  56902. import { Nullable } from "babylonjs/types";
  56903. import { Skeleton } from "babylonjs/Bones/skeleton";
  56904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56905. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  56906. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56907. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  56908. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  56909. /**
  56910. * Class used to render a debug view of a given skeleton
  56911. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  56912. */
  56913. export class SkeletonViewer {
  56914. /** defines the skeleton to render */
  56915. skeleton: Skeleton;
  56916. /** defines the mesh attached to the skeleton */
  56917. mesh: AbstractMesh;
  56918. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  56919. autoUpdateBonesMatrices: boolean;
  56920. /** defines the rendering group id to use with the viewer */
  56921. renderingGroupId: number;
  56922. /** is the options for the viewer */
  56923. options: Partial<ISkeletonViewerOptions>;
  56924. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  56925. static readonly DISPLAY_LINES: number;
  56926. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  56927. static readonly DISPLAY_SPHERES: number;
  56928. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  56929. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  56930. /** public static method to create a BoneWeight Shader
  56931. * @param options The constructor options
  56932. * @param scene The scene that the shader is scoped to
  56933. * @returns The created ShaderMaterial
  56934. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  56935. */
  56936. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  56937. /** public static method to create a BoneWeight Shader
  56938. * @param options The constructor options
  56939. * @param scene The scene that the shader is scoped to
  56940. * @returns The created ShaderMaterial
  56941. */
  56942. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  56943. /** private static method to create a BoneWeight Shader
  56944. * @param size The size of the buffer to create (usually the bone count)
  56945. * @param colorMap The gradient data to generate
  56946. * @param scene The scene that the shader is scoped to
  56947. * @returns an Array of floats from the color gradient values
  56948. */
  56949. private static _CreateBoneMapColorBuffer;
  56950. /** If SkeletonViewer scene scope. */
  56951. private _scene;
  56952. /** Gets or sets the color used to render the skeleton */
  56953. color: Color3;
  56954. /** Array of the points of the skeleton fo the line view. */
  56955. private _debugLines;
  56956. /** The SkeletonViewers Mesh. */
  56957. private _debugMesh;
  56958. /** The local axes Meshes. */
  56959. private _localAxes;
  56960. /** If SkeletonViewer is enabled. */
  56961. private _isEnabled;
  56962. /** If SkeletonViewer is ready. */
  56963. private _ready;
  56964. /** SkeletonViewer render observable. */
  56965. private _obs;
  56966. /** The Utility Layer to render the gizmos in. */
  56967. private _utilityLayer;
  56968. private _boneIndices;
  56969. /** Gets the Scene. */
  56970. get scene(): Scene;
  56971. /** Gets the utilityLayer. */
  56972. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  56973. /** Checks Ready Status. */
  56974. get isReady(): Boolean;
  56975. /** Sets Ready Status. */
  56976. set ready(value: boolean);
  56977. /** Gets the debugMesh */
  56978. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  56979. /** Sets the debugMesh */
  56980. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  56981. /** Gets the displayMode */
  56982. get displayMode(): number;
  56983. /** Sets the displayMode */
  56984. set displayMode(value: number);
  56985. /**
  56986. * Creates a new SkeletonViewer
  56987. * @param skeleton defines the skeleton to render
  56988. * @param mesh defines the mesh attached to the skeleton
  56989. * @param scene defines the hosting scene
  56990. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  56991. * @param renderingGroupId defines the rendering group id to use with the viewer
  56992. * @param options All of the extra constructor options for the SkeletonViewer
  56993. */
  56994. constructor(
  56995. /** defines the skeleton to render */
  56996. skeleton: Skeleton,
  56997. /** defines the mesh attached to the skeleton */
  56998. mesh: AbstractMesh,
  56999. /** The Scene scope*/
  57000. scene: Scene,
  57001. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  57002. autoUpdateBonesMatrices?: boolean,
  57003. /** defines the rendering group id to use with the viewer */
  57004. renderingGroupId?: number,
  57005. /** is the options for the viewer */
  57006. options?: Partial<ISkeletonViewerOptions>);
  57007. /** The Dynamic bindings for the update functions */
  57008. private _bindObs;
  57009. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  57010. update(): void;
  57011. /** Gets or sets a boolean indicating if the viewer is enabled */
  57012. set isEnabled(value: boolean);
  57013. get isEnabled(): boolean;
  57014. private _getBonePosition;
  57015. private _getLinesForBonesWithLength;
  57016. private _getLinesForBonesNoLength;
  57017. /** function to revert the mesh and scene back to the initial state. */
  57018. private _revert;
  57019. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  57020. private _getAbsoluteBindPoseToRef;
  57021. /** function to build and bind sphere joint points and spur bone representations. */
  57022. private _buildSpheresAndSpurs;
  57023. private _buildLocalAxes;
  57024. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  57025. private _displayLinesUpdate;
  57026. /** Changes the displayMode of the skeleton viewer
  57027. * @param mode The displayMode numerical value
  57028. */
  57029. changeDisplayMode(mode: number): void;
  57030. /** Sets a display option of the skeleton viewer
  57031. *
  57032. * | Option | Type | Default | Description |
  57033. * | ---------------- | ------- | ------- | ----------- |
  57034. * | 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`. |
  57035. * | 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`. |
  57036. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  57037. * | 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`. |
  57038. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  57039. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  57040. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  57041. *
  57042. * @param option String of the option name
  57043. * @param value The numerical option value
  57044. */
  57045. changeDisplayOptions(option: string, value: number): void;
  57046. /** Release associated resources */
  57047. dispose(): void;
  57048. }
  57049. }
  57050. declare module "babylonjs/Debug/index" {
  57051. export * from "babylonjs/Debug/axesViewer";
  57052. export * from "babylonjs/Debug/boneAxesViewer";
  57053. export * from "babylonjs/Debug/debugLayer";
  57054. export * from "babylonjs/Debug/physicsViewer";
  57055. export * from "babylonjs/Debug/rayHelper";
  57056. export * from "babylonjs/Debug/skeletonViewer";
  57057. export * from "babylonjs/Debug/ISkeletonViewer";
  57058. }
  57059. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  57060. /**
  57061. * Enum for Device Types
  57062. */
  57063. export enum DeviceType {
  57064. /** Generic */
  57065. Generic = 0,
  57066. /** Keyboard */
  57067. Keyboard = 1,
  57068. /** Mouse */
  57069. Mouse = 2,
  57070. /** Touch Pointers */
  57071. Touch = 3,
  57072. /** PS4 Dual Shock */
  57073. DualShock = 4,
  57074. /** Xbox */
  57075. Xbox = 5,
  57076. /** Switch Controller */
  57077. Switch = 6
  57078. }
  57079. /**
  57080. * Enum for All Pointers (Touch/Mouse)
  57081. */
  57082. export enum PointerInput {
  57083. /** Horizontal Axis */
  57084. Horizontal = 0,
  57085. /** Vertical Axis */
  57086. Vertical = 1,
  57087. /** Left Click or Touch */
  57088. LeftClick = 2,
  57089. /** Middle Click */
  57090. MiddleClick = 3,
  57091. /** Right Click */
  57092. RightClick = 4,
  57093. /** Browser Back */
  57094. BrowserBack = 5,
  57095. /** Browser Forward */
  57096. BrowserForward = 6
  57097. }
  57098. /**
  57099. * Enum for Dual Shock Gamepad
  57100. */
  57101. export enum DualShockInput {
  57102. /** Cross */
  57103. Cross = 0,
  57104. /** Circle */
  57105. Circle = 1,
  57106. /** Square */
  57107. Square = 2,
  57108. /** Triangle */
  57109. Triangle = 3,
  57110. /** L1 */
  57111. L1 = 4,
  57112. /** R1 */
  57113. R1 = 5,
  57114. /** L2 */
  57115. L2 = 6,
  57116. /** R2 */
  57117. R2 = 7,
  57118. /** Share */
  57119. Share = 8,
  57120. /** Options */
  57121. Options = 9,
  57122. /** L3 */
  57123. L3 = 10,
  57124. /** R3 */
  57125. R3 = 11,
  57126. /** DPadUp */
  57127. DPadUp = 12,
  57128. /** DPadDown */
  57129. DPadDown = 13,
  57130. /** DPadLeft */
  57131. DPadLeft = 14,
  57132. /** DRight */
  57133. DPadRight = 15,
  57134. /** Home */
  57135. Home = 16,
  57136. /** TouchPad */
  57137. TouchPad = 17,
  57138. /** LStickXAxis */
  57139. LStickXAxis = 18,
  57140. /** LStickYAxis */
  57141. LStickYAxis = 19,
  57142. /** RStickXAxis */
  57143. RStickXAxis = 20,
  57144. /** RStickYAxis */
  57145. RStickYAxis = 21
  57146. }
  57147. /**
  57148. * Enum for Xbox Gamepad
  57149. */
  57150. export enum XboxInput {
  57151. /** A */
  57152. A = 0,
  57153. /** B */
  57154. B = 1,
  57155. /** X */
  57156. X = 2,
  57157. /** Y */
  57158. Y = 3,
  57159. /** LB */
  57160. LB = 4,
  57161. /** RB */
  57162. RB = 5,
  57163. /** LT */
  57164. LT = 6,
  57165. /** RT */
  57166. RT = 7,
  57167. /** Back */
  57168. Back = 8,
  57169. /** Start */
  57170. Start = 9,
  57171. /** LS */
  57172. LS = 10,
  57173. /** RS */
  57174. RS = 11,
  57175. /** DPadUp */
  57176. DPadUp = 12,
  57177. /** DPadDown */
  57178. DPadDown = 13,
  57179. /** DPadLeft */
  57180. DPadLeft = 14,
  57181. /** DRight */
  57182. DPadRight = 15,
  57183. /** Home */
  57184. Home = 16,
  57185. /** LStickXAxis */
  57186. LStickXAxis = 17,
  57187. /** LStickYAxis */
  57188. LStickYAxis = 18,
  57189. /** RStickXAxis */
  57190. RStickXAxis = 19,
  57191. /** RStickYAxis */
  57192. RStickYAxis = 20
  57193. }
  57194. /**
  57195. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  57196. */
  57197. export enum SwitchInput {
  57198. /** B */
  57199. B = 0,
  57200. /** A */
  57201. A = 1,
  57202. /** Y */
  57203. Y = 2,
  57204. /** X */
  57205. X = 3,
  57206. /** L */
  57207. L = 4,
  57208. /** R */
  57209. R = 5,
  57210. /** ZL */
  57211. ZL = 6,
  57212. /** ZR */
  57213. ZR = 7,
  57214. /** Minus */
  57215. Minus = 8,
  57216. /** Plus */
  57217. Plus = 9,
  57218. /** LS */
  57219. LS = 10,
  57220. /** RS */
  57221. RS = 11,
  57222. /** DPadUp */
  57223. DPadUp = 12,
  57224. /** DPadDown */
  57225. DPadDown = 13,
  57226. /** DPadLeft */
  57227. DPadLeft = 14,
  57228. /** DRight */
  57229. DPadRight = 15,
  57230. /** Home */
  57231. Home = 16,
  57232. /** Capture */
  57233. Capture = 17,
  57234. /** LStickXAxis */
  57235. LStickXAxis = 18,
  57236. /** LStickYAxis */
  57237. LStickYAxis = 19,
  57238. /** RStickXAxis */
  57239. RStickXAxis = 20,
  57240. /** RStickYAxis */
  57241. RStickYAxis = 21
  57242. }
  57243. }
  57244. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  57245. import { Engine } from "babylonjs/Engines/engine";
  57246. import { IDisposable } from "babylonjs/scene";
  57247. import { Nullable } from "babylonjs/types";
  57248. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57249. /**
  57250. * This class will take all inputs from Keyboard, Pointer, and
  57251. * any Gamepads and provide a polling system that all devices
  57252. * will use. This class assumes that there will only be one
  57253. * pointer device and one keyboard.
  57254. */
  57255. export class DeviceInputSystem implements IDisposable {
  57256. /**
  57257. * Callback to be triggered when a device is connected
  57258. */
  57259. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  57260. /**
  57261. * Callback to be triggered when a device is disconnected
  57262. */
  57263. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  57264. /**
  57265. * Callback to be triggered when event driven input is updated
  57266. */
  57267. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  57268. private _inputs;
  57269. private _gamepads;
  57270. private _keyboardActive;
  57271. private _pointerActive;
  57272. private _elementToAttachTo;
  57273. private _keyboardDownEvent;
  57274. private _keyboardUpEvent;
  57275. private _pointerMoveEvent;
  57276. private _pointerDownEvent;
  57277. private _pointerUpEvent;
  57278. private _gamepadConnectedEvent;
  57279. private _gamepadDisconnectedEvent;
  57280. private static _MAX_KEYCODES;
  57281. private static _MAX_POINTER_INPUTS;
  57282. private constructor();
  57283. /**
  57284. * Creates a new DeviceInputSystem instance
  57285. * @param engine Engine to pull input element from
  57286. * @returns The new instance
  57287. */
  57288. static Create(engine: Engine): DeviceInputSystem;
  57289. /**
  57290. * Checks for current device input value, given an id and input index
  57291. * @param deviceName Id of connected device
  57292. * @param inputIndex Index of device input
  57293. * @returns Current value of input
  57294. */
  57295. /**
  57296. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  57297. * @param deviceType Enum specifiying device type
  57298. * @param deviceSlot "Slot" or index that device is referenced in
  57299. * @param inputIndex Id of input to be checked
  57300. * @returns Current value of input
  57301. */
  57302. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  57303. /**
  57304. * Dispose of all the eventlisteners
  57305. */
  57306. dispose(): void;
  57307. /**
  57308. * Add device and inputs to device array
  57309. * @param deviceType Enum specifiying device type
  57310. * @param deviceSlot "Slot" or index that device is referenced in
  57311. * @param numberOfInputs Number of input entries to create for given device
  57312. */
  57313. private _registerDevice;
  57314. /**
  57315. * Given a specific device name, remove that device from the device map
  57316. * @param deviceType Enum specifiying device type
  57317. * @param deviceSlot "Slot" or index that device is referenced in
  57318. */
  57319. private _unregisterDevice;
  57320. /**
  57321. * Handle all actions that come from keyboard interaction
  57322. */
  57323. private _handleKeyActions;
  57324. /**
  57325. * Handle all actions that come from pointer interaction
  57326. */
  57327. private _handlePointerActions;
  57328. /**
  57329. * Handle all actions that come from gamepad interaction
  57330. */
  57331. private _handleGamepadActions;
  57332. /**
  57333. * Update all non-event based devices with each frame
  57334. * @param deviceType Enum specifiying device type
  57335. * @param deviceSlot "Slot" or index that device is referenced in
  57336. * @param inputIndex Id of input to be checked
  57337. */
  57338. private _updateDevice;
  57339. /**
  57340. * Gets DeviceType from the device name
  57341. * @param deviceName Name of Device from DeviceInputSystem
  57342. * @returns DeviceType enum value
  57343. */
  57344. private _getGamepadDeviceType;
  57345. }
  57346. }
  57347. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  57348. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57349. /**
  57350. * Type to handle enforcement of inputs
  57351. */
  57352. 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;
  57353. }
  57354. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  57355. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  57356. import { Engine } from "babylonjs/Engines/engine";
  57357. import { IDisposable } from "babylonjs/scene";
  57358. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57359. import { Nullable } from "babylonjs/types";
  57360. import { Observable } from "babylonjs/Misc/observable";
  57361. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57362. /**
  57363. * Class that handles all input for a specific device
  57364. */
  57365. export class DeviceSource<T extends DeviceType> {
  57366. /** Type of device */
  57367. readonly deviceType: DeviceType;
  57368. /** "Slot" or index that device is referenced in */
  57369. readonly deviceSlot: number;
  57370. /**
  57371. * Observable to handle device input changes per device
  57372. */
  57373. readonly onInputChangedObservable: Observable<{
  57374. inputIndex: DeviceInput<T>;
  57375. previousState: Nullable<number>;
  57376. currentState: Nullable<number>;
  57377. }>;
  57378. private readonly _deviceInputSystem;
  57379. /**
  57380. * Default Constructor
  57381. * @param deviceInputSystem Reference to DeviceInputSystem
  57382. * @param deviceType Type of device
  57383. * @param deviceSlot "Slot" or index that device is referenced in
  57384. */
  57385. constructor(deviceInputSystem: DeviceInputSystem,
  57386. /** Type of device */
  57387. deviceType: DeviceType,
  57388. /** "Slot" or index that device is referenced in */
  57389. deviceSlot?: number);
  57390. /**
  57391. * Get input for specific input
  57392. * @param inputIndex index of specific input on device
  57393. * @returns Input value from DeviceInputSystem
  57394. */
  57395. getInput(inputIndex: DeviceInput<T>): number;
  57396. }
  57397. /**
  57398. * Class to keep track of devices
  57399. */
  57400. export class DeviceSourceManager implements IDisposable {
  57401. /**
  57402. * Observable to be triggered when before a device is connected
  57403. */
  57404. readonly onBeforeDeviceConnectedObservable: Observable<{
  57405. deviceType: DeviceType;
  57406. deviceSlot: number;
  57407. }>;
  57408. /**
  57409. * Observable to be triggered when before a device is disconnected
  57410. */
  57411. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  57412. deviceType: DeviceType;
  57413. deviceSlot: number;
  57414. }>;
  57415. /**
  57416. * Observable to be triggered when after a device is connected
  57417. */
  57418. readonly onAfterDeviceConnectedObservable: Observable<{
  57419. deviceType: DeviceType;
  57420. deviceSlot: number;
  57421. }>;
  57422. /**
  57423. * Observable to be triggered when after a device is disconnected
  57424. */
  57425. readonly onAfterDeviceDisconnectedObservable: Observable<{
  57426. deviceType: DeviceType;
  57427. deviceSlot: number;
  57428. }>;
  57429. private readonly _devices;
  57430. private readonly _firstDevice;
  57431. private readonly _deviceInputSystem;
  57432. /**
  57433. * Default Constructor
  57434. * @param engine engine to pull input element from
  57435. */
  57436. constructor(engine: Engine);
  57437. /**
  57438. * Gets a DeviceSource, given a type and slot
  57439. * @param deviceType Enum specifying device type
  57440. * @param deviceSlot "Slot" or index that device is referenced in
  57441. * @returns DeviceSource object
  57442. */
  57443. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  57444. /**
  57445. * Gets an array of DeviceSource objects for a given device type
  57446. * @param deviceType Enum specifying device type
  57447. * @returns Array of DeviceSource objects
  57448. */
  57449. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  57450. /**
  57451. * Dispose of DeviceInputSystem and other parts
  57452. */
  57453. dispose(): void;
  57454. /**
  57455. * Function to add device name to device list
  57456. * @param deviceType Enum specifying device type
  57457. * @param deviceSlot "Slot" or index that device is referenced in
  57458. */
  57459. private _addDevice;
  57460. /**
  57461. * Function to remove device name to device list
  57462. * @param deviceType Enum specifying device type
  57463. * @param deviceSlot "Slot" or index that device is referenced in
  57464. */
  57465. private _removeDevice;
  57466. /**
  57467. * Updates array storing first connected device of each type
  57468. * @param type Type of Device
  57469. */
  57470. private _updateFirstDevices;
  57471. }
  57472. }
  57473. declare module "babylonjs/DeviceInput/index" {
  57474. export * from "babylonjs/DeviceInput/deviceInputSystem";
  57475. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  57476. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  57477. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57478. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  57479. }
  57480. declare module "babylonjs/Engines/nullEngine" {
  57481. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  57482. import { Engine } from "babylonjs/Engines/engine";
  57483. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  57484. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  57485. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  57486. import { Effect } from "babylonjs/Materials/effect";
  57487. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  57488. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  57489. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  57490. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  57491. /**
  57492. * Options to create the null engine
  57493. */
  57494. export class NullEngineOptions {
  57495. /**
  57496. * Render width (Default: 512)
  57497. */
  57498. renderWidth: number;
  57499. /**
  57500. * Render height (Default: 256)
  57501. */
  57502. renderHeight: number;
  57503. /**
  57504. * Texture size (Default: 512)
  57505. */
  57506. textureSize: number;
  57507. /**
  57508. * If delta time between frames should be constant
  57509. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57510. */
  57511. deterministicLockstep: boolean;
  57512. /**
  57513. * Maximum about of steps between frames (Default: 4)
  57514. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57515. */
  57516. lockstepMaxSteps: number;
  57517. /**
  57518. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  57519. */
  57520. useHighPrecisionMatrix?: boolean;
  57521. }
  57522. /**
  57523. * The null engine class provides support for headless version of babylon.js.
  57524. * This can be used in server side scenario or for testing purposes
  57525. */
  57526. export class NullEngine extends Engine {
  57527. private _options;
  57528. /**
  57529. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  57530. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57531. * @returns true if engine is in deterministic lock step mode
  57532. */
  57533. isDeterministicLockStep(): boolean;
  57534. /**
  57535. * Gets the max steps when engine is running in deterministic lock step
  57536. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  57537. * @returns the max steps
  57538. */
  57539. getLockstepMaxSteps(): number;
  57540. /**
  57541. * Gets the current hardware scaling level.
  57542. * By default the hardware scaling level is computed from the window device ratio.
  57543. * 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.
  57544. * @returns a number indicating the current hardware scaling level
  57545. */
  57546. getHardwareScalingLevel(): number;
  57547. constructor(options?: NullEngineOptions);
  57548. /**
  57549. * Creates a vertex buffer
  57550. * @param vertices the data for the vertex buffer
  57551. * @returns the new WebGL static buffer
  57552. */
  57553. createVertexBuffer(vertices: FloatArray): DataBuffer;
  57554. /**
  57555. * Creates a new index buffer
  57556. * @param indices defines the content of the index buffer
  57557. * @param updatable defines if the index buffer must be updatable
  57558. * @returns a new webGL buffer
  57559. */
  57560. createIndexBuffer(indices: IndicesArray): DataBuffer;
  57561. /**
  57562. * Clear the current render buffer or the current render target (if any is set up)
  57563. * @param color defines the color to use
  57564. * @param backBuffer defines if the back buffer must be cleared
  57565. * @param depth defines if the depth buffer must be cleared
  57566. * @param stencil defines if the stencil buffer must be cleared
  57567. */
  57568. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  57569. /**
  57570. * Gets the current render width
  57571. * @param useScreen defines if screen size must be used (or the current render target if any)
  57572. * @returns a number defining the current render width
  57573. */
  57574. getRenderWidth(useScreen?: boolean): number;
  57575. /**
  57576. * Gets the current render height
  57577. * @param useScreen defines if screen size must be used (or the current render target if any)
  57578. * @returns a number defining the current render height
  57579. */
  57580. getRenderHeight(useScreen?: boolean): number;
  57581. /**
  57582. * Set the WebGL's viewport
  57583. * @param viewport defines the viewport element to be used
  57584. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  57585. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  57586. */
  57587. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  57588. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  57589. /**
  57590. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  57591. * @param pipelineContext defines the pipeline context to use
  57592. * @param uniformsNames defines the list of uniform names
  57593. * @returns an array of webGL uniform locations
  57594. */
  57595. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  57596. /**
  57597. * Gets the lsit of active attributes for a given webGL program
  57598. * @param pipelineContext defines the pipeline context to use
  57599. * @param attributesNames defines the list of attribute names to get
  57600. * @returns an array of indices indicating the offset of each attribute
  57601. */
  57602. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  57603. /**
  57604. * Binds an effect to the webGL context
  57605. * @param effect defines the effect to bind
  57606. */
  57607. bindSamplers(effect: Effect): void;
  57608. /**
  57609. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  57610. * @param effect defines the effect to activate
  57611. */
  57612. enableEffect(effect: Effect): void;
  57613. /**
  57614. * Set various states to the webGL context
  57615. * @param culling defines backface culling state
  57616. * @param zOffset defines the value to apply to zOffset (0 by default)
  57617. * @param force defines if states must be applied even if cache is up to date
  57618. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  57619. */
  57620. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  57621. /**
  57622. * Set the value of an uniform to an array of int32
  57623. * @param uniform defines the webGL uniform location where to store the value
  57624. * @param array defines the array of int32 to store
  57625. * @returns true if value was set
  57626. */
  57627. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57628. /**
  57629. * Set the value of an uniform to an array of int32 (stored as vec2)
  57630. * @param uniform defines the webGL uniform location where to store the value
  57631. * @param array defines the array of int32 to store
  57632. * @returns true if value was set
  57633. */
  57634. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57635. /**
  57636. * Set the value of an uniform to an array of int32 (stored as vec3)
  57637. * @param uniform defines the webGL uniform location where to store the value
  57638. * @param array defines the array of int32 to store
  57639. * @returns true if value was set
  57640. */
  57641. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57642. /**
  57643. * Set the value of an uniform to an array of int32 (stored as vec4)
  57644. * @param uniform defines the webGL uniform location where to store the value
  57645. * @param array defines the array of int32 to store
  57646. * @returns true if value was set
  57647. */
  57648. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  57649. /**
  57650. * Set the value of an uniform to an array of float32
  57651. * @param uniform defines the webGL uniform location where to store the value
  57652. * @param array defines the array of float32 to store
  57653. * @returns true if value was set
  57654. */
  57655. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57656. /**
  57657. * Set the value of an uniform to an array of float32 (stored as vec2)
  57658. * @param uniform defines the webGL uniform location where to store the value
  57659. * @param array defines the array of float32 to store
  57660. * @returns true if value was set
  57661. */
  57662. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57663. /**
  57664. * Set the value of an uniform to an array of float32 (stored as vec3)
  57665. * @param uniform defines the webGL uniform location where to store the value
  57666. * @param array defines the array of float32 to store
  57667. * @returns true if value was set
  57668. */
  57669. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57670. /**
  57671. * Set the value of an uniform to an array of float32 (stored as vec4)
  57672. * @param uniform defines the webGL uniform location where to store the value
  57673. * @param array defines the array of float32 to store
  57674. * @returns true if value was set
  57675. */
  57676. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  57677. /**
  57678. * Set the value of an uniform to an array of number
  57679. * @param uniform defines the webGL uniform location where to store the value
  57680. * @param array defines the array of number to store
  57681. * @returns true if value was set
  57682. */
  57683. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  57684. /**
  57685. * Set the value of an uniform to an array of number (stored as vec2)
  57686. * @param uniform defines the webGL uniform location where to store the value
  57687. * @param array defines the array of number to store
  57688. * @returns true if value was set
  57689. */
  57690. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  57691. /**
  57692. * Set the value of an uniform to an array of number (stored as vec3)
  57693. * @param uniform defines the webGL uniform location where to store the value
  57694. * @param array defines the array of number to store
  57695. * @returns true if value was set
  57696. */
  57697. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  57698. /**
  57699. * Set the value of an uniform to an array of number (stored as vec4)
  57700. * @param uniform defines the webGL uniform location where to store the value
  57701. * @param array defines the array of number to store
  57702. * @returns true if value was set
  57703. */
  57704. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  57705. /**
  57706. * Set the value of an uniform to an array of float32 (stored as matrices)
  57707. * @param uniform defines the webGL uniform location where to store the value
  57708. * @param matrices defines the array of float32 to store
  57709. * @returns true if value was set
  57710. */
  57711. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  57712. /**
  57713. * Set the value of an uniform to a matrix (3x3)
  57714. * @param uniform defines the webGL uniform location where to store the value
  57715. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  57716. * @returns true if value was set
  57717. */
  57718. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57719. /**
  57720. * Set the value of an uniform to a matrix (2x2)
  57721. * @param uniform defines the webGL uniform location where to store the value
  57722. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  57723. * @returns true if value was set
  57724. */
  57725. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  57726. /**
  57727. * Set the value of an uniform to a number (float)
  57728. * @param uniform defines the webGL uniform location where to store the value
  57729. * @param value defines the float number to store
  57730. * @returns true if value was set
  57731. */
  57732. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  57733. /**
  57734. * Set the value of an uniform to a vec2
  57735. * @param uniform defines the webGL uniform location where to store the value
  57736. * @param x defines the 1st component of the value
  57737. * @param y defines the 2nd component of the value
  57738. * @returns true if value was set
  57739. */
  57740. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  57741. /**
  57742. * Set the value of an uniform to a vec3
  57743. * @param uniform defines the webGL uniform location where to store the value
  57744. * @param x defines the 1st component of the value
  57745. * @param y defines the 2nd component of the value
  57746. * @param z defines the 3rd component of the value
  57747. * @returns true if value was set
  57748. */
  57749. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  57750. /**
  57751. * Set the value of an uniform to a boolean
  57752. * @param uniform defines the webGL uniform location where to store the value
  57753. * @param bool defines the boolean to store
  57754. * @returns true if value was set
  57755. */
  57756. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  57757. /**
  57758. * Set the value of an uniform to a vec4
  57759. * @param uniform defines the webGL uniform location where to store the value
  57760. * @param x defines the 1st component of the value
  57761. * @param y defines the 2nd component of the value
  57762. * @param z defines the 3rd component of the value
  57763. * @param w defines the 4th component of the value
  57764. * @returns true if value was set
  57765. */
  57766. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  57767. /**
  57768. * Sets the current alpha mode
  57769. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  57770. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  57771. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  57772. */
  57773. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  57774. /**
  57775. * Bind webGl buffers directly to the webGL context
  57776. * @param vertexBuffers defines the vertex buffer to bind
  57777. * @param indexBuffer defines the index buffer to bind
  57778. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  57779. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  57780. * @param effect defines the effect associated with the vertex buffer
  57781. */
  57782. bindBuffers(vertexBuffers: {
  57783. [key: string]: VertexBuffer;
  57784. }, indexBuffer: DataBuffer, effect: Effect): void;
  57785. /**
  57786. * Force the entire cache to be cleared
  57787. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  57788. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  57789. */
  57790. wipeCaches(bruteForce?: boolean): void;
  57791. /**
  57792. * Send a draw order
  57793. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  57794. * @param indexStart defines the starting index
  57795. * @param indexCount defines the number of index to draw
  57796. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57797. */
  57798. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  57799. /**
  57800. * Draw a list of indexed primitives
  57801. * @param fillMode defines the primitive to use
  57802. * @param indexStart defines the starting index
  57803. * @param indexCount defines the number of index to draw
  57804. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57805. */
  57806. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  57807. /**
  57808. * Draw a list of unindexed primitives
  57809. * @param fillMode defines the primitive to use
  57810. * @param verticesStart defines the index of first vertex to draw
  57811. * @param verticesCount defines the count of vertices to draw
  57812. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  57813. */
  57814. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  57815. /** @hidden */
  57816. _createTexture(): WebGLTexture;
  57817. /** @hidden */
  57818. _releaseTexture(texture: InternalTexture): void;
  57819. /**
  57820. * Usually called from Texture.ts.
  57821. * Passed information to create a WebGLTexture
  57822. * @param urlArg defines a value which contains one of the following:
  57823. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  57824. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  57825. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  57826. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  57827. * @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)
  57828. * @param scene needed for loading to the correct scene
  57829. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  57830. * @param onLoad optional callback to be called upon successful completion
  57831. * @param onError optional callback to be called upon failure
  57832. * @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
  57833. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  57834. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  57835. * @param forcedExtension defines the extension to use to pick the right loader
  57836. * @param mimeType defines an optional mime type
  57837. * @returns a InternalTexture for assignment back into BABYLON.Texture
  57838. */
  57839. 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;
  57840. /**
  57841. * Creates a new render target texture
  57842. * @param size defines the size of the texture
  57843. * @param options defines the options used to create the texture
  57844. * @returns a new render target texture stored in an InternalTexture
  57845. */
  57846. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  57847. /**
  57848. * Update the sampling mode of a given texture
  57849. * @param samplingMode defines the required sampling mode
  57850. * @param texture defines the texture to update
  57851. */
  57852. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  57853. /**
  57854. * Binds the frame buffer to the specified texture.
  57855. * @param texture The texture to render to or null for the default canvas
  57856. * @param faceIndex The face of the texture to render to in case of cube texture
  57857. * @param requiredWidth The width of the target to render to
  57858. * @param requiredHeight The height of the target to render to
  57859. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  57860. * @param lodLevel defines le lod level to bind to the frame buffer
  57861. */
  57862. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  57863. /**
  57864. * Unbind the current render target texture from the webGL context
  57865. * @param texture defines the render target texture to unbind
  57866. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  57867. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  57868. */
  57869. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  57870. /**
  57871. * Creates a dynamic vertex buffer
  57872. * @param vertices the data for the dynamic vertex buffer
  57873. * @returns the new WebGL dynamic buffer
  57874. */
  57875. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  57876. /**
  57877. * Update the content of a dynamic texture
  57878. * @param texture defines the texture to update
  57879. * @param canvas defines the canvas containing the source
  57880. * @param invertY defines if data must be stored with Y axis inverted
  57881. * @param premulAlpha defines if alpha is stored as premultiplied
  57882. * @param format defines the format of the data
  57883. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  57884. */
  57885. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  57886. /**
  57887. * Gets a boolean indicating if all created effects are ready
  57888. * @returns true if all effects are ready
  57889. */
  57890. areAllEffectsReady(): boolean;
  57891. /**
  57892. * @hidden
  57893. * Get the current error code of the webGL context
  57894. * @returns the error code
  57895. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  57896. */
  57897. getError(): number;
  57898. /** @hidden */
  57899. _getUnpackAlignement(): number;
  57900. /** @hidden */
  57901. _unpackFlipY(value: boolean): void;
  57902. /**
  57903. * Update a dynamic index buffer
  57904. * @param indexBuffer defines the target index buffer
  57905. * @param indices defines the data to update
  57906. * @param offset defines the offset in the target index buffer where update should start
  57907. */
  57908. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  57909. /**
  57910. * Updates a dynamic vertex buffer.
  57911. * @param vertexBuffer the vertex buffer to update
  57912. * @param vertices the data used to update the vertex buffer
  57913. * @param byteOffset the byte offset of the data (optional)
  57914. * @param byteLength the byte length of the data (optional)
  57915. */
  57916. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  57917. /** @hidden */
  57918. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  57919. /** @hidden */
  57920. _bindTexture(channel: number, texture: InternalTexture): void;
  57921. protected _deleteBuffer(buffer: WebGLBuffer): void;
  57922. /**
  57923. * 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
  57924. */
  57925. releaseEffects(): void;
  57926. displayLoadingUI(): void;
  57927. hideLoadingUI(): void;
  57928. /** @hidden */
  57929. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57930. /** @hidden */
  57931. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57932. /** @hidden */
  57933. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  57934. /** @hidden */
  57935. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  57936. }
  57937. }
  57938. declare module "babylonjs/Instrumentation/timeToken" {
  57939. import { Nullable } from "babylonjs/types";
  57940. /**
  57941. * @hidden
  57942. **/
  57943. export class _TimeToken {
  57944. _startTimeQuery: Nullable<WebGLQuery>;
  57945. _endTimeQuery: Nullable<WebGLQuery>;
  57946. _timeElapsedQuery: Nullable<WebGLQuery>;
  57947. _timeElapsedQueryEnded: boolean;
  57948. }
  57949. }
  57950. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  57951. import { Nullable, int } from "babylonjs/types";
  57952. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  57953. /** @hidden */
  57954. export class _OcclusionDataStorage {
  57955. /** @hidden */
  57956. occlusionInternalRetryCounter: number;
  57957. /** @hidden */
  57958. isOcclusionQueryInProgress: boolean;
  57959. /** @hidden */
  57960. isOccluded: boolean;
  57961. /** @hidden */
  57962. occlusionRetryCount: number;
  57963. /** @hidden */
  57964. occlusionType: number;
  57965. /** @hidden */
  57966. occlusionQueryAlgorithmType: number;
  57967. }
  57968. module "babylonjs/Engines/engine" {
  57969. interface Engine {
  57970. /**
  57971. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  57972. * @return the new query
  57973. */
  57974. createQuery(): WebGLQuery;
  57975. /**
  57976. * Delete and release a webGL query
  57977. * @param query defines the query to delete
  57978. * @return the current engine
  57979. */
  57980. deleteQuery(query: WebGLQuery): Engine;
  57981. /**
  57982. * Check if a given query has resolved and got its value
  57983. * @param query defines the query to check
  57984. * @returns true if the query got its value
  57985. */
  57986. isQueryResultAvailable(query: WebGLQuery): boolean;
  57987. /**
  57988. * Gets the value of a given query
  57989. * @param query defines the query to check
  57990. * @returns the value of the query
  57991. */
  57992. getQueryResult(query: WebGLQuery): number;
  57993. /**
  57994. * Initiates an occlusion query
  57995. * @param algorithmType defines the algorithm to use
  57996. * @param query defines the query to use
  57997. * @returns the current engine
  57998. * @see https://doc.babylonjs.com/features/occlusionquery
  57999. */
  58000. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  58001. /**
  58002. * Ends an occlusion query
  58003. * @see https://doc.babylonjs.com/features/occlusionquery
  58004. * @param algorithmType defines the algorithm to use
  58005. * @returns the current engine
  58006. */
  58007. endOcclusionQuery(algorithmType: number): Engine;
  58008. /**
  58009. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  58010. * Please note that only one query can be issued at a time
  58011. * @returns a time token used to track the time span
  58012. */
  58013. startTimeQuery(): Nullable<_TimeToken>;
  58014. /**
  58015. * Ends a time query
  58016. * @param token defines the token used to measure the time span
  58017. * @returns the time spent (in ns)
  58018. */
  58019. endTimeQuery(token: _TimeToken): int;
  58020. /** @hidden */
  58021. _currentNonTimestampToken: Nullable<_TimeToken>;
  58022. /** @hidden */
  58023. _createTimeQuery(): WebGLQuery;
  58024. /** @hidden */
  58025. _deleteTimeQuery(query: WebGLQuery): void;
  58026. /** @hidden */
  58027. _getGlAlgorithmType(algorithmType: number): number;
  58028. /** @hidden */
  58029. _getTimeQueryResult(query: WebGLQuery): any;
  58030. /** @hidden */
  58031. _getTimeQueryAvailability(query: WebGLQuery): any;
  58032. }
  58033. }
  58034. module "babylonjs/Meshes/abstractMesh" {
  58035. interface AbstractMesh {
  58036. /**
  58037. * Backing filed
  58038. * @hidden
  58039. */
  58040. __occlusionDataStorage: _OcclusionDataStorage;
  58041. /**
  58042. * Access property
  58043. * @hidden
  58044. */
  58045. _occlusionDataStorage: _OcclusionDataStorage;
  58046. /**
  58047. * 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.
  58048. * The default value is -1 which means don't break the query and wait till the result
  58049. * @see https://doc.babylonjs.com/features/occlusionquery
  58050. */
  58051. occlusionRetryCount: number;
  58052. /**
  58053. * 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:
  58054. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  58055. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  58056. * * 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.
  58057. * @see https://doc.babylonjs.com/features/occlusionquery
  58058. */
  58059. occlusionType: number;
  58060. /**
  58061. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  58062. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  58063. * * 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.
  58064. * @see https://doc.babylonjs.com/features/occlusionquery
  58065. */
  58066. occlusionQueryAlgorithmType: number;
  58067. /**
  58068. * 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
  58069. * @see https://doc.babylonjs.com/features/occlusionquery
  58070. */
  58071. isOccluded: boolean;
  58072. /**
  58073. * Flag to check the progress status of the query
  58074. * @see https://doc.babylonjs.com/features/occlusionquery
  58075. */
  58076. isOcclusionQueryInProgress: boolean;
  58077. }
  58078. }
  58079. }
  58080. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  58081. import { Nullable } from "babylonjs/types";
  58082. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58083. /** @hidden */
  58084. export var _forceTransformFeedbackToBundle: boolean;
  58085. module "babylonjs/Engines/engine" {
  58086. interface Engine {
  58087. /**
  58088. * Creates a webGL transform feedback object
  58089. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  58090. * @returns the webGL transform feedback object
  58091. */
  58092. createTransformFeedback(): WebGLTransformFeedback;
  58093. /**
  58094. * Delete a webGL transform feedback object
  58095. * @param value defines the webGL transform feedback object to delete
  58096. */
  58097. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  58098. /**
  58099. * Bind a webGL transform feedback object to the webgl context
  58100. * @param value defines the webGL transform feedback object to bind
  58101. */
  58102. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  58103. /**
  58104. * Begins a transform feedback operation
  58105. * @param usePoints defines if points or triangles must be used
  58106. */
  58107. beginTransformFeedback(usePoints: boolean): void;
  58108. /**
  58109. * Ends a transform feedback operation
  58110. */
  58111. endTransformFeedback(): void;
  58112. /**
  58113. * Specify the varyings to use with transform feedback
  58114. * @param program defines the associated webGL program
  58115. * @param value defines the list of strings representing the varying names
  58116. */
  58117. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  58118. /**
  58119. * Bind a webGL buffer for a transform feedback operation
  58120. * @param value defines the webGL buffer to bind
  58121. */
  58122. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  58123. }
  58124. }
  58125. }
  58126. declare module "babylonjs/Engines/Extensions/engine.views" {
  58127. import { Camera } from "babylonjs/Cameras/camera";
  58128. import { Nullable } from "babylonjs/types";
  58129. /**
  58130. * Class used to define an additional view for the engine
  58131. * @see https://doc.babylonjs.com/how_to/multi_canvases
  58132. */
  58133. export class EngineView {
  58134. /** Defines the canvas where to render the view */
  58135. target: HTMLCanvasElement;
  58136. /** Defines an optional camera used to render the view (will use active camera else) */
  58137. camera?: Camera;
  58138. }
  58139. module "babylonjs/Engines/engine" {
  58140. interface Engine {
  58141. /**
  58142. * Gets or sets the HTML element to use for attaching events
  58143. */
  58144. inputElement: Nullable<HTMLElement>;
  58145. /**
  58146. * Gets the current engine view
  58147. * @see https://doc.babylonjs.com/how_to/multi_canvases
  58148. */
  58149. activeView: Nullable<EngineView>;
  58150. /** Gets or sets the list of views */
  58151. views: EngineView[];
  58152. /**
  58153. * Register a new child canvas
  58154. * @param canvas defines the canvas to register
  58155. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  58156. * @returns the associated view
  58157. */
  58158. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  58159. /**
  58160. * Remove a registered child canvas
  58161. * @param canvas defines the canvas to remove
  58162. * @returns the current engine
  58163. */
  58164. unRegisterView(canvas: HTMLCanvasElement): Engine;
  58165. }
  58166. }
  58167. }
  58168. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  58169. import { Nullable } from "babylonjs/types";
  58170. module "babylonjs/Engines/engine" {
  58171. interface Engine {
  58172. /** @hidden */
  58173. _excludedCompressedTextures: string[];
  58174. /** @hidden */
  58175. _textureFormatInUse: string;
  58176. /**
  58177. * Gets the list of texture formats supported
  58178. */
  58179. readonly texturesSupported: Array<string>;
  58180. /**
  58181. * Gets the texture format in use
  58182. */
  58183. readonly textureFormatInUse: Nullable<string>;
  58184. /**
  58185. * Set the compressed texture extensions or file names to skip.
  58186. *
  58187. * @param skippedFiles defines the list of those texture files you want to skip
  58188. * Example: [".dds", ".env", "myfile.png"]
  58189. */
  58190. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  58191. /**
  58192. * Set the compressed texture format to use, based on the formats you have, and the formats
  58193. * supported by the hardware / browser.
  58194. *
  58195. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  58196. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  58197. * to API arguments needed to compressed textures. This puts the burden on the container
  58198. * generator to house the arcane code for determining these for current & future formats.
  58199. *
  58200. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58201. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58202. *
  58203. * Note: The result of this call is not taken into account when a texture is base64.
  58204. *
  58205. * @param formatsAvailable defines the list of those format families you have created
  58206. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  58207. *
  58208. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  58209. * @returns The extension selected.
  58210. */
  58211. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  58212. }
  58213. }
  58214. }
  58215. declare module "babylonjs/Engines/Extensions/index" {
  58216. export * from "babylonjs/Engines/Extensions/engine.alpha";
  58217. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  58218. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  58219. export * from "babylonjs/Engines/Extensions/engine.multiview";
  58220. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  58221. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58222. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  58223. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  58224. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  58225. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  58226. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  58227. export * from "babylonjs/Engines/Extensions/engine.webVR";
  58228. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  58229. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  58230. export * from "babylonjs/Engines/Extensions/engine.views";
  58231. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  58232. import "babylonjs/Engines/Extensions/engine.textureSelector";
  58233. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  58234. }
  58235. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  58236. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58237. /** @hidden */
  58238. export var rgbdEncodePixelShader: {
  58239. name: string;
  58240. shader: string;
  58241. };
  58242. }
  58243. declare module "babylonjs/Misc/environmentTextureTools" {
  58244. import { Nullable } from "babylonjs/types";
  58245. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58246. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58248. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  58249. import "babylonjs/Engines/Extensions/engine.readTexture";
  58250. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  58251. import "babylonjs/Shaders/rgbdEncode.fragment";
  58252. import "babylonjs/Shaders/rgbdDecode.fragment";
  58253. /**
  58254. * Raw texture data and descriptor sufficient for WebGL texture upload
  58255. */
  58256. export interface EnvironmentTextureInfo {
  58257. /**
  58258. * Version of the environment map
  58259. */
  58260. version: number;
  58261. /**
  58262. * Width of image
  58263. */
  58264. width: number;
  58265. /**
  58266. * Irradiance information stored in the file.
  58267. */
  58268. irradiance: any;
  58269. /**
  58270. * Specular information stored in the file.
  58271. */
  58272. specular: any;
  58273. }
  58274. /**
  58275. * Defines One Image in the file. It requires only the position in the file
  58276. * as well as the length.
  58277. */
  58278. interface BufferImageData {
  58279. /**
  58280. * Length of the image data.
  58281. */
  58282. length: number;
  58283. /**
  58284. * Position of the data from the null terminator delimiting the end of the JSON.
  58285. */
  58286. position: number;
  58287. }
  58288. /**
  58289. * Defines the specular data enclosed in the file.
  58290. * This corresponds to the version 1 of the data.
  58291. */
  58292. export interface EnvironmentTextureSpecularInfoV1 {
  58293. /**
  58294. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  58295. */
  58296. specularDataPosition?: number;
  58297. /**
  58298. * This contains all the images data needed to reconstruct the cubemap.
  58299. */
  58300. mipmaps: Array<BufferImageData>;
  58301. /**
  58302. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  58303. */
  58304. lodGenerationScale: number;
  58305. }
  58306. /**
  58307. * Sets of helpers addressing the serialization and deserialization of environment texture
  58308. * stored in a BabylonJS env file.
  58309. * Those files are usually stored as .env files.
  58310. */
  58311. export class EnvironmentTextureTools {
  58312. /**
  58313. * Magic number identifying the env file.
  58314. */
  58315. private static _MagicBytes;
  58316. /**
  58317. * Gets the environment info from an env file.
  58318. * @param data The array buffer containing the .env bytes.
  58319. * @returns the environment file info (the json header) if successfully parsed.
  58320. */
  58321. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  58322. /**
  58323. * Creates an environment texture from a loaded cube texture.
  58324. * @param texture defines the cube texture to convert in env file
  58325. * @return a promise containing the environment data if succesfull.
  58326. */
  58327. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  58328. /**
  58329. * Creates a JSON representation of the spherical data.
  58330. * @param texture defines the texture containing the polynomials
  58331. * @return the JSON representation of the spherical info
  58332. */
  58333. private static _CreateEnvTextureIrradiance;
  58334. /**
  58335. * Creates the ArrayBufferViews used for initializing environment texture image data.
  58336. * @param data the image data
  58337. * @param info parameters that determine what views will be created for accessing the underlying buffer
  58338. * @return the views described by info providing access to the underlying buffer
  58339. */
  58340. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  58341. /**
  58342. * Uploads the texture info contained in the env file to the GPU.
  58343. * @param texture defines the internal texture to upload to
  58344. * @param data defines the data to load
  58345. * @param info defines the texture info retrieved through the GetEnvInfo method
  58346. * @returns a promise
  58347. */
  58348. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  58349. private static _OnImageReadyAsync;
  58350. /**
  58351. * Uploads the levels of image data to the GPU.
  58352. * @param texture defines the internal texture to upload to
  58353. * @param imageData defines the array buffer views of image data [mipmap][face]
  58354. * @returns a promise
  58355. */
  58356. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  58357. /**
  58358. * Uploads spherical polynomials information to the texture.
  58359. * @param texture defines the texture we are trying to upload the information to
  58360. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  58361. */
  58362. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  58363. /** @hidden */
  58364. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58365. }
  58366. }
  58367. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  58368. /**
  58369. * Class used to inline functions in shader code
  58370. */
  58371. export class ShaderCodeInliner {
  58372. private static readonly _RegexpFindFunctionNameAndType;
  58373. private _sourceCode;
  58374. private _functionDescr;
  58375. private _numMaxIterations;
  58376. /** Gets or sets the token used to mark the functions to inline */
  58377. inlineToken: string;
  58378. /** Gets or sets the debug mode */
  58379. debug: boolean;
  58380. /** Gets the code after the inlining process */
  58381. get code(): string;
  58382. /**
  58383. * Initializes the inliner
  58384. * @param sourceCode shader code source to inline
  58385. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  58386. */
  58387. constructor(sourceCode: string, numMaxIterations?: number);
  58388. /**
  58389. * Start the processing of the shader code
  58390. */
  58391. processCode(): void;
  58392. private _collectFunctions;
  58393. private _processInlining;
  58394. private _extractBetweenMarkers;
  58395. private _skipWhitespaces;
  58396. private _removeComments;
  58397. private _replaceFunctionCallsByCode;
  58398. private _findBackward;
  58399. private _escapeRegExp;
  58400. private _replaceNames;
  58401. }
  58402. }
  58403. declare module "babylonjs/Engines/nativeEngine" {
  58404. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  58405. import { Engine } from "babylonjs/Engines/engine";
  58406. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  58407. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58408. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58409. import { Effect } from "babylonjs/Materials/effect";
  58410. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  58411. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  58412. import { IColor4Like } from "babylonjs/Maths/math.like";
  58413. import { Scene } from "babylonjs/scene";
  58414. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  58415. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  58416. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  58417. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  58418. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  58419. /**
  58420. * Container for accessors for natively-stored mesh data buffers.
  58421. */
  58422. class NativeDataBuffer extends DataBuffer {
  58423. /**
  58424. * Accessor value used to identify/retrieve a natively-stored index buffer.
  58425. */
  58426. nativeIndexBuffer?: any;
  58427. /**
  58428. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  58429. */
  58430. nativeVertexBuffer?: any;
  58431. }
  58432. /** @hidden */
  58433. class NativeTexture extends InternalTexture {
  58434. getInternalTexture(): InternalTexture;
  58435. getViewCount(): number;
  58436. }
  58437. /** @hidden */
  58438. export class NativeEngine extends Engine {
  58439. private readonly _native;
  58440. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  58441. private readonly INVALID_HANDLE;
  58442. private _boundBuffersVertexArray;
  58443. private _currentDepthTest;
  58444. getHardwareScalingLevel(): number;
  58445. constructor();
  58446. dispose(): void;
  58447. /**
  58448. * Can be used to override the current requestAnimationFrame requester.
  58449. * @hidden
  58450. */
  58451. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  58452. /**
  58453. * Override default engine behavior.
  58454. * @param color
  58455. * @param backBuffer
  58456. * @param depth
  58457. * @param stencil
  58458. */
  58459. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  58460. /**
  58461. * Gets host document
  58462. * @returns the host document object
  58463. */
  58464. getHostDocument(): Nullable<Document>;
  58465. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  58466. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  58467. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  58468. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  58469. [key: string]: VertexBuffer;
  58470. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58471. bindBuffers(vertexBuffers: {
  58472. [key: string]: VertexBuffer;
  58473. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  58474. recordVertexArrayObject(vertexBuffers: {
  58475. [key: string]: VertexBuffer;
  58476. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  58477. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58478. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  58479. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  58480. /**
  58481. * Draw a list of indexed primitives
  58482. * @param fillMode defines the primitive to use
  58483. * @param indexStart defines the starting index
  58484. * @param indexCount defines the number of index to draw
  58485. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58486. */
  58487. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  58488. /**
  58489. * Draw a list of unindexed primitives
  58490. * @param fillMode defines the primitive to use
  58491. * @param verticesStart defines the index of first vertex to draw
  58492. * @param verticesCount defines the count of vertices to draw
  58493. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  58494. */
  58495. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  58496. createPipelineContext(): IPipelineContext;
  58497. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  58498. /** @hidden */
  58499. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  58500. /** @hidden */
  58501. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  58502. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58503. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  58504. protected _setProgram(program: WebGLProgram): void;
  58505. _releaseEffect(effect: Effect): void;
  58506. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  58507. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  58508. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  58509. bindSamplers(effect: Effect): void;
  58510. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  58511. getRenderWidth(useScreen?: boolean): number;
  58512. getRenderHeight(useScreen?: boolean): number;
  58513. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  58514. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  58515. /**
  58516. * Set the z offset to apply to current rendering
  58517. * @param value defines the offset to apply
  58518. */
  58519. setZOffset(value: number): void;
  58520. /**
  58521. * Gets the current value of the zOffset
  58522. * @returns the current zOffset state
  58523. */
  58524. getZOffset(): number;
  58525. /**
  58526. * Enable or disable depth buffering
  58527. * @param enable defines the state to set
  58528. */
  58529. setDepthBuffer(enable: boolean): void;
  58530. /**
  58531. * Gets a boolean indicating if depth writing is enabled
  58532. * @returns the current depth writing state
  58533. */
  58534. getDepthWrite(): boolean;
  58535. setDepthFunctionToGreater(): void;
  58536. setDepthFunctionToGreaterOrEqual(): void;
  58537. setDepthFunctionToLess(): void;
  58538. setDepthFunctionToLessOrEqual(): void;
  58539. /**
  58540. * Enable or disable depth writing
  58541. * @param enable defines the state to set
  58542. */
  58543. setDepthWrite(enable: boolean): void;
  58544. /**
  58545. * Enable or disable color writing
  58546. * @param enable defines the state to set
  58547. */
  58548. setColorWrite(enable: boolean): void;
  58549. /**
  58550. * Gets a boolean indicating if color writing is enabled
  58551. * @returns the current color writing state
  58552. */
  58553. getColorWrite(): boolean;
  58554. /**
  58555. * Sets alpha constants used by some alpha blending modes
  58556. * @param r defines the red component
  58557. * @param g defines the green component
  58558. * @param b defines the blue component
  58559. * @param a defines the alpha component
  58560. */
  58561. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  58562. /**
  58563. * Sets the current alpha mode
  58564. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  58565. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  58566. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58567. */
  58568. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  58569. /**
  58570. * Gets the current alpha mode
  58571. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  58572. * @returns the current alpha mode
  58573. */
  58574. getAlphaMode(): number;
  58575. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  58576. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58577. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58578. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58579. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  58580. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58581. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58582. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58583. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  58584. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  58585. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  58586. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  58587. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  58588. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  58589. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58590. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  58591. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  58592. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  58593. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  58594. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  58595. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  58596. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  58597. wipeCaches(bruteForce?: boolean): void;
  58598. _createTexture(): WebGLTexture;
  58599. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  58600. /**
  58601. * Update the content of a dynamic texture
  58602. * @param texture defines the texture to update
  58603. * @param canvas defines the canvas containing the source
  58604. * @param invertY defines if data must be stored with Y axis inverted
  58605. * @param premulAlpha defines if alpha is stored as premultiplied
  58606. * @param format defines the format of the data
  58607. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  58608. */
  58609. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  58610. /**
  58611. * Usually called from Texture.ts.
  58612. * Passed information to create a WebGLTexture
  58613. * @param url defines a value which contains one of the following:
  58614. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  58615. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  58616. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  58617. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  58618. * @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)
  58619. * @param scene needed for loading to the correct scene
  58620. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  58621. * @param onLoad optional callback to be called upon successful completion
  58622. * @param onError optional callback to be called upon failure
  58623. * @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
  58624. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  58625. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  58626. * @param forcedExtension defines the extension to use to pick the right loader
  58627. * @param mimeType defines an optional mime type
  58628. * @param loaderOptions options to be passed to the loader
  58629. * @returns a InternalTexture for assignment back into BABYLON.Texture
  58630. */
  58631. 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;
  58632. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  58633. _releaseFramebufferObjects(texture: InternalTexture): void;
  58634. /**
  58635. * Creates a cube texture
  58636. * @param rootUrl defines the url where the files to load is located
  58637. * @param scene defines the current scene
  58638. * @param files defines the list of files to load (1 per face)
  58639. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  58640. * @param onLoad defines an optional callback raised when the texture is loaded
  58641. * @param onError defines an optional callback raised if there is an issue to load the texture
  58642. * @param format defines the format of the data
  58643. * @param forcedExtension defines the extension to use to pick the right loader
  58644. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  58645. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58646. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58647. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  58648. * @returns the cube texture as an InternalTexture
  58649. */
  58650. 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;
  58651. createRenderTargetTexture(size: number | {
  58652. width: number;
  58653. height: number;
  58654. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  58655. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  58656. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  58657. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  58658. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  58659. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  58660. /**
  58661. * Updates a dynamic vertex buffer.
  58662. * @param vertexBuffer the vertex buffer to update
  58663. * @param data the data used to update the vertex buffer
  58664. * @param byteOffset the byte offset of the data (optional)
  58665. * @param byteLength the byte length of the data (optional)
  58666. */
  58667. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  58668. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  58669. private _updateAnisotropicLevel;
  58670. private _getAddressMode;
  58671. /** @hidden */
  58672. _bindTexture(channel: number, texture: InternalTexture): void;
  58673. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  58674. releaseEffects(): void;
  58675. /** @hidden */
  58676. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58677. /** @hidden */
  58678. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58679. /** @hidden */
  58680. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  58681. /** @hidden */
  58682. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  58683. private _getNativeSamplingMode;
  58684. private _getNativeTextureFormat;
  58685. private _getNativeAlphaMode;
  58686. private _getNativeAttribType;
  58687. }
  58688. }
  58689. declare module "babylonjs/Engines/index" {
  58690. export * from "babylonjs/Engines/constants";
  58691. export * from "babylonjs/Engines/engineCapabilities";
  58692. export * from "babylonjs/Engines/instancingAttributeInfo";
  58693. export * from "babylonjs/Engines/thinEngine";
  58694. export * from "babylonjs/Engines/engine";
  58695. export * from "babylonjs/Engines/engineStore";
  58696. export * from "babylonjs/Engines/nullEngine";
  58697. export * from "babylonjs/Engines/Extensions/index";
  58698. export * from "babylonjs/Engines/IPipelineContext";
  58699. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  58700. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  58701. export * from "babylonjs/Engines/nativeEngine";
  58702. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  58703. export * from "babylonjs/Engines/performanceConfigurator";
  58704. }
  58705. declare module "babylonjs/Events/clipboardEvents" {
  58706. /**
  58707. * Gather the list of clipboard event types as constants.
  58708. */
  58709. export class ClipboardEventTypes {
  58710. /**
  58711. * The clipboard event is fired when a copy command is active (pressed).
  58712. */
  58713. static readonly COPY: number;
  58714. /**
  58715. * The clipboard event is fired when a cut command is active (pressed).
  58716. */
  58717. static readonly CUT: number;
  58718. /**
  58719. * The clipboard event is fired when a paste command is active (pressed).
  58720. */
  58721. static readonly PASTE: number;
  58722. }
  58723. /**
  58724. * This class is used to store clipboard related info for the onClipboardObservable event.
  58725. */
  58726. export class ClipboardInfo {
  58727. /**
  58728. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58729. */
  58730. type: number;
  58731. /**
  58732. * Defines the related dom event
  58733. */
  58734. event: ClipboardEvent;
  58735. /**
  58736. *Creates an instance of ClipboardInfo.
  58737. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  58738. * @param event Defines the related dom event
  58739. */
  58740. constructor(
  58741. /**
  58742. * Defines the type of event (BABYLON.ClipboardEventTypes)
  58743. */
  58744. type: number,
  58745. /**
  58746. * Defines the related dom event
  58747. */
  58748. event: ClipboardEvent);
  58749. /**
  58750. * Get the clipboard event's type from the keycode.
  58751. * @param keyCode Defines the keyCode for the current keyboard event.
  58752. * @return {number}
  58753. */
  58754. static GetTypeFromCharacter(keyCode: number): number;
  58755. }
  58756. }
  58757. declare module "babylonjs/Events/index" {
  58758. export * from "babylonjs/Events/keyboardEvents";
  58759. export * from "babylonjs/Events/pointerEvents";
  58760. export * from "babylonjs/Events/clipboardEvents";
  58761. }
  58762. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  58763. import { Scene } from "babylonjs/scene";
  58764. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58765. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58766. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58767. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58768. /**
  58769. * Google Daydream controller
  58770. */
  58771. export class DaydreamController extends WebVRController {
  58772. /**
  58773. * Base Url for the controller model.
  58774. */
  58775. static MODEL_BASE_URL: string;
  58776. /**
  58777. * File name for the controller model.
  58778. */
  58779. static MODEL_FILENAME: string;
  58780. /**
  58781. * Gamepad Id prefix used to identify Daydream Controller.
  58782. */
  58783. static readonly GAMEPAD_ID_PREFIX: string;
  58784. /**
  58785. * Creates a new DaydreamController from a gamepad
  58786. * @param vrGamepad the gamepad that the controller should be created from
  58787. */
  58788. constructor(vrGamepad: any);
  58789. /**
  58790. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58791. * @param scene scene in which to add meshes
  58792. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58793. */
  58794. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58795. /**
  58796. * Called once for each button that changed state since the last frame
  58797. * @param buttonIdx Which button index changed
  58798. * @param state New state of the button
  58799. * @param changes Which properties on the state changed since last frame
  58800. */
  58801. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58802. }
  58803. }
  58804. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  58805. import { Scene } from "babylonjs/scene";
  58806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58807. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58808. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58809. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58810. /**
  58811. * Gear VR Controller
  58812. */
  58813. export class GearVRController extends WebVRController {
  58814. /**
  58815. * Base Url for the controller model.
  58816. */
  58817. static MODEL_BASE_URL: string;
  58818. /**
  58819. * File name for the controller model.
  58820. */
  58821. static MODEL_FILENAME: string;
  58822. /**
  58823. * Gamepad Id prefix used to identify this controller.
  58824. */
  58825. static readonly GAMEPAD_ID_PREFIX: string;
  58826. private readonly _buttonIndexToObservableNameMap;
  58827. /**
  58828. * Creates a new GearVRController from a gamepad
  58829. * @param vrGamepad the gamepad that the controller should be created from
  58830. */
  58831. constructor(vrGamepad: any);
  58832. /**
  58833. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58834. * @param scene scene in which to add meshes
  58835. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58836. */
  58837. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58838. /**
  58839. * Called once for each button that changed state since the last frame
  58840. * @param buttonIdx Which button index changed
  58841. * @param state New state of the button
  58842. * @param changes Which properties on the state changed since last frame
  58843. */
  58844. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58845. }
  58846. }
  58847. declare module "babylonjs/Gamepads/Controllers/genericController" {
  58848. import { Scene } from "babylonjs/scene";
  58849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58850. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58851. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58852. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58853. /**
  58854. * Generic Controller
  58855. */
  58856. export class GenericController extends WebVRController {
  58857. /**
  58858. * Base Url for the controller model.
  58859. */
  58860. static readonly MODEL_BASE_URL: string;
  58861. /**
  58862. * File name for the controller model.
  58863. */
  58864. static readonly MODEL_FILENAME: string;
  58865. /**
  58866. * Creates a new GenericController from a gamepad
  58867. * @param vrGamepad the gamepad that the controller should be created from
  58868. */
  58869. constructor(vrGamepad: any);
  58870. /**
  58871. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58872. * @param scene scene in which to add meshes
  58873. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58874. */
  58875. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58876. /**
  58877. * Called once for each button that changed state since the last frame
  58878. * @param buttonIdx Which button index changed
  58879. * @param state New state of the button
  58880. * @param changes Which properties on the state changed since last frame
  58881. */
  58882. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58883. }
  58884. }
  58885. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  58886. import { Observable } from "babylonjs/Misc/observable";
  58887. import { Scene } from "babylonjs/scene";
  58888. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58889. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58890. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58891. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58892. /**
  58893. * Oculus Touch Controller
  58894. */
  58895. export class OculusTouchController extends WebVRController {
  58896. /**
  58897. * Base Url for the controller model.
  58898. */
  58899. static MODEL_BASE_URL: string;
  58900. /**
  58901. * File name for the left controller model.
  58902. */
  58903. static MODEL_LEFT_FILENAME: string;
  58904. /**
  58905. * File name for the right controller model.
  58906. */
  58907. static MODEL_RIGHT_FILENAME: string;
  58908. /**
  58909. * Base Url for the Quest controller model.
  58910. */
  58911. static QUEST_MODEL_BASE_URL: string;
  58912. /**
  58913. * @hidden
  58914. * If the controllers are running on a device that needs the updated Quest controller models
  58915. */
  58916. static _IsQuest: boolean;
  58917. /**
  58918. * Fired when the secondary trigger on this controller is modified
  58919. */
  58920. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  58921. /**
  58922. * Fired when the thumb rest on this controller is modified
  58923. */
  58924. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  58925. /**
  58926. * Creates a new OculusTouchController from a gamepad
  58927. * @param vrGamepad the gamepad that the controller should be created from
  58928. */
  58929. constructor(vrGamepad: any);
  58930. /**
  58931. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58932. * @param scene scene in which to add meshes
  58933. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58934. */
  58935. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58936. /**
  58937. * Fired when the A button on this controller is modified
  58938. */
  58939. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58940. /**
  58941. * Fired when the B button on this controller is modified
  58942. */
  58943. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58944. /**
  58945. * Fired when the X button on this controller is modified
  58946. */
  58947. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58948. /**
  58949. * Fired when the Y button on this controller is modified
  58950. */
  58951. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  58952. /**
  58953. * Called once for each button that changed state since the last frame
  58954. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  58955. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  58956. * 2) secondary trigger (same)
  58957. * 3) A (right) X (left), touch, pressed = value
  58958. * 4) B / Y
  58959. * 5) thumb rest
  58960. * @param buttonIdx Which button index changed
  58961. * @param state New state of the button
  58962. * @param changes Which properties on the state changed since last frame
  58963. */
  58964. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  58965. }
  58966. }
  58967. declare module "babylonjs/Gamepads/Controllers/viveController" {
  58968. import { Scene } from "babylonjs/scene";
  58969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58970. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  58971. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  58972. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  58973. import { Observable } from "babylonjs/Misc/observable";
  58974. /**
  58975. * Vive Controller
  58976. */
  58977. export class ViveController extends WebVRController {
  58978. /**
  58979. * Base Url for the controller model.
  58980. */
  58981. static MODEL_BASE_URL: string;
  58982. /**
  58983. * File name for the controller model.
  58984. */
  58985. static MODEL_FILENAME: string;
  58986. /**
  58987. * Creates a new ViveController from a gamepad
  58988. * @param vrGamepad the gamepad that the controller should be created from
  58989. */
  58990. constructor(vrGamepad: any);
  58991. /**
  58992. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  58993. * @param scene scene in which to add meshes
  58994. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  58995. */
  58996. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  58997. /**
  58998. * Fired when the left button on this controller is modified
  58999. */
  59000. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59001. /**
  59002. * Fired when the right button on this controller is modified
  59003. */
  59004. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59005. /**
  59006. * Fired when the menu button on this controller is modified
  59007. */
  59008. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59009. /**
  59010. * Called once for each button that changed state since the last frame
  59011. * Vive mapping:
  59012. * 0: touchpad
  59013. * 1: trigger
  59014. * 2: left AND right buttons
  59015. * 3: menu button
  59016. * @param buttonIdx Which button index changed
  59017. * @param state New state of the button
  59018. * @param changes Which properties on the state changed since last frame
  59019. */
  59020. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59021. }
  59022. }
  59023. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  59024. import { Observable } from "babylonjs/Misc/observable";
  59025. import { Scene } from "babylonjs/scene";
  59026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59027. import { Ray } from "babylonjs/Culling/ray";
  59028. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  59029. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59030. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  59031. /**
  59032. * Defines the WindowsMotionController object that the state of the windows motion controller
  59033. */
  59034. export class WindowsMotionController extends WebVRController {
  59035. /**
  59036. * The base url used to load the left and right controller models
  59037. */
  59038. static MODEL_BASE_URL: string;
  59039. /**
  59040. * The name of the left controller model file
  59041. */
  59042. static MODEL_LEFT_FILENAME: string;
  59043. /**
  59044. * The name of the right controller model file
  59045. */
  59046. static MODEL_RIGHT_FILENAME: string;
  59047. /**
  59048. * The controller name prefix for this controller type
  59049. */
  59050. static readonly GAMEPAD_ID_PREFIX: string;
  59051. /**
  59052. * The controller id pattern for this controller type
  59053. */
  59054. private static readonly GAMEPAD_ID_PATTERN;
  59055. private _loadedMeshInfo;
  59056. protected readonly _mapping: {
  59057. buttons: string[];
  59058. buttonMeshNames: {
  59059. trigger: string;
  59060. menu: string;
  59061. grip: string;
  59062. thumbstick: string;
  59063. trackpad: string;
  59064. };
  59065. buttonObservableNames: {
  59066. trigger: string;
  59067. menu: string;
  59068. grip: string;
  59069. thumbstick: string;
  59070. trackpad: string;
  59071. };
  59072. axisMeshNames: string[];
  59073. pointingPoseMeshName: string;
  59074. };
  59075. /**
  59076. * Fired when the trackpad on this controller is clicked
  59077. */
  59078. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  59079. /**
  59080. * Fired when the trackpad on this controller is modified
  59081. */
  59082. onTrackpadValuesChangedObservable: Observable<StickValues>;
  59083. /**
  59084. * The current x and y values of this controller's trackpad
  59085. */
  59086. trackpad: StickValues;
  59087. /**
  59088. * Creates a new WindowsMotionController from a gamepad
  59089. * @param vrGamepad the gamepad that the controller should be created from
  59090. */
  59091. constructor(vrGamepad: any);
  59092. /**
  59093. * Fired when the trigger on this controller is modified
  59094. */
  59095. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59096. /**
  59097. * Fired when the menu button on this controller is modified
  59098. */
  59099. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59100. /**
  59101. * Fired when the grip button on this controller is modified
  59102. */
  59103. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59104. /**
  59105. * Fired when the thumbstick button on this controller is modified
  59106. */
  59107. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59108. /**
  59109. * Fired when the touchpad button on this controller is modified
  59110. */
  59111. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59112. /**
  59113. * Fired when the touchpad values on this controller are modified
  59114. */
  59115. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  59116. protected _updateTrackpad(): void;
  59117. /**
  59118. * Called once per frame by the engine.
  59119. */
  59120. update(): void;
  59121. /**
  59122. * Called once for each button that changed state since the last frame
  59123. * @param buttonIdx Which button index changed
  59124. * @param state New state of the button
  59125. * @param changes Which properties on the state changed since last frame
  59126. */
  59127. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  59128. /**
  59129. * Moves the buttons on the controller mesh based on their current state
  59130. * @param buttonName the name of the button to move
  59131. * @param buttonValue the value of the button which determines the buttons new position
  59132. */
  59133. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  59134. /**
  59135. * Moves the axis on the controller mesh based on its current state
  59136. * @param axis the index of the axis
  59137. * @param axisValue the value of the axis which determines the meshes new position
  59138. * @hidden
  59139. */
  59140. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  59141. /**
  59142. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  59143. * @param scene scene in which to add meshes
  59144. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  59145. */
  59146. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  59147. /**
  59148. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  59149. * can be transformed by button presses and axes values, based on this._mapping.
  59150. *
  59151. * @param scene scene in which the meshes exist
  59152. * @param meshes list of meshes that make up the controller model to process
  59153. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  59154. */
  59155. private processModel;
  59156. private createMeshInfo;
  59157. /**
  59158. * Gets the ray of the controller in the direction the controller is pointing
  59159. * @param length the length the resulting ray should be
  59160. * @returns a ray in the direction the controller is pointing
  59161. */
  59162. getForwardRay(length?: number): Ray;
  59163. /**
  59164. * Disposes of the controller
  59165. */
  59166. dispose(): void;
  59167. }
  59168. /**
  59169. * This class represents a new windows motion controller in XR.
  59170. */
  59171. export class XRWindowsMotionController extends WindowsMotionController {
  59172. /**
  59173. * Changing the original WIndowsMotionController mapping to fir the new mapping
  59174. */
  59175. protected readonly _mapping: {
  59176. buttons: string[];
  59177. buttonMeshNames: {
  59178. trigger: string;
  59179. menu: string;
  59180. grip: string;
  59181. thumbstick: string;
  59182. trackpad: string;
  59183. };
  59184. buttonObservableNames: {
  59185. trigger: string;
  59186. menu: string;
  59187. grip: string;
  59188. thumbstick: string;
  59189. trackpad: string;
  59190. };
  59191. axisMeshNames: string[];
  59192. pointingPoseMeshName: string;
  59193. };
  59194. /**
  59195. * Construct a new XR-Based windows motion controller
  59196. *
  59197. * @param gamepadInfo the gamepad object from the browser
  59198. */
  59199. constructor(gamepadInfo: any);
  59200. /**
  59201. * holds the thumbstick values (X,Y)
  59202. */
  59203. thumbstickValues: StickValues;
  59204. /**
  59205. * Fired when the thumbstick on this controller is clicked
  59206. */
  59207. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  59208. /**
  59209. * Fired when the thumbstick on this controller is modified
  59210. */
  59211. onThumbstickValuesChangedObservable: Observable<StickValues>;
  59212. /**
  59213. * Fired when the touchpad button on this controller is modified
  59214. */
  59215. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  59216. /**
  59217. * Fired when the touchpad values on this controller are modified
  59218. */
  59219. onTrackpadValuesChangedObservable: Observable<StickValues>;
  59220. /**
  59221. * Fired when the thumbstick button on this controller is modified
  59222. * here to prevent breaking changes
  59223. */
  59224. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  59225. /**
  59226. * updating the thumbstick(!) and not the trackpad.
  59227. * This is named this way due to the difference between WebVR and XR and to avoid
  59228. * changing the parent class.
  59229. */
  59230. protected _updateTrackpad(): void;
  59231. /**
  59232. * Disposes the class with joy
  59233. */
  59234. dispose(): void;
  59235. }
  59236. }
  59237. declare module "babylonjs/Gamepads/Controllers/index" {
  59238. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  59239. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  59240. export * from "babylonjs/Gamepads/Controllers/genericController";
  59241. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  59242. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  59243. export * from "babylonjs/Gamepads/Controllers/viveController";
  59244. export * from "babylonjs/Gamepads/Controllers/webVRController";
  59245. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  59246. }
  59247. declare module "babylonjs/Gamepads/index" {
  59248. export * from "babylonjs/Gamepads/Controllers/index";
  59249. export * from "babylonjs/Gamepads/gamepad";
  59250. export * from "babylonjs/Gamepads/gamepadManager";
  59251. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  59252. export * from "babylonjs/Gamepads/xboxGamepad";
  59253. export * from "babylonjs/Gamepads/dualShockGamepad";
  59254. }
  59255. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  59256. import { Scene } from "babylonjs/scene";
  59257. import { Vector4 } from "babylonjs/Maths/math.vector";
  59258. import { Color4 } from "babylonjs/Maths/math.color";
  59259. import { Mesh } from "babylonjs/Meshes/mesh";
  59260. import { Nullable } from "babylonjs/types";
  59261. /**
  59262. * Class containing static functions to help procedurally build meshes
  59263. */
  59264. export class PolyhedronBuilder {
  59265. /**
  59266. * Creates a polyhedron mesh
  59267. * * 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
  59268. * * The parameter `size` (positive float, default 1) sets the polygon size
  59269. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59270. * * 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`
  59271. * * 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
  59272. * * 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)`)
  59273. * * 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
  59274. * * 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
  59275. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59276. * * 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
  59277. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59278. * @param name defines the name of the mesh
  59279. * @param options defines the options used to create the mesh
  59280. * @param scene defines the hosting scene
  59281. * @returns the polyhedron mesh
  59282. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59283. */
  59284. static CreatePolyhedron(name: string, options: {
  59285. type?: number;
  59286. size?: number;
  59287. sizeX?: number;
  59288. sizeY?: number;
  59289. sizeZ?: number;
  59290. custom?: any;
  59291. faceUV?: Vector4[];
  59292. faceColors?: Color4[];
  59293. flat?: boolean;
  59294. updatable?: boolean;
  59295. sideOrientation?: number;
  59296. frontUVs?: Vector4;
  59297. backUVs?: Vector4;
  59298. }, scene?: Nullable<Scene>): Mesh;
  59299. }
  59300. }
  59301. declare module "babylonjs/Gizmos/scaleGizmo" {
  59302. import { Observable } from "babylonjs/Misc/observable";
  59303. import { Nullable } from "babylonjs/types";
  59304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59305. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59306. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  59307. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59308. import { Node } from "babylonjs/node";
  59309. /**
  59310. * Gizmo that enables scaling a mesh along 3 axis
  59311. */
  59312. export class ScaleGizmo extends Gizmo {
  59313. /**
  59314. * Internal gizmo used for interactions on the x axis
  59315. */
  59316. xGizmo: AxisScaleGizmo;
  59317. /**
  59318. * Internal gizmo used for interactions on the y axis
  59319. */
  59320. yGizmo: AxisScaleGizmo;
  59321. /**
  59322. * Internal gizmo used for interactions on the z axis
  59323. */
  59324. zGizmo: AxisScaleGizmo;
  59325. /**
  59326. * Internal gizmo used to scale all axis equally
  59327. */
  59328. uniformScaleGizmo: AxisScaleGizmo;
  59329. private _meshAttached;
  59330. private _nodeAttached;
  59331. private _snapDistance;
  59332. private _uniformScalingMesh;
  59333. private _octahedron;
  59334. private _sensitivity;
  59335. /** Fires an event when any of it's sub gizmos are dragged */
  59336. onDragStartObservable: Observable<unknown>;
  59337. /** Fires an event when any of it's sub gizmos are released from dragging */
  59338. onDragEndObservable: Observable<unknown>;
  59339. get attachedMesh(): Nullable<AbstractMesh>;
  59340. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59341. get attachedNode(): Nullable<Node>;
  59342. set attachedNode(node: Nullable<Node>);
  59343. /**
  59344. * True when the mouse pointer is hovering a gizmo mesh
  59345. */
  59346. get isHovered(): boolean;
  59347. /**
  59348. * Creates a ScaleGizmo
  59349. * @param gizmoLayer The utility layer the gizmo will be added to
  59350. * @param thickness display gizmo axis thickness
  59351. */
  59352. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  59353. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59354. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59355. /**
  59356. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59357. */
  59358. set snapDistance(value: number);
  59359. get snapDistance(): number;
  59360. /**
  59361. * Ratio for the scale of the gizmo (Default: 1)
  59362. */
  59363. set scaleRatio(value: number);
  59364. get scaleRatio(): number;
  59365. /**
  59366. * Sensitivity factor for dragging (Default: 1)
  59367. */
  59368. set sensitivity(value: number);
  59369. get sensitivity(): number;
  59370. /**
  59371. * Disposes of the gizmo
  59372. */
  59373. dispose(): void;
  59374. }
  59375. }
  59376. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  59377. import { Observable } from "babylonjs/Misc/observable";
  59378. import { Nullable } from "babylonjs/types";
  59379. import { Vector3 } from "babylonjs/Maths/math.vector";
  59380. import { Node } from "babylonjs/node";
  59381. import { Mesh } from "babylonjs/Meshes/mesh";
  59382. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59383. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59384. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59385. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59386. import { Color3 } from "babylonjs/Maths/math.color";
  59387. /**
  59388. * Single axis scale gizmo
  59389. */
  59390. export class AxisScaleGizmo extends Gizmo {
  59391. /**
  59392. * Drag behavior responsible for the gizmos dragging interactions
  59393. */
  59394. dragBehavior: PointerDragBehavior;
  59395. private _pointerObserver;
  59396. /**
  59397. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59398. */
  59399. snapDistance: number;
  59400. /**
  59401. * Event that fires each time the gizmo snaps to a new location.
  59402. * * snapDistance is the the change in distance
  59403. */
  59404. onSnapObservable: Observable<{
  59405. snapDistance: number;
  59406. }>;
  59407. /**
  59408. * If the scaling operation should be done on all axis (default: false)
  59409. */
  59410. uniformScaling: boolean;
  59411. /**
  59412. * Custom sensitivity value for the drag strength
  59413. */
  59414. sensitivity: number;
  59415. private _isEnabled;
  59416. private _parent;
  59417. private _arrow;
  59418. private _coloredMaterial;
  59419. private _hoverMaterial;
  59420. /**
  59421. * Creates an AxisScaleGizmo
  59422. * @param gizmoLayer The utility layer the gizmo will be added to
  59423. * @param dragAxis The axis which the gizmo will be able to scale on
  59424. * @param color The color of the gizmo
  59425. * @param thickness display gizmo axis thickness
  59426. */
  59427. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  59428. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59429. /**
  59430. * If the gizmo is enabled
  59431. */
  59432. set isEnabled(value: boolean);
  59433. get isEnabled(): boolean;
  59434. /**
  59435. * Disposes of the gizmo
  59436. */
  59437. dispose(): void;
  59438. /**
  59439. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  59440. * @param mesh The mesh to replace the default mesh of the gizmo
  59441. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  59442. */
  59443. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  59444. }
  59445. }
  59446. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  59447. import { Observable } from "babylonjs/Misc/observable";
  59448. import { Nullable } from "babylonjs/types";
  59449. import { Vector3 } from "babylonjs/Maths/math.vector";
  59450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59451. import { Mesh } from "babylonjs/Meshes/mesh";
  59452. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59453. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59454. import { Color3 } from "babylonjs/Maths/math.color";
  59455. import "babylonjs/Meshes/Builders/boxBuilder";
  59456. /**
  59457. * Bounding box gizmo
  59458. */
  59459. export class BoundingBoxGizmo extends Gizmo {
  59460. private _lineBoundingBox;
  59461. private _rotateSpheresParent;
  59462. private _scaleBoxesParent;
  59463. private _boundingDimensions;
  59464. private _renderObserver;
  59465. private _pointerObserver;
  59466. private _scaleDragSpeed;
  59467. private _tmpQuaternion;
  59468. private _tmpVector;
  59469. private _tmpRotationMatrix;
  59470. /**
  59471. * 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)
  59472. */
  59473. ignoreChildren: boolean;
  59474. /**
  59475. * 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)
  59476. */
  59477. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  59478. /**
  59479. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  59480. */
  59481. rotationSphereSize: number;
  59482. /**
  59483. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  59484. */
  59485. scaleBoxSize: number;
  59486. /**
  59487. * 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)
  59488. */
  59489. fixedDragMeshScreenSize: boolean;
  59490. /**
  59491. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  59492. */
  59493. fixedDragMeshScreenSizeDistanceFactor: number;
  59494. /**
  59495. * Fired when a rotation sphere or scale box is dragged
  59496. */
  59497. onDragStartObservable: Observable<{}>;
  59498. /**
  59499. * Fired when a scale box is dragged
  59500. */
  59501. onScaleBoxDragObservable: Observable<{}>;
  59502. /**
  59503. * Fired when a scale box drag is ended
  59504. */
  59505. onScaleBoxDragEndObservable: Observable<{}>;
  59506. /**
  59507. * Fired when a rotation sphere is dragged
  59508. */
  59509. onRotationSphereDragObservable: Observable<{}>;
  59510. /**
  59511. * Fired when a rotation sphere drag is ended
  59512. */
  59513. onRotationSphereDragEndObservable: Observable<{}>;
  59514. /**
  59515. * 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)
  59516. */
  59517. scalePivot: Nullable<Vector3>;
  59518. /**
  59519. * Mesh used as a pivot to rotate the attached node
  59520. */
  59521. private _anchorMesh;
  59522. private _existingMeshScale;
  59523. private _dragMesh;
  59524. private pointerDragBehavior;
  59525. private coloredMaterial;
  59526. private hoverColoredMaterial;
  59527. /**
  59528. * Sets the color of the bounding box gizmo
  59529. * @param color the color to set
  59530. */
  59531. setColor(color: Color3): void;
  59532. /**
  59533. * Creates an BoundingBoxGizmo
  59534. * @param gizmoLayer The utility layer the gizmo will be added to
  59535. * @param color The color of the gizmo
  59536. */
  59537. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  59538. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  59539. private _selectNode;
  59540. /**
  59541. * Updates the bounding box information for the Gizmo
  59542. */
  59543. updateBoundingBox(): void;
  59544. private _updateRotationSpheres;
  59545. private _updateScaleBoxes;
  59546. /**
  59547. * Enables rotation on the specified axis and disables rotation on the others
  59548. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  59549. */
  59550. setEnabledRotationAxis(axis: string): void;
  59551. /**
  59552. * Enables/disables scaling
  59553. * @param enable if scaling should be enabled
  59554. * @param homogeneousScaling defines if scaling should only be homogeneous
  59555. */
  59556. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  59557. private _updateDummy;
  59558. /**
  59559. * Enables a pointer drag behavior on the bounding box of the gizmo
  59560. */
  59561. enableDragBehavior(): void;
  59562. /**
  59563. * Disposes of the gizmo
  59564. */
  59565. dispose(): void;
  59566. /**
  59567. * 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)
  59568. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  59569. * @returns the bounding box mesh with the passed in mesh as a child
  59570. */
  59571. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  59572. /**
  59573. * CustomMeshes are not supported by this gizmo
  59574. * @param mesh The mesh to replace the default mesh of the gizmo
  59575. */
  59576. setCustomMesh(mesh: Mesh): void;
  59577. }
  59578. }
  59579. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  59580. import { Observable } from "babylonjs/Misc/observable";
  59581. import { Nullable } from "babylonjs/types";
  59582. import { Vector3 } from "babylonjs/Maths/math.vector";
  59583. import { Color3 } from "babylonjs/Maths/math.color";
  59584. import { Node } from "babylonjs/node";
  59585. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  59586. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59587. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59588. import "babylonjs/Meshes/Builders/linesBuilder";
  59589. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59590. /**
  59591. * Single plane rotation gizmo
  59592. */
  59593. export class PlaneRotationGizmo extends Gizmo {
  59594. /**
  59595. * Drag behavior responsible for the gizmos dragging interactions
  59596. */
  59597. dragBehavior: PointerDragBehavior;
  59598. private _pointerObserver;
  59599. /**
  59600. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  59601. */
  59602. snapDistance: number;
  59603. /**
  59604. * Event that fires each time the gizmo snaps to a new location.
  59605. * * snapDistance is the the change in distance
  59606. */
  59607. onSnapObservable: Observable<{
  59608. snapDistance: number;
  59609. }>;
  59610. private _isEnabled;
  59611. private _parent;
  59612. /**
  59613. * Creates a PlaneRotationGizmo
  59614. * @param gizmoLayer The utility layer the gizmo will be added to
  59615. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  59616. * @param color The color of the gizmo
  59617. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59618. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59619. * @param thickness display gizmo axis thickness
  59620. */
  59621. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  59622. protected _attachedNodeChanged(value: Nullable<Node>): void;
  59623. /**
  59624. * If the gizmo is enabled
  59625. */
  59626. set isEnabled(value: boolean);
  59627. get isEnabled(): boolean;
  59628. /**
  59629. * Disposes of the gizmo
  59630. */
  59631. dispose(): void;
  59632. }
  59633. }
  59634. declare module "babylonjs/Gizmos/rotationGizmo" {
  59635. import { Observable } from "babylonjs/Misc/observable";
  59636. import { Nullable } from "babylonjs/types";
  59637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59638. import { Mesh } from "babylonjs/Meshes/mesh";
  59639. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  59640. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  59641. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59642. import { Node } from "babylonjs/node";
  59643. /**
  59644. * Gizmo that enables rotating a mesh along 3 axis
  59645. */
  59646. export class RotationGizmo extends Gizmo {
  59647. /**
  59648. * Internal gizmo used for interactions on the x axis
  59649. */
  59650. xGizmo: PlaneRotationGizmo;
  59651. /**
  59652. * Internal gizmo used for interactions on the y axis
  59653. */
  59654. yGizmo: PlaneRotationGizmo;
  59655. /**
  59656. * Internal gizmo used for interactions on the z axis
  59657. */
  59658. zGizmo: PlaneRotationGizmo;
  59659. /** Fires an event when any of it's sub gizmos are dragged */
  59660. onDragStartObservable: Observable<unknown>;
  59661. /** Fires an event when any of it's sub gizmos are released from dragging */
  59662. onDragEndObservable: Observable<unknown>;
  59663. private _meshAttached;
  59664. private _nodeAttached;
  59665. get attachedMesh(): Nullable<AbstractMesh>;
  59666. set attachedMesh(mesh: Nullable<AbstractMesh>);
  59667. get attachedNode(): Nullable<Node>;
  59668. set attachedNode(node: Nullable<Node>);
  59669. protected _checkBillboardTransform(): void;
  59670. /**
  59671. * True when the mouse pointer is hovering a gizmo mesh
  59672. */
  59673. get isHovered(): boolean;
  59674. /**
  59675. * Creates a RotationGizmo
  59676. * @param gizmoLayer The utility layer the gizmo will be added to
  59677. * @param tessellation Amount of tessellation to be used when creating rotation circles
  59678. * @param useEulerRotation Use and update Euler angle instead of quaternion
  59679. * @param thickness display gizmo axis thickness
  59680. */
  59681. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  59682. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  59683. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  59684. /**
  59685. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  59686. */
  59687. set snapDistance(value: number);
  59688. get snapDistance(): number;
  59689. /**
  59690. * Ratio for the scale of the gizmo (Default: 1)
  59691. */
  59692. set scaleRatio(value: number);
  59693. get scaleRatio(): number;
  59694. /**
  59695. * Disposes of the gizmo
  59696. */
  59697. dispose(): void;
  59698. /**
  59699. * CustomMeshes are not supported by this gizmo
  59700. * @param mesh The mesh to replace the default mesh of the gizmo
  59701. */
  59702. setCustomMesh(mesh: Mesh): void;
  59703. }
  59704. }
  59705. declare module "babylonjs/Gizmos/gizmoManager" {
  59706. import { Observable } from "babylonjs/Misc/observable";
  59707. import { Nullable } from "babylonjs/types";
  59708. import { Scene, IDisposable } from "babylonjs/scene";
  59709. import { Node } from "babylonjs/node";
  59710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59711. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  59712. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  59713. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  59714. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  59715. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  59716. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  59717. /**
  59718. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  59719. */
  59720. export class GizmoManager implements IDisposable {
  59721. private scene;
  59722. /**
  59723. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  59724. */
  59725. gizmos: {
  59726. positionGizmo: Nullable<PositionGizmo>;
  59727. rotationGizmo: Nullable<RotationGizmo>;
  59728. scaleGizmo: Nullable<ScaleGizmo>;
  59729. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  59730. };
  59731. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  59732. clearGizmoOnEmptyPointerEvent: boolean;
  59733. /** Fires an event when the manager is attached to a mesh */
  59734. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  59735. /** Fires an event when the manager is attached to a node */
  59736. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  59737. private _gizmosEnabled;
  59738. private _pointerObserver;
  59739. private _attachedMesh;
  59740. private _attachedNode;
  59741. private _boundingBoxColor;
  59742. private _defaultUtilityLayer;
  59743. private _defaultKeepDepthUtilityLayer;
  59744. private _thickness;
  59745. /**
  59746. * When bounding box gizmo is enabled, this can be used to track drag/end events
  59747. */
  59748. boundingBoxDragBehavior: SixDofDragBehavior;
  59749. /**
  59750. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  59751. */
  59752. attachableMeshes: Nullable<Array<AbstractMesh>>;
  59753. /**
  59754. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  59755. */
  59756. attachableNodes: Nullable<Array<Node>>;
  59757. /**
  59758. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  59759. */
  59760. usePointerToAttachGizmos: boolean;
  59761. /**
  59762. * Utility layer that the bounding box gizmo belongs to
  59763. */
  59764. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  59765. /**
  59766. * Utility layer that all gizmos besides bounding box belong to
  59767. */
  59768. get utilityLayer(): UtilityLayerRenderer;
  59769. /**
  59770. * True when the mouse pointer is hovering a gizmo mesh
  59771. */
  59772. get isHovered(): boolean;
  59773. /**
  59774. * Instatiates a gizmo manager
  59775. * @param scene the scene to overlay the gizmos on top of
  59776. * @param thickness display gizmo axis thickness
  59777. */
  59778. constructor(scene: Scene, thickness?: number);
  59779. /**
  59780. * Attaches a set of gizmos to the specified mesh
  59781. * @param mesh The mesh the gizmo's should be attached to
  59782. */
  59783. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  59784. /**
  59785. * Attaches a set of gizmos to the specified node
  59786. * @param node The node the gizmo's should be attached to
  59787. */
  59788. attachToNode(node: Nullable<Node>): void;
  59789. /**
  59790. * If the position gizmo is enabled
  59791. */
  59792. set positionGizmoEnabled(value: boolean);
  59793. get positionGizmoEnabled(): boolean;
  59794. /**
  59795. * If the rotation gizmo is enabled
  59796. */
  59797. set rotationGizmoEnabled(value: boolean);
  59798. get rotationGizmoEnabled(): boolean;
  59799. /**
  59800. * If the scale gizmo is enabled
  59801. */
  59802. set scaleGizmoEnabled(value: boolean);
  59803. get scaleGizmoEnabled(): boolean;
  59804. /**
  59805. * If the boundingBox gizmo is enabled
  59806. */
  59807. set boundingBoxGizmoEnabled(value: boolean);
  59808. get boundingBoxGizmoEnabled(): boolean;
  59809. /**
  59810. * Disposes of the gizmo manager
  59811. */
  59812. dispose(): void;
  59813. }
  59814. }
  59815. declare module "babylonjs/Lights/directionalLight" {
  59816. import { Camera } from "babylonjs/Cameras/camera";
  59817. import { Scene } from "babylonjs/scene";
  59818. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59819. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59820. import { Light } from "babylonjs/Lights/light";
  59821. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59822. import { Effect } from "babylonjs/Materials/effect";
  59823. /**
  59824. * A directional light is defined by a direction (what a surprise!).
  59825. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  59826. * 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.
  59827. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59828. */
  59829. export class DirectionalLight extends ShadowLight {
  59830. private _shadowFrustumSize;
  59831. /**
  59832. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  59833. */
  59834. get shadowFrustumSize(): number;
  59835. /**
  59836. * Specifies a fix frustum size for the shadow generation.
  59837. */
  59838. set shadowFrustumSize(value: number);
  59839. private _shadowOrthoScale;
  59840. /**
  59841. * Gets the shadow projection scale against the optimal computed one.
  59842. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59843. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59844. */
  59845. get shadowOrthoScale(): number;
  59846. /**
  59847. * Sets the shadow projection scale against the optimal computed one.
  59848. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  59849. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  59850. */
  59851. set shadowOrthoScale(value: number);
  59852. /**
  59853. * Automatically compute the projection matrix to best fit (including all the casters)
  59854. * on each frame.
  59855. */
  59856. autoUpdateExtends: boolean;
  59857. /**
  59858. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  59859. * on each frame. autoUpdateExtends must be set to true for this to work
  59860. */
  59861. autoCalcShadowZBounds: boolean;
  59862. private _orthoLeft;
  59863. private _orthoRight;
  59864. private _orthoTop;
  59865. private _orthoBottom;
  59866. /**
  59867. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  59868. * The directional light is emitted from everywhere in the given direction.
  59869. * It can cast shadows.
  59870. * Documentation : https://doc.babylonjs.com/babylon101/lights
  59871. * @param name The friendly name of the light
  59872. * @param direction The direction of the light
  59873. * @param scene The scene the light belongs to
  59874. */
  59875. constructor(name: string, direction: Vector3, scene: Scene);
  59876. /**
  59877. * Returns the string "DirectionalLight".
  59878. * @return The class name
  59879. */
  59880. getClassName(): string;
  59881. /**
  59882. * Returns the integer 1.
  59883. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  59884. */
  59885. getTypeID(): number;
  59886. /**
  59887. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  59888. * Returns the DirectionalLight Shadow projection matrix.
  59889. */
  59890. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59891. /**
  59892. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  59893. * Returns the DirectionalLight Shadow projection matrix.
  59894. */
  59895. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  59896. /**
  59897. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  59898. * Returns the DirectionalLight Shadow projection matrix.
  59899. */
  59900. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  59901. protected _buildUniformLayout(): void;
  59902. /**
  59903. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  59904. * @param effect The effect to update
  59905. * @param lightIndex The index of the light in the effect to update
  59906. * @returns The directional light
  59907. */
  59908. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  59909. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  59910. /**
  59911. * Gets the minZ used for shadow according to both the scene and the light.
  59912. *
  59913. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59914. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59915. * @param activeCamera The camera we are returning the min for
  59916. * @returns the depth min z
  59917. */
  59918. getDepthMinZ(activeCamera: Camera): number;
  59919. /**
  59920. * Gets the maxZ used for shadow according to both the scene and the light.
  59921. *
  59922. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  59923. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  59924. * @param activeCamera The camera we are returning the max for
  59925. * @returns the depth max z
  59926. */
  59927. getDepthMaxZ(activeCamera: Camera): number;
  59928. /**
  59929. * Prepares the list of defines specific to the light type.
  59930. * @param defines the list of defines
  59931. * @param lightIndex defines the index of the light for the effect
  59932. */
  59933. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  59934. }
  59935. }
  59936. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  59937. import { Mesh } from "babylonjs/Meshes/mesh";
  59938. /**
  59939. * Class containing static functions to help procedurally build meshes
  59940. */
  59941. export class HemisphereBuilder {
  59942. /**
  59943. * Creates a hemisphere mesh
  59944. * @param name defines the name of the mesh
  59945. * @param options defines the options used to create the mesh
  59946. * @param scene defines the hosting scene
  59947. * @returns the hemisphere mesh
  59948. */
  59949. static CreateHemisphere(name: string, options: {
  59950. segments?: number;
  59951. diameter?: number;
  59952. sideOrientation?: number;
  59953. }, scene: any): Mesh;
  59954. }
  59955. }
  59956. declare module "babylonjs/Lights/spotLight" {
  59957. import { Nullable } from "babylonjs/types";
  59958. import { Scene } from "babylonjs/scene";
  59959. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  59960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59961. import { Effect } from "babylonjs/Materials/effect";
  59962. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59963. import { Light } from "babylonjs/Lights/light";
  59964. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  59965. /**
  59966. * A spot light is defined by a position, a direction, an angle, and an exponent.
  59967. * These values define a cone of light starting from the position, emitting toward the direction.
  59968. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  59969. * and the exponent defines the speed of the decay of the light with distance (reach).
  59970. * Documentation: https://doc.babylonjs.com/babylon101/lights
  59971. */
  59972. export class SpotLight extends ShadowLight {
  59973. private _angle;
  59974. private _innerAngle;
  59975. private _cosHalfAngle;
  59976. private _lightAngleScale;
  59977. private _lightAngleOffset;
  59978. /**
  59979. * Gets the cone angle of the spot light in Radians.
  59980. */
  59981. get angle(): number;
  59982. /**
  59983. * Sets the cone angle of the spot light in Radians.
  59984. */
  59985. set angle(value: number);
  59986. /**
  59987. * Only used in gltf falloff mode, this defines the angle where
  59988. * the directional falloff will start before cutting at angle which could be seen
  59989. * as outer angle.
  59990. */
  59991. get innerAngle(): number;
  59992. /**
  59993. * Only used in gltf falloff mode, this defines the angle where
  59994. * the directional falloff will start before cutting at angle which could be seen
  59995. * as outer angle.
  59996. */
  59997. set innerAngle(value: number);
  59998. private _shadowAngleScale;
  59999. /**
  60000. * Allows scaling the angle of the light for shadow generation only.
  60001. */
  60002. get shadowAngleScale(): number;
  60003. /**
  60004. * Allows scaling the angle of the light for shadow generation only.
  60005. */
  60006. set shadowAngleScale(value: number);
  60007. /**
  60008. * The light decay speed with the distance from the emission spot.
  60009. */
  60010. exponent: number;
  60011. private _projectionTextureMatrix;
  60012. /**
  60013. * Allows reading the projecton texture
  60014. */
  60015. get projectionTextureMatrix(): Matrix;
  60016. protected _projectionTextureLightNear: number;
  60017. /**
  60018. * Gets the near clip of the Spotlight for texture projection.
  60019. */
  60020. get projectionTextureLightNear(): number;
  60021. /**
  60022. * Sets the near clip of the Spotlight for texture projection.
  60023. */
  60024. set projectionTextureLightNear(value: number);
  60025. protected _projectionTextureLightFar: number;
  60026. /**
  60027. * Gets the far clip of the Spotlight for texture projection.
  60028. */
  60029. get projectionTextureLightFar(): number;
  60030. /**
  60031. * Sets the far clip of the Spotlight for texture projection.
  60032. */
  60033. set projectionTextureLightFar(value: number);
  60034. protected _projectionTextureUpDirection: Vector3;
  60035. /**
  60036. * Gets the Up vector of the Spotlight for texture projection.
  60037. */
  60038. get projectionTextureUpDirection(): Vector3;
  60039. /**
  60040. * Sets the Up vector of the Spotlight for texture projection.
  60041. */
  60042. set projectionTextureUpDirection(value: Vector3);
  60043. private _projectionTexture;
  60044. /**
  60045. * Gets the projection texture of the light.
  60046. */
  60047. get projectionTexture(): Nullable<BaseTexture>;
  60048. /**
  60049. * Sets the projection texture of the light.
  60050. */
  60051. set projectionTexture(value: Nullable<BaseTexture>);
  60052. private _projectionTextureViewLightDirty;
  60053. private _projectionTextureProjectionLightDirty;
  60054. private _projectionTextureDirty;
  60055. private _projectionTextureViewTargetVector;
  60056. private _projectionTextureViewLightMatrix;
  60057. private _projectionTextureProjectionLightMatrix;
  60058. private _projectionTextureScalingMatrix;
  60059. /**
  60060. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  60061. * It can cast shadows.
  60062. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60063. * @param name The light friendly name
  60064. * @param position The position of the spot light in the scene
  60065. * @param direction The direction of the light in the scene
  60066. * @param angle The cone angle of the light in Radians
  60067. * @param exponent The light decay speed with the distance from the emission spot
  60068. * @param scene The scene the lights belongs to
  60069. */
  60070. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  60071. /**
  60072. * Returns the string "SpotLight".
  60073. * @returns the class name
  60074. */
  60075. getClassName(): string;
  60076. /**
  60077. * Returns the integer 2.
  60078. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60079. */
  60080. getTypeID(): number;
  60081. /**
  60082. * Overrides the direction setter to recompute the projection texture view light Matrix.
  60083. */
  60084. protected _setDirection(value: Vector3): void;
  60085. /**
  60086. * Overrides the position setter to recompute the projection texture view light Matrix.
  60087. */
  60088. protected _setPosition(value: Vector3): void;
  60089. /**
  60090. * 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.
  60091. * Returns the SpotLight.
  60092. */
  60093. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60094. protected _computeProjectionTextureViewLightMatrix(): void;
  60095. protected _computeProjectionTextureProjectionLightMatrix(): void;
  60096. /**
  60097. * Main function for light texture projection matrix computing.
  60098. */
  60099. protected _computeProjectionTextureMatrix(): void;
  60100. protected _buildUniformLayout(): void;
  60101. private _computeAngleValues;
  60102. /**
  60103. * Sets the passed Effect "effect" with the Light textures.
  60104. * @param effect The effect to update
  60105. * @param lightIndex The index of the light in the effect to update
  60106. * @returns The light
  60107. */
  60108. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  60109. /**
  60110. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  60111. * @param effect The effect to update
  60112. * @param lightIndex The index of the light in the effect to update
  60113. * @returns The spot light
  60114. */
  60115. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  60116. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60117. /**
  60118. * Disposes the light and the associated resources.
  60119. */
  60120. dispose(): void;
  60121. /**
  60122. * Prepares the list of defines specific to the light type.
  60123. * @param defines the list of defines
  60124. * @param lightIndex defines the index of the light for the effect
  60125. */
  60126. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60127. }
  60128. }
  60129. declare module "babylonjs/Gizmos/lightGizmo" {
  60130. import { Nullable } from "babylonjs/types";
  60131. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60132. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60133. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60134. import { Light } from "babylonjs/Lights/light";
  60135. import { Observable } from "babylonjs/Misc/observable";
  60136. /**
  60137. * Gizmo that enables viewing a light
  60138. */
  60139. export class LightGizmo extends Gizmo {
  60140. private _lightMesh;
  60141. private _material;
  60142. private _cachedPosition;
  60143. private _cachedForward;
  60144. private _attachedMeshParent;
  60145. private _pointerObserver;
  60146. /**
  60147. * Event that fires each time the gizmo is clicked
  60148. */
  60149. onClickedObservable: Observable<Light>;
  60150. /**
  60151. * Creates a LightGizmo
  60152. * @param gizmoLayer The utility layer the gizmo will be added to
  60153. */
  60154. constructor(gizmoLayer?: UtilityLayerRenderer);
  60155. private _light;
  60156. /**
  60157. * The light that the gizmo is attached to
  60158. */
  60159. set light(light: Nullable<Light>);
  60160. get light(): Nullable<Light>;
  60161. /**
  60162. * Gets the material used to render the light gizmo
  60163. */
  60164. get material(): StandardMaterial;
  60165. /**
  60166. * @hidden
  60167. * Updates the gizmo to match the attached mesh's position/rotation
  60168. */
  60169. protected _update(): void;
  60170. private static _Scale;
  60171. /**
  60172. * Creates the lines for a light mesh
  60173. */
  60174. private static _CreateLightLines;
  60175. /**
  60176. * Disposes of the light gizmo
  60177. */
  60178. dispose(): void;
  60179. private static _CreateHemisphericLightMesh;
  60180. private static _CreatePointLightMesh;
  60181. private static _CreateSpotLightMesh;
  60182. private static _CreateDirectionalLightMesh;
  60183. }
  60184. }
  60185. declare module "babylonjs/Gizmos/cameraGizmo" {
  60186. import { Nullable } from "babylonjs/types";
  60187. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  60188. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  60189. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  60190. import { Camera } from "babylonjs/Cameras/camera";
  60191. import { Observable } from "babylonjs/Misc/observable";
  60192. /**
  60193. * Gizmo that enables viewing a camera
  60194. */
  60195. export class CameraGizmo extends Gizmo {
  60196. private _cameraMesh;
  60197. private _cameraLinesMesh;
  60198. private _material;
  60199. private _pointerObserver;
  60200. /**
  60201. * Event that fires each time the gizmo is clicked
  60202. */
  60203. onClickedObservable: Observable<Camera>;
  60204. /**
  60205. * Creates a CameraGizmo
  60206. * @param gizmoLayer The utility layer the gizmo will be added to
  60207. */
  60208. constructor(gizmoLayer?: UtilityLayerRenderer);
  60209. private _camera;
  60210. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  60211. get displayFrustum(): boolean;
  60212. set displayFrustum(value: boolean);
  60213. /**
  60214. * The camera that the gizmo is attached to
  60215. */
  60216. set camera(camera: Nullable<Camera>);
  60217. get camera(): Nullable<Camera>;
  60218. /**
  60219. * Gets the material used to render the camera gizmo
  60220. */
  60221. get material(): StandardMaterial;
  60222. /**
  60223. * @hidden
  60224. * Updates the gizmo to match the attached mesh's position/rotation
  60225. */
  60226. protected _update(): void;
  60227. private static _Scale;
  60228. private _invProjection;
  60229. /**
  60230. * Disposes of the camera gizmo
  60231. */
  60232. dispose(): void;
  60233. private static _CreateCameraMesh;
  60234. private static _CreateCameraFrustum;
  60235. }
  60236. }
  60237. declare module "babylonjs/Gizmos/index" {
  60238. export * from "babylonjs/Gizmos/axisDragGizmo";
  60239. export * from "babylonjs/Gizmos/axisScaleGizmo";
  60240. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  60241. export * from "babylonjs/Gizmos/gizmo";
  60242. export * from "babylonjs/Gizmos/gizmoManager";
  60243. export * from "babylonjs/Gizmos/planeRotationGizmo";
  60244. export * from "babylonjs/Gizmos/positionGizmo";
  60245. export * from "babylonjs/Gizmos/rotationGizmo";
  60246. export * from "babylonjs/Gizmos/scaleGizmo";
  60247. export * from "babylonjs/Gizmos/lightGizmo";
  60248. export * from "babylonjs/Gizmos/cameraGizmo";
  60249. export * from "babylonjs/Gizmos/planeDragGizmo";
  60250. }
  60251. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  60252. /** @hidden */
  60253. export var backgroundFragmentDeclaration: {
  60254. name: string;
  60255. shader: string;
  60256. };
  60257. }
  60258. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  60259. /** @hidden */
  60260. export var backgroundUboDeclaration: {
  60261. name: string;
  60262. shader: string;
  60263. };
  60264. }
  60265. declare module "babylonjs/Shaders/background.fragment" {
  60266. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  60267. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60268. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60269. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60270. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60271. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60272. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60273. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  60274. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  60275. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60276. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  60277. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  60278. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60279. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  60280. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  60281. /** @hidden */
  60282. export var backgroundPixelShader: {
  60283. name: string;
  60284. shader: string;
  60285. };
  60286. }
  60287. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  60288. /** @hidden */
  60289. export var backgroundVertexDeclaration: {
  60290. name: string;
  60291. shader: string;
  60292. };
  60293. }
  60294. declare module "babylonjs/Shaders/background.vertex" {
  60295. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  60296. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  60297. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60298. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60299. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60300. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  60301. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  60302. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  60303. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  60304. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60305. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60306. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60307. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  60308. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  60309. /** @hidden */
  60310. export var backgroundVertexShader: {
  60311. name: string;
  60312. shader: string;
  60313. };
  60314. }
  60315. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  60316. import { Nullable, int, float } from "babylonjs/types";
  60317. import { Scene } from "babylonjs/scene";
  60318. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  60319. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60321. import { Mesh } from "babylonjs/Meshes/mesh";
  60322. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60323. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  60324. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  60325. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60326. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  60327. import { Color3 } from "babylonjs/Maths/math.color";
  60328. import "babylonjs/Shaders/background.fragment";
  60329. import "babylonjs/Shaders/background.vertex";
  60330. /**
  60331. * Background material used to create an efficient environement around your scene.
  60332. */
  60333. export class BackgroundMaterial extends PushMaterial {
  60334. /**
  60335. * Standard reflectance value at parallel view angle.
  60336. */
  60337. static StandardReflectance0: number;
  60338. /**
  60339. * Standard reflectance value at grazing angle.
  60340. */
  60341. static StandardReflectance90: number;
  60342. protected _primaryColor: Color3;
  60343. /**
  60344. * Key light Color (multiply against the environement texture)
  60345. */
  60346. primaryColor: Color3;
  60347. protected __perceptualColor: Nullable<Color3>;
  60348. /**
  60349. * Experimental Internal Use Only.
  60350. *
  60351. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  60352. * This acts as a helper to set the primary color to a more "human friendly" value.
  60353. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  60354. * output color as close as possible from the chosen value.
  60355. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  60356. * part of lighting setup.)
  60357. */
  60358. get _perceptualColor(): Nullable<Color3>;
  60359. set _perceptualColor(value: Nullable<Color3>);
  60360. protected _primaryColorShadowLevel: float;
  60361. /**
  60362. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  60363. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  60364. */
  60365. get primaryColorShadowLevel(): float;
  60366. set primaryColorShadowLevel(value: float);
  60367. protected _primaryColorHighlightLevel: float;
  60368. /**
  60369. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  60370. * The primary color is used at the level chosen to define what the white area would look.
  60371. */
  60372. get primaryColorHighlightLevel(): float;
  60373. set primaryColorHighlightLevel(value: float);
  60374. protected _reflectionTexture: Nullable<BaseTexture>;
  60375. /**
  60376. * Reflection Texture used in the material.
  60377. * Should be author in a specific way for the best result (refer to the documentation).
  60378. */
  60379. reflectionTexture: Nullable<BaseTexture>;
  60380. protected _reflectionBlur: float;
  60381. /**
  60382. * Reflection Texture level of blur.
  60383. *
  60384. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  60385. * texture twice.
  60386. */
  60387. reflectionBlur: float;
  60388. protected _diffuseTexture: Nullable<BaseTexture>;
  60389. /**
  60390. * Diffuse Texture used in the material.
  60391. * Should be author in a specific way for the best result (refer to the documentation).
  60392. */
  60393. diffuseTexture: Nullable<BaseTexture>;
  60394. protected _shadowLights: Nullable<IShadowLight[]>;
  60395. /**
  60396. * Specify the list of lights casting shadow on the material.
  60397. * All scene shadow lights will be included if null.
  60398. */
  60399. shadowLights: Nullable<IShadowLight[]>;
  60400. protected _shadowLevel: float;
  60401. /**
  60402. * Helps adjusting the shadow to a softer level if required.
  60403. * 0 means black shadows and 1 means no shadows.
  60404. */
  60405. shadowLevel: float;
  60406. protected _sceneCenter: Vector3;
  60407. /**
  60408. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  60409. * It is usually zero but might be interesting to modify according to your setup.
  60410. */
  60411. sceneCenter: Vector3;
  60412. protected _opacityFresnel: boolean;
  60413. /**
  60414. * This helps specifying that the material is falling off to the sky box at grazing angle.
  60415. * This helps ensuring a nice transition when the camera goes under the ground.
  60416. */
  60417. opacityFresnel: boolean;
  60418. protected _reflectionFresnel: boolean;
  60419. /**
  60420. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  60421. * This helps adding a mirror texture on the ground.
  60422. */
  60423. reflectionFresnel: boolean;
  60424. protected _reflectionFalloffDistance: number;
  60425. /**
  60426. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  60427. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  60428. */
  60429. reflectionFalloffDistance: number;
  60430. protected _reflectionAmount: number;
  60431. /**
  60432. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  60433. */
  60434. reflectionAmount: number;
  60435. protected _reflectionReflectance0: number;
  60436. /**
  60437. * This specifies the weight of the reflection at grazing angle.
  60438. */
  60439. reflectionReflectance0: number;
  60440. protected _reflectionReflectance90: number;
  60441. /**
  60442. * This specifies the weight of the reflection at a perpendicular point of view.
  60443. */
  60444. reflectionReflectance90: number;
  60445. /**
  60446. * Sets the reflection reflectance fresnel values according to the default standard
  60447. * empirically know to work well :-)
  60448. */
  60449. set reflectionStandardFresnelWeight(value: number);
  60450. protected _useRGBColor: boolean;
  60451. /**
  60452. * Helps to directly use the maps channels instead of their level.
  60453. */
  60454. useRGBColor: boolean;
  60455. protected _enableNoise: boolean;
  60456. /**
  60457. * This helps reducing the banding effect that could occur on the background.
  60458. */
  60459. enableNoise: boolean;
  60460. /**
  60461. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  60462. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  60463. * Recommended to be keep at 1.0 except for special cases.
  60464. */
  60465. get fovMultiplier(): number;
  60466. set fovMultiplier(value: number);
  60467. private _fovMultiplier;
  60468. /**
  60469. * Enable the FOV adjustment feature controlled by fovMultiplier.
  60470. */
  60471. useEquirectangularFOV: boolean;
  60472. private _maxSimultaneousLights;
  60473. /**
  60474. * Number of Simultaneous lights allowed on the material.
  60475. */
  60476. maxSimultaneousLights: int;
  60477. private _shadowOnly;
  60478. /**
  60479. * Make the material only render shadows
  60480. */
  60481. shadowOnly: boolean;
  60482. /**
  60483. * Default configuration related to image processing available in the Background Material.
  60484. */
  60485. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60486. /**
  60487. * Keep track of the image processing observer to allow dispose and replace.
  60488. */
  60489. private _imageProcessingObserver;
  60490. /**
  60491. * Attaches a new image processing configuration to the PBR Material.
  60492. * @param configuration (if null the scene configuration will be use)
  60493. */
  60494. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60495. /**
  60496. * Gets the image processing configuration used either in this material.
  60497. */
  60498. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  60499. /**
  60500. * Sets the Default image processing configuration used either in the this material.
  60501. *
  60502. * If sets to null, the scene one is in use.
  60503. */
  60504. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  60505. /**
  60506. * Gets wether the color curves effect is enabled.
  60507. */
  60508. get cameraColorCurvesEnabled(): boolean;
  60509. /**
  60510. * Sets wether the color curves effect is enabled.
  60511. */
  60512. set cameraColorCurvesEnabled(value: boolean);
  60513. /**
  60514. * Gets wether the color grading effect is enabled.
  60515. */
  60516. get cameraColorGradingEnabled(): boolean;
  60517. /**
  60518. * Gets wether the color grading effect is enabled.
  60519. */
  60520. set cameraColorGradingEnabled(value: boolean);
  60521. /**
  60522. * Gets wether tonemapping is enabled or not.
  60523. */
  60524. get cameraToneMappingEnabled(): boolean;
  60525. /**
  60526. * Sets wether tonemapping is enabled or not
  60527. */
  60528. set cameraToneMappingEnabled(value: boolean);
  60529. /**
  60530. * The camera exposure used on this material.
  60531. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60532. * This corresponds to a photographic exposure.
  60533. */
  60534. get cameraExposure(): float;
  60535. /**
  60536. * The camera exposure used on this material.
  60537. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60538. * This corresponds to a photographic exposure.
  60539. */
  60540. set cameraExposure(value: float);
  60541. /**
  60542. * Gets The camera contrast used on this material.
  60543. */
  60544. get cameraContrast(): float;
  60545. /**
  60546. * Sets The camera contrast used on this material.
  60547. */
  60548. set cameraContrast(value: float);
  60549. /**
  60550. * Gets the Color Grading 2D Lookup Texture.
  60551. */
  60552. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60553. /**
  60554. * Sets the Color Grading 2D Lookup Texture.
  60555. */
  60556. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60557. /**
  60558. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60559. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60560. * 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;
  60561. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60562. */
  60563. get cameraColorCurves(): Nullable<ColorCurves>;
  60564. /**
  60565. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60566. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60567. * 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;
  60568. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60569. */
  60570. set cameraColorCurves(value: Nullable<ColorCurves>);
  60571. /**
  60572. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  60573. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  60574. */
  60575. switchToBGR: boolean;
  60576. private _renderTargets;
  60577. private _reflectionControls;
  60578. private _white;
  60579. private _primaryShadowColor;
  60580. private _primaryHighlightColor;
  60581. /**
  60582. * Instantiates a Background Material in the given scene
  60583. * @param name The friendly name of the material
  60584. * @param scene The scene to add the material to
  60585. */
  60586. constructor(name: string, scene: Scene);
  60587. /**
  60588. * Gets a boolean indicating that current material needs to register RTT
  60589. */
  60590. get hasRenderTargetTextures(): boolean;
  60591. /**
  60592. * The entire material has been created in order to prevent overdraw.
  60593. * @returns false
  60594. */
  60595. needAlphaTesting(): boolean;
  60596. /**
  60597. * The entire material has been created in order to prevent overdraw.
  60598. * @returns true if blending is enable
  60599. */
  60600. needAlphaBlending(): boolean;
  60601. /**
  60602. * Checks wether the material is ready to be rendered for a given mesh.
  60603. * @param mesh The mesh to render
  60604. * @param subMesh The submesh to check against
  60605. * @param useInstances Specify wether or not the material is used with instances
  60606. * @returns true if all the dependencies are ready (Textures, Effects...)
  60607. */
  60608. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60609. /**
  60610. * Compute the primary color according to the chosen perceptual color.
  60611. */
  60612. private _computePrimaryColorFromPerceptualColor;
  60613. /**
  60614. * Compute the highlights and shadow colors according to their chosen levels.
  60615. */
  60616. private _computePrimaryColors;
  60617. /**
  60618. * Build the uniform buffer used in the material.
  60619. */
  60620. buildUniformLayout(): void;
  60621. /**
  60622. * Unbind the material.
  60623. */
  60624. unbind(): void;
  60625. /**
  60626. * Bind only the world matrix to the material.
  60627. * @param world The world matrix to bind.
  60628. */
  60629. bindOnlyWorldMatrix(world: Matrix): void;
  60630. /**
  60631. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  60632. * @param world The world matrix to bind.
  60633. * @param subMesh The submesh to bind for.
  60634. */
  60635. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60636. /**
  60637. * Checks to see if a texture is used in the material.
  60638. * @param texture - Base texture to use.
  60639. * @returns - Boolean specifying if a texture is used in the material.
  60640. */
  60641. hasTexture(texture: BaseTexture): boolean;
  60642. /**
  60643. * Dispose the material.
  60644. * @param forceDisposeEffect Force disposal of the associated effect.
  60645. * @param forceDisposeTextures Force disposal of the associated textures.
  60646. */
  60647. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  60648. /**
  60649. * Clones the material.
  60650. * @param name The cloned name.
  60651. * @returns The cloned material.
  60652. */
  60653. clone(name: string): BackgroundMaterial;
  60654. /**
  60655. * Serializes the current material to its JSON representation.
  60656. * @returns The JSON representation.
  60657. */
  60658. serialize(): any;
  60659. /**
  60660. * Gets the class name of the material
  60661. * @returns "BackgroundMaterial"
  60662. */
  60663. getClassName(): string;
  60664. /**
  60665. * Parse a JSON input to create back a background material.
  60666. * @param source The JSON data to parse
  60667. * @param scene The scene to create the parsed material in
  60668. * @param rootUrl The root url of the assets the material depends upon
  60669. * @returns the instantiated BackgroundMaterial.
  60670. */
  60671. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  60672. }
  60673. }
  60674. declare module "babylonjs/Helpers/environmentHelper" {
  60675. import { Observable } from "babylonjs/Misc/observable";
  60676. import { Nullable } from "babylonjs/types";
  60677. import { Scene } from "babylonjs/scene";
  60678. import { Vector3 } from "babylonjs/Maths/math.vector";
  60679. import { Color3 } from "babylonjs/Maths/math.color";
  60680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60681. import { Mesh } from "babylonjs/Meshes/mesh";
  60682. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60683. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  60684. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60685. import "babylonjs/Meshes/Builders/planeBuilder";
  60686. import "babylonjs/Meshes/Builders/boxBuilder";
  60687. /**
  60688. * Represents the different options available during the creation of
  60689. * a Environment helper.
  60690. *
  60691. * This can control the default ground, skybox and image processing setup of your scene.
  60692. */
  60693. export interface IEnvironmentHelperOptions {
  60694. /**
  60695. * Specifies whether or not to create a ground.
  60696. * True by default.
  60697. */
  60698. createGround: boolean;
  60699. /**
  60700. * Specifies the ground size.
  60701. * 15 by default.
  60702. */
  60703. groundSize: number;
  60704. /**
  60705. * The texture used on the ground for the main color.
  60706. * Comes from the BabylonJS CDN by default.
  60707. *
  60708. * Remarks: Can be either a texture or a url.
  60709. */
  60710. groundTexture: string | BaseTexture;
  60711. /**
  60712. * The color mixed in the ground texture by default.
  60713. * BabylonJS clearColor by default.
  60714. */
  60715. groundColor: Color3;
  60716. /**
  60717. * Specifies the ground opacity.
  60718. * 1 by default.
  60719. */
  60720. groundOpacity: number;
  60721. /**
  60722. * Enables the ground to receive shadows.
  60723. * True by default.
  60724. */
  60725. enableGroundShadow: boolean;
  60726. /**
  60727. * Helps preventing the shadow to be fully black on the ground.
  60728. * 0.5 by default.
  60729. */
  60730. groundShadowLevel: number;
  60731. /**
  60732. * Creates a mirror texture attach to the ground.
  60733. * false by default.
  60734. */
  60735. enableGroundMirror: boolean;
  60736. /**
  60737. * Specifies the ground mirror size ratio.
  60738. * 0.3 by default as the default kernel is 64.
  60739. */
  60740. groundMirrorSizeRatio: number;
  60741. /**
  60742. * Specifies the ground mirror blur kernel size.
  60743. * 64 by default.
  60744. */
  60745. groundMirrorBlurKernel: number;
  60746. /**
  60747. * Specifies the ground mirror visibility amount.
  60748. * 1 by default
  60749. */
  60750. groundMirrorAmount: number;
  60751. /**
  60752. * Specifies the ground mirror reflectance weight.
  60753. * This uses the standard weight of the background material to setup the fresnel effect
  60754. * of the mirror.
  60755. * 1 by default.
  60756. */
  60757. groundMirrorFresnelWeight: number;
  60758. /**
  60759. * Specifies the ground mirror Falloff distance.
  60760. * This can helps reducing the size of the reflection.
  60761. * 0 by Default.
  60762. */
  60763. groundMirrorFallOffDistance: number;
  60764. /**
  60765. * Specifies the ground mirror texture type.
  60766. * Unsigned Int by Default.
  60767. */
  60768. groundMirrorTextureType: number;
  60769. /**
  60770. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  60771. * the shown objects.
  60772. */
  60773. groundYBias: number;
  60774. /**
  60775. * Specifies whether or not to create a skybox.
  60776. * True by default.
  60777. */
  60778. createSkybox: boolean;
  60779. /**
  60780. * Specifies the skybox size.
  60781. * 20 by default.
  60782. */
  60783. skyboxSize: number;
  60784. /**
  60785. * The texture used on the skybox for the main color.
  60786. * Comes from the BabylonJS CDN by default.
  60787. *
  60788. * Remarks: Can be either a texture or a url.
  60789. */
  60790. skyboxTexture: string | BaseTexture;
  60791. /**
  60792. * The color mixed in the skybox texture by default.
  60793. * BabylonJS clearColor by default.
  60794. */
  60795. skyboxColor: Color3;
  60796. /**
  60797. * The background rotation around the Y axis of the scene.
  60798. * This helps aligning the key lights of your scene with the background.
  60799. * 0 by default.
  60800. */
  60801. backgroundYRotation: number;
  60802. /**
  60803. * Compute automatically the size of the elements to best fit with the scene.
  60804. */
  60805. sizeAuto: boolean;
  60806. /**
  60807. * Default position of the rootMesh if autoSize is not true.
  60808. */
  60809. rootPosition: Vector3;
  60810. /**
  60811. * Sets up the image processing in the scene.
  60812. * true by default.
  60813. */
  60814. setupImageProcessing: boolean;
  60815. /**
  60816. * The texture used as your environment texture in the scene.
  60817. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  60818. *
  60819. * Remarks: Can be either a texture or a url.
  60820. */
  60821. environmentTexture: string | BaseTexture;
  60822. /**
  60823. * The value of the exposure to apply to the scene.
  60824. * 0.6 by default if setupImageProcessing is true.
  60825. */
  60826. cameraExposure: number;
  60827. /**
  60828. * The value of the contrast to apply to the scene.
  60829. * 1.6 by default if setupImageProcessing is true.
  60830. */
  60831. cameraContrast: number;
  60832. /**
  60833. * Specifies whether or not tonemapping should be enabled in the scene.
  60834. * true by default if setupImageProcessing is true.
  60835. */
  60836. toneMappingEnabled: boolean;
  60837. }
  60838. /**
  60839. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  60840. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  60841. * It also helps with the default setup of your imageProcessing configuration.
  60842. */
  60843. export class EnvironmentHelper {
  60844. /**
  60845. * Default ground texture URL.
  60846. */
  60847. private static _groundTextureCDNUrl;
  60848. /**
  60849. * Default skybox texture URL.
  60850. */
  60851. private static _skyboxTextureCDNUrl;
  60852. /**
  60853. * Default environment texture URL.
  60854. */
  60855. private static _environmentTextureCDNUrl;
  60856. /**
  60857. * Creates the default options for the helper.
  60858. */
  60859. private static _getDefaultOptions;
  60860. private _rootMesh;
  60861. /**
  60862. * Gets the root mesh created by the helper.
  60863. */
  60864. get rootMesh(): Mesh;
  60865. private _skybox;
  60866. /**
  60867. * Gets the skybox created by the helper.
  60868. */
  60869. get skybox(): Nullable<Mesh>;
  60870. private _skyboxTexture;
  60871. /**
  60872. * Gets the skybox texture created by the helper.
  60873. */
  60874. get skyboxTexture(): Nullable<BaseTexture>;
  60875. private _skyboxMaterial;
  60876. /**
  60877. * Gets the skybox material created by the helper.
  60878. */
  60879. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  60880. private _ground;
  60881. /**
  60882. * Gets the ground mesh created by the helper.
  60883. */
  60884. get ground(): Nullable<Mesh>;
  60885. private _groundTexture;
  60886. /**
  60887. * Gets the ground texture created by the helper.
  60888. */
  60889. get groundTexture(): Nullable<BaseTexture>;
  60890. private _groundMirror;
  60891. /**
  60892. * Gets the ground mirror created by the helper.
  60893. */
  60894. get groundMirror(): Nullable<MirrorTexture>;
  60895. /**
  60896. * Gets the ground mirror render list to helps pushing the meshes
  60897. * you wish in the ground reflection.
  60898. */
  60899. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  60900. private _groundMaterial;
  60901. /**
  60902. * Gets the ground material created by the helper.
  60903. */
  60904. get groundMaterial(): Nullable<BackgroundMaterial>;
  60905. /**
  60906. * Stores the creation options.
  60907. */
  60908. private readonly _scene;
  60909. private _options;
  60910. /**
  60911. * This observable will be notified with any error during the creation of the environment,
  60912. * mainly texture creation errors.
  60913. */
  60914. onErrorObservable: Observable<{
  60915. message?: string;
  60916. exception?: any;
  60917. }>;
  60918. /**
  60919. * constructor
  60920. * @param options Defines the options we want to customize the helper
  60921. * @param scene The scene to add the material to
  60922. */
  60923. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  60924. /**
  60925. * Updates the background according to the new options
  60926. * @param options
  60927. */
  60928. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  60929. /**
  60930. * Sets the primary color of all the available elements.
  60931. * @param color the main color to affect to the ground and the background
  60932. */
  60933. setMainColor(color: Color3): void;
  60934. /**
  60935. * Setup the image processing according to the specified options.
  60936. */
  60937. private _setupImageProcessing;
  60938. /**
  60939. * Setup the environment texture according to the specified options.
  60940. */
  60941. private _setupEnvironmentTexture;
  60942. /**
  60943. * Setup the background according to the specified options.
  60944. */
  60945. private _setupBackground;
  60946. /**
  60947. * Get the scene sizes according to the setup.
  60948. */
  60949. private _getSceneSize;
  60950. /**
  60951. * Setup the ground according to the specified options.
  60952. */
  60953. private _setupGround;
  60954. /**
  60955. * Setup the ground material according to the specified options.
  60956. */
  60957. private _setupGroundMaterial;
  60958. /**
  60959. * Setup the ground diffuse texture according to the specified options.
  60960. */
  60961. private _setupGroundDiffuseTexture;
  60962. /**
  60963. * Setup the ground mirror texture according to the specified options.
  60964. */
  60965. private _setupGroundMirrorTexture;
  60966. /**
  60967. * Setup the ground to receive the mirror texture.
  60968. */
  60969. private _setupMirrorInGroundMaterial;
  60970. /**
  60971. * Setup the skybox according to the specified options.
  60972. */
  60973. private _setupSkybox;
  60974. /**
  60975. * Setup the skybox material according to the specified options.
  60976. */
  60977. private _setupSkyboxMaterial;
  60978. /**
  60979. * Setup the skybox reflection texture according to the specified options.
  60980. */
  60981. private _setupSkyboxReflectionTexture;
  60982. private _errorHandler;
  60983. /**
  60984. * Dispose all the elements created by the Helper.
  60985. */
  60986. dispose(): void;
  60987. }
  60988. }
  60989. declare module "babylonjs/Helpers/textureDome" {
  60990. import { Scene } from "babylonjs/scene";
  60991. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60992. import { Mesh } from "babylonjs/Meshes/mesh";
  60993. import { Texture } from "babylonjs/Materials/Textures/texture";
  60994. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  60995. import "babylonjs/Meshes/Builders/sphereBuilder";
  60996. import { Nullable } from "babylonjs/types";
  60997. import { Observable } from "babylonjs/Misc/observable";
  60998. /**
  60999. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  61000. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  61001. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61002. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61003. */
  61004. export abstract class TextureDome<T extends Texture> extends TransformNode {
  61005. protected onError: Nullable<(message?: string, exception?: any) => void>;
  61006. /**
  61007. * Define the source as a Monoscopic panoramic 360/180.
  61008. */
  61009. static readonly MODE_MONOSCOPIC: number;
  61010. /**
  61011. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  61012. */
  61013. static readonly MODE_TOPBOTTOM: number;
  61014. /**
  61015. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  61016. */
  61017. static readonly MODE_SIDEBYSIDE: number;
  61018. private _halfDome;
  61019. private _crossEye;
  61020. protected _useDirectMapping: boolean;
  61021. /**
  61022. * The texture being displayed on the sphere
  61023. */
  61024. protected _texture: T;
  61025. /**
  61026. * Gets the texture being displayed on the sphere
  61027. */
  61028. get texture(): T;
  61029. /**
  61030. * Sets the texture being displayed on the sphere
  61031. */
  61032. set texture(newTexture: T);
  61033. /**
  61034. * The skybox material
  61035. */
  61036. protected _material: BackgroundMaterial;
  61037. /**
  61038. * The surface used for the dome
  61039. */
  61040. protected _mesh: Mesh;
  61041. /**
  61042. * Gets the mesh used for the dome.
  61043. */
  61044. get mesh(): Mesh;
  61045. /**
  61046. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  61047. */
  61048. private _halfDomeMask;
  61049. /**
  61050. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  61051. * Also see the options.resolution property.
  61052. */
  61053. get fovMultiplier(): number;
  61054. set fovMultiplier(value: number);
  61055. protected _textureMode: number;
  61056. /**
  61057. * Gets or set the current texture mode for the texture. It can be:
  61058. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61059. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61060. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61061. */
  61062. get textureMode(): number;
  61063. /**
  61064. * Sets the current texture mode for the texture. It can be:
  61065. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61066. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61067. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61068. */
  61069. set textureMode(value: number);
  61070. /**
  61071. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  61072. */
  61073. get halfDome(): boolean;
  61074. /**
  61075. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  61076. */
  61077. set halfDome(enabled: boolean);
  61078. /**
  61079. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  61080. */
  61081. set crossEye(enabled: boolean);
  61082. /**
  61083. * Is it a cross-eye texture?
  61084. */
  61085. get crossEye(): boolean;
  61086. /**
  61087. * The background material of this dome.
  61088. */
  61089. get material(): BackgroundMaterial;
  61090. /**
  61091. * Oberserver used in Stereoscopic VR Mode.
  61092. */
  61093. private _onBeforeCameraRenderObserver;
  61094. /**
  61095. * Observable raised when an error occured while loading the 360 image
  61096. */
  61097. onLoadErrorObservable: Observable<string>;
  61098. /**
  61099. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  61100. * @param name Element's name, child elements will append suffixes for their own names.
  61101. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  61102. * @param options An object containing optional or exposed sub element properties
  61103. */
  61104. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  61105. resolution?: number;
  61106. clickToPlay?: boolean;
  61107. autoPlay?: boolean;
  61108. loop?: boolean;
  61109. size?: number;
  61110. poster?: string;
  61111. faceForward?: boolean;
  61112. useDirectMapping?: boolean;
  61113. halfDomeMode?: boolean;
  61114. crossEyeMode?: boolean;
  61115. generateMipMaps?: boolean;
  61116. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  61117. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  61118. protected _changeTextureMode(value: number): void;
  61119. /**
  61120. * Releases resources associated with this node.
  61121. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  61122. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  61123. */
  61124. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  61125. }
  61126. }
  61127. declare module "babylonjs/Helpers/photoDome" {
  61128. import { Scene } from "babylonjs/scene";
  61129. import { Texture } from "babylonjs/Materials/Textures/texture";
  61130. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61131. /**
  61132. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  61133. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  61134. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  61135. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61136. */
  61137. export class PhotoDome extends TextureDome<Texture> {
  61138. /**
  61139. * Define the image as a Monoscopic panoramic 360 image.
  61140. */
  61141. static readonly MODE_MONOSCOPIC: number;
  61142. /**
  61143. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  61144. */
  61145. static readonly MODE_TOPBOTTOM: number;
  61146. /**
  61147. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  61148. */
  61149. static readonly MODE_SIDEBYSIDE: number;
  61150. /**
  61151. * Gets or sets the texture being displayed on the sphere
  61152. */
  61153. get photoTexture(): Texture;
  61154. /**
  61155. * sets the texture being displayed on the sphere
  61156. */
  61157. set photoTexture(value: Texture);
  61158. /**
  61159. * Gets the current video mode for the video. It can be:
  61160. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61161. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61162. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61163. */
  61164. get imageMode(): number;
  61165. /**
  61166. * Sets the current video mode for the video. It can be:
  61167. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  61168. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  61169. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  61170. */
  61171. set imageMode(value: number);
  61172. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  61173. }
  61174. }
  61175. declare module "babylonjs/Misc/dds" {
  61176. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  61177. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61178. import { Nullable } from "babylonjs/types";
  61179. import { Scene } from "babylonjs/scene";
  61180. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  61181. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61182. /**
  61183. * Direct draw surface info
  61184. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  61185. */
  61186. export interface DDSInfo {
  61187. /**
  61188. * Width of the texture
  61189. */
  61190. width: number;
  61191. /**
  61192. * Width of the texture
  61193. */
  61194. height: number;
  61195. /**
  61196. * Number of Mipmaps for the texture
  61197. * @see https://en.wikipedia.org/wiki/Mipmap
  61198. */
  61199. mipmapCount: number;
  61200. /**
  61201. * If the textures format is a known fourCC format
  61202. * @see https://www.fourcc.org/
  61203. */
  61204. isFourCC: boolean;
  61205. /**
  61206. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  61207. */
  61208. isRGB: boolean;
  61209. /**
  61210. * If the texture is a lumincance format
  61211. */
  61212. isLuminance: boolean;
  61213. /**
  61214. * If this is a cube texture
  61215. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  61216. */
  61217. isCube: boolean;
  61218. /**
  61219. * If the texture is a compressed format eg. FOURCC_DXT1
  61220. */
  61221. isCompressed: boolean;
  61222. /**
  61223. * The dxgiFormat of the texture
  61224. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  61225. */
  61226. dxgiFormat: number;
  61227. /**
  61228. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  61229. */
  61230. textureType: number;
  61231. /**
  61232. * Sphericle polynomial created for the dds texture
  61233. */
  61234. sphericalPolynomial?: SphericalPolynomial;
  61235. }
  61236. /**
  61237. * Class used to provide DDS decompression tools
  61238. */
  61239. export class DDSTools {
  61240. /**
  61241. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  61242. */
  61243. static StoreLODInAlphaChannel: boolean;
  61244. /**
  61245. * Gets DDS information from an array buffer
  61246. * @param data defines the array buffer view to read data from
  61247. * @returns the DDS information
  61248. */
  61249. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  61250. private static _FloatView;
  61251. private static _Int32View;
  61252. private static _ToHalfFloat;
  61253. private static _FromHalfFloat;
  61254. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  61255. private static _GetHalfFloatRGBAArrayBuffer;
  61256. private static _GetFloatRGBAArrayBuffer;
  61257. private static _GetFloatAsUIntRGBAArrayBuffer;
  61258. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  61259. private static _GetRGBAArrayBuffer;
  61260. private static _ExtractLongWordOrder;
  61261. private static _GetRGBArrayBuffer;
  61262. private static _GetLuminanceArrayBuffer;
  61263. /**
  61264. * Uploads DDS Levels to a Babylon Texture
  61265. * @hidden
  61266. */
  61267. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  61268. }
  61269. module "babylonjs/Engines/thinEngine" {
  61270. interface ThinEngine {
  61271. /**
  61272. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  61273. * @param rootUrl defines the url where the file to load is located
  61274. * @param scene defines the current scene
  61275. * @param lodScale defines scale to apply to the mip map selection
  61276. * @param lodOffset defines offset to apply to the mip map selection
  61277. * @param onLoad defines an optional callback raised when the texture is loaded
  61278. * @param onError defines an optional callback raised if there is an issue to load the texture
  61279. * @param format defines the format of the data
  61280. * @param forcedExtension defines the extension to use to pick the right loader
  61281. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  61282. * @returns the cube texture as an InternalTexture
  61283. */
  61284. 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;
  61285. }
  61286. }
  61287. }
  61288. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  61289. import { Nullable } from "babylonjs/types";
  61290. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61291. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61292. /**
  61293. * Implementation of the DDS Texture Loader.
  61294. * @hidden
  61295. */
  61296. export class _DDSTextureLoader implements IInternalTextureLoader {
  61297. /**
  61298. * Defines wether the loader supports cascade loading the different faces.
  61299. */
  61300. readonly supportCascades: boolean;
  61301. /**
  61302. * This returns if the loader support the current file information.
  61303. * @param extension defines the file extension of the file being loaded
  61304. * @returns true if the loader can load the specified file
  61305. */
  61306. canLoad(extension: string): boolean;
  61307. /**
  61308. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61309. * @param data contains the texture data
  61310. * @param texture defines the BabylonJS internal texture
  61311. * @param createPolynomials will be true if polynomials have been requested
  61312. * @param onLoad defines the callback to trigger once the texture is ready
  61313. * @param onError defines the callback to trigger in case of error
  61314. */
  61315. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61316. /**
  61317. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61318. * @param data contains the texture data
  61319. * @param texture defines the BabylonJS internal texture
  61320. * @param callback defines the method to call once ready to upload
  61321. */
  61322. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61323. }
  61324. }
  61325. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  61326. import { Nullable } from "babylonjs/types";
  61327. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61328. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61329. /**
  61330. * Implementation of the ENV Texture Loader.
  61331. * @hidden
  61332. */
  61333. export class _ENVTextureLoader implements IInternalTextureLoader {
  61334. /**
  61335. * Defines wether the loader supports cascade loading the different faces.
  61336. */
  61337. readonly supportCascades: boolean;
  61338. /**
  61339. * This returns if the loader support the current file information.
  61340. * @param extension defines the file extension of the file being loaded
  61341. * @returns true if the loader can load the specified file
  61342. */
  61343. canLoad(extension: string): boolean;
  61344. /**
  61345. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61346. * @param data contains the texture data
  61347. * @param texture defines the BabylonJS internal texture
  61348. * @param createPolynomials will be true if polynomials have been requested
  61349. * @param onLoad defines the callback to trigger once the texture is ready
  61350. * @param onError defines the callback to trigger in case of error
  61351. */
  61352. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61353. /**
  61354. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61355. * @param data contains the texture data
  61356. * @param texture defines the BabylonJS internal texture
  61357. * @param callback defines the method to call once ready to upload
  61358. */
  61359. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  61360. }
  61361. }
  61362. declare module "babylonjs/Misc/khronosTextureContainer" {
  61363. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61364. /**
  61365. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  61366. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  61367. */
  61368. export class KhronosTextureContainer {
  61369. /** contents of the KTX container file */
  61370. data: ArrayBufferView;
  61371. private static HEADER_LEN;
  61372. private static COMPRESSED_2D;
  61373. private static COMPRESSED_3D;
  61374. private static TEX_2D;
  61375. private static TEX_3D;
  61376. /**
  61377. * Gets the openGL type
  61378. */
  61379. glType: number;
  61380. /**
  61381. * Gets the openGL type size
  61382. */
  61383. glTypeSize: number;
  61384. /**
  61385. * Gets the openGL format
  61386. */
  61387. glFormat: number;
  61388. /**
  61389. * Gets the openGL internal format
  61390. */
  61391. glInternalFormat: number;
  61392. /**
  61393. * Gets the base internal format
  61394. */
  61395. glBaseInternalFormat: number;
  61396. /**
  61397. * Gets image width in pixel
  61398. */
  61399. pixelWidth: number;
  61400. /**
  61401. * Gets image height in pixel
  61402. */
  61403. pixelHeight: number;
  61404. /**
  61405. * Gets image depth in pixels
  61406. */
  61407. pixelDepth: number;
  61408. /**
  61409. * Gets the number of array elements
  61410. */
  61411. numberOfArrayElements: number;
  61412. /**
  61413. * Gets the number of faces
  61414. */
  61415. numberOfFaces: number;
  61416. /**
  61417. * Gets the number of mipmap levels
  61418. */
  61419. numberOfMipmapLevels: number;
  61420. /**
  61421. * Gets the bytes of key value data
  61422. */
  61423. bytesOfKeyValueData: number;
  61424. /**
  61425. * Gets the load type
  61426. */
  61427. loadType: number;
  61428. /**
  61429. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  61430. */
  61431. isInvalid: boolean;
  61432. /**
  61433. * Creates a new KhronosTextureContainer
  61434. * @param data contents of the KTX container file
  61435. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  61436. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  61437. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  61438. */
  61439. constructor(
  61440. /** contents of the KTX container file */
  61441. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  61442. /**
  61443. * Uploads KTX content to a Babylon Texture.
  61444. * It is assumed that the texture has already been created & is currently bound
  61445. * @hidden
  61446. */
  61447. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  61448. private _upload2DCompressedLevels;
  61449. /**
  61450. * Checks if the given data starts with a KTX file identifier.
  61451. * @param data the data to check
  61452. * @returns true if the data is a KTX file or false otherwise
  61453. */
  61454. static IsValid(data: ArrayBufferView): boolean;
  61455. }
  61456. }
  61457. declare module "babylonjs/Misc/workerPool" {
  61458. import { IDisposable } from "babylonjs/scene";
  61459. /**
  61460. * Helper class to push actions to a pool of workers.
  61461. */
  61462. export class WorkerPool implements IDisposable {
  61463. private _workerInfos;
  61464. private _pendingActions;
  61465. /**
  61466. * Constructor
  61467. * @param workers Array of workers to use for actions
  61468. */
  61469. constructor(workers: Array<Worker>);
  61470. /**
  61471. * Terminates all workers and clears any pending actions.
  61472. */
  61473. dispose(): void;
  61474. /**
  61475. * Pushes an action to the worker pool. If all the workers are active, the action will be
  61476. * pended until a worker has completed its action.
  61477. * @param action The action to perform. Call onComplete when the action is complete.
  61478. */
  61479. push(action: (worker: Worker, onComplete: () => void) => void): void;
  61480. private _execute;
  61481. }
  61482. }
  61483. declare module "babylonjs/Misc/khronosTextureContainer2" {
  61484. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61485. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61486. /**
  61487. * Class for loading KTX2 files
  61488. */
  61489. export class KhronosTextureContainer2 {
  61490. private static _WorkerPoolPromise?;
  61491. private static _Initialized;
  61492. private static _Ktx2Decoder;
  61493. /**
  61494. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  61495. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  61496. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  61497. * Urls you can change:
  61498. * URLConfig.jsDecoderModule
  61499. * URLConfig.wasmUASTCToASTC
  61500. * URLConfig.wasmUASTCToBC7
  61501. * URLConfig.jsMSCTranscoder
  61502. * URLConfig.wasmMSCTranscoder
  61503. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  61504. */
  61505. static URLConfig: {
  61506. jsDecoderModule: string;
  61507. wasmUASTCToASTC: null;
  61508. wasmUASTCToBC7: null;
  61509. jsMSCTranscoder: null;
  61510. wasmMSCTranscoder: null;
  61511. };
  61512. /**
  61513. * Default number of workers used to handle data decoding
  61514. */
  61515. static DefaultNumWorkers: number;
  61516. private static GetDefaultNumWorkers;
  61517. private _engine;
  61518. private static _CreateWorkerPool;
  61519. /**
  61520. * Constructor
  61521. * @param engine The engine to use
  61522. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  61523. */
  61524. constructor(engine: ThinEngine, numWorkers?: number);
  61525. /** @hidden */
  61526. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  61527. /**
  61528. * Stop all async operations and release resources.
  61529. */
  61530. dispose(): void;
  61531. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  61532. /**
  61533. * Checks if the given data starts with a KTX2 file identifier.
  61534. * @param data the data to check
  61535. * @returns true if the data is a KTX2 file or false otherwise
  61536. */
  61537. static IsValid(data: ArrayBufferView): boolean;
  61538. }
  61539. }
  61540. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  61541. import { Nullable } from "babylonjs/types";
  61542. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61543. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  61544. /**
  61545. * Implementation of the KTX Texture Loader.
  61546. * @hidden
  61547. */
  61548. export class _KTXTextureLoader implements IInternalTextureLoader {
  61549. /**
  61550. * Defines wether the loader supports cascade loading the different faces.
  61551. */
  61552. readonly supportCascades: boolean;
  61553. /**
  61554. * This returns if the loader support the current file information.
  61555. * @param extension defines the file extension of the file being loaded
  61556. * @param mimeType defines the optional mime type of the file being loaded
  61557. * @returns true if the loader can load the specified file
  61558. */
  61559. canLoad(extension: string, mimeType?: string): boolean;
  61560. /**
  61561. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  61562. * @param data contains the texture data
  61563. * @param texture defines the BabylonJS internal texture
  61564. * @param createPolynomials will be true if polynomials have been requested
  61565. * @param onLoad defines the callback to trigger once the texture is ready
  61566. * @param onError defines the callback to trigger in case of error
  61567. */
  61568. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  61569. /**
  61570. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  61571. * @param data contains the texture data
  61572. * @param texture defines the BabylonJS internal texture
  61573. * @param callback defines the method to call once ready to upload
  61574. */
  61575. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  61576. }
  61577. }
  61578. declare module "babylonjs/Helpers/sceneHelpers" {
  61579. import { Nullable } from "babylonjs/types";
  61580. import { Mesh } from "babylonjs/Meshes/mesh";
  61581. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61582. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  61583. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  61584. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  61585. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  61586. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  61587. import "babylonjs/Meshes/Builders/boxBuilder";
  61588. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  61589. /** @hidden */
  61590. export var _forceSceneHelpersToBundle: boolean;
  61591. module "babylonjs/scene" {
  61592. interface Scene {
  61593. /**
  61594. * Creates a default light for the scene.
  61595. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  61596. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  61597. */
  61598. createDefaultLight(replace?: boolean): void;
  61599. /**
  61600. * Creates a default camera for the scene.
  61601. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  61602. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61603. * @param replace has default false, when true replaces the active camera in the scene
  61604. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  61605. */
  61606. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61607. /**
  61608. * Creates a default camera and a default light.
  61609. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  61610. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  61611. * @param replace has the default false, when true replaces the active camera/light in the scene
  61612. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  61613. */
  61614. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  61615. /**
  61616. * Creates a new sky box
  61617. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  61618. * @param environmentTexture defines the texture to use as environment texture
  61619. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  61620. * @param scale defines the overall scale of the skybox
  61621. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  61622. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  61623. * @returns a new mesh holding the sky box
  61624. */
  61625. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  61626. /**
  61627. * Creates a new environment
  61628. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  61629. * @param options defines the options you can use to configure the environment
  61630. * @returns the new EnvironmentHelper
  61631. */
  61632. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  61633. /**
  61634. * Creates a new VREXperienceHelper
  61635. * @see https://doc.babylonjs.com/how_to/webvr_helper
  61636. * @param webVROptions defines the options used to create the new VREXperienceHelper
  61637. * @returns a new VREXperienceHelper
  61638. */
  61639. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  61640. /**
  61641. * Creates a new WebXRDefaultExperience
  61642. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  61643. * @param options experience options
  61644. * @returns a promise for a new WebXRDefaultExperience
  61645. */
  61646. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  61647. }
  61648. }
  61649. }
  61650. declare module "babylonjs/Helpers/videoDome" {
  61651. import { Scene } from "babylonjs/scene";
  61652. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  61653. import { TextureDome } from "babylonjs/Helpers/textureDome";
  61654. /**
  61655. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  61656. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  61657. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  61658. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  61659. */
  61660. export class VideoDome extends TextureDome<VideoTexture> {
  61661. /**
  61662. * Define the video source as a Monoscopic panoramic 360 video.
  61663. */
  61664. static readonly MODE_MONOSCOPIC: number;
  61665. /**
  61666. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  61667. */
  61668. static readonly MODE_TOPBOTTOM: number;
  61669. /**
  61670. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  61671. */
  61672. static readonly MODE_SIDEBYSIDE: number;
  61673. /**
  61674. * Get the video texture associated with this video dome
  61675. */
  61676. get videoTexture(): VideoTexture;
  61677. /**
  61678. * Get the video mode of this dome
  61679. */
  61680. get videoMode(): number;
  61681. /**
  61682. * Set the video mode of this dome.
  61683. * @see textureMode
  61684. */
  61685. set videoMode(value: number);
  61686. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  61687. }
  61688. }
  61689. declare module "babylonjs/Helpers/index" {
  61690. export * from "babylonjs/Helpers/environmentHelper";
  61691. export * from "babylonjs/Helpers/photoDome";
  61692. export * from "babylonjs/Helpers/sceneHelpers";
  61693. export * from "babylonjs/Helpers/videoDome";
  61694. }
  61695. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  61696. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61697. import { IDisposable } from "babylonjs/scene";
  61698. import { Engine } from "babylonjs/Engines/engine";
  61699. /**
  61700. * This class can be used to get instrumentation data from a Babylon engine
  61701. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61702. */
  61703. export class EngineInstrumentation implements IDisposable {
  61704. /**
  61705. * Define the instrumented engine.
  61706. */
  61707. engine: Engine;
  61708. private _captureGPUFrameTime;
  61709. private _gpuFrameTimeToken;
  61710. private _gpuFrameTime;
  61711. private _captureShaderCompilationTime;
  61712. private _shaderCompilationTime;
  61713. private _onBeginFrameObserver;
  61714. private _onEndFrameObserver;
  61715. private _onBeforeShaderCompilationObserver;
  61716. private _onAfterShaderCompilationObserver;
  61717. /**
  61718. * Gets the perf counter used for GPU frame time
  61719. */
  61720. get gpuFrameTimeCounter(): PerfCounter;
  61721. /**
  61722. * Gets the GPU frame time capture status
  61723. */
  61724. get captureGPUFrameTime(): boolean;
  61725. /**
  61726. * Enable or disable the GPU frame time capture
  61727. */
  61728. set captureGPUFrameTime(value: boolean);
  61729. /**
  61730. * Gets the perf counter used for shader compilation time
  61731. */
  61732. get shaderCompilationTimeCounter(): PerfCounter;
  61733. /**
  61734. * Gets the shader compilation time capture status
  61735. */
  61736. get captureShaderCompilationTime(): boolean;
  61737. /**
  61738. * Enable or disable the shader compilation time capture
  61739. */
  61740. set captureShaderCompilationTime(value: boolean);
  61741. /**
  61742. * Instantiates a new engine instrumentation.
  61743. * This class can be used to get instrumentation data from a Babylon engine
  61744. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  61745. * @param engine Defines the engine to instrument
  61746. */
  61747. constructor(
  61748. /**
  61749. * Define the instrumented engine.
  61750. */
  61751. engine: Engine);
  61752. /**
  61753. * Dispose and release associated resources.
  61754. */
  61755. dispose(): void;
  61756. }
  61757. }
  61758. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  61759. import { Scene, IDisposable } from "babylonjs/scene";
  61760. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  61761. /**
  61762. * This class can be used to get instrumentation data from a Babylon engine
  61763. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61764. */
  61765. export class SceneInstrumentation implements IDisposable {
  61766. /**
  61767. * Defines the scene to instrument
  61768. */
  61769. scene: Scene;
  61770. private _captureActiveMeshesEvaluationTime;
  61771. private _activeMeshesEvaluationTime;
  61772. private _captureRenderTargetsRenderTime;
  61773. private _renderTargetsRenderTime;
  61774. private _captureFrameTime;
  61775. private _frameTime;
  61776. private _captureRenderTime;
  61777. private _renderTime;
  61778. private _captureInterFrameTime;
  61779. private _interFrameTime;
  61780. private _captureParticlesRenderTime;
  61781. private _particlesRenderTime;
  61782. private _captureSpritesRenderTime;
  61783. private _spritesRenderTime;
  61784. private _capturePhysicsTime;
  61785. private _physicsTime;
  61786. private _captureAnimationsTime;
  61787. private _animationsTime;
  61788. private _captureCameraRenderTime;
  61789. private _cameraRenderTime;
  61790. private _onBeforeActiveMeshesEvaluationObserver;
  61791. private _onAfterActiveMeshesEvaluationObserver;
  61792. private _onBeforeRenderTargetsRenderObserver;
  61793. private _onAfterRenderTargetsRenderObserver;
  61794. private _onAfterRenderObserver;
  61795. private _onBeforeDrawPhaseObserver;
  61796. private _onAfterDrawPhaseObserver;
  61797. private _onBeforeAnimationsObserver;
  61798. private _onBeforeParticlesRenderingObserver;
  61799. private _onAfterParticlesRenderingObserver;
  61800. private _onBeforeSpritesRenderingObserver;
  61801. private _onAfterSpritesRenderingObserver;
  61802. private _onBeforePhysicsObserver;
  61803. private _onAfterPhysicsObserver;
  61804. private _onAfterAnimationsObserver;
  61805. private _onBeforeCameraRenderObserver;
  61806. private _onAfterCameraRenderObserver;
  61807. /**
  61808. * Gets the perf counter used for active meshes evaluation time
  61809. */
  61810. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61811. /**
  61812. * Gets the active meshes evaluation time capture status
  61813. */
  61814. get captureActiveMeshesEvaluationTime(): boolean;
  61815. /**
  61816. * Enable or disable the active meshes evaluation time capture
  61817. */
  61818. set captureActiveMeshesEvaluationTime(value: boolean);
  61819. /**
  61820. * Gets the perf counter used for render targets render time
  61821. */
  61822. get renderTargetsRenderTimeCounter(): PerfCounter;
  61823. /**
  61824. * Gets the render targets render time capture status
  61825. */
  61826. get captureRenderTargetsRenderTime(): boolean;
  61827. /**
  61828. * Enable or disable the render targets render time capture
  61829. */
  61830. set captureRenderTargetsRenderTime(value: boolean);
  61831. /**
  61832. * Gets the perf counter used for particles render time
  61833. */
  61834. get particlesRenderTimeCounter(): PerfCounter;
  61835. /**
  61836. * Gets the particles render time capture status
  61837. */
  61838. get captureParticlesRenderTime(): boolean;
  61839. /**
  61840. * Enable or disable the particles render time capture
  61841. */
  61842. set captureParticlesRenderTime(value: boolean);
  61843. /**
  61844. * Gets the perf counter used for sprites render time
  61845. */
  61846. get spritesRenderTimeCounter(): PerfCounter;
  61847. /**
  61848. * Gets the sprites render time capture status
  61849. */
  61850. get captureSpritesRenderTime(): boolean;
  61851. /**
  61852. * Enable or disable the sprites render time capture
  61853. */
  61854. set captureSpritesRenderTime(value: boolean);
  61855. /**
  61856. * Gets the perf counter used for physics time
  61857. */
  61858. get physicsTimeCounter(): PerfCounter;
  61859. /**
  61860. * Gets the physics time capture status
  61861. */
  61862. get capturePhysicsTime(): boolean;
  61863. /**
  61864. * Enable or disable the physics time capture
  61865. */
  61866. set capturePhysicsTime(value: boolean);
  61867. /**
  61868. * Gets the perf counter used for animations time
  61869. */
  61870. get animationsTimeCounter(): PerfCounter;
  61871. /**
  61872. * Gets the animations time capture status
  61873. */
  61874. get captureAnimationsTime(): boolean;
  61875. /**
  61876. * Enable or disable the animations time capture
  61877. */
  61878. set captureAnimationsTime(value: boolean);
  61879. /**
  61880. * Gets the perf counter used for frame time capture
  61881. */
  61882. get frameTimeCounter(): PerfCounter;
  61883. /**
  61884. * Gets the frame time capture status
  61885. */
  61886. get captureFrameTime(): boolean;
  61887. /**
  61888. * Enable or disable the frame time capture
  61889. */
  61890. set captureFrameTime(value: boolean);
  61891. /**
  61892. * Gets the perf counter used for inter-frames time capture
  61893. */
  61894. get interFrameTimeCounter(): PerfCounter;
  61895. /**
  61896. * Gets the inter-frames time capture status
  61897. */
  61898. get captureInterFrameTime(): boolean;
  61899. /**
  61900. * Enable or disable the inter-frames time capture
  61901. */
  61902. set captureInterFrameTime(value: boolean);
  61903. /**
  61904. * Gets the perf counter used for render time capture
  61905. */
  61906. get renderTimeCounter(): PerfCounter;
  61907. /**
  61908. * Gets the render time capture status
  61909. */
  61910. get captureRenderTime(): boolean;
  61911. /**
  61912. * Enable or disable the render time capture
  61913. */
  61914. set captureRenderTime(value: boolean);
  61915. /**
  61916. * Gets the perf counter used for camera render time capture
  61917. */
  61918. get cameraRenderTimeCounter(): PerfCounter;
  61919. /**
  61920. * Gets the camera render time capture status
  61921. */
  61922. get captureCameraRenderTime(): boolean;
  61923. /**
  61924. * Enable or disable the camera render time capture
  61925. */
  61926. set captureCameraRenderTime(value: boolean);
  61927. /**
  61928. * Gets the perf counter used for draw calls
  61929. */
  61930. get drawCallsCounter(): PerfCounter;
  61931. /**
  61932. * Instantiates a new scene instrumentation.
  61933. * This class can be used to get instrumentation data from a Babylon engine
  61934. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61935. * @param scene Defines the scene to instrument
  61936. */
  61937. constructor(
  61938. /**
  61939. * Defines the scene to instrument
  61940. */
  61941. scene: Scene);
  61942. /**
  61943. * Dispose and release associated resources.
  61944. */
  61945. dispose(): void;
  61946. }
  61947. }
  61948. declare module "babylonjs/Instrumentation/index" {
  61949. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61950. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61951. export * from "babylonjs/Instrumentation/timeToken";
  61952. }
  61953. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61954. /** @hidden */
  61955. export var glowMapGenerationPixelShader: {
  61956. name: string;
  61957. shader: string;
  61958. };
  61959. }
  61960. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61961. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61962. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61963. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61964. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61965. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61966. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61967. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61968. /** @hidden */
  61969. export var glowMapGenerationVertexShader: {
  61970. name: string;
  61971. shader: string;
  61972. };
  61973. }
  61974. declare module "babylonjs/Layers/effectLayer" {
  61975. import { Observable } from "babylonjs/Misc/observable";
  61976. import { Nullable } from "babylonjs/types";
  61977. import { Camera } from "babylonjs/Cameras/camera";
  61978. import { Scene } from "babylonjs/scene";
  61979. import { ISize } from "babylonjs/Maths/math.size";
  61980. import { Color4 } from "babylonjs/Maths/math.color";
  61981. import { Engine } from "babylonjs/Engines/engine";
  61982. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61983. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61984. import { Mesh } from "babylonjs/Meshes/mesh";
  61985. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61986. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61987. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61988. import { Effect } from "babylonjs/Materials/effect";
  61989. import { Material } from "babylonjs/Materials/material";
  61990. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61991. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61992. /**
  61993. * Effect layer options. This helps customizing the behaviour
  61994. * of the effect layer.
  61995. */
  61996. export interface IEffectLayerOptions {
  61997. /**
  61998. * Multiplication factor apply to the canvas size to compute the render target size
  61999. * used to generated the objects (the smaller the faster).
  62000. */
  62001. mainTextureRatio: number;
  62002. /**
  62003. * Enforces a fixed size texture to ensure effect stability across devices.
  62004. */
  62005. mainTextureFixedSize?: number;
  62006. /**
  62007. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  62008. */
  62009. alphaBlendingMode: number;
  62010. /**
  62011. * The camera attached to the layer.
  62012. */
  62013. camera: Nullable<Camera>;
  62014. /**
  62015. * The rendering group to draw the layer in.
  62016. */
  62017. renderingGroupId: number;
  62018. }
  62019. /**
  62020. * The effect layer Helps adding post process effect blended with the main pass.
  62021. *
  62022. * This can be for instance use to generate glow or higlight effects on the scene.
  62023. *
  62024. * The effect layer class can not be used directly and is intented to inherited from to be
  62025. * customized per effects.
  62026. */
  62027. export abstract class EffectLayer {
  62028. private _vertexBuffers;
  62029. private _indexBuffer;
  62030. private _cachedDefines;
  62031. private _effectLayerMapGenerationEffect;
  62032. private _effectLayerOptions;
  62033. private _mergeEffect;
  62034. protected _scene: Scene;
  62035. protected _engine: Engine;
  62036. protected _maxSize: number;
  62037. protected _mainTextureDesiredSize: ISize;
  62038. protected _mainTexture: RenderTargetTexture;
  62039. protected _shouldRender: boolean;
  62040. protected _postProcesses: PostProcess[];
  62041. protected _textures: BaseTexture[];
  62042. protected _emissiveTextureAndColor: {
  62043. texture: Nullable<BaseTexture>;
  62044. color: Color4;
  62045. };
  62046. /**
  62047. * The name of the layer
  62048. */
  62049. name: string;
  62050. /**
  62051. * The clear color of the texture used to generate the glow map.
  62052. */
  62053. neutralColor: Color4;
  62054. /**
  62055. * Specifies whether the highlight layer is enabled or not.
  62056. */
  62057. isEnabled: boolean;
  62058. /**
  62059. * Gets the camera attached to the layer.
  62060. */
  62061. get camera(): Nullable<Camera>;
  62062. /**
  62063. * Gets the rendering group id the layer should render in.
  62064. */
  62065. get renderingGroupId(): number;
  62066. set renderingGroupId(renderingGroupId: number);
  62067. /**
  62068. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  62069. */
  62070. disableBoundingBoxesFromEffectLayer: boolean;
  62071. /**
  62072. * An event triggered when the effect layer has been disposed.
  62073. */
  62074. onDisposeObservable: Observable<EffectLayer>;
  62075. /**
  62076. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  62077. */
  62078. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  62079. /**
  62080. * An event triggered when the generated texture is being merged in the scene.
  62081. */
  62082. onBeforeComposeObservable: Observable<EffectLayer>;
  62083. /**
  62084. * An event triggered when the mesh is rendered into the effect render target.
  62085. */
  62086. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  62087. /**
  62088. * An event triggered after the mesh has been rendered into the effect render target.
  62089. */
  62090. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  62091. /**
  62092. * An event triggered when the generated texture has been merged in the scene.
  62093. */
  62094. onAfterComposeObservable: Observable<EffectLayer>;
  62095. /**
  62096. * An event triggered when the efffect layer changes its size.
  62097. */
  62098. onSizeChangedObservable: Observable<EffectLayer>;
  62099. /** @hidden */
  62100. static _SceneComponentInitialization: (scene: Scene) => void;
  62101. /**
  62102. * Instantiates a new effect Layer and references it in the scene.
  62103. * @param name The name of the layer
  62104. * @param scene The scene to use the layer in
  62105. */
  62106. constructor(
  62107. /** The Friendly of the effect in the scene */
  62108. name: string, scene: Scene);
  62109. /**
  62110. * Get the effect name of the layer.
  62111. * @return The effect name
  62112. */
  62113. abstract getEffectName(): string;
  62114. /**
  62115. * Checks for the readiness of the element composing the layer.
  62116. * @param subMesh the mesh to check for
  62117. * @param useInstances specify whether or not to use instances to render the mesh
  62118. * @return true if ready otherwise, false
  62119. */
  62120. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62121. /**
  62122. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62123. * @returns true if the effect requires stencil during the main canvas render pass.
  62124. */
  62125. abstract needStencil(): boolean;
  62126. /**
  62127. * Create the merge effect. This is the shader use to blit the information back
  62128. * to the main canvas at the end of the scene rendering.
  62129. * @returns The effect containing the shader used to merge the effect on the main canvas
  62130. */
  62131. protected abstract _createMergeEffect(): Effect;
  62132. /**
  62133. * Creates the render target textures and post processes used in the effect layer.
  62134. */
  62135. protected abstract _createTextureAndPostProcesses(): void;
  62136. /**
  62137. * Implementation specific of rendering the generating effect on the main canvas.
  62138. * @param effect The effect used to render through
  62139. */
  62140. protected abstract _internalRender(effect: Effect): void;
  62141. /**
  62142. * Sets the required values for both the emissive texture and and the main color.
  62143. */
  62144. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62145. /**
  62146. * Free any resources and references associated to a mesh.
  62147. * Internal use
  62148. * @param mesh The mesh to free.
  62149. */
  62150. abstract _disposeMesh(mesh: Mesh): void;
  62151. /**
  62152. * Serializes this layer (Glow or Highlight for example)
  62153. * @returns a serialized layer object
  62154. */
  62155. abstract serialize?(): any;
  62156. /**
  62157. * Initializes the effect layer with the required options.
  62158. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  62159. */
  62160. protected _init(options: Partial<IEffectLayerOptions>): void;
  62161. /**
  62162. * Generates the index buffer of the full screen quad blending to the main canvas.
  62163. */
  62164. private _generateIndexBuffer;
  62165. /**
  62166. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  62167. */
  62168. private _generateVertexBuffer;
  62169. /**
  62170. * Sets the main texture desired size which is the closest power of two
  62171. * of the engine canvas size.
  62172. */
  62173. private _setMainTextureSize;
  62174. /**
  62175. * Creates the main texture for the effect layer.
  62176. */
  62177. protected _createMainTexture(): void;
  62178. /**
  62179. * Adds specific effects defines.
  62180. * @param defines The defines to add specifics to.
  62181. */
  62182. protected _addCustomEffectDefines(defines: string[]): void;
  62183. /**
  62184. * Checks for the readiness of the element composing the layer.
  62185. * @param subMesh the mesh to check for
  62186. * @param useInstances specify whether or not to use instances to render the mesh
  62187. * @param emissiveTexture the associated emissive texture used to generate the glow
  62188. * @return true if ready otherwise, false
  62189. */
  62190. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  62191. /**
  62192. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  62193. */
  62194. render(): void;
  62195. /**
  62196. * Determine if a given mesh will be used in the current effect.
  62197. * @param mesh mesh to test
  62198. * @returns true if the mesh will be used
  62199. */
  62200. hasMesh(mesh: AbstractMesh): boolean;
  62201. /**
  62202. * Returns true if the layer contains information to display, otherwise false.
  62203. * @returns true if the glow layer should be rendered
  62204. */
  62205. shouldRender(): boolean;
  62206. /**
  62207. * Returns true if the mesh should render, otherwise false.
  62208. * @param mesh The mesh to render
  62209. * @returns true if it should render otherwise false
  62210. */
  62211. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  62212. /**
  62213. * Returns true if the mesh can be rendered, otherwise false.
  62214. * @param mesh The mesh to render
  62215. * @param material The material used on the mesh
  62216. * @returns true if it can be rendered otherwise false
  62217. */
  62218. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62219. /**
  62220. * Returns true if the mesh should render, otherwise false.
  62221. * @param mesh The mesh to render
  62222. * @returns true if it should render otherwise false
  62223. */
  62224. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  62225. /**
  62226. * Renders the submesh passed in parameter to the generation map.
  62227. */
  62228. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  62229. /**
  62230. * Defines whether the current material of the mesh should be use to render the effect.
  62231. * @param mesh defines the current mesh to render
  62232. */
  62233. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62234. /**
  62235. * Rebuild the required buffers.
  62236. * @hidden Internal use only.
  62237. */
  62238. _rebuild(): void;
  62239. /**
  62240. * Dispose only the render target textures and post process.
  62241. */
  62242. private _disposeTextureAndPostProcesses;
  62243. /**
  62244. * Dispose the highlight layer and free resources.
  62245. */
  62246. dispose(): void;
  62247. /**
  62248. * Gets the class name of the effect layer
  62249. * @returns the string with the class name of the effect layer
  62250. */
  62251. getClassName(): string;
  62252. /**
  62253. * Creates an effect layer from parsed effect layer data
  62254. * @param parsedEffectLayer defines effect layer data
  62255. * @param scene defines the current scene
  62256. * @param rootUrl defines the root URL containing the effect layer information
  62257. * @returns a parsed effect Layer
  62258. */
  62259. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  62260. }
  62261. }
  62262. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  62263. import { Scene } from "babylonjs/scene";
  62264. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62265. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62266. import { AbstractScene } from "babylonjs/abstractScene";
  62267. module "babylonjs/abstractScene" {
  62268. interface AbstractScene {
  62269. /**
  62270. * The list of effect layers (highlights/glow) added to the scene
  62271. * @see https://doc.babylonjs.com/how_to/highlight_layer
  62272. * @see https://doc.babylonjs.com/how_to/glow_layer
  62273. */
  62274. effectLayers: Array<EffectLayer>;
  62275. /**
  62276. * Removes the given effect layer from this scene.
  62277. * @param toRemove defines the effect layer to remove
  62278. * @returns the index of the removed effect layer
  62279. */
  62280. removeEffectLayer(toRemove: EffectLayer): number;
  62281. /**
  62282. * Adds the given effect layer to this scene
  62283. * @param newEffectLayer defines the effect layer to add
  62284. */
  62285. addEffectLayer(newEffectLayer: EffectLayer): void;
  62286. }
  62287. }
  62288. /**
  62289. * Defines the layer scene component responsible to manage any effect layers
  62290. * in a given scene.
  62291. */
  62292. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  62293. /**
  62294. * The component name helpfull to identify the component in the list of scene components.
  62295. */
  62296. readonly name: string;
  62297. /**
  62298. * The scene the component belongs to.
  62299. */
  62300. scene: Scene;
  62301. private _engine;
  62302. private _renderEffects;
  62303. private _needStencil;
  62304. private _previousStencilState;
  62305. /**
  62306. * Creates a new instance of the component for the given scene
  62307. * @param scene Defines the scene to register the component in
  62308. */
  62309. constructor(scene: Scene);
  62310. /**
  62311. * Registers the component in a given scene
  62312. */
  62313. register(): void;
  62314. /**
  62315. * Rebuilds the elements related to this component in case of
  62316. * context lost for instance.
  62317. */
  62318. rebuild(): void;
  62319. /**
  62320. * Serializes the component data to the specified json object
  62321. * @param serializationObject The object to serialize to
  62322. */
  62323. serialize(serializationObject: any): void;
  62324. /**
  62325. * Adds all the elements from the container to the scene
  62326. * @param container the container holding the elements
  62327. */
  62328. addFromContainer(container: AbstractScene): void;
  62329. /**
  62330. * Removes all the elements in the container from the scene
  62331. * @param container contains the elements to remove
  62332. * @param dispose if the removed element should be disposed (default: false)
  62333. */
  62334. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62335. /**
  62336. * Disposes the component and the associated ressources.
  62337. */
  62338. dispose(): void;
  62339. private _isReadyForMesh;
  62340. private _renderMainTexture;
  62341. private _setStencil;
  62342. private _setStencilBack;
  62343. private _draw;
  62344. private _drawCamera;
  62345. private _drawRenderingGroup;
  62346. }
  62347. }
  62348. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  62349. /** @hidden */
  62350. export var glowMapMergePixelShader: {
  62351. name: string;
  62352. shader: string;
  62353. };
  62354. }
  62355. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  62356. /** @hidden */
  62357. export var glowMapMergeVertexShader: {
  62358. name: string;
  62359. shader: string;
  62360. };
  62361. }
  62362. declare module "babylonjs/Layers/glowLayer" {
  62363. import { Nullable } from "babylonjs/types";
  62364. import { Camera } from "babylonjs/Cameras/camera";
  62365. import { Scene } from "babylonjs/scene";
  62366. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62368. import { Mesh } from "babylonjs/Meshes/mesh";
  62369. import { Texture } from "babylonjs/Materials/Textures/texture";
  62370. import { Effect } from "babylonjs/Materials/effect";
  62371. import { Material } from "babylonjs/Materials/material";
  62372. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62373. import { Color4 } from "babylonjs/Maths/math.color";
  62374. import "babylonjs/Shaders/glowMapMerge.fragment";
  62375. import "babylonjs/Shaders/glowMapMerge.vertex";
  62376. import "babylonjs/Layers/effectLayerSceneComponent";
  62377. module "babylonjs/abstractScene" {
  62378. interface AbstractScene {
  62379. /**
  62380. * Return a the first highlight layer of the scene with a given name.
  62381. * @param name The name of the highlight layer to look for.
  62382. * @return The highlight layer if found otherwise null.
  62383. */
  62384. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  62385. }
  62386. }
  62387. /**
  62388. * Glow layer options. This helps customizing the behaviour
  62389. * of the glow layer.
  62390. */
  62391. export interface IGlowLayerOptions {
  62392. /**
  62393. * Multiplication factor apply to the canvas size to compute the render target size
  62394. * used to generated the glowing objects (the smaller the faster).
  62395. */
  62396. mainTextureRatio: number;
  62397. /**
  62398. * Enforces a fixed size texture to ensure resize independant blur.
  62399. */
  62400. mainTextureFixedSize?: number;
  62401. /**
  62402. * How big is the kernel of the blur texture.
  62403. */
  62404. blurKernelSize: number;
  62405. /**
  62406. * The camera attached to the layer.
  62407. */
  62408. camera: Nullable<Camera>;
  62409. /**
  62410. * Enable MSAA by chosing the number of samples.
  62411. */
  62412. mainTextureSamples?: number;
  62413. /**
  62414. * The rendering group to draw the layer in.
  62415. */
  62416. renderingGroupId: number;
  62417. }
  62418. /**
  62419. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  62420. *
  62421. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  62422. *
  62423. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  62424. */
  62425. export class GlowLayer extends EffectLayer {
  62426. /**
  62427. * Effect Name of the layer.
  62428. */
  62429. static readonly EffectName: string;
  62430. /**
  62431. * The default blur kernel size used for the glow.
  62432. */
  62433. static DefaultBlurKernelSize: number;
  62434. /**
  62435. * The default texture size ratio used for the glow.
  62436. */
  62437. static DefaultTextureRatio: number;
  62438. /**
  62439. * Sets the kernel size of the blur.
  62440. */
  62441. set blurKernelSize(value: number);
  62442. /**
  62443. * Gets the kernel size of the blur.
  62444. */
  62445. get blurKernelSize(): number;
  62446. /**
  62447. * Sets the glow intensity.
  62448. */
  62449. set intensity(value: number);
  62450. /**
  62451. * Gets the glow intensity.
  62452. */
  62453. get intensity(): number;
  62454. private _options;
  62455. private _intensity;
  62456. private _horizontalBlurPostprocess1;
  62457. private _verticalBlurPostprocess1;
  62458. private _horizontalBlurPostprocess2;
  62459. private _verticalBlurPostprocess2;
  62460. private _blurTexture1;
  62461. private _blurTexture2;
  62462. private _postProcesses1;
  62463. private _postProcesses2;
  62464. private _includedOnlyMeshes;
  62465. private _excludedMeshes;
  62466. private _meshesUsingTheirOwnMaterials;
  62467. /**
  62468. * Callback used to let the user override the color selection on a per mesh basis
  62469. */
  62470. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  62471. /**
  62472. * Callback used to let the user override the texture selection on a per mesh basis
  62473. */
  62474. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  62475. /**
  62476. * Instantiates a new glow Layer and references it to the scene.
  62477. * @param name The name of the layer
  62478. * @param scene The scene to use the layer in
  62479. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  62480. */
  62481. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  62482. /**
  62483. * Get the effect name of the layer.
  62484. * @return The effect name
  62485. */
  62486. getEffectName(): string;
  62487. /**
  62488. * Create the merge effect. This is the shader use to blit the information back
  62489. * to the main canvas at the end of the scene rendering.
  62490. */
  62491. protected _createMergeEffect(): Effect;
  62492. /**
  62493. * Creates the render target textures and post processes used in the glow layer.
  62494. */
  62495. protected _createTextureAndPostProcesses(): void;
  62496. /**
  62497. * Checks for the readiness of the element composing the layer.
  62498. * @param subMesh the mesh to check for
  62499. * @param useInstances specify wether or not to use instances to render the mesh
  62500. * @param emissiveTexture the associated emissive texture used to generate the glow
  62501. * @return true if ready otherwise, false
  62502. */
  62503. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62504. /**
  62505. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  62506. */
  62507. needStencil(): boolean;
  62508. /**
  62509. * Returns true if the mesh can be rendered, otherwise false.
  62510. * @param mesh The mesh to render
  62511. * @param material The material used on the mesh
  62512. * @returns true if it can be rendered otherwise false
  62513. */
  62514. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62515. /**
  62516. * Implementation specific of rendering the generating effect on the main canvas.
  62517. * @param effect The effect used to render through
  62518. */
  62519. protected _internalRender(effect: Effect): void;
  62520. /**
  62521. * Sets the required values for both the emissive texture and and the main color.
  62522. */
  62523. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62524. /**
  62525. * Returns true if the mesh should render, otherwise false.
  62526. * @param mesh The mesh to render
  62527. * @returns true if it should render otherwise false
  62528. */
  62529. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62530. /**
  62531. * Adds specific effects defines.
  62532. * @param defines The defines to add specifics to.
  62533. */
  62534. protected _addCustomEffectDefines(defines: string[]): void;
  62535. /**
  62536. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  62537. * @param mesh The mesh to exclude from the glow layer
  62538. */
  62539. addExcludedMesh(mesh: Mesh): void;
  62540. /**
  62541. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  62542. * @param mesh The mesh to remove
  62543. */
  62544. removeExcludedMesh(mesh: Mesh): void;
  62545. /**
  62546. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  62547. * @param mesh The mesh to include in the glow layer
  62548. */
  62549. addIncludedOnlyMesh(mesh: Mesh): void;
  62550. /**
  62551. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  62552. * @param mesh The mesh to remove
  62553. */
  62554. removeIncludedOnlyMesh(mesh: Mesh): void;
  62555. /**
  62556. * Determine if a given mesh will be used in the glow layer
  62557. * @param mesh The mesh to test
  62558. * @returns true if the mesh will be highlighted by the current glow layer
  62559. */
  62560. hasMesh(mesh: AbstractMesh): boolean;
  62561. /**
  62562. * Defines whether the current material of the mesh should be use to render the effect.
  62563. * @param mesh defines the current mesh to render
  62564. */
  62565. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  62566. /**
  62567. * Add a mesh to be rendered through its own material and not with emissive only.
  62568. * @param mesh The mesh for which we need to use its material
  62569. */
  62570. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  62571. /**
  62572. * Remove a mesh from being rendered through its own material and not with emissive only.
  62573. * @param mesh The mesh for which we need to not use its material
  62574. */
  62575. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  62576. /**
  62577. * Free any resources and references associated to a mesh.
  62578. * Internal use
  62579. * @param mesh The mesh to free.
  62580. * @hidden
  62581. */
  62582. _disposeMesh(mesh: Mesh): void;
  62583. /**
  62584. * Gets the class name of the effect layer
  62585. * @returns the string with the class name of the effect layer
  62586. */
  62587. getClassName(): string;
  62588. /**
  62589. * Serializes this glow layer
  62590. * @returns a serialized glow layer object
  62591. */
  62592. serialize(): any;
  62593. /**
  62594. * Creates a Glow Layer from parsed glow layer data
  62595. * @param parsedGlowLayer defines glow layer data
  62596. * @param scene defines the current scene
  62597. * @param rootUrl defines the root URL containing the glow layer information
  62598. * @returns a parsed Glow Layer
  62599. */
  62600. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  62601. }
  62602. }
  62603. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  62604. /** @hidden */
  62605. export var glowBlurPostProcessPixelShader: {
  62606. name: string;
  62607. shader: string;
  62608. };
  62609. }
  62610. declare module "babylonjs/Layers/highlightLayer" {
  62611. import { Observable } from "babylonjs/Misc/observable";
  62612. import { Nullable } from "babylonjs/types";
  62613. import { Camera } from "babylonjs/Cameras/camera";
  62614. import { Scene } from "babylonjs/scene";
  62615. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62616. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62617. import { Mesh } from "babylonjs/Meshes/mesh";
  62618. import { Effect } from "babylonjs/Materials/effect";
  62619. import { Material } from "babylonjs/Materials/material";
  62620. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  62621. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  62622. import "babylonjs/Shaders/glowMapMerge.fragment";
  62623. import "babylonjs/Shaders/glowMapMerge.vertex";
  62624. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  62625. module "babylonjs/abstractScene" {
  62626. interface AbstractScene {
  62627. /**
  62628. * Return a the first highlight layer of the scene with a given name.
  62629. * @param name The name of the highlight layer to look for.
  62630. * @return The highlight layer if found otherwise null.
  62631. */
  62632. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  62633. }
  62634. }
  62635. /**
  62636. * Highlight layer options. This helps customizing the behaviour
  62637. * of the highlight layer.
  62638. */
  62639. export interface IHighlightLayerOptions {
  62640. /**
  62641. * Multiplication factor apply to the canvas size to compute the render target size
  62642. * used to generated the glowing objects (the smaller the faster).
  62643. */
  62644. mainTextureRatio: number;
  62645. /**
  62646. * Enforces a fixed size texture to ensure resize independant blur.
  62647. */
  62648. mainTextureFixedSize?: number;
  62649. /**
  62650. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  62651. * of the picture to blur (the smaller the faster).
  62652. */
  62653. blurTextureSizeRatio: number;
  62654. /**
  62655. * How big in texel of the blur texture is the vertical blur.
  62656. */
  62657. blurVerticalSize: number;
  62658. /**
  62659. * How big in texel of the blur texture is the horizontal blur.
  62660. */
  62661. blurHorizontalSize: number;
  62662. /**
  62663. * Alpha blending mode used to apply the blur. Default is combine.
  62664. */
  62665. alphaBlendingMode: number;
  62666. /**
  62667. * The camera attached to the layer.
  62668. */
  62669. camera: Nullable<Camera>;
  62670. /**
  62671. * Should we display highlight as a solid stroke?
  62672. */
  62673. isStroke?: boolean;
  62674. /**
  62675. * The rendering group to draw the layer in.
  62676. */
  62677. renderingGroupId: number;
  62678. }
  62679. /**
  62680. * The highlight layer Helps adding a glow effect around a mesh.
  62681. *
  62682. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  62683. * glowy meshes to your scene.
  62684. *
  62685. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  62686. */
  62687. export class HighlightLayer extends EffectLayer {
  62688. name: string;
  62689. /**
  62690. * Effect Name of the highlight layer.
  62691. */
  62692. static readonly EffectName: string;
  62693. /**
  62694. * The neutral color used during the preparation of the glow effect.
  62695. * This is black by default as the blend operation is a blend operation.
  62696. */
  62697. static NeutralColor: Color4;
  62698. /**
  62699. * Stencil value used for glowing meshes.
  62700. */
  62701. static GlowingMeshStencilReference: number;
  62702. /**
  62703. * Stencil value used for the other meshes in the scene.
  62704. */
  62705. static NormalMeshStencilReference: number;
  62706. /**
  62707. * Specifies whether or not the inner glow is ACTIVE in the layer.
  62708. */
  62709. innerGlow: boolean;
  62710. /**
  62711. * Specifies whether or not the outer glow is ACTIVE in the layer.
  62712. */
  62713. outerGlow: boolean;
  62714. /**
  62715. * Specifies the horizontal size of the blur.
  62716. */
  62717. set blurHorizontalSize(value: number);
  62718. /**
  62719. * Specifies the vertical size of the blur.
  62720. */
  62721. set blurVerticalSize(value: number);
  62722. /**
  62723. * Gets the horizontal size of the blur.
  62724. */
  62725. get blurHorizontalSize(): number;
  62726. /**
  62727. * Gets the vertical size of the blur.
  62728. */
  62729. get blurVerticalSize(): number;
  62730. /**
  62731. * An event triggered when the highlight layer is being blurred.
  62732. */
  62733. onBeforeBlurObservable: Observable<HighlightLayer>;
  62734. /**
  62735. * An event triggered when the highlight layer has been blurred.
  62736. */
  62737. onAfterBlurObservable: Observable<HighlightLayer>;
  62738. private _instanceGlowingMeshStencilReference;
  62739. private _options;
  62740. private _downSamplePostprocess;
  62741. private _horizontalBlurPostprocess;
  62742. private _verticalBlurPostprocess;
  62743. private _blurTexture;
  62744. private _meshes;
  62745. private _excludedMeshes;
  62746. /**
  62747. * Instantiates a new highlight Layer and references it to the scene..
  62748. * @param name The name of the layer
  62749. * @param scene The scene to use the layer in
  62750. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  62751. */
  62752. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  62753. /**
  62754. * Get the effect name of the layer.
  62755. * @return The effect name
  62756. */
  62757. getEffectName(): string;
  62758. /**
  62759. * Create the merge effect. This is the shader use to blit the information back
  62760. * to the main canvas at the end of the scene rendering.
  62761. */
  62762. protected _createMergeEffect(): Effect;
  62763. /**
  62764. * Creates the render target textures and post processes used in the highlight layer.
  62765. */
  62766. protected _createTextureAndPostProcesses(): void;
  62767. /**
  62768. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  62769. */
  62770. needStencil(): boolean;
  62771. /**
  62772. * Checks for the readiness of the element composing the layer.
  62773. * @param subMesh the mesh to check for
  62774. * @param useInstances specify wether or not to use instances to render the mesh
  62775. * @param emissiveTexture the associated emissive texture used to generate the glow
  62776. * @return true if ready otherwise, false
  62777. */
  62778. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62779. /**
  62780. * Implementation specific of rendering the generating effect on the main canvas.
  62781. * @param effect The effect used to render through
  62782. */
  62783. protected _internalRender(effect: Effect): void;
  62784. /**
  62785. * Returns true if the layer contains information to display, otherwise false.
  62786. */
  62787. shouldRender(): boolean;
  62788. /**
  62789. * Returns true if the mesh should render, otherwise false.
  62790. * @param mesh The mesh to render
  62791. * @returns true if it should render otherwise false
  62792. */
  62793. protected _shouldRenderMesh(mesh: Mesh): boolean;
  62794. /**
  62795. * Returns true if the mesh can be rendered, otherwise false.
  62796. * @param mesh The mesh to render
  62797. * @param material The material used on the mesh
  62798. * @returns true if it can be rendered otherwise false
  62799. */
  62800. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62801. /**
  62802. * Adds specific effects defines.
  62803. * @param defines The defines to add specifics to.
  62804. */
  62805. protected _addCustomEffectDefines(defines: string[]): void;
  62806. /**
  62807. * Sets the required values for both the emissive texture and and the main color.
  62808. */
  62809. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62810. /**
  62811. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62812. * @param mesh The mesh to exclude from the highlight layer
  62813. */
  62814. addExcludedMesh(mesh: Mesh): void;
  62815. /**
  62816. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62817. * @param mesh The mesh to highlight
  62818. */
  62819. removeExcludedMesh(mesh: Mesh): void;
  62820. /**
  62821. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62822. * @param mesh mesh to test
  62823. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62824. */
  62825. hasMesh(mesh: AbstractMesh): boolean;
  62826. /**
  62827. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62828. * @param mesh The mesh to highlight
  62829. * @param color The color of the highlight
  62830. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62831. */
  62832. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62833. /**
  62834. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62835. * @param mesh The mesh to highlight
  62836. */
  62837. removeMesh(mesh: Mesh): void;
  62838. /**
  62839. * Remove all the meshes currently referenced in the highlight layer
  62840. */
  62841. removeAllMeshes(): void;
  62842. /**
  62843. * Force the stencil to the normal expected value for none glowing parts
  62844. */
  62845. private _defaultStencilReference;
  62846. /**
  62847. * Free any resources and references associated to a mesh.
  62848. * Internal use
  62849. * @param mesh The mesh to free.
  62850. * @hidden
  62851. */
  62852. _disposeMesh(mesh: Mesh): void;
  62853. /**
  62854. * Dispose the highlight layer and free resources.
  62855. */
  62856. dispose(): void;
  62857. /**
  62858. * Gets the class name of the effect layer
  62859. * @returns the string with the class name of the effect layer
  62860. */
  62861. getClassName(): string;
  62862. /**
  62863. * Serializes this Highlight layer
  62864. * @returns a serialized Highlight layer object
  62865. */
  62866. serialize(): any;
  62867. /**
  62868. * Creates a Highlight layer from parsed Highlight layer data
  62869. * @param parsedHightlightLayer defines the Highlight layer data
  62870. * @param scene defines the current scene
  62871. * @param rootUrl defines the root URL containing the Highlight layer information
  62872. * @returns a parsed Highlight layer
  62873. */
  62874. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62875. }
  62876. }
  62877. declare module "babylonjs/Layers/layerSceneComponent" {
  62878. import { Scene } from "babylonjs/scene";
  62879. import { ISceneComponent } from "babylonjs/sceneComponent";
  62880. import { Layer } from "babylonjs/Layers/layer";
  62881. import { AbstractScene } from "babylonjs/abstractScene";
  62882. module "babylonjs/abstractScene" {
  62883. interface AbstractScene {
  62884. /**
  62885. * The list of layers (background and foreground) of the scene
  62886. */
  62887. layers: Array<Layer>;
  62888. }
  62889. }
  62890. /**
  62891. * Defines the layer scene component responsible to manage any layers
  62892. * in a given scene.
  62893. */
  62894. export class LayerSceneComponent implements ISceneComponent {
  62895. /**
  62896. * The component name helpfull to identify the component in the list of scene components.
  62897. */
  62898. readonly name: string;
  62899. /**
  62900. * The scene the component belongs to.
  62901. */
  62902. scene: Scene;
  62903. private _engine;
  62904. /**
  62905. * Creates a new instance of the component for the given scene
  62906. * @param scene Defines the scene to register the component in
  62907. */
  62908. constructor(scene: Scene);
  62909. /**
  62910. * Registers the component in a given scene
  62911. */
  62912. register(): void;
  62913. /**
  62914. * Rebuilds the elements related to this component in case of
  62915. * context lost for instance.
  62916. */
  62917. rebuild(): void;
  62918. /**
  62919. * Disposes the component and the associated ressources.
  62920. */
  62921. dispose(): void;
  62922. private _draw;
  62923. private _drawCameraPredicate;
  62924. private _drawCameraBackground;
  62925. private _drawCameraForeground;
  62926. private _drawRenderTargetPredicate;
  62927. private _drawRenderTargetBackground;
  62928. private _drawRenderTargetForeground;
  62929. /**
  62930. * Adds all the elements from the container to the scene
  62931. * @param container the container holding the elements
  62932. */
  62933. addFromContainer(container: AbstractScene): void;
  62934. /**
  62935. * Removes all the elements in the container from the scene
  62936. * @param container contains the elements to remove
  62937. * @param dispose if the removed element should be disposed (default: false)
  62938. */
  62939. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62940. }
  62941. }
  62942. declare module "babylonjs/Shaders/layer.fragment" {
  62943. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62944. /** @hidden */
  62945. export var layerPixelShader: {
  62946. name: string;
  62947. shader: string;
  62948. };
  62949. }
  62950. declare module "babylonjs/Shaders/layer.vertex" {
  62951. /** @hidden */
  62952. export var layerVertexShader: {
  62953. name: string;
  62954. shader: string;
  62955. };
  62956. }
  62957. declare module "babylonjs/Layers/layer" {
  62958. import { Observable } from "babylonjs/Misc/observable";
  62959. import { Nullable } from "babylonjs/types";
  62960. import { Scene } from "babylonjs/scene";
  62961. import { Vector2 } from "babylonjs/Maths/math.vector";
  62962. import { Color4 } from "babylonjs/Maths/math.color";
  62963. import { Texture } from "babylonjs/Materials/Textures/texture";
  62964. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62965. import "babylonjs/Shaders/layer.fragment";
  62966. import "babylonjs/Shaders/layer.vertex";
  62967. /**
  62968. * This represents a full screen 2d layer.
  62969. * This can be useful to display a picture in the background of your scene for instance.
  62970. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62971. */
  62972. export class Layer {
  62973. /**
  62974. * Define the name of the layer.
  62975. */
  62976. name: string;
  62977. /**
  62978. * Define the texture the layer should display.
  62979. */
  62980. texture: Nullable<Texture>;
  62981. /**
  62982. * Is the layer in background or foreground.
  62983. */
  62984. isBackground: boolean;
  62985. /**
  62986. * Define the color of the layer (instead of texture).
  62987. */
  62988. color: Color4;
  62989. /**
  62990. * Define the scale of the layer in order to zoom in out of the texture.
  62991. */
  62992. scale: Vector2;
  62993. /**
  62994. * Define an offset for the layer in order to shift the texture.
  62995. */
  62996. offset: Vector2;
  62997. /**
  62998. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62999. */
  63000. alphaBlendingMode: number;
  63001. /**
  63002. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  63003. * Alpha test will not mix with the background color in case of transparency.
  63004. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  63005. */
  63006. alphaTest: boolean;
  63007. /**
  63008. * Define a mask to restrict the layer to only some of the scene cameras.
  63009. */
  63010. layerMask: number;
  63011. /**
  63012. * Define the list of render target the layer is visible into.
  63013. */
  63014. renderTargetTextures: RenderTargetTexture[];
  63015. /**
  63016. * Define if the layer is only used in renderTarget or if it also
  63017. * renders in the main frame buffer of the canvas.
  63018. */
  63019. renderOnlyInRenderTargetTextures: boolean;
  63020. private _scene;
  63021. private _vertexBuffers;
  63022. private _indexBuffer;
  63023. private _effect;
  63024. private _previousDefines;
  63025. /**
  63026. * An event triggered when the layer is disposed.
  63027. */
  63028. onDisposeObservable: Observable<Layer>;
  63029. private _onDisposeObserver;
  63030. /**
  63031. * Back compatibility with callback before the onDisposeObservable existed.
  63032. * The set callback will be triggered when the layer has been disposed.
  63033. */
  63034. set onDispose(callback: () => void);
  63035. /**
  63036. * An event triggered before rendering the scene
  63037. */
  63038. onBeforeRenderObservable: Observable<Layer>;
  63039. private _onBeforeRenderObserver;
  63040. /**
  63041. * Back compatibility with callback before the onBeforeRenderObservable existed.
  63042. * The set callback will be triggered just before rendering the layer.
  63043. */
  63044. set onBeforeRender(callback: () => void);
  63045. /**
  63046. * An event triggered after rendering the scene
  63047. */
  63048. onAfterRenderObservable: Observable<Layer>;
  63049. private _onAfterRenderObserver;
  63050. /**
  63051. * Back compatibility with callback before the onAfterRenderObservable existed.
  63052. * The set callback will be triggered just after rendering the layer.
  63053. */
  63054. set onAfterRender(callback: () => void);
  63055. /**
  63056. * Instantiates a new layer.
  63057. * This represents a full screen 2d layer.
  63058. * This can be useful to display a picture in the background of your scene for instance.
  63059. * @see https://www.babylonjs-playground.com/#08A2BS#1
  63060. * @param name Define the name of the layer in the scene
  63061. * @param imgUrl Define the url of the texture to display in the layer
  63062. * @param scene Define the scene the layer belongs to
  63063. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  63064. * @param color Defines a color for the layer
  63065. */
  63066. constructor(
  63067. /**
  63068. * Define the name of the layer.
  63069. */
  63070. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  63071. private _createIndexBuffer;
  63072. /** @hidden */
  63073. _rebuild(): void;
  63074. /**
  63075. * Renders the layer in the scene.
  63076. */
  63077. render(): void;
  63078. /**
  63079. * Disposes and releases the associated ressources.
  63080. */
  63081. dispose(): void;
  63082. }
  63083. }
  63084. declare module "babylonjs/Layers/index" {
  63085. export * from "babylonjs/Layers/effectLayer";
  63086. export * from "babylonjs/Layers/effectLayerSceneComponent";
  63087. export * from "babylonjs/Layers/glowLayer";
  63088. export * from "babylonjs/Layers/highlightLayer";
  63089. export * from "babylonjs/Layers/layer";
  63090. export * from "babylonjs/Layers/layerSceneComponent";
  63091. }
  63092. declare module "babylonjs/Shaders/lensFlare.fragment" {
  63093. /** @hidden */
  63094. export var lensFlarePixelShader: {
  63095. name: string;
  63096. shader: string;
  63097. };
  63098. }
  63099. declare module "babylonjs/Shaders/lensFlare.vertex" {
  63100. /** @hidden */
  63101. export var lensFlareVertexShader: {
  63102. name: string;
  63103. shader: string;
  63104. };
  63105. }
  63106. declare module "babylonjs/LensFlares/lensFlareSystem" {
  63107. import { Scene } from "babylonjs/scene";
  63108. import { Vector3 } from "babylonjs/Maths/math.vector";
  63109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63110. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  63111. import "babylonjs/Shaders/lensFlare.fragment";
  63112. import "babylonjs/Shaders/lensFlare.vertex";
  63113. import { Viewport } from "babylonjs/Maths/math.viewport";
  63114. /**
  63115. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63116. * It is usually composed of several `lensFlare`.
  63117. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63118. */
  63119. export class LensFlareSystem {
  63120. /**
  63121. * Define the name of the lens flare system
  63122. */
  63123. name: string;
  63124. /**
  63125. * List of lens flares used in this system.
  63126. */
  63127. lensFlares: LensFlare[];
  63128. /**
  63129. * Define a limit from the border the lens flare can be visible.
  63130. */
  63131. borderLimit: number;
  63132. /**
  63133. * Define a viewport border we do not want to see the lens flare in.
  63134. */
  63135. viewportBorder: number;
  63136. /**
  63137. * Define a predicate which could limit the list of meshes able to occlude the effect.
  63138. */
  63139. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  63140. /**
  63141. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  63142. */
  63143. layerMask: number;
  63144. /**
  63145. * Define the id of the lens flare system in the scene.
  63146. * (equal to name by default)
  63147. */
  63148. id: string;
  63149. private _scene;
  63150. private _emitter;
  63151. private _vertexBuffers;
  63152. private _indexBuffer;
  63153. private _effect;
  63154. private _positionX;
  63155. private _positionY;
  63156. private _isEnabled;
  63157. /** @hidden */
  63158. static _SceneComponentInitialization: (scene: Scene) => void;
  63159. /**
  63160. * Instantiates a lens flare system.
  63161. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  63162. * It is usually composed of several `lensFlare`.
  63163. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63164. * @param name Define the name of the lens flare system in the scene
  63165. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  63166. * @param scene Define the scene the lens flare system belongs to
  63167. */
  63168. constructor(
  63169. /**
  63170. * Define the name of the lens flare system
  63171. */
  63172. name: string, emitter: any, scene: Scene);
  63173. /**
  63174. * Define if the lens flare system is enabled.
  63175. */
  63176. get isEnabled(): boolean;
  63177. set isEnabled(value: boolean);
  63178. /**
  63179. * Get the scene the effects belongs to.
  63180. * @returns the scene holding the lens flare system
  63181. */
  63182. getScene(): Scene;
  63183. /**
  63184. * Get the emitter of the lens flare system.
  63185. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63186. * @returns the emitter of the lens flare system
  63187. */
  63188. getEmitter(): any;
  63189. /**
  63190. * Set the emitter of the lens flare system.
  63191. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  63192. * @param newEmitter Define the new emitter of the system
  63193. */
  63194. setEmitter(newEmitter: any): void;
  63195. /**
  63196. * Get the lens flare system emitter position.
  63197. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  63198. * @returns the position
  63199. */
  63200. getEmitterPosition(): Vector3;
  63201. /**
  63202. * @hidden
  63203. */
  63204. computeEffectivePosition(globalViewport: Viewport): boolean;
  63205. /** @hidden */
  63206. _isVisible(): boolean;
  63207. /**
  63208. * @hidden
  63209. */
  63210. render(): boolean;
  63211. /**
  63212. * Dispose and release the lens flare with its associated resources.
  63213. */
  63214. dispose(): void;
  63215. /**
  63216. * Parse a lens flare system from a JSON repressentation
  63217. * @param parsedLensFlareSystem Define the JSON to parse
  63218. * @param scene Define the scene the parsed system should be instantiated in
  63219. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  63220. * @returns the parsed system
  63221. */
  63222. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  63223. /**
  63224. * Serialize the current Lens Flare System into a JSON representation.
  63225. * @returns the serialized JSON
  63226. */
  63227. serialize(): any;
  63228. }
  63229. }
  63230. declare module "babylonjs/LensFlares/lensFlare" {
  63231. import { Nullable } from "babylonjs/types";
  63232. import { Color3 } from "babylonjs/Maths/math.color";
  63233. import { Texture } from "babylonjs/Materials/Textures/texture";
  63234. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63235. /**
  63236. * This represents one of the lens effect in a `lensFlareSystem`.
  63237. * It controls one of the indiviual texture used in the effect.
  63238. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63239. */
  63240. export class LensFlare {
  63241. /**
  63242. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63243. */
  63244. size: number;
  63245. /**
  63246. * 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.
  63247. */
  63248. position: number;
  63249. /**
  63250. * Define the lens color.
  63251. */
  63252. color: Color3;
  63253. /**
  63254. * Define the lens texture.
  63255. */
  63256. texture: Nullable<Texture>;
  63257. /**
  63258. * Define the alpha mode to render this particular lens.
  63259. */
  63260. alphaMode: number;
  63261. private _system;
  63262. /**
  63263. * Creates a new Lens Flare.
  63264. * This represents one of the lens effect in a `lensFlareSystem`.
  63265. * It controls one of the indiviual texture used in the effect.
  63266. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63267. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  63268. * @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.
  63269. * @param color Define the lens color
  63270. * @param imgUrl Define the lens texture url
  63271. * @param system Define the `lensFlareSystem` this flare is part of
  63272. * @returns The newly created Lens Flare
  63273. */
  63274. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  63275. /**
  63276. * Instantiates a new Lens Flare.
  63277. * This represents one of the lens effect in a `lensFlareSystem`.
  63278. * It controls one of the indiviual texture used in the effect.
  63279. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63280. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  63281. * @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.
  63282. * @param color Define the lens color
  63283. * @param imgUrl Define the lens texture url
  63284. * @param system Define the `lensFlareSystem` this flare is part of
  63285. */
  63286. constructor(
  63287. /**
  63288. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  63289. */
  63290. size: number,
  63291. /**
  63292. * 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.
  63293. */
  63294. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  63295. /**
  63296. * Dispose and release the lens flare with its associated resources.
  63297. */
  63298. dispose(): void;
  63299. }
  63300. }
  63301. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  63302. import { Nullable } from "babylonjs/types";
  63303. import { Scene } from "babylonjs/scene";
  63304. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63305. import { AbstractScene } from "babylonjs/abstractScene";
  63306. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  63307. module "babylonjs/abstractScene" {
  63308. interface AbstractScene {
  63309. /**
  63310. * The list of lens flare system added to the scene
  63311. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  63312. */
  63313. lensFlareSystems: Array<LensFlareSystem>;
  63314. /**
  63315. * Removes the given lens flare system from this scene.
  63316. * @param toRemove The lens flare system to remove
  63317. * @returns The index of the removed lens flare system
  63318. */
  63319. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  63320. /**
  63321. * Adds the given lens flare system to this scene
  63322. * @param newLensFlareSystem The lens flare system to add
  63323. */
  63324. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  63325. /**
  63326. * Gets a lens flare system using its name
  63327. * @param name defines the name to look for
  63328. * @returns the lens flare system or null if not found
  63329. */
  63330. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  63331. /**
  63332. * Gets a lens flare system using its id
  63333. * @param id defines the id to look for
  63334. * @returns the lens flare system or null if not found
  63335. */
  63336. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  63337. }
  63338. }
  63339. /**
  63340. * Defines the lens flare scene component responsible to manage any lens flares
  63341. * in a given scene.
  63342. */
  63343. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  63344. /**
  63345. * The component name helpfull to identify the component in the list of scene components.
  63346. */
  63347. readonly name: string;
  63348. /**
  63349. * The scene the component belongs to.
  63350. */
  63351. scene: Scene;
  63352. /**
  63353. * Creates a new instance of the component for the given scene
  63354. * @param scene Defines the scene to register the component in
  63355. */
  63356. constructor(scene: Scene);
  63357. /**
  63358. * Registers the component in a given scene
  63359. */
  63360. register(): void;
  63361. /**
  63362. * Rebuilds the elements related to this component in case of
  63363. * context lost for instance.
  63364. */
  63365. rebuild(): void;
  63366. /**
  63367. * Adds all the elements from the container to the scene
  63368. * @param container the container holding the elements
  63369. */
  63370. addFromContainer(container: AbstractScene): void;
  63371. /**
  63372. * Removes all the elements in the container from the scene
  63373. * @param container contains the elements to remove
  63374. * @param dispose if the removed element should be disposed (default: false)
  63375. */
  63376. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63377. /**
  63378. * Serializes the component data to the specified json object
  63379. * @param serializationObject The object to serialize to
  63380. */
  63381. serialize(serializationObject: any): void;
  63382. /**
  63383. * Disposes the component and the associated ressources.
  63384. */
  63385. dispose(): void;
  63386. private _draw;
  63387. }
  63388. }
  63389. declare module "babylonjs/LensFlares/index" {
  63390. export * from "babylonjs/LensFlares/lensFlare";
  63391. export * from "babylonjs/LensFlares/lensFlareSystem";
  63392. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  63393. }
  63394. declare module "babylonjs/Shaders/depth.fragment" {
  63395. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63396. /** @hidden */
  63397. export var depthPixelShader: {
  63398. name: string;
  63399. shader: string;
  63400. };
  63401. }
  63402. declare module "babylonjs/Shaders/depth.vertex" {
  63403. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  63404. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  63405. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  63406. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  63407. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  63408. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  63409. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  63410. /** @hidden */
  63411. export var depthVertexShader: {
  63412. name: string;
  63413. shader: string;
  63414. };
  63415. }
  63416. declare module "babylonjs/Rendering/depthRenderer" {
  63417. import { Nullable } from "babylonjs/types";
  63418. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63419. import { Scene } from "babylonjs/scene";
  63420. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63421. import { Camera } from "babylonjs/Cameras/camera";
  63422. import "babylonjs/Shaders/depth.fragment";
  63423. import "babylonjs/Shaders/depth.vertex";
  63424. /**
  63425. * This represents a depth renderer in Babylon.
  63426. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  63427. */
  63428. export class DepthRenderer {
  63429. private _scene;
  63430. private _depthMap;
  63431. private _effect;
  63432. private readonly _storeNonLinearDepth;
  63433. private readonly _clearColor;
  63434. /** Get if the depth renderer is using packed depth or not */
  63435. readonly isPacked: boolean;
  63436. private _cachedDefines;
  63437. private _camera;
  63438. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  63439. enabled: boolean;
  63440. /**
  63441. * Specifiess that the depth renderer will only be used within
  63442. * the camera it is created for.
  63443. * This can help forcing its rendering during the camera processing.
  63444. */
  63445. useOnlyInActiveCamera: boolean;
  63446. /** @hidden */
  63447. static _SceneComponentInitialization: (scene: Scene) => void;
  63448. /**
  63449. * Instantiates a depth renderer
  63450. * @param scene The scene the renderer belongs to
  63451. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  63452. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  63453. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  63454. */
  63455. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  63456. /**
  63457. * Creates the depth rendering effect and checks if the effect is ready.
  63458. * @param subMesh The submesh to be used to render the depth map of
  63459. * @param useInstances If multiple world instances should be used
  63460. * @returns if the depth renderer is ready to render the depth map
  63461. */
  63462. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  63463. /**
  63464. * Gets the texture which the depth map will be written to.
  63465. * @returns The depth map texture
  63466. */
  63467. getDepthMap(): RenderTargetTexture;
  63468. /**
  63469. * Disposes of the depth renderer.
  63470. */
  63471. dispose(): void;
  63472. }
  63473. }
  63474. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  63475. /** @hidden */
  63476. export var minmaxReduxPixelShader: {
  63477. name: string;
  63478. shader: string;
  63479. };
  63480. }
  63481. declare module "babylonjs/Misc/minMaxReducer" {
  63482. import { Nullable } from "babylonjs/types";
  63483. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63484. import { Camera } from "babylonjs/Cameras/camera";
  63485. import { Observer } from "babylonjs/Misc/observable";
  63486. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63487. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  63488. import { Observable } from "babylonjs/Misc/observable";
  63489. import "babylonjs/Shaders/minmaxRedux.fragment";
  63490. /**
  63491. * This class computes a min/max reduction from a texture: it means it computes the minimum
  63492. * and maximum values from all values of the texture.
  63493. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  63494. * The source values are read from the red channel of the texture.
  63495. */
  63496. export class MinMaxReducer {
  63497. /**
  63498. * Observable triggered when the computation has been performed
  63499. */
  63500. onAfterReductionPerformed: Observable<{
  63501. min: number;
  63502. max: number;
  63503. }>;
  63504. protected _camera: Camera;
  63505. protected _sourceTexture: Nullable<RenderTargetTexture>;
  63506. protected _reductionSteps: Nullable<Array<PostProcess>>;
  63507. protected _postProcessManager: PostProcessManager;
  63508. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  63509. protected _forceFullscreenViewport: boolean;
  63510. /**
  63511. * Creates a min/max reducer
  63512. * @param camera The camera to use for the post processes
  63513. */
  63514. constructor(camera: Camera);
  63515. /**
  63516. * Gets the texture used to read the values from.
  63517. */
  63518. get sourceTexture(): Nullable<RenderTargetTexture>;
  63519. /**
  63520. * Sets the source texture to read the values from.
  63521. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  63522. * because in such textures '1' value must not be taken into account to compute the maximum
  63523. * as this value is used to clear the texture.
  63524. * Note that the computation is not activated by calling this function, you must call activate() for that!
  63525. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  63526. * @param depthRedux Indicates if the texture is a depth texture or not
  63527. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  63528. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63529. */
  63530. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63531. /**
  63532. * Defines the refresh rate of the computation.
  63533. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63534. */
  63535. get refreshRate(): number;
  63536. set refreshRate(value: number);
  63537. protected _activated: boolean;
  63538. /**
  63539. * Gets the activation status of the reducer
  63540. */
  63541. get activated(): boolean;
  63542. /**
  63543. * Activates the reduction computation.
  63544. * When activated, the observers registered in onAfterReductionPerformed are
  63545. * called after the compuation is performed
  63546. */
  63547. activate(): void;
  63548. /**
  63549. * Deactivates the reduction computation.
  63550. */
  63551. deactivate(): void;
  63552. /**
  63553. * Disposes the min/max reducer
  63554. * @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.
  63555. */
  63556. dispose(disposeAll?: boolean): void;
  63557. }
  63558. }
  63559. declare module "babylonjs/Misc/depthReducer" {
  63560. import { Nullable } from "babylonjs/types";
  63561. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63562. import { Camera } from "babylonjs/Cameras/camera";
  63563. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63564. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  63565. /**
  63566. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  63567. */
  63568. export class DepthReducer extends MinMaxReducer {
  63569. private _depthRenderer;
  63570. private _depthRendererId;
  63571. /**
  63572. * Gets the depth renderer used for the computation.
  63573. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  63574. */
  63575. get depthRenderer(): Nullable<DepthRenderer>;
  63576. /**
  63577. * Creates a depth reducer
  63578. * @param camera The camera used to render the depth texture
  63579. */
  63580. constructor(camera: Camera);
  63581. /**
  63582. * Sets the depth renderer to use to generate the depth map
  63583. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  63584. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  63585. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  63586. */
  63587. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  63588. /** @hidden */
  63589. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  63590. /**
  63591. * Activates the reduction computation.
  63592. * When activated, the observers registered in onAfterReductionPerformed are
  63593. * called after the compuation is performed
  63594. */
  63595. activate(): void;
  63596. /**
  63597. * Deactivates the reduction computation.
  63598. */
  63599. deactivate(): void;
  63600. /**
  63601. * Disposes the depth reducer
  63602. * @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.
  63603. */
  63604. dispose(disposeAll?: boolean): void;
  63605. }
  63606. }
  63607. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  63608. import { Nullable } from "babylonjs/types";
  63609. import { Scene } from "babylonjs/scene";
  63610. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63611. import { SubMesh } from "babylonjs/Meshes/subMesh";
  63612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63613. import { Effect } from "babylonjs/Materials/effect";
  63614. import "babylonjs/Shaders/shadowMap.fragment";
  63615. import "babylonjs/Shaders/shadowMap.vertex";
  63616. import "babylonjs/Shaders/depthBoxBlur.fragment";
  63617. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  63618. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63619. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  63620. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  63621. /**
  63622. * A CSM implementation allowing casting shadows on large scenes.
  63623. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63624. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  63625. */
  63626. export class CascadedShadowGenerator extends ShadowGenerator {
  63627. private static readonly frustumCornersNDCSpace;
  63628. /**
  63629. * Name of the CSM class
  63630. */
  63631. static CLASSNAME: string;
  63632. /**
  63633. * Defines the default number of cascades used by the CSM.
  63634. */
  63635. static readonly DEFAULT_CASCADES_COUNT: number;
  63636. /**
  63637. * Defines the minimum number of cascades used by the CSM.
  63638. */
  63639. static readonly MIN_CASCADES_COUNT: number;
  63640. /**
  63641. * Defines the maximum number of cascades used by the CSM.
  63642. */
  63643. static readonly MAX_CASCADES_COUNT: number;
  63644. protected _validateFilter(filter: number): number;
  63645. /**
  63646. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  63647. */
  63648. penumbraDarkness: number;
  63649. private _numCascades;
  63650. /**
  63651. * Gets or set the number of cascades used by the CSM.
  63652. */
  63653. get numCascades(): number;
  63654. set numCascades(value: number);
  63655. /**
  63656. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  63657. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  63658. */
  63659. stabilizeCascades: boolean;
  63660. private _freezeShadowCastersBoundingInfo;
  63661. private _freezeShadowCastersBoundingInfoObservable;
  63662. /**
  63663. * Enables or disables the shadow casters bounding info computation.
  63664. * If your shadow casters don't move, you can disable this feature.
  63665. * If it is enabled, the bounding box computation is done every frame.
  63666. */
  63667. get freezeShadowCastersBoundingInfo(): boolean;
  63668. set freezeShadowCastersBoundingInfo(freeze: boolean);
  63669. private _scbiMin;
  63670. private _scbiMax;
  63671. protected _computeShadowCastersBoundingInfo(): void;
  63672. protected _shadowCastersBoundingInfo: BoundingInfo;
  63673. /**
  63674. * Gets or sets the shadow casters bounding info.
  63675. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  63676. * so that the system won't overwrite the bounds you provide
  63677. */
  63678. get shadowCastersBoundingInfo(): BoundingInfo;
  63679. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  63680. protected _breaksAreDirty: boolean;
  63681. protected _minDistance: number;
  63682. protected _maxDistance: number;
  63683. /**
  63684. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  63685. *
  63686. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  63687. * If you don't know these values, simply leave them to their defaults and don't call this function.
  63688. * @param min minimal distance for the breaks (default to 0.)
  63689. * @param max maximal distance for the breaks (default to 1.)
  63690. */
  63691. setMinMaxDistance(min: number, max: number): void;
  63692. /** Gets the minimal distance used in the cascade break computation */
  63693. get minDistance(): number;
  63694. /** Gets the maximal distance used in the cascade break computation */
  63695. get maxDistance(): number;
  63696. /**
  63697. * Gets the class name of that object
  63698. * @returns "CascadedShadowGenerator"
  63699. */
  63700. getClassName(): string;
  63701. private _cascadeMinExtents;
  63702. private _cascadeMaxExtents;
  63703. /**
  63704. * Gets a cascade minimum extents
  63705. * @param cascadeIndex index of the cascade
  63706. * @returns the minimum cascade extents
  63707. */
  63708. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  63709. /**
  63710. * Gets a cascade maximum extents
  63711. * @param cascadeIndex index of the cascade
  63712. * @returns the maximum cascade extents
  63713. */
  63714. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  63715. private _cascades;
  63716. private _currentLayer;
  63717. private _viewSpaceFrustumsZ;
  63718. private _viewMatrices;
  63719. private _projectionMatrices;
  63720. private _transformMatrices;
  63721. private _transformMatricesAsArray;
  63722. private _frustumLengths;
  63723. private _lightSizeUVCorrection;
  63724. private _depthCorrection;
  63725. private _frustumCornersWorldSpace;
  63726. private _frustumCenter;
  63727. private _shadowCameraPos;
  63728. private _shadowMaxZ;
  63729. /**
  63730. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  63731. * It defaults to camera.maxZ
  63732. */
  63733. get shadowMaxZ(): number;
  63734. /**
  63735. * Sets the shadow max z distance.
  63736. */
  63737. set shadowMaxZ(value: number);
  63738. protected _debug: boolean;
  63739. /**
  63740. * Gets or sets the debug flag.
  63741. * When enabled, the cascades are materialized by different colors on the screen.
  63742. */
  63743. get debug(): boolean;
  63744. set debug(dbg: boolean);
  63745. private _depthClamp;
  63746. /**
  63747. * Gets or sets the depth clamping value.
  63748. *
  63749. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  63750. * to account for the shadow casters far away.
  63751. *
  63752. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  63753. */
  63754. get depthClamp(): boolean;
  63755. set depthClamp(value: boolean);
  63756. private _cascadeBlendPercentage;
  63757. /**
  63758. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  63759. * It defaults to 0.1 (10% blending).
  63760. */
  63761. get cascadeBlendPercentage(): number;
  63762. set cascadeBlendPercentage(value: number);
  63763. private _lambda;
  63764. /**
  63765. * Gets or set the lambda parameter.
  63766. * This parameter is used to split the camera frustum and create the cascades.
  63767. * 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.
  63768. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  63769. */
  63770. get lambda(): number;
  63771. set lambda(value: number);
  63772. /**
  63773. * Gets the view matrix corresponding to a given cascade
  63774. * @param cascadeNum cascade to retrieve the view matrix from
  63775. * @returns the cascade view matrix
  63776. */
  63777. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  63778. /**
  63779. * Gets the projection matrix corresponding to a given cascade
  63780. * @param cascadeNum cascade to retrieve the projection matrix from
  63781. * @returns the cascade projection matrix
  63782. */
  63783. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  63784. /**
  63785. * Gets the transformation matrix corresponding to a given cascade
  63786. * @param cascadeNum cascade to retrieve the transformation matrix from
  63787. * @returns the cascade transformation matrix
  63788. */
  63789. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  63790. private _depthRenderer;
  63791. /**
  63792. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  63793. *
  63794. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  63795. *
  63796. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  63797. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63798. * @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
  63799. */
  63800. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63801. private _depthReducer;
  63802. private _autoCalcDepthBounds;
  63803. /**
  63804. * Gets or sets the autoCalcDepthBounds property.
  63805. *
  63806. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63807. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63808. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63809. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63810. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63811. */
  63812. get autoCalcDepthBounds(): boolean;
  63813. set autoCalcDepthBounds(value: boolean);
  63814. /**
  63815. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63816. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63817. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63818. * for setting the refresh rate on the renderer yourself!
  63819. */
  63820. get autoCalcDepthBoundsRefreshRate(): number;
  63821. set autoCalcDepthBoundsRefreshRate(value: number);
  63822. /**
  63823. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63824. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63825. * you change the camera near/far planes!
  63826. */
  63827. splitFrustum(): void;
  63828. private _splitFrustum;
  63829. private _computeMatrices;
  63830. private _computeFrustumInWorldSpace;
  63831. private _computeCascadeFrustum;
  63832. /**
  63833. * Support test.
  63834. */
  63835. static get IsSupported(): boolean;
  63836. /** @hidden */
  63837. static _SceneComponentInitialization: (scene: Scene) => void;
  63838. /**
  63839. * Creates a Cascaded Shadow Generator object.
  63840. * A ShadowGenerator is the required tool to use the shadows.
  63841. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63842. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63843. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63844. * @param light The directional light object generating the shadows.
  63845. * @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.
  63846. */
  63847. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63848. protected _initializeGenerator(): void;
  63849. protected _createTargetRenderTexture(): void;
  63850. protected _initializeShadowMap(): void;
  63851. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63852. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63853. /**
  63854. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63855. * @param defines Defines of the material we want to update
  63856. * @param lightIndex Index of the light in the enabled light list of the material
  63857. */
  63858. prepareDefines(defines: any, lightIndex: number): void;
  63859. /**
  63860. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63861. * defined in the generator but impacting the effect).
  63862. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63863. * @param effect The effect we are binfing the information for
  63864. */
  63865. bindShadowLight(lightIndex: string, effect: Effect): void;
  63866. /**
  63867. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63868. * (eq to view projection * shadow projection matrices)
  63869. * @returns The transform matrix used to create the shadow map
  63870. */
  63871. getTransformMatrix(): Matrix;
  63872. /**
  63873. * Disposes the ShadowGenerator.
  63874. * Returns nothing.
  63875. */
  63876. dispose(): void;
  63877. /**
  63878. * Serializes the shadow generator setup to a json object.
  63879. * @returns The serialized JSON object
  63880. */
  63881. serialize(): any;
  63882. /**
  63883. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63884. * @param parsedShadowGenerator The JSON object to parse
  63885. * @param scene The scene to create the shadow map for
  63886. * @returns The parsed shadow generator
  63887. */
  63888. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63889. }
  63890. }
  63891. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63892. import { Scene } from "babylonjs/scene";
  63893. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63894. import { AbstractScene } from "babylonjs/abstractScene";
  63895. /**
  63896. * Defines the shadow generator component responsible to manage any shadow generators
  63897. * in a given scene.
  63898. */
  63899. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63900. /**
  63901. * The component name helpfull to identify the component in the list of scene components.
  63902. */
  63903. readonly name: string;
  63904. /**
  63905. * The scene the component belongs to.
  63906. */
  63907. scene: Scene;
  63908. /**
  63909. * Creates a new instance of the component for the given scene
  63910. * @param scene Defines the scene to register the component in
  63911. */
  63912. constructor(scene: Scene);
  63913. /**
  63914. * Registers the component in a given scene
  63915. */
  63916. register(): void;
  63917. /**
  63918. * Rebuilds the elements related to this component in case of
  63919. * context lost for instance.
  63920. */
  63921. rebuild(): void;
  63922. /**
  63923. * Serializes the component data to the specified json object
  63924. * @param serializationObject The object to serialize to
  63925. */
  63926. serialize(serializationObject: any): void;
  63927. /**
  63928. * Adds all the elements from the container to the scene
  63929. * @param container the container holding the elements
  63930. */
  63931. addFromContainer(container: AbstractScene): void;
  63932. /**
  63933. * Removes all the elements in the container from the scene
  63934. * @param container contains the elements to remove
  63935. * @param dispose if the removed element should be disposed (default: false)
  63936. */
  63937. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63938. /**
  63939. * Rebuilds the elements related to this component in case of
  63940. * context lost for instance.
  63941. */
  63942. dispose(): void;
  63943. private _gatherRenderTargets;
  63944. }
  63945. }
  63946. declare module "babylonjs/Lights/Shadows/index" {
  63947. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63948. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63949. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63950. }
  63951. declare module "babylonjs/Lights/pointLight" {
  63952. import { Scene } from "babylonjs/scene";
  63953. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63954. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63955. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63956. import { Effect } from "babylonjs/Materials/effect";
  63957. /**
  63958. * A point light is a light defined by an unique point in world space.
  63959. * The light is emitted in every direction from this point.
  63960. * A good example of a point light is a standard light bulb.
  63961. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63962. */
  63963. export class PointLight extends ShadowLight {
  63964. private _shadowAngle;
  63965. /**
  63966. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63967. * This specifies what angle the shadow will use to be created.
  63968. *
  63969. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63970. */
  63971. get shadowAngle(): number;
  63972. /**
  63973. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63974. * This specifies what angle the shadow will use to be created.
  63975. *
  63976. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63977. */
  63978. set shadowAngle(value: number);
  63979. /**
  63980. * Gets the direction if it has been set.
  63981. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63982. */
  63983. get direction(): Vector3;
  63984. /**
  63985. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63986. */
  63987. set direction(value: Vector3);
  63988. /**
  63989. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63990. * A PointLight emits the light in every direction.
  63991. * It can cast shadows.
  63992. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63993. * ```javascript
  63994. * var pointLight = new PointLight("pl", camera.position, scene);
  63995. * ```
  63996. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63997. * @param name The light friendly name
  63998. * @param position The position of the point light in the scene
  63999. * @param scene The scene the lights belongs to
  64000. */
  64001. constructor(name: string, position: Vector3, scene: Scene);
  64002. /**
  64003. * Returns the string "PointLight"
  64004. * @returns the class name
  64005. */
  64006. getClassName(): string;
  64007. /**
  64008. * Returns the integer 0.
  64009. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  64010. */
  64011. getTypeID(): number;
  64012. /**
  64013. * Specifies wether or not the shadowmap should be a cube texture.
  64014. * @returns true if the shadowmap needs to be a cube texture.
  64015. */
  64016. needCube(): boolean;
  64017. /**
  64018. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  64019. * @param faceIndex The index of the face we are computed the direction to generate shadow
  64020. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  64021. */
  64022. getShadowDirection(faceIndex?: number): Vector3;
  64023. /**
  64024. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  64025. * - fov = PI / 2
  64026. * - aspect ratio : 1.0
  64027. * - z-near and far equal to the active camera minZ and maxZ.
  64028. * Returns the PointLight.
  64029. */
  64030. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  64031. protected _buildUniformLayout(): void;
  64032. /**
  64033. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  64034. * @param effect The effect to update
  64035. * @param lightIndex The index of the light in the effect to update
  64036. * @returns The point light
  64037. */
  64038. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  64039. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  64040. /**
  64041. * Prepares the list of defines specific to the light type.
  64042. * @param defines the list of defines
  64043. * @param lightIndex defines the index of the light for the effect
  64044. */
  64045. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  64046. }
  64047. }
  64048. declare module "babylonjs/Lights/index" {
  64049. export * from "babylonjs/Lights/light";
  64050. export * from "babylonjs/Lights/shadowLight";
  64051. export * from "babylonjs/Lights/Shadows/index";
  64052. export * from "babylonjs/Lights/directionalLight";
  64053. export * from "babylonjs/Lights/hemisphericLight";
  64054. export * from "babylonjs/Lights/pointLight";
  64055. export * from "babylonjs/Lights/spotLight";
  64056. }
  64057. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  64058. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  64059. /**
  64060. * Header information of HDR texture files.
  64061. */
  64062. export interface HDRInfo {
  64063. /**
  64064. * The height of the texture in pixels.
  64065. */
  64066. height: number;
  64067. /**
  64068. * The width of the texture in pixels.
  64069. */
  64070. width: number;
  64071. /**
  64072. * The index of the beginning of the data in the binary file.
  64073. */
  64074. dataPosition: number;
  64075. }
  64076. /**
  64077. * This groups tools to convert HDR texture to native colors array.
  64078. */
  64079. export class HDRTools {
  64080. private static Ldexp;
  64081. private static Rgbe2float;
  64082. private static readStringLine;
  64083. /**
  64084. * Reads header information from an RGBE texture stored in a native array.
  64085. * More information on this format are available here:
  64086. * https://en.wikipedia.org/wiki/RGBE_image_format
  64087. *
  64088. * @param uint8array The binary file stored in native array.
  64089. * @return The header information.
  64090. */
  64091. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  64092. /**
  64093. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  64094. * This RGBE texture needs to store the information as a panorama.
  64095. *
  64096. * More information on this format are available here:
  64097. * https://en.wikipedia.org/wiki/RGBE_image_format
  64098. *
  64099. * @param buffer The binary file stored in an array buffer.
  64100. * @param size The expected size of the extracted cubemap.
  64101. * @return The Cube Map information.
  64102. */
  64103. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  64104. /**
  64105. * Returns the pixels data extracted from an RGBE texture.
  64106. * This pixels will be stored left to right up to down in the R G B order in one array.
  64107. *
  64108. * More information on this format are available here:
  64109. * https://en.wikipedia.org/wiki/RGBE_image_format
  64110. *
  64111. * @param uint8array The binary file stored in an array buffer.
  64112. * @param hdrInfo The header information of the file.
  64113. * @return The pixels data in RGB right to left up to down order.
  64114. */
  64115. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  64116. private static RGBE_ReadPixels_RLE;
  64117. private static RGBE_ReadPixels_NOT_RLE;
  64118. }
  64119. }
  64120. declare module "babylonjs/Materials/effectRenderer" {
  64121. import { Nullable } from "babylonjs/types";
  64122. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64123. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64124. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64125. import { Viewport } from "babylonjs/Maths/math.viewport";
  64126. import { Observable } from "babylonjs/Misc/observable";
  64127. import { Effect } from "babylonjs/Materials/effect";
  64128. import "babylonjs/Shaders/postprocess.vertex";
  64129. /**
  64130. * Effect Render Options
  64131. */
  64132. export interface IEffectRendererOptions {
  64133. /**
  64134. * Defines the vertices positions.
  64135. */
  64136. positions?: number[];
  64137. /**
  64138. * Defines the indices.
  64139. */
  64140. indices?: number[];
  64141. }
  64142. /**
  64143. * Helper class to render one or more effects.
  64144. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  64145. */
  64146. export class EffectRenderer {
  64147. private engine;
  64148. private static _DefaultOptions;
  64149. private _vertexBuffers;
  64150. private _indexBuffer;
  64151. private _fullscreenViewport;
  64152. /**
  64153. * Creates an effect renderer
  64154. * @param engine the engine to use for rendering
  64155. * @param options defines the options of the effect renderer
  64156. */
  64157. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  64158. /**
  64159. * Sets the current viewport in normalized coordinates 0-1
  64160. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  64161. */
  64162. setViewport(viewport?: Viewport): void;
  64163. /**
  64164. * Binds the embedded attributes buffer to the effect.
  64165. * @param effect Defines the effect to bind the attributes for
  64166. */
  64167. bindBuffers(effect: Effect): void;
  64168. /**
  64169. * Sets the current effect wrapper to use during draw.
  64170. * The effect needs to be ready before calling this api.
  64171. * This also sets the default full screen position attribute.
  64172. * @param effectWrapper Defines the effect to draw with
  64173. */
  64174. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  64175. /**
  64176. * Restores engine states
  64177. */
  64178. restoreStates(): void;
  64179. /**
  64180. * Draws a full screen quad.
  64181. */
  64182. draw(): void;
  64183. private isRenderTargetTexture;
  64184. /**
  64185. * renders one or more effects to a specified texture
  64186. * @param effectWrapper the effect to renderer
  64187. * @param outputTexture texture to draw to, if null it will render to the screen.
  64188. */
  64189. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  64190. /**
  64191. * Disposes of the effect renderer
  64192. */
  64193. dispose(): void;
  64194. }
  64195. /**
  64196. * Options to create an EffectWrapper
  64197. */
  64198. interface EffectWrapperCreationOptions {
  64199. /**
  64200. * Engine to use to create the effect
  64201. */
  64202. engine: ThinEngine;
  64203. /**
  64204. * Fragment shader for the effect
  64205. */
  64206. fragmentShader: string;
  64207. /**
  64208. * Use the shader store instead of direct source code
  64209. */
  64210. useShaderStore?: boolean;
  64211. /**
  64212. * Vertex shader for the effect
  64213. */
  64214. vertexShader?: string;
  64215. /**
  64216. * Attributes to use in the shader
  64217. */
  64218. attributeNames?: Array<string>;
  64219. /**
  64220. * Uniforms to use in the shader
  64221. */
  64222. uniformNames?: Array<string>;
  64223. /**
  64224. * Texture sampler names to use in the shader
  64225. */
  64226. samplerNames?: Array<string>;
  64227. /**
  64228. * Defines to use in the shader
  64229. */
  64230. defines?: Array<string>;
  64231. /**
  64232. * Callback when effect is compiled
  64233. */
  64234. onCompiled?: Nullable<(effect: Effect) => void>;
  64235. /**
  64236. * The friendly name of the effect displayed in Spector.
  64237. */
  64238. name?: string;
  64239. }
  64240. /**
  64241. * Wraps an effect to be used for rendering
  64242. */
  64243. export class EffectWrapper {
  64244. /**
  64245. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  64246. */
  64247. onApplyObservable: Observable<{}>;
  64248. /**
  64249. * The underlying effect
  64250. */
  64251. effect: Effect;
  64252. /**
  64253. * Creates an effect to be renderer
  64254. * @param creationOptions options to create the effect
  64255. */
  64256. constructor(creationOptions: EffectWrapperCreationOptions);
  64257. /**
  64258. * Disposes of the effect wrapper
  64259. */
  64260. dispose(): void;
  64261. }
  64262. }
  64263. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  64264. /** @hidden */
  64265. export var hdrFilteringVertexShader: {
  64266. name: string;
  64267. shader: string;
  64268. };
  64269. }
  64270. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  64271. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64272. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  64273. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  64274. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  64275. /** @hidden */
  64276. export var hdrFilteringPixelShader: {
  64277. name: string;
  64278. shader: string;
  64279. };
  64280. }
  64281. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  64282. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64283. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64284. import { Nullable } from "babylonjs/types";
  64285. import "babylonjs/Shaders/hdrFiltering.vertex";
  64286. import "babylonjs/Shaders/hdrFiltering.fragment";
  64287. /**
  64288. * Options for texture filtering
  64289. */
  64290. interface IHDRFilteringOptions {
  64291. /**
  64292. * Scales pixel intensity for the input HDR map.
  64293. */
  64294. hdrScale?: number;
  64295. /**
  64296. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  64297. */
  64298. quality?: number;
  64299. }
  64300. /**
  64301. * Filters HDR maps to get correct renderings of PBR reflections
  64302. */
  64303. export class HDRFiltering {
  64304. private _engine;
  64305. private _effectRenderer;
  64306. private _effectWrapper;
  64307. private _lodGenerationOffset;
  64308. private _lodGenerationScale;
  64309. /**
  64310. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  64311. * you care about baking speed.
  64312. */
  64313. quality: number;
  64314. /**
  64315. * Scales pixel intensity for the input HDR map.
  64316. */
  64317. hdrScale: number;
  64318. /**
  64319. * Instantiates HDR filter for reflection maps
  64320. *
  64321. * @param engine Thin engine
  64322. * @param options Options
  64323. */
  64324. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  64325. private _createRenderTarget;
  64326. private _prefilterInternal;
  64327. private _createEffect;
  64328. /**
  64329. * Get a value indicating if the filter is ready to be used
  64330. * @param texture Texture to filter
  64331. * @returns true if the filter is ready
  64332. */
  64333. isReady(texture: BaseTexture): boolean;
  64334. /**
  64335. * Prefilters a cube texture to have mipmap levels representing roughness values.
  64336. * Prefiltering will be invoked at the end of next rendering pass.
  64337. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  64338. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  64339. * @param texture Texture to filter
  64340. * @param onFinished Callback when filtering is done
  64341. * @return Promise called when prefiltering is done
  64342. */
  64343. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  64344. }
  64345. }
  64346. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  64347. import { Nullable } from "babylonjs/types";
  64348. import { Scene } from "babylonjs/scene";
  64349. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64350. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64351. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64352. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64353. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  64354. /**
  64355. * This represents a texture coming from an HDR input.
  64356. *
  64357. * The only supported format is currently panorama picture stored in RGBE format.
  64358. * Example of such files can be found on HDRLib: http://hdrlib.com/
  64359. */
  64360. export class HDRCubeTexture extends BaseTexture {
  64361. private static _facesMapping;
  64362. private _generateHarmonics;
  64363. private _noMipmap;
  64364. private _prefilterOnLoad;
  64365. private _textureMatrix;
  64366. private _size;
  64367. private _onLoad;
  64368. private _onError;
  64369. /**
  64370. * The texture URL.
  64371. */
  64372. url: string;
  64373. protected _isBlocking: boolean;
  64374. /**
  64375. * Sets wether or not the texture is blocking during loading.
  64376. */
  64377. set isBlocking(value: boolean);
  64378. /**
  64379. * Gets wether or not the texture is blocking during loading.
  64380. */
  64381. get isBlocking(): boolean;
  64382. protected _rotationY: number;
  64383. /**
  64384. * Sets texture matrix rotation angle around Y axis in radians.
  64385. */
  64386. set rotationY(value: number);
  64387. /**
  64388. * Gets texture matrix rotation angle around Y axis radians.
  64389. */
  64390. get rotationY(): number;
  64391. /**
  64392. * Gets or sets the center of the bounding box associated with the cube texture
  64393. * It must define where the camera used to render the texture was set
  64394. */
  64395. boundingBoxPosition: Vector3;
  64396. private _boundingBoxSize;
  64397. /**
  64398. * Gets or sets the size of the bounding box associated with the cube texture
  64399. * When defined, the cubemap will switch to local mode
  64400. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  64401. * @example https://www.babylonjs-playground.com/#RNASML
  64402. */
  64403. set boundingBoxSize(value: Vector3);
  64404. get boundingBoxSize(): Vector3;
  64405. /**
  64406. * Instantiates an HDRTexture from the following parameters.
  64407. *
  64408. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  64409. * @param sceneOrEngine The scene or engine the texture will be used in
  64410. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64411. * @param noMipmap Forces to not generate the mipmap if true
  64412. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  64413. * @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)
  64414. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  64415. */
  64416. 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>);
  64417. /**
  64418. * Get the current class name of the texture useful for serialization or dynamic coding.
  64419. * @returns "HDRCubeTexture"
  64420. */
  64421. getClassName(): string;
  64422. /**
  64423. * Occurs when the file is raw .hdr file.
  64424. */
  64425. private loadTexture;
  64426. clone(): HDRCubeTexture;
  64427. delayLoad(): void;
  64428. /**
  64429. * Get the texture reflection matrix used to rotate/transform the reflection.
  64430. * @returns the reflection matrix
  64431. */
  64432. getReflectionTextureMatrix(): Matrix;
  64433. /**
  64434. * Set the texture reflection matrix used to rotate/transform the reflection.
  64435. * @param value Define the reflection matrix to set
  64436. */
  64437. setReflectionTextureMatrix(value: Matrix): void;
  64438. /**
  64439. * Parses a JSON representation of an HDR Texture in order to create the texture
  64440. * @param parsedTexture Define the JSON representation
  64441. * @param scene Define the scene the texture should be created in
  64442. * @param rootUrl Define the root url in case we need to load relative dependencies
  64443. * @returns the newly created texture after parsing
  64444. */
  64445. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  64446. serialize(): any;
  64447. }
  64448. }
  64449. declare module "babylonjs/Physics/physicsEngine" {
  64450. import { Nullable } from "babylonjs/types";
  64451. import { Vector3 } from "babylonjs/Maths/math.vector";
  64452. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  64453. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  64454. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  64455. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64456. /**
  64457. * Class used to control physics engine
  64458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64459. */
  64460. export class PhysicsEngine implements IPhysicsEngine {
  64461. private _physicsPlugin;
  64462. /**
  64463. * Global value used to control the smallest number supported by the simulation
  64464. */
  64465. static Epsilon: number;
  64466. private _impostors;
  64467. private _joints;
  64468. private _subTimeStep;
  64469. /**
  64470. * Gets the gravity vector used by the simulation
  64471. */
  64472. gravity: Vector3;
  64473. /**
  64474. * Factory used to create the default physics plugin.
  64475. * @returns The default physics plugin
  64476. */
  64477. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  64478. /**
  64479. * Creates a new Physics Engine
  64480. * @param gravity defines the gravity vector used by the simulation
  64481. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  64482. */
  64483. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  64484. /**
  64485. * Sets the gravity vector used by the simulation
  64486. * @param gravity defines the gravity vector to use
  64487. */
  64488. setGravity(gravity: Vector3): void;
  64489. /**
  64490. * Set the time step of the physics engine.
  64491. * Default is 1/60.
  64492. * To slow it down, enter 1/600 for example.
  64493. * To speed it up, 1/30
  64494. * @param newTimeStep defines the new timestep to apply to this world.
  64495. */
  64496. setTimeStep(newTimeStep?: number): void;
  64497. /**
  64498. * Get the time step of the physics engine.
  64499. * @returns the current time step
  64500. */
  64501. getTimeStep(): number;
  64502. /**
  64503. * Set the sub time step of the physics engine.
  64504. * Default is 0 meaning there is no sub steps
  64505. * To increase physics resolution precision, set a small value (like 1 ms)
  64506. * @param subTimeStep defines the new sub timestep used for physics resolution.
  64507. */
  64508. setSubTimeStep(subTimeStep?: number): void;
  64509. /**
  64510. * Get the sub time step of the physics engine.
  64511. * @returns the current sub time step
  64512. */
  64513. getSubTimeStep(): number;
  64514. /**
  64515. * Release all resources
  64516. */
  64517. dispose(): void;
  64518. /**
  64519. * Gets the name of the current physics plugin
  64520. * @returns the name of the plugin
  64521. */
  64522. getPhysicsPluginName(): string;
  64523. /**
  64524. * Adding a new impostor for the impostor tracking.
  64525. * This will be done by the impostor itself.
  64526. * @param impostor the impostor to add
  64527. */
  64528. addImpostor(impostor: PhysicsImpostor): void;
  64529. /**
  64530. * Remove an impostor from the engine.
  64531. * This impostor and its mesh will not longer be updated by the physics engine.
  64532. * @param impostor the impostor to remove
  64533. */
  64534. removeImpostor(impostor: PhysicsImpostor): void;
  64535. /**
  64536. * Add a joint to the physics engine
  64537. * @param mainImpostor defines the main impostor to which the joint is added.
  64538. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  64539. * @param joint defines the joint that will connect both impostors.
  64540. */
  64541. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64542. /**
  64543. * Removes a joint from the simulation
  64544. * @param mainImpostor defines the impostor used with the joint
  64545. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  64546. * @param joint defines the joint to remove
  64547. */
  64548. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  64549. /**
  64550. * Called by the scene. No need to call it.
  64551. * @param delta defines the timespam between frames
  64552. */
  64553. _step(delta: number): void;
  64554. /**
  64555. * Gets the current plugin used to run the simulation
  64556. * @returns current plugin
  64557. */
  64558. getPhysicsPlugin(): IPhysicsEnginePlugin;
  64559. /**
  64560. * Gets the list of physic impostors
  64561. * @returns an array of PhysicsImpostor
  64562. */
  64563. getImpostors(): Array<PhysicsImpostor>;
  64564. /**
  64565. * Gets the impostor for a physics enabled object
  64566. * @param object defines the object impersonated by the impostor
  64567. * @returns the PhysicsImpostor or null if not found
  64568. */
  64569. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  64570. /**
  64571. * Gets the impostor for a physics body object
  64572. * @param body defines physics body used by the impostor
  64573. * @returns the PhysicsImpostor or null if not found
  64574. */
  64575. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  64576. /**
  64577. * Does a raycast in the physics world
  64578. * @param from when should the ray start?
  64579. * @param to when should the ray end?
  64580. * @returns PhysicsRaycastResult
  64581. */
  64582. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64583. }
  64584. }
  64585. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  64586. import { Nullable } from "babylonjs/types";
  64587. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64588. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64589. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64590. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64591. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64592. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64593. /** @hidden */
  64594. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  64595. private _useDeltaForWorldStep;
  64596. world: any;
  64597. name: string;
  64598. private _physicsMaterials;
  64599. private _fixedTimeStep;
  64600. private _cannonRaycastResult;
  64601. private _raycastResult;
  64602. private _physicsBodysToRemoveAfterStep;
  64603. private _firstFrame;
  64604. BJSCANNON: any;
  64605. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  64606. setGravity(gravity: Vector3): void;
  64607. setTimeStep(timeStep: number): void;
  64608. getTimeStep(): number;
  64609. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64610. private _removeMarkedPhysicsBodiesFromWorld;
  64611. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64612. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64613. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64614. private _processChildMeshes;
  64615. removePhysicsBody(impostor: PhysicsImpostor): void;
  64616. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64617. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64618. private _addMaterial;
  64619. private _checkWithEpsilon;
  64620. private _createShape;
  64621. private _createHeightmap;
  64622. private _minus90X;
  64623. private _plus90X;
  64624. private _tmpPosition;
  64625. private _tmpDeltaPosition;
  64626. private _tmpUnityRotation;
  64627. private _updatePhysicsBodyTransformation;
  64628. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64629. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64630. isSupported(): boolean;
  64631. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64632. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64633. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64634. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64635. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64636. getBodyMass(impostor: PhysicsImpostor): number;
  64637. getBodyFriction(impostor: PhysicsImpostor): number;
  64638. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64639. getBodyRestitution(impostor: PhysicsImpostor): number;
  64640. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64641. sleepBody(impostor: PhysicsImpostor): void;
  64642. wakeUpBody(impostor: PhysicsImpostor): void;
  64643. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  64644. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64645. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64646. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64647. getRadius(impostor: PhysicsImpostor): number;
  64648. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64649. dispose(): void;
  64650. private _extendNamespace;
  64651. /**
  64652. * Does a raycast in the physics world
  64653. * @param from when should the ray start?
  64654. * @param to when should the ray end?
  64655. * @returns PhysicsRaycastResult
  64656. */
  64657. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64658. }
  64659. }
  64660. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  64661. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64662. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64663. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64665. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  64666. import { Nullable } from "babylonjs/types";
  64667. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64668. /** @hidden */
  64669. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  64670. private _useDeltaForWorldStep;
  64671. world: any;
  64672. name: string;
  64673. BJSOIMO: any;
  64674. private _raycastResult;
  64675. private _fixedTimeStep;
  64676. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  64677. setGravity(gravity: Vector3): void;
  64678. setTimeStep(timeStep: number): void;
  64679. getTimeStep(): number;
  64680. private _tmpImpostorsArray;
  64681. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64682. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64683. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64684. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64685. private _tmpPositionVector;
  64686. removePhysicsBody(impostor: PhysicsImpostor): void;
  64687. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64688. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64689. isSupported(): boolean;
  64690. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64691. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64692. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64693. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64694. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64695. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64696. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64697. getBodyMass(impostor: PhysicsImpostor): number;
  64698. getBodyFriction(impostor: PhysicsImpostor): number;
  64699. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64700. getBodyRestitution(impostor: PhysicsImpostor): number;
  64701. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64702. sleepBody(impostor: PhysicsImpostor): void;
  64703. wakeUpBody(impostor: PhysicsImpostor): void;
  64704. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64705. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  64706. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  64707. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64708. getRadius(impostor: PhysicsImpostor): number;
  64709. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64710. dispose(): void;
  64711. /**
  64712. * Does a raycast in the physics world
  64713. * @param from when should the ray start?
  64714. * @param to when should the ray end?
  64715. * @returns PhysicsRaycastResult
  64716. */
  64717. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64718. }
  64719. }
  64720. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  64721. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  64722. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  64723. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  64724. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  64725. import { Nullable } from "babylonjs/types";
  64726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64727. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  64728. /**
  64729. * AmmoJS Physics plugin
  64730. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  64731. * @see https://github.com/kripken/ammo.js/
  64732. */
  64733. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  64734. private _useDeltaForWorldStep;
  64735. /**
  64736. * Reference to the Ammo library
  64737. */
  64738. bjsAMMO: any;
  64739. /**
  64740. * Created ammoJS world which physics bodies are added to
  64741. */
  64742. world: any;
  64743. /**
  64744. * Name of the plugin
  64745. */
  64746. name: string;
  64747. private _timeStep;
  64748. private _fixedTimeStep;
  64749. private _maxSteps;
  64750. private _tmpQuaternion;
  64751. private _tmpAmmoTransform;
  64752. private _tmpAmmoQuaternion;
  64753. private _tmpAmmoConcreteContactResultCallback;
  64754. private _collisionConfiguration;
  64755. private _dispatcher;
  64756. private _overlappingPairCache;
  64757. private _solver;
  64758. private _softBodySolver;
  64759. private _tmpAmmoVectorA;
  64760. private _tmpAmmoVectorB;
  64761. private _tmpAmmoVectorC;
  64762. private _tmpAmmoVectorD;
  64763. private _tmpContactCallbackResult;
  64764. private _tmpAmmoVectorRCA;
  64765. private _tmpAmmoVectorRCB;
  64766. private _raycastResult;
  64767. private _tmpContactPoint;
  64768. private static readonly DISABLE_COLLISION_FLAG;
  64769. private static readonly KINEMATIC_FLAG;
  64770. private static readonly DISABLE_DEACTIVATION_FLAG;
  64771. /**
  64772. * Initializes the ammoJS plugin
  64773. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  64774. * @param ammoInjection can be used to inject your own ammo reference
  64775. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  64776. */
  64777. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  64778. /**
  64779. * Sets the gravity of the physics world (m/(s^2))
  64780. * @param gravity Gravity to set
  64781. */
  64782. setGravity(gravity: Vector3): void;
  64783. /**
  64784. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  64785. * @param timeStep timestep to use in seconds
  64786. */
  64787. setTimeStep(timeStep: number): void;
  64788. /**
  64789. * 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)
  64790. * @param fixedTimeStep fixedTimeStep to use in seconds
  64791. */
  64792. setFixedTimeStep(fixedTimeStep: number): void;
  64793. /**
  64794. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  64795. * @param maxSteps the maximum number of steps by the physics engine per frame
  64796. */
  64797. setMaxSteps(maxSteps: number): void;
  64798. /**
  64799. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64800. * @returns the current timestep in seconds
  64801. */
  64802. getTimeStep(): number;
  64803. /**
  64804. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64805. */
  64806. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64807. private _isImpostorInContact;
  64808. private _isImpostorPairInContact;
  64809. private _stepSimulation;
  64810. /**
  64811. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64812. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64813. * After the step the babylon meshes are set to the position of the physics imposters
  64814. * @param delta amount of time to step forward
  64815. * @param impostors array of imposters to update before/after the step
  64816. */
  64817. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64818. /**
  64819. * Update babylon mesh to match physics world object
  64820. * @param impostor imposter to match
  64821. */
  64822. private _afterSoftStep;
  64823. /**
  64824. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64825. * @param impostor imposter to match
  64826. */
  64827. private _ropeStep;
  64828. /**
  64829. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64830. * @param impostor imposter to match
  64831. */
  64832. private _softbodyOrClothStep;
  64833. private _tmpMatrix;
  64834. /**
  64835. * Applies an impulse on the imposter
  64836. * @param impostor imposter to apply impulse to
  64837. * @param force amount of force to be applied to the imposter
  64838. * @param contactPoint the location to apply the impulse on the imposter
  64839. */
  64840. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64841. /**
  64842. * Applies a force on the imposter
  64843. * @param impostor imposter to apply force
  64844. * @param force amount of force to be applied to the imposter
  64845. * @param contactPoint the location to apply the force on the imposter
  64846. */
  64847. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64848. /**
  64849. * Creates a physics body using the plugin
  64850. * @param impostor the imposter to create the physics body on
  64851. */
  64852. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64853. /**
  64854. * Removes the physics body from the imposter and disposes of the body's memory
  64855. * @param impostor imposter to remove the physics body from
  64856. */
  64857. removePhysicsBody(impostor: PhysicsImpostor): void;
  64858. /**
  64859. * Generates a joint
  64860. * @param impostorJoint the imposter joint to create the joint with
  64861. */
  64862. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64863. /**
  64864. * Removes a joint
  64865. * @param impostorJoint the imposter joint to remove the joint from
  64866. */
  64867. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64868. private _addMeshVerts;
  64869. /**
  64870. * Initialise the soft body vertices to match its object's (mesh) vertices
  64871. * Softbody vertices (nodes) are in world space and to match this
  64872. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64873. * @param impostor to create the softbody for
  64874. */
  64875. private _softVertexData;
  64876. /**
  64877. * Create an impostor's soft body
  64878. * @param impostor to create the softbody for
  64879. */
  64880. private _createSoftbody;
  64881. /**
  64882. * Create cloth for an impostor
  64883. * @param impostor to create the softbody for
  64884. */
  64885. private _createCloth;
  64886. /**
  64887. * Create rope for an impostor
  64888. * @param impostor to create the softbody for
  64889. */
  64890. private _createRope;
  64891. /**
  64892. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64893. * @param impostor to create the custom physics shape for
  64894. */
  64895. private _createCustom;
  64896. private _addHullVerts;
  64897. private _createShape;
  64898. /**
  64899. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64900. * @param impostor imposter containing the physics body and babylon object
  64901. */
  64902. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64903. /**
  64904. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64905. * @param impostor imposter containing the physics body and babylon object
  64906. * @param newPosition new position
  64907. * @param newRotation new rotation
  64908. */
  64909. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64910. /**
  64911. * If this plugin is supported
  64912. * @returns true if its supported
  64913. */
  64914. isSupported(): boolean;
  64915. /**
  64916. * Sets the linear velocity of the physics body
  64917. * @param impostor imposter to set the velocity on
  64918. * @param velocity velocity to set
  64919. */
  64920. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64921. /**
  64922. * Sets the angular velocity of the physics body
  64923. * @param impostor imposter to set the velocity on
  64924. * @param velocity velocity to set
  64925. */
  64926. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64927. /**
  64928. * gets the linear velocity
  64929. * @param impostor imposter to get linear velocity from
  64930. * @returns linear velocity
  64931. */
  64932. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64933. /**
  64934. * gets the angular velocity
  64935. * @param impostor imposter to get angular velocity from
  64936. * @returns angular velocity
  64937. */
  64938. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64939. /**
  64940. * Sets the mass of physics body
  64941. * @param impostor imposter to set the mass on
  64942. * @param mass mass to set
  64943. */
  64944. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64945. /**
  64946. * Gets the mass of the physics body
  64947. * @param impostor imposter to get the mass from
  64948. * @returns mass
  64949. */
  64950. getBodyMass(impostor: PhysicsImpostor): number;
  64951. /**
  64952. * Gets friction of the impostor
  64953. * @param impostor impostor to get friction from
  64954. * @returns friction value
  64955. */
  64956. getBodyFriction(impostor: PhysicsImpostor): number;
  64957. /**
  64958. * Sets friction of the impostor
  64959. * @param impostor impostor to set friction on
  64960. * @param friction friction value
  64961. */
  64962. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64963. /**
  64964. * Gets restitution of the impostor
  64965. * @param impostor impostor to get restitution from
  64966. * @returns restitution value
  64967. */
  64968. getBodyRestitution(impostor: PhysicsImpostor): number;
  64969. /**
  64970. * Sets resitution of the impostor
  64971. * @param impostor impostor to set resitution on
  64972. * @param restitution resitution value
  64973. */
  64974. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64975. /**
  64976. * Gets pressure inside the impostor
  64977. * @param impostor impostor to get pressure from
  64978. * @returns pressure value
  64979. */
  64980. getBodyPressure(impostor: PhysicsImpostor): number;
  64981. /**
  64982. * Sets pressure inside a soft body impostor
  64983. * Cloth and rope must remain 0 pressure
  64984. * @param impostor impostor to set pressure on
  64985. * @param pressure pressure value
  64986. */
  64987. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64988. /**
  64989. * Gets stiffness of the impostor
  64990. * @param impostor impostor to get stiffness from
  64991. * @returns pressure value
  64992. */
  64993. getBodyStiffness(impostor: PhysicsImpostor): number;
  64994. /**
  64995. * Sets stiffness of the impostor
  64996. * @param impostor impostor to set stiffness on
  64997. * @param stiffness stiffness value from 0 to 1
  64998. */
  64999. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  65000. /**
  65001. * Gets velocityIterations of the impostor
  65002. * @param impostor impostor to get velocity iterations from
  65003. * @returns velocityIterations value
  65004. */
  65005. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  65006. /**
  65007. * Sets velocityIterations of the impostor
  65008. * @param impostor impostor to set velocity iterations on
  65009. * @param velocityIterations velocityIterations value
  65010. */
  65011. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  65012. /**
  65013. * Gets positionIterations of the impostor
  65014. * @param impostor impostor to get position iterations from
  65015. * @returns positionIterations value
  65016. */
  65017. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  65018. /**
  65019. * Sets positionIterations of the impostor
  65020. * @param impostor impostor to set position on
  65021. * @param positionIterations positionIterations value
  65022. */
  65023. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  65024. /**
  65025. * Append an anchor to a cloth object
  65026. * @param impostor is the cloth impostor to add anchor to
  65027. * @param otherImpostor is the rigid impostor to anchor to
  65028. * @param width ratio across width from 0 to 1
  65029. * @param height ratio up height from 0 to 1
  65030. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  65031. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65032. */
  65033. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65034. /**
  65035. * Append an hook to a rope object
  65036. * @param impostor is the rope impostor to add hook to
  65037. * @param otherImpostor is the rigid impostor to hook to
  65038. * @param length ratio along the rope from 0 to 1
  65039. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  65040. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  65041. */
  65042. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  65043. /**
  65044. * Sleeps the physics body and stops it from being active
  65045. * @param impostor impostor to sleep
  65046. */
  65047. sleepBody(impostor: PhysicsImpostor): void;
  65048. /**
  65049. * Activates the physics body
  65050. * @param impostor impostor to activate
  65051. */
  65052. wakeUpBody(impostor: PhysicsImpostor): void;
  65053. /**
  65054. * Updates the distance parameters of the joint
  65055. * @param joint joint to update
  65056. * @param maxDistance maximum distance of the joint
  65057. * @param minDistance minimum distance of the joint
  65058. */
  65059. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  65060. /**
  65061. * Sets a motor on the joint
  65062. * @param joint joint to set motor on
  65063. * @param speed speed of the motor
  65064. * @param maxForce maximum force of the motor
  65065. * @param motorIndex index of the motor
  65066. */
  65067. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  65068. /**
  65069. * Sets the motors limit
  65070. * @param joint joint to set limit on
  65071. * @param upperLimit upper limit
  65072. * @param lowerLimit lower limit
  65073. */
  65074. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  65075. /**
  65076. * Syncs the position and rotation of a mesh with the impostor
  65077. * @param mesh mesh to sync
  65078. * @param impostor impostor to update the mesh with
  65079. */
  65080. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  65081. /**
  65082. * Gets the radius of the impostor
  65083. * @param impostor impostor to get radius from
  65084. * @returns the radius
  65085. */
  65086. getRadius(impostor: PhysicsImpostor): number;
  65087. /**
  65088. * Gets the box size of the impostor
  65089. * @param impostor impostor to get box size from
  65090. * @param result the resulting box size
  65091. */
  65092. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  65093. /**
  65094. * Disposes of the impostor
  65095. */
  65096. dispose(): void;
  65097. /**
  65098. * Does a raycast in the physics world
  65099. * @param from when should the ray start?
  65100. * @param to when should the ray end?
  65101. * @returns PhysicsRaycastResult
  65102. */
  65103. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  65104. }
  65105. }
  65106. declare module "babylonjs/Probes/reflectionProbe" {
  65107. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65108. import { Vector3 } from "babylonjs/Maths/math.vector";
  65109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65110. import { Nullable } from "babylonjs/types";
  65111. import { Scene } from "babylonjs/scene";
  65112. module "babylonjs/abstractScene" {
  65113. interface AbstractScene {
  65114. /**
  65115. * The list of reflection probes added to the scene
  65116. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65117. */
  65118. reflectionProbes: Array<ReflectionProbe>;
  65119. /**
  65120. * Removes the given reflection probe from this scene.
  65121. * @param toRemove The reflection probe to remove
  65122. * @returns The index of the removed reflection probe
  65123. */
  65124. removeReflectionProbe(toRemove: ReflectionProbe): number;
  65125. /**
  65126. * Adds the given reflection probe to this scene.
  65127. * @param newReflectionProbe The reflection probe to add
  65128. */
  65129. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  65130. }
  65131. }
  65132. /**
  65133. * Class used to generate realtime reflection / refraction cube textures
  65134. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  65135. */
  65136. export class ReflectionProbe {
  65137. /** defines the name of the probe */
  65138. name: string;
  65139. private _scene;
  65140. private _renderTargetTexture;
  65141. private _projectionMatrix;
  65142. private _viewMatrix;
  65143. private _target;
  65144. private _add;
  65145. private _attachedMesh;
  65146. private _invertYAxis;
  65147. /** Gets or sets probe position (center of the cube map) */
  65148. position: Vector3;
  65149. /**
  65150. * Creates a new reflection probe
  65151. * @param name defines the name of the probe
  65152. * @param size defines the texture resolution (for each face)
  65153. * @param scene defines the hosting scene
  65154. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  65155. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  65156. */
  65157. constructor(
  65158. /** defines the name of the probe */
  65159. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  65160. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  65161. get samples(): number;
  65162. set samples(value: number);
  65163. /** Gets or sets the refresh rate to use (on every frame by default) */
  65164. get refreshRate(): number;
  65165. set refreshRate(value: number);
  65166. /**
  65167. * Gets the hosting scene
  65168. * @returns a Scene
  65169. */
  65170. getScene(): Scene;
  65171. /** Gets the internal CubeTexture used to render to */
  65172. get cubeTexture(): RenderTargetTexture;
  65173. /** Gets the list of meshes to render */
  65174. get renderList(): Nullable<AbstractMesh[]>;
  65175. /**
  65176. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  65177. * @param mesh defines the mesh to attach to
  65178. */
  65179. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  65180. /**
  65181. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  65182. * @param renderingGroupId The rendering group id corresponding to its index
  65183. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  65184. */
  65185. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  65186. /**
  65187. * Clean all associated resources
  65188. */
  65189. dispose(): void;
  65190. /**
  65191. * Converts the reflection probe information to a readable string for debug purpose.
  65192. * @param fullDetails Supports for multiple levels of logging within scene loading
  65193. * @returns the human readable reflection probe info
  65194. */
  65195. toString(fullDetails?: boolean): string;
  65196. /**
  65197. * Get the class name of the relfection probe.
  65198. * @returns "ReflectionProbe"
  65199. */
  65200. getClassName(): string;
  65201. /**
  65202. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  65203. * @returns The JSON representation of the texture
  65204. */
  65205. serialize(): any;
  65206. /**
  65207. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  65208. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  65209. * @param scene Define the scene the parsed reflection probe should be instantiated in
  65210. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  65211. * @returns The parsed reflection probe if successful
  65212. */
  65213. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  65214. }
  65215. }
  65216. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  65217. /** @hidden */
  65218. export var _BabylonLoaderRegistered: boolean;
  65219. /**
  65220. * Helps setting up some configuration for the babylon file loader.
  65221. */
  65222. export class BabylonFileLoaderConfiguration {
  65223. /**
  65224. * The loader does not allow injecting custom physix engine into the plugins.
  65225. * Unfortunately in ES6, we need to manually inject them into the plugin.
  65226. * So you could set this variable to your engine import to make it work.
  65227. */
  65228. static LoaderInjectedPhysicsEngine: any;
  65229. }
  65230. }
  65231. declare module "babylonjs/Loading/Plugins/index" {
  65232. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  65233. }
  65234. declare module "babylonjs/Loading/index" {
  65235. export * from "babylonjs/Loading/loadingScreen";
  65236. export * from "babylonjs/Loading/Plugins/index";
  65237. export * from "babylonjs/Loading/sceneLoader";
  65238. export * from "babylonjs/Loading/sceneLoaderFlags";
  65239. }
  65240. declare module "babylonjs/Materials/Background/index" {
  65241. export * from "babylonjs/Materials/Background/backgroundMaterial";
  65242. }
  65243. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  65244. import { Scene } from "babylonjs/scene";
  65245. import { Color3 } from "babylonjs/Maths/math.color";
  65246. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65248. /**
  65249. * The Physically based simple base material of BJS.
  65250. *
  65251. * This enables better naming and convention enforcements on top of the pbrMaterial.
  65252. * It is used as the base class for both the specGloss and metalRough conventions.
  65253. */
  65254. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  65255. /**
  65256. * Number of Simultaneous lights allowed on the material.
  65257. */
  65258. maxSimultaneousLights: number;
  65259. /**
  65260. * If sets to true, disables all the lights affecting the material.
  65261. */
  65262. disableLighting: boolean;
  65263. /**
  65264. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  65265. */
  65266. environmentTexture: BaseTexture;
  65267. /**
  65268. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  65269. */
  65270. invertNormalMapX: boolean;
  65271. /**
  65272. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  65273. */
  65274. invertNormalMapY: boolean;
  65275. /**
  65276. * Normal map used in the model.
  65277. */
  65278. normalTexture: BaseTexture;
  65279. /**
  65280. * Emissivie color used to self-illuminate the model.
  65281. */
  65282. emissiveColor: Color3;
  65283. /**
  65284. * Emissivie texture used to self-illuminate the model.
  65285. */
  65286. emissiveTexture: BaseTexture;
  65287. /**
  65288. * Occlusion Channel Strenght.
  65289. */
  65290. occlusionStrength: number;
  65291. /**
  65292. * Occlusion Texture of the material (adding extra occlusion effects).
  65293. */
  65294. occlusionTexture: BaseTexture;
  65295. /**
  65296. * Defines the alpha limits in alpha test mode.
  65297. */
  65298. alphaCutOff: number;
  65299. /**
  65300. * Gets the current double sided mode.
  65301. */
  65302. get doubleSided(): boolean;
  65303. /**
  65304. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  65305. */
  65306. set doubleSided(value: boolean);
  65307. /**
  65308. * Stores the pre-calculated light information of a mesh in a texture.
  65309. */
  65310. lightmapTexture: BaseTexture;
  65311. /**
  65312. * If true, the light map contains occlusion information instead of lighting info.
  65313. */
  65314. useLightmapAsShadowmap: boolean;
  65315. /**
  65316. * Instantiates a new PBRMaterial instance.
  65317. *
  65318. * @param name The material name
  65319. * @param scene The scene the material will be use in.
  65320. */
  65321. constructor(name: string, scene: Scene);
  65322. getClassName(): string;
  65323. }
  65324. }
  65325. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  65326. import { Scene } from "babylonjs/scene";
  65327. import { Color3 } from "babylonjs/Maths/math.color";
  65328. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65329. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65330. /**
  65331. * The PBR material of BJS following the metal roughness convention.
  65332. *
  65333. * This fits to the PBR convention in the GLTF definition:
  65334. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  65335. */
  65336. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  65337. /**
  65338. * The base color has two different interpretations depending on the value of metalness.
  65339. * When the material is a metal, the base color is the specific measured reflectance value
  65340. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  65341. * of the material.
  65342. */
  65343. baseColor: Color3;
  65344. /**
  65345. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  65346. * well as opacity information in the alpha channel.
  65347. */
  65348. baseTexture: BaseTexture;
  65349. /**
  65350. * Specifies the metallic scalar value of the material.
  65351. * Can also be used to scale the metalness values of the metallic texture.
  65352. */
  65353. metallic: number;
  65354. /**
  65355. * Specifies the roughness scalar value of the material.
  65356. * Can also be used to scale the roughness values of the metallic texture.
  65357. */
  65358. roughness: number;
  65359. /**
  65360. * Texture containing both the metallic value in the B channel and the
  65361. * roughness value in the G channel to keep better precision.
  65362. */
  65363. metallicRoughnessTexture: BaseTexture;
  65364. /**
  65365. * Instantiates a new PBRMetalRoughnessMaterial instance.
  65366. *
  65367. * @param name The material name
  65368. * @param scene The scene the material will be use in.
  65369. */
  65370. constructor(name: string, scene: Scene);
  65371. /**
  65372. * Return the currrent class name of the material.
  65373. */
  65374. getClassName(): string;
  65375. /**
  65376. * Makes a duplicate of the current material.
  65377. * @param name - name to use for the new material.
  65378. */
  65379. clone(name: string): PBRMetallicRoughnessMaterial;
  65380. /**
  65381. * Serialize the material to a parsable JSON object.
  65382. */
  65383. serialize(): any;
  65384. /**
  65385. * Parses a JSON object correponding to the serialize function.
  65386. */
  65387. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  65388. }
  65389. }
  65390. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  65391. import { Scene } from "babylonjs/scene";
  65392. import { Color3 } from "babylonjs/Maths/math.color";
  65393. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65394. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65395. /**
  65396. * The PBR material of BJS following the specular glossiness convention.
  65397. *
  65398. * This fits to the PBR convention in the GLTF definition:
  65399. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  65400. */
  65401. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  65402. /**
  65403. * Specifies the diffuse color of the material.
  65404. */
  65405. diffuseColor: Color3;
  65406. /**
  65407. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  65408. * channel.
  65409. */
  65410. diffuseTexture: BaseTexture;
  65411. /**
  65412. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  65413. */
  65414. specularColor: Color3;
  65415. /**
  65416. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  65417. */
  65418. glossiness: number;
  65419. /**
  65420. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  65421. */
  65422. specularGlossinessTexture: BaseTexture;
  65423. /**
  65424. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  65425. *
  65426. * @param name The material name
  65427. * @param scene The scene the material will be use in.
  65428. */
  65429. constructor(name: string, scene: Scene);
  65430. /**
  65431. * Return the currrent class name of the material.
  65432. */
  65433. getClassName(): string;
  65434. /**
  65435. * Makes a duplicate of the current material.
  65436. * @param name - name to use for the new material.
  65437. */
  65438. clone(name: string): PBRSpecularGlossinessMaterial;
  65439. /**
  65440. * Serialize the material to a parsable JSON object.
  65441. */
  65442. serialize(): any;
  65443. /**
  65444. * Parses a JSON object correponding to the serialize function.
  65445. */
  65446. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  65447. }
  65448. }
  65449. declare module "babylonjs/Materials/PBR/index" {
  65450. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  65451. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  65452. export * from "babylonjs/Materials/PBR/pbrMaterial";
  65453. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  65454. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  65455. }
  65456. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  65457. import { Nullable } from "babylonjs/types";
  65458. import { Scene } from "babylonjs/scene";
  65459. import { Matrix } from "babylonjs/Maths/math.vector";
  65460. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65461. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65462. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65463. /**
  65464. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  65465. * It can help converting any input color in a desired output one. This can then be used to create effects
  65466. * from sepia, black and white to sixties or futuristic rendering...
  65467. *
  65468. * The only supported format is currently 3dl.
  65469. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  65470. */
  65471. export class ColorGradingTexture extends BaseTexture {
  65472. /**
  65473. * The texture URL.
  65474. */
  65475. url: string;
  65476. /**
  65477. * Empty line regex stored for GC.
  65478. */
  65479. private static _noneEmptyLineRegex;
  65480. private _textureMatrix;
  65481. private _onLoad;
  65482. /**
  65483. * Instantiates a ColorGradingTexture from the following parameters.
  65484. *
  65485. * @param url The location of the color gradind data (currently only supporting 3dl)
  65486. * @param sceneOrEngine The scene or engine the texture will be used in
  65487. * @param onLoad defines a callback triggered when the texture has been loaded
  65488. */
  65489. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  65490. /**
  65491. * Fires the onload event from the constructor if requested.
  65492. */
  65493. private _triggerOnLoad;
  65494. /**
  65495. * Returns the texture matrix used in most of the material.
  65496. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  65497. */
  65498. getTextureMatrix(): Matrix;
  65499. /**
  65500. * Occurs when the file being loaded is a .3dl LUT file.
  65501. */
  65502. private load3dlTexture;
  65503. /**
  65504. * Starts the loading process of the texture.
  65505. */
  65506. private loadTexture;
  65507. /**
  65508. * Clones the color gradind texture.
  65509. */
  65510. clone(): ColorGradingTexture;
  65511. /**
  65512. * Called during delayed load for textures.
  65513. */
  65514. delayLoad(): void;
  65515. /**
  65516. * Parses a color grading texture serialized by Babylon.
  65517. * @param parsedTexture The texture information being parsedTexture
  65518. * @param scene The scene to load the texture in
  65519. * @param rootUrl The root url of the data assets to load
  65520. * @return A color gradind texture
  65521. */
  65522. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  65523. /**
  65524. * Serializes the LUT texture to json format.
  65525. */
  65526. serialize(): any;
  65527. }
  65528. }
  65529. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  65530. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65531. import { Scene } from "babylonjs/scene";
  65532. import { Nullable } from "babylonjs/types";
  65533. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65534. /**
  65535. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  65536. */
  65537. export class EquiRectangularCubeTexture extends BaseTexture {
  65538. /** The six faces of the cube. */
  65539. private static _FacesMapping;
  65540. private _noMipmap;
  65541. private _onLoad;
  65542. private _onError;
  65543. /** The size of the cubemap. */
  65544. private _size;
  65545. /** The buffer of the image. */
  65546. private _buffer;
  65547. /** The width of the input image. */
  65548. private _width;
  65549. /** The height of the input image. */
  65550. private _height;
  65551. /** The URL to the image. */
  65552. url: string;
  65553. /**
  65554. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  65555. * @param url The location of the image
  65556. * @param scene The scene the texture will be used in
  65557. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  65558. * @param noMipmap Forces to not generate the mipmap if true
  65559. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65560. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65561. * @param onLoad — defines a callback called when texture is loaded
  65562. * @param onError — defines a callback called if there is an error
  65563. */
  65564. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  65565. /**
  65566. * Load the image data, by putting the image on a canvas and extracting its buffer.
  65567. */
  65568. private loadImage;
  65569. /**
  65570. * Convert the image buffer into a cubemap and create a CubeTexture.
  65571. */
  65572. private loadTexture;
  65573. /**
  65574. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  65575. * @param buffer The ArrayBuffer that should be converted.
  65576. * @returns The buffer as Float32Array.
  65577. */
  65578. private getFloat32ArrayFromArrayBuffer;
  65579. /**
  65580. * Get the current class name of the texture useful for serialization or dynamic coding.
  65581. * @returns "EquiRectangularCubeTexture"
  65582. */
  65583. getClassName(): string;
  65584. /**
  65585. * Create a clone of the current EquiRectangularCubeTexture and return it.
  65586. * @returns A clone of the current EquiRectangularCubeTexture.
  65587. */
  65588. clone(): EquiRectangularCubeTexture;
  65589. }
  65590. }
  65591. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  65592. import { Nullable } from "babylonjs/types";
  65593. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65594. import { Matrix } from "babylonjs/Maths/math.vector";
  65595. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  65596. import "babylonjs/Engines/Extensions/engine.videoTexture";
  65597. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  65598. import { Scene } from "babylonjs/scene";
  65599. /**
  65600. * Defines the options related to the creation of an HtmlElementTexture
  65601. */
  65602. export interface IHtmlElementTextureOptions {
  65603. /**
  65604. * Defines wether mip maps should be created or not.
  65605. */
  65606. generateMipMaps?: boolean;
  65607. /**
  65608. * Defines the sampling mode of the texture.
  65609. */
  65610. samplingMode?: number;
  65611. /**
  65612. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  65613. */
  65614. engine: Nullable<ThinEngine>;
  65615. /**
  65616. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  65617. */
  65618. scene: Nullable<Scene>;
  65619. }
  65620. /**
  65621. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  65622. * To be as efficient as possible depending on your constraints nothing aside the first upload
  65623. * is automatically managed.
  65624. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  65625. * in your application.
  65626. *
  65627. * As the update is not automatic, you need to call them manually.
  65628. */
  65629. export class HtmlElementTexture extends BaseTexture {
  65630. /**
  65631. * The texture URL.
  65632. */
  65633. element: HTMLVideoElement | HTMLCanvasElement;
  65634. private static readonly DefaultOptions;
  65635. private _textureMatrix;
  65636. private _isVideo;
  65637. private _generateMipMaps;
  65638. private _samplingMode;
  65639. /**
  65640. * Instantiates a HtmlElementTexture from the following parameters.
  65641. *
  65642. * @param name Defines the name of the texture
  65643. * @param element Defines the video or canvas the texture is filled with
  65644. * @param options Defines the other none mandatory texture creation options
  65645. */
  65646. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  65647. private _createInternalTexture;
  65648. /**
  65649. * Returns the texture matrix used in most of the material.
  65650. */
  65651. getTextureMatrix(): Matrix;
  65652. /**
  65653. * Updates the content of the texture.
  65654. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  65655. */
  65656. update(invertY?: Nullable<boolean>): void;
  65657. }
  65658. }
  65659. declare module "babylonjs/Misc/tga" {
  65660. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65661. /**
  65662. * Based on jsTGALoader - Javascript loader for TGA file
  65663. * By Vincent Thibault
  65664. * @see http://blog.robrowser.com/javascript-tga-loader.html
  65665. */
  65666. export class TGATools {
  65667. private static _TYPE_INDEXED;
  65668. private static _TYPE_RGB;
  65669. private static _TYPE_GREY;
  65670. private static _TYPE_RLE_INDEXED;
  65671. private static _TYPE_RLE_RGB;
  65672. private static _TYPE_RLE_GREY;
  65673. private static _ORIGIN_MASK;
  65674. private static _ORIGIN_SHIFT;
  65675. private static _ORIGIN_BL;
  65676. private static _ORIGIN_BR;
  65677. private static _ORIGIN_UL;
  65678. private static _ORIGIN_UR;
  65679. /**
  65680. * Gets the header of a TGA file
  65681. * @param data defines the TGA data
  65682. * @returns the header
  65683. */
  65684. static GetTGAHeader(data: Uint8Array): any;
  65685. /**
  65686. * Uploads TGA content to a Babylon Texture
  65687. * @hidden
  65688. */
  65689. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  65690. /** @hidden */
  65691. 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;
  65692. /** @hidden */
  65693. 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;
  65694. /** @hidden */
  65695. 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;
  65696. /** @hidden */
  65697. 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;
  65698. /** @hidden */
  65699. 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;
  65700. /** @hidden */
  65701. 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;
  65702. }
  65703. }
  65704. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  65705. import { Nullable } from "babylonjs/types";
  65706. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65707. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65708. /**
  65709. * Implementation of the TGA Texture Loader.
  65710. * @hidden
  65711. */
  65712. export class _TGATextureLoader implements IInternalTextureLoader {
  65713. /**
  65714. * Defines wether the loader supports cascade loading the different faces.
  65715. */
  65716. readonly supportCascades: boolean;
  65717. /**
  65718. * This returns if the loader support the current file information.
  65719. * @param extension defines the file extension of the file being loaded
  65720. * @returns true if the loader can load the specified file
  65721. */
  65722. canLoad(extension: string): boolean;
  65723. /**
  65724. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65725. * @param data contains the texture data
  65726. * @param texture defines the BabylonJS internal texture
  65727. * @param createPolynomials will be true if polynomials have been requested
  65728. * @param onLoad defines the callback to trigger once the texture is ready
  65729. * @param onError defines the callback to trigger in case of error
  65730. */
  65731. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65732. /**
  65733. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65734. * @param data contains the texture data
  65735. * @param texture defines the BabylonJS internal texture
  65736. * @param callback defines the method to call once ready to upload
  65737. */
  65738. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65739. }
  65740. }
  65741. declare module "babylonjs/Misc/basis" {
  65742. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65743. /**
  65744. * Info about the .basis files
  65745. */
  65746. class BasisFileInfo {
  65747. /**
  65748. * If the file has alpha
  65749. */
  65750. hasAlpha: boolean;
  65751. /**
  65752. * Info about each image of the basis file
  65753. */
  65754. images: Array<{
  65755. levels: Array<{
  65756. width: number;
  65757. height: number;
  65758. transcodedPixels: ArrayBufferView;
  65759. }>;
  65760. }>;
  65761. }
  65762. /**
  65763. * Result of transcoding a basis file
  65764. */
  65765. class TranscodeResult {
  65766. /**
  65767. * Info about the .basis file
  65768. */
  65769. fileInfo: BasisFileInfo;
  65770. /**
  65771. * Format to use when loading the file
  65772. */
  65773. format: number;
  65774. }
  65775. /**
  65776. * Configuration options for the Basis transcoder
  65777. */
  65778. export class BasisTranscodeConfiguration {
  65779. /**
  65780. * Supported compression formats used to determine the supported output format of the transcoder
  65781. */
  65782. supportedCompressionFormats?: {
  65783. /**
  65784. * etc1 compression format
  65785. */
  65786. etc1?: boolean;
  65787. /**
  65788. * s3tc compression format
  65789. */
  65790. s3tc?: boolean;
  65791. /**
  65792. * pvrtc compression format
  65793. */
  65794. pvrtc?: boolean;
  65795. /**
  65796. * etc2 compression format
  65797. */
  65798. etc2?: boolean;
  65799. };
  65800. /**
  65801. * If mipmap levels should be loaded for transcoded images (Default: true)
  65802. */
  65803. loadMipmapLevels?: boolean;
  65804. /**
  65805. * Index of a single image to load (Default: all images)
  65806. */
  65807. loadSingleImage?: number;
  65808. }
  65809. /**
  65810. * Used to load .Basis files
  65811. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65812. */
  65813. export class BasisTools {
  65814. private static _IgnoreSupportedFormats;
  65815. /**
  65816. * URL to use when loading the basis transcoder
  65817. */
  65818. static JSModuleURL: string;
  65819. /**
  65820. * URL to use when loading the wasm module for the transcoder
  65821. */
  65822. static WasmModuleURL: string;
  65823. /**
  65824. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65825. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65826. * @returns internal format corresponding to the Basis format
  65827. */
  65828. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65829. private static _WorkerPromise;
  65830. private static _Worker;
  65831. private static _actionId;
  65832. private static _CreateWorkerAsync;
  65833. /**
  65834. * Transcodes a loaded image file to compressed pixel data
  65835. * @param data image data to transcode
  65836. * @param config configuration options for the transcoding
  65837. * @returns a promise resulting in the transcoded image
  65838. */
  65839. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65840. /**
  65841. * Loads a texture from the transcode result
  65842. * @param texture texture load to
  65843. * @param transcodeResult the result of transcoding the basis file to load from
  65844. */
  65845. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65846. }
  65847. }
  65848. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65849. import { Nullable } from "babylonjs/types";
  65850. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65851. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65852. /**
  65853. * Loader for .basis file format
  65854. */
  65855. export class _BasisTextureLoader implements IInternalTextureLoader {
  65856. /**
  65857. * Defines whether the loader supports cascade loading the different faces.
  65858. */
  65859. readonly supportCascades: boolean;
  65860. /**
  65861. * This returns if the loader support the current file information.
  65862. * @param extension defines the file extension of the file being loaded
  65863. * @returns true if the loader can load the specified file
  65864. */
  65865. canLoad(extension: string): boolean;
  65866. /**
  65867. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65868. * @param data contains the texture data
  65869. * @param texture defines the BabylonJS internal texture
  65870. * @param createPolynomials will be true if polynomials have been requested
  65871. * @param onLoad defines the callback to trigger once the texture is ready
  65872. * @param onError defines the callback to trigger in case of error
  65873. */
  65874. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65875. /**
  65876. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65877. * @param data contains the texture data
  65878. * @param texture defines the BabylonJS internal texture
  65879. * @param callback defines the method to call once ready to upload
  65880. */
  65881. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65882. }
  65883. }
  65884. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65885. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65886. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65887. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65888. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65889. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65890. }
  65891. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65892. import { Vector2 } from "babylonjs/Maths/math.vector";
  65893. /**
  65894. * Defines the basic options interface of a TexturePacker Frame
  65895. */
  65896. export interface ITexturePackerFrame {
  65897. /**
  65898. * The frame ID
  65899. */
  65900. id: number;
  65901. /**
  65902. * The frames Scale
  65903. */
  65904. scale: Vector2;
  65905. /**
  65906. * The Frames offset
  65907. */
  65908. offset: Vector2;
  65909. }
  65910. /**
  65911. * This is a support class for frame Data on texture packer sets.
  65912. */
  65913. export class TexturePackerFrame implements ITexturePackerFrame {
  65914. /**
  65915. * The frame ID
  65916. */
  65917. id: number;
  65918. /**
  65919. * The frames Scale
  65920. */
  65921. scale: Vector2;
  65922. /**
  65923. * The Frames offset
  65924. */
  65925. offset: Vector2;
  65926. /**
  65927. * Initializes a texture package frame.
  65928. * @param id The numerical frame identifier
  65929. * @param scale Scalar Vector2 for UV frame
  65930. * @param offset Vector2 for the frame position in UV units.
  65931. * @returns TexturePackerFrame
  65932. */
  65933. constructor(id: number, scale: Vector2, offset: Vector2);
  65934. }
  65935. }
  65936. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65938. import { Scene } from "babylonjs/scene";
  65939. import { Nullable } from "babylonjs/types";
  65940. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65941. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65942. /**
  65943. * Defines the basic options interface of a TexturePacker
  65944. */
  65945. export interface ITexturePackerOptions {
  65946. /**
  65947. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65948. */
  65949. map?: string[];
  65950. /**
  65951. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65952. */
  65953. uvsIn?: string;
  65954. /**
  65955. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65956. */
  65957. uvsOut?: string;
  65958. /**
  65959. * number representing the layout style. Defaults to LAYOUT_STRIP
  65960. */
  65961. layout?: number;
  65962. /**
  65963. * number of columns if using custom column count layout(2). This defaults to 4.
  65964. */
  65965. colnum?: number;
  65966. /**
  65967. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65968. */
  65969. updateInputMeshes?: boolean;
  65970. /**
  65971. * boolean flag to dispose all the source textures. Defaults to true.
  65972. */
  65973. disposeSources?: boolean;
  65974. /**
  65975. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65976. */
  65977. fillBlanks?: boolean;
  65978. /**
  65979. * string value representing the context fill style color. Defaults to 'black'.
  65980. */
  65981. customFillColor?: string;
  65982. /**
  65983. * Width and Height Value of each Frame in the TexturePacker Sets
  65984. */
  65985. frameSize?: number;
  65986. /**
  65987. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65988. */
  65989. paddingRatio?: number;
  65990. /**
  65991. * Number that declares the fill method for the padding gutter.
  65992. */
  65993. paddingMode?: number;
  65994. /**
  65995. * If in SUBUV_COLOR padding mode what color to use.
  65996. */
  65997. paddingColor?: Color3 | Color4;
  65998. }
  65999. /**
  66000. * Defines the basic interface of a TexturePacker JSON File
  66001. */
  66002. export interface ITexturePackerJSON {
  66003. /**
  66004. * The frame ID
  66005. */
  66006. name: string;
  66007. /**
  66008. * The base64 channel data
  66009. */
  66010. sets: any;
  66011. /**
  66012. * The options of the Packer
  66013. */
  66014. options: ITexturePackerOptions;
  66015. /**
  66016. * The frame data of the Packer
  66017. */
  66018. frames: Array<number>;
  66019. }
  66020. /**
  66021. * This is a support class that generates a series of packed texture sets.
  66022. * @see https://doc.babylonjs.com/babylon101/materials
  66023. */
  66024. export class TexturePacker {
  66025. /** Packer Layout Constant 0 */
  66026. static readonly LAYOUT_STRIP: number;
  66027. /** Packer Layout Constant 1 */
  66028. static readonly LAYOUT_POWER2: number;
  66029. /** Packer Layout Constant 2 */
  66030. static readonly LAYOUT_COLNUM: number;
  66031. /** Packer Layout Constant 0 */
  66032. static readonly SUBUV_WRAP: number;
  66033. /** Packer Layout Constant 1 */
  66034. static readonly SUBUV_EXTEND: number;
  66035. /** Packer Layout Constant 2 */
  66036. static readonly SUBUV_COLOR: number;
  66037. /** The Name of the Texture Package */
  66038. name: string;
  66039. /** The scene scope of the TexturePacker */
  66040. scene: Scene;
  66041. /** The Meshes to target */
  66042. meshes: AbstractMesh[];
  66043. /** Arguments passed with the Constructor */
  66044. options: ITexturePackerOptions;
  66045. /** The promise that is started upon initialization */
  66046. promise: Nullable<Promise<TexturePacker | string>>;
  66047. /** The Container object for the channel sets that are generated */
  66048. sets: object;
  66049. /** The Container array for the frames that are generated */
  66050. frames: TexturePackerFrame[];
  66051. /** The expected number of textures the system is parsing. */
  66052. private _expecting;
  66053. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  66054. private _paddingValue;
  66055. /**
  66056. * Initializes a texture package series from an array of meshes or a single mesh.
  66057. * @param name The name of the package
  66058. * @param meshes The target meshes to compose the package from
  66059. * @param options The arguments that texture packer should follow while building.
  66060. * @param scene The scene which the textures are scoped to.
  66061. * @returns TexturePacker
  66062. */
  66063. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  66064. /**
  66065. * Starts the package process
  66066. * @param resolve The promises resolution function
  66067. * @returns TexturePacker
  66068. */
  66069. private _createFrames;
  66070. /**
  66071. * Calculates the Size of the Channel Sets
  66072. * @returns Vector2
  66073. */
  66074. private _calculateSize;
  66075. /**
  66076. * Calculates the UV data for the frames.
  66077. * @param baseSize the base frameSize
  66078. * @param padding the base frame padding
  66079. * @param dtSize size of the Dynamic Texture for that channel
  66080. * @param dtUnits is 1/dtSize
  66081. * @param update flag to update the input meshes
  66082. */
  66083. private _calculateMeshUVFrames;
  66084. /**
  66085. * Calculates the frames Offset.
  66086. * @param index of the frame
  66087. * @returns Vector2
  66088. */
  66089. private _getFrameOffset;
  66090. /**
  66091. * Updates a Mesh to the frame data
  66092. * @param mesh that is the target
  66093. * @param frameID or the frame index
  66094. */
  66095. private _updateMeshUV;
  66096. /**
  66097. * Updates a Meshes materials to use the texture packer channels
  66098. * @param m is the mesh to target
  66099. * @param force all channels on the packer to be set.
  66100. */
  66101. private _updateTextureReferences;
  66102. /**
  66103. * Public method to set a Mesh to a frame
  66104. * @param m that is the target
  66105. * @param frameID or the frame index
  66106. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  66107. */
  66108. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  66109. /**
  66110. * Starts the async promise to compile the texture packer.
  66111. * @returns Promise<void>
  66112. */
  66113. processAsync(): Promise<void>;
  66114. /**
  66115. * Disposes all textures associated with this packer
  66116. */
  66117. dispose(): void;
  66118. /**
  66119. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  66120. * @param imageType is the image type to use.
  66121. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  66122. */
  66123. download(imageType?: string, quality?: number): void;
  66124. /**
  66125. * Public method to load a texturePacker JSON file.
  66126. * @param data of the JSON file in string format.
  66127. */
  66128. updateFromJSON(data: string): void;
  66129. }
  66130. }
  66131. declare module "babylonjs/Materials/Textures/Packer/index" {
  66132. export * from "babylonjs/Materials/Textures/Packer/packer";
  66133. export * from "babylonjs/Materials/Textures/Packer/frame";
  66134. }
  66135. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  66136. import { Scene } from "babylonjs/scene";
  66137. import { Texture } from "babylonjs/Materials/Textures/texture";
  66138. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66139. /**
  66140. * 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.
  66141. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66142. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66143. */
  66144. export class CustomProceduralTexture extends ProceduralTexture {
  66145. private _animate;
  66146. private _time;
  66147. private _config;
  66148. private _texturePath;
  66149. /**
  66150. * Instantiates a new Custom Procedural Texture.
  66151. * 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.
  66152. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  66153. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  66154. * @param name Define the name of the texture
  66155. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  66156. * @param size Define the size of the texture to create
  66157. * @param scene Define the scene the texture belongs to
  66158. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  66159. * @param generateMipMaps Define if the texture should creates mip maps or not
  66160. */
  66161. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66162. private _loadJson;
  66163. /**
  66164. * Is the texture ready to be used ? (rendered at least once)
  66165. * @returns true if ready, otherwise, false.
  66166. */
  66167. isReady(): boolean;
  66168. /**
  66169. * Render the texture to its associated render target.
  66170. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  66171. */
  66172. render(useCameraPostProcess?: boolean): void;
  66173. /**
  66174. * Update the list of dependant textures samplers in the shader.
  66175. */
  66176. updateTextures(): void;
  66177. /**
  66178. * Update the uniform values of the procedural texture in the shader.
  66179. */
  66180. updateShaderUniforms(): void;
  66181. /**
  66182. * Define if the texture animates or not.
  66183. */
  66184. get animate(): boolean;
  66185. set animate(value: boolean);
  66186. }
  66187. }
  66188. declare module "babylonjs/Shaders/noise.fragment" {
  66189. /** @hidden */
  66190. export var noisePixelShader: {
  66191. name: string;
  66192. shader: string;
  66193. };
  66194. }
  66195. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  66196. import { Nullable } from "babylonjs/types";
  66197. import { Scene } from "babylonjs/scene";
  66198. import { Texture } from "babylonjs/Materials/Textures/texture";
  66199. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66200. import "babylonjs/Shaders/noise.fragment";
  66201. /**
  66202. * Class used to generate noise procedural textures
  66203. */
  66204. export class NoiseProceduralTexture extends ProceduralTexture {
  66205. /** Gets or sets the start time (default is 0) */
  66206. time: number;
  66207. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  66208. brightness: number;
  66209. /** Defines the number of octaves to process */
  66210. octaves: number;
  66211. /** Defines the level of persistence (0.8 by default) */
  66212. persistence: number;
  66213. /** Gets or sets animation speed factor (default is 1) */
  66214. animationSpeedFactor: number;
  66215. /**
  66216. * Creates a new NoiseProceduralTexture
  66217. * @param name defines the name fo the texture
  66218. * @param size defines the size of the texture (default is 256)
  66219. * @param scene defines the hosting scene
  66220. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  66221. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  66222. */
  66223. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  66224. private _updateShaderUniforms;
  66225. protected _getDefines(): string;
  66226. /** Generate the current state of the procedural texture */
  66227. render(useCameraPostProcess?: boolean): void;
  66228. /**
  66229. * Serializes this noise procedural texture
  66230. * @returns a serialized noise procedural texture object
  66231. */
  66232. serialize(): any;
  66233. /**
  66234. * Clone the texture.
  66235. * @returns the cloned texture
  66236. */
  66237. clone(): NoiseProceduralTexture;
  66238. /**
  66239. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  66240. * @param parsedTexture defines parsed texture data
  66241. * @param scene defines the current scene
  66242. * @param rootUrl defines the root URL containing noise procedural texture information
  66243. * @returns a parsed NoiseProceduralTexture
  66244. */
  66245. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  66246. }
  66247. }
  66248. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  66249. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  66250. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  66251. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  66252. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  66253. }
  66254. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  66255. import { Nullable } from "babylonjs/types";
  66256. import { Scene } from "babylonjs/scene";
  66257. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  66258. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  66259. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  66260. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66261. /**
  66262. * Raw cube texture where the raw buffers are passed in
  66263. */
  66264. export class RawCubeTexture extends CubeTexture {
  66265. /**
  66266. * Creates a cube texture where the raw buffers are passed in.
  66267. * @param scene defines the scene the texture is attached to
  66268. * @param data defines the array of data to use to create each face
  66269. * @param size defines the size of the textures
  66270. * @param format defines the format of the data
  66271. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  66272. * @param generateMipMaps defines if the engine should generate the mip levels
  66273. * @param invertY defines if data must be stored with Y axis inverted
  66274. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  66275. * @param compression defines the compression used (null by default)
  66276. */
  66277. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  66278. /**
  66279. * Updates the raw cube texture.
  66280. * @param data defines the data to store
  66281. * @param format defines the data format
  66282. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  66283. * @param invertY defines if data must be stored with Y axis inverted
  66284. * @param compression defines the compression used (null by default)
  66285. * @param level defines which level of the texture to update
  66286. */
  66287. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  66288. /**
  66289. * Updates a raw cube texture with RGBD encoded data.
  66290. * @param data defines the array of data [mipmap][face] to use to create each face
  66291. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  66292. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  66293. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  66294. * @returns a promsie that resolves when the operation is complete
  66295. */
  66296. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  66297. /**
  66298. * Clones the raw cube texture.
  66299. * @return a new cube texture
  66300. */
  66301. clone(): CubeTexture;
  66302. /** @hidden */
  66303. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  66304. }
  66305. }
  66306. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  66307. import { Scene } from "babylonjs/scene";
  66308. import { Texture } from "babylonjs/Materials/Textures/texture";
  66309. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66310. /**
  66311. * Class used to store 2D array textures containing user data
  66312. */
  66313. export class RawTexture2DArray extends Texture {
  66314. /** Gets or sets the texture format to use */
  66315. format: number;
  66316. /**
  66317. * Create a new RawTexture2DArray
  66318. * @param data defines the data of the texture
  66319. * @param width defines the width of the texture
  66320. * @param height defines the height of the texture
  66321. * @param depth defines the number of layers of the texture
  66322. * @param format defines the texture format to use
  66323. * @param scene defines the hosting scene
  66324. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66325. * @param invertY defines if texture must be stored with Y axis inverted
  66326. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66327. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66328. */
  66329. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66330. /** Gets or sets the texture format to use */
  66331. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66332. /**
  66333. * Update the texture with new data
  66334. * @param data defines the data to store in the texture
  66335. */
  66336. update(data: ArrayBufferView): void;
  66337. }
  66338. }
  66339. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  66340. import { Scene } from "babylonjs/scene";
  66341. import { Texture } from "babylonjs/Materials/Textures/texture";
  66342. import "babylonjs/Engines/Extensions/engine.rawTexture";
  66343. /**
  66344. * Class used to store 3D textures containing user data
  66345. */
  66346. export class RawTexture3D extends Texture {
  66347. /** Gets or sets the texture format to use */
  66348. format: number;
  66349. /**
  66350. * Create a new RawTexture3D
  66351. * @param data defines the data of the texture
  66352. * @param width defines the width of the texture
  66353. * @param height defines the height of the texture
  66354. * @param depth defines the depth of the texture
  66355. * @param format defines the texture format to use
  66356. * @param scene defines the hosting scene
  66357. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  66358. * @param invertY defines if texture must be stored with Y axis inverted
  66359. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  66360. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  66361. */
  66362. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  66363. /** Gets or sets the texture format to use */
  66364. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  66365. /**
  66366. * Update the texture with new data
  66367. * @param data defines the data to store in the texture
  66368. */
  66369. update(data: ArrayBufferView): void;
  66370. }
  66371. }
  66372. declare module "babylonjs/Materials/Textures/refractionTexture" {
  66373. import { Scene } from "babylonjs/scene";
  66374. import { Plane } from "babylonjs/Maths/math.plane";
  66375. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  66376. /**
  66377. * Creates a refraction texture used by refraction channel of the standard material.
  66378. * It is like a mirror but to see through a material.
  66379. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66380. */
  66381. export class RefractionTexture extends RenderTargetTexture {
  66382. /**
  66383. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  66384. * 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.
  66385. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66386. */
  66387. refractionPlane: Plane;
  66388. /**
  66389. * Define how deep under the surface we should see.
  66390. */
  66391. depth: number;
  66392. /**
  66393. * Creates a refraction texture used by refraction channel of the standard material.
  66394. * It is like a mirror but to see through a material.
  66395. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  66396. * @param name Define the texture name
  66397. * @param size Define the size of the underlying texture
  66398. * @param scene Define the scene the refraction belongs to
  66399. * @param generateMipMaps Define if we need to generate mips level for the refraction
  66400. */
  66401. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  66402. /**
  66403. * Clone the refraction texture.
  66404. * @returns the cloned texture
  66405. */
  66406. clone(): RefractionTexture;
  66407. /**
  66408. * Serialize the texture to a JSON representation you could use in Parse later on
  66409. * @returns the serialized JSON representation
  66410. */
  66411. serialize(): any;
  66412. }
  66413. }
  66414. declare module "babylonjs/Materials/Textures/index" {
  66415. export * from "babylonjs/Materials/Textures/baseTexture";
  66416. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  66417. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  66418. export * from "babylonjs/Materials/Textures/cubeTexture";
  66419. export * from "babylonjs/Materials/Textures/dynamicTexture";
  66420. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  66421. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  66422. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  66423. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  66424. export * from "babylonjs/Materials/Textures/internalTexture";
  66425. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  66426. export * from "babylonjs/Materials/Textures/Loaders/index";
  66427. export * from "babylonjs/Materials/Textures/mirrorTexture";
  66428. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  66429. export * from "babylonjs/Materials/Textures/Packer/index";
  66430. export * from "babylonjs/Materials/Textures/Procedurals/index";
  66431. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  66432. export * from "babylonjs/Materials/Textures/rawTexture";
  66433. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  66434. export * from "babylonjs/Materials/Textures/rawTexture3D";
  66435. export * from "babylonjs/Materials/Textures/refractionTexture";
  66436. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  66437. export * from "babylonjs/Materials/Textures/texture";
  66438. export * from "babylonjs/Materials/Textures/videoTexture";
  66439. }
  66440. declare module "babylonjs/Materials/Node/Enums/index" {
  66441. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  66442. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  66443. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  66444. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  66445. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  66446. }
  66447. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  66448. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66449. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66450. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66451. import { Mesh } from "babylonjs/Meshes/mesh";
  66452. import { Effect } from "babylonjs/Materials/effect";
  66453. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66454. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66455. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  66456. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  66457. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66458. /**
  66459. * Block used to add support for vertex skinning (bones)
  66460. */
  66461. export class BonesBlock extends NodeMaterialBlock {
  66462. /**
  66463. * Creates a new BonesBlock
  66464. * @param name defines the block name
  66465. */
  66466. constructor(name: string);
  66467. /**
  66468. * Initialize the block and prepare the context for build
  66469. * @param state defines the state that will be used for the build
  66470. */
  66471. initialize(state: NodeMaterialBuildState): void;
  66472. /**
  66473. * Gets the current class name
  66474. * @returns the class name
  66475. */
  66476. getClassName(): string;
  66477. /**
  66478. * Gets the matrix indices input component
  66479. */
  66480. get matricesIndices(): NodeMaterialConnectionPoint;
  66481. /**
  66482. * Gets the matrix weights input component
  66483. */
  66484. get matricesWeights(): NodeMaterialConnectionPoint;
  66485. /**
  66486. * Gets the extra matrix indices input component
  66487. */
  66488. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  66489. /**
  66490. * Gets the extra matrix weights input component
  66491. */
  66492. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  66493. /**
  66494. * Gets the world input component
  66495. */
  66496. get world(): NodeMaterialConnectionPoint;
  66497. /**
  66498. * Gets the output component
  66499. */
  66500. get output(): NodeMaterialConnectionPoint;
  66501. autoConfigure(material: NodeMaterial): void;
  66502. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  66503. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66504. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66505. protected _buildBlock(state: NodeMaterialBuildState): this;
  66506. }
  66507. }
  66508. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  66509. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66510. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66511. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66513. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66514. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66515. /**
  66516. * Block used to add support for instances
  66517. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  66518. */
  66519. export class InstancesBlock extends NodeMaterialBlock {
  66520. /**
  66521. * Creates a new InstancesBlock
  66522. * @param name defines the block name
  66523. */
  66524. constructor(name: string);
  66525. /**
  66526. * Gets the current class name
  66527. * @returns the class name
  66528. */
  66529. getClassName(): string;
  66530. /**
  66531. * Gets the first world row input component
  66532. */
  66533. get world0(): NodeMaterialConnectionPoint;
  66534. /**
  66535. * Gets the second world row input component
  66536. */
  66537. get world1(): NodeMaterialConnectionPoint;
  66538. /**
  66539. * Gets the third world row input component
  66540. */
  66541. get world2(): NodeMaterialConnectionPoint;
  66542. /**
  66543. * Gets the forth world row input component
  66544. */
  66545. get world3(): NodeMaterialConnectionPoint;
  66546. /**
  66547. * Gets the world input component
  66548. */
  66549. get world(): NodeMaterialConnectionPoint;
  66550. /**
  66551. * Gets the output component
  66552. */
  66553. get output(): NodeMaterialConnectionPoint;
  66554. /**
  66555. * Gets the isntanceID component
  66556. */
  66557. get instanceID(): NodeMaterialConnectionPoint;
  66558. autoConfigure(material: NodeMaterial): void;
  66559. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  66560. protected _buildBlock(state: NodeMaterialBuildState): this;
  66561. }
  66562. }
  66563. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  66564. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66565. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66566. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66568. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66569. import { Effect } from "babylonjs/Materials/effect";
  66570. import { Mesh } from "babylonjs/Meshes/mesh";
  66571. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  66572. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  66573. /**
  66574. * Block used to add morph targets support to vertex shader
  66575. */
  66576. export class MorphTargetsBlock extends NodeMaterialBlock {
  66577. private _repeatableContentAnchor;
  66578. /**
  66579. * Create a new MorphTargetsBlock
  66580. * @param name defines the block name
  66581. */
  66582. constructor(name: string);
  66583. /**
  66584. * Gets the current class name
  66585. * @returns the class name
  66586. */
  66587. getClassName(): string;
  66588. /**
  66589. * Gets the position input component
  66590. */
  66591. get position(): NodeMaterialConnectionPoint;
  66592. /**
  66593. * Gets the normal input component
  66594. */
  66595. get normal(): NodeMaterialConnectionPoint;
  66596. /**
  66597. * Gets the tangent input component
  66598. */
  66599. get tangent(): NodeMaterialConnectionPoint;
  66600. /**
  66601. * Gets the tangent input component
  66602. */
  66603. get uv(): NodeMaterialConnectionPoint;
  66604. /**
  66605. * Gets the position output component
  66606. */
  66607. get positionOutput(): NodeMaterialConnectionPoint;
  66608. /**
  66609. * Gets the normal output component
  66610. */
  66611. get normalOutput(): NodeMaterialConnectionPoint;
  66612. /**
  66613. * Gets the tangent output component
  66614. */
  66615. get tangentOutput(): NodeMaterialConnectionPoint;
  66616. /**
  66617. * Gets the tangent output component
  66618. */
  66619. get uvOutput(): NodeMaterialConnectionPoint;
  66620. initialize(state: NodeMaterialBuildState): void;
  66621. autoConfigure(material: NodeMaterial): void;
  66622. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66623. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66624. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  66625. protected _buildBlock(state: NodeMaterialBuildState): this;
  66626. }
  66627. }
  66628. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  66629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66630. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66631. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66632. import { Nullable } from "babylonjs/types";
  66633. import { Scene } from "babylonjs/scene";
  66634. import { Effect } from "babylonjs/Materials/effect";
  66635. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66636. import { Mesh } from "babylonjs/Meshes/mesh";
  66637. import { Light } from "babylonjs/Lights/light";
  66638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66639. /**
  66640. * Block used to get data information from a light
  66641. */
  66642. export class LightInformationBlock extends NodeMaterialBlock {
  66643. private _lightDataUniformName;
  66644. private _lightColorUniformName;
  66645. private _lightTypeDefineName;
  66646. /**
  66647. * Gets or sets the light associated with this block
  66648. */
  66649. light: Nullable<Light>;
  66650. /**
  66651. * Creates a new LightInformationBlock
  66652. * @param name defines the block name
  66653. */
  66654. constructor(name: string);
  66655. /**
  66656. * Gets the current class name
  66657. * @returns the class name
  66658. */
  66659. getClassName(): string;
  66660. /**
  66661. * Gets the world position input component
  66662. */
  66663. get worldPosition(): NodeMaterialConnectionPoint;
  66664. /**
  66665. * Gets the direction output component
  66666. */
  66667. get direction(): NodeMaterialConnectionPoint;
  66668. /**
  66669. * Gets the direction output component
  66670. */
  66671. get color(): NodeMaterialConnectionPoint;
  66672. /**
  66673. * Gets the direction output component
  66674. */
  66675. get intensity(): NodeMaterialConnectionPoint;
  66676. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66677. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66678. protected _buildBlock(state: NodeMaterialBuildState): this;
  66679. serialize(): any;
  66680. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66681. }
  66682. }
  66683. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  66684. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  66685. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  66686. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  66687. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  66688. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  66689. }
  66690. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  66691. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66692. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66693. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66694. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66695. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66696. import { Effect } from "babylonjs/Materials/effect";
  66697. import { Mesh } from "babylonjs/Meshes/mesh";
  66698. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66699. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66700. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66701. /**
  66702. * Block used to add image processing support to fragment shader
  66703. */
  66704. export class ImageProcessingBlock extends NodeMaterialBlock {
  66705. /**
  66706. * Create a new ImageProcessingBlock
  66707. * @param name defines the block name
  66708. */
  66709. constructor(name: string);
  66710. /**
  66711. * Gets the current class name
  66712. * @returns the class name
  66713. */
  66714. getClassName(): string;
  66715. /**
  66716. * Gets the color input component
  66717. */
  66718. get color(): NodeMaterialConnectionPoint;
  66719. /**
  66720. * Gets the output component
  66721. */
  66722. get output(): NodeMaterialConnectionPoint;
  66723. /**
  66724. * Initialize the block and prepare the context for build
  66725. * @param state defines the state that will be used for the build
  66726. */
  66727. initialize(state: NodeMaterialBuildState): void;
  66728. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  66729. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66730. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66731. protected _buildBlock(state: NodeMaterialBuildState): this;
  66732. }
  66733. }
  66734. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  66735. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66736. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66737. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66738. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66740. import { Effect } from "babylonjs/Materials/effect";
  66741. import { Mesh } from "babylonjs/Meshes/mesh";
  66742. import { Scene } from "babylonjs/scene";
  66743. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  66744. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  66745. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  66746. /**
  66747. * Block used to pertub normals based on a normal map
  66748. */
  66749. export class PerturbNormalBlock extends NodeMaterialBlock {
  66750. private _tangentSpaceParameterName;
  66751. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66752. invertX: boolean;
  66753. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  66754. invertY: boolean;
  66755. /**
  66756. * Create a new PerturbNormalBlock
  66757. * @param name defines the block name
  66758. */
  66759. constructor(name: string);
  66760. /**
  66761. * Gets the current class name
  66762. * @returns the class name
  66763. */
  66764. getClassName(): string;
  66765. /**
  66766. * Gets the world position input component
  66767. */
  66768. get worldPosition(): NodeMaterialConnectionPoint;
  66769. /**
  66770. * Gets the world normal input component
  66771. */
  66772. get worldNormal(): NodeMaterialConnectionPoint;
  66773. /**
  66774. * Gets the world tangent input component
  66775. */
  66776. get worldTangent(): NodeMaterialConnectionPoint;
  66777. /**
  66778. * Gets the uv input component
  66779. */
  66780. get uv(): NodeMaterialConnectionPoint;
  66781. /**
  66782. * Gets the normal map color input component
  66783. */
  66784. get normalMapColor(): NodeMaterialConnectionPoint;
  66785. /**
  66786. * Gets the strength input component
  66787. */
  66788. get strength(): NodeMaterialConnectionPoint;
  66789. /**
  66790. * Gets the output component
  66791. */
  66792. get output(): NodeMaterialConnectionPoint;
  66793. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66794. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66795. autoConfigure(material: NodeMaterial): void;
  66796. protected _buildBlock(state: NodeMaterialBuildState): this;
  66797. protected _dumpPropertiesCode(): string;
  66798. serialize(): any;
  66799. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66800. }
  66801. }
  66802. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66803. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66804. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66805. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66806. /**
  66807. * Block used to discard a pixel if a value is smaller than a cutoff
  66808. */
  66809. export class DiscardBlock extends NodeMaterialBlock {
  66810. /**
  66811. * Create a new DiscardBlock
  66812. * @param name defines the block name
  66813. */
  66814. constructor(name: string);
  66815. /**
  66816. * Gets the current class name
  66817. * @returns the class name
  66818. */
  66819. getClassName(): string;
  66820. /**
  66821. * Gets the color input component
  66822. */
  66823. get value(): NodeMaterialConnectionPoint;
  66824. /**
  66825. * Gets the cutoff input component
  66826. */
  66827. get cutoff(): NodeMaterialConnectionPoint;
  66828. protected _buildBlock(state: NodeMaterialBuildState): this;
  66829. }
  66830. }
  66831. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66832. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66834. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66835. /**
  66836. * Block used to test if the fragment shader is front facing
  66837. */
  66838. export class FrontFacingBlock extends NodeMaterialBlock {
  66839. /**
  66840. * Creates a new FrontFacingBlock
  66841. * @param name defines the block name
  66842. */
  66843. constructor(name: string);
  66844. /**
  66845. * Gets the current class name
  66846. * @returns the class name
  66847. */
  66848. getClassName(): string;
  66849. /**
  66850. * Gets the output component
  66851. */
  66852. get output(): NodeMaterialConnectionPoint;
  66853. protected _buildBlock(state: NodeMaterialBuildState): this;
  66854. }
  66855. }
  66856. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66857. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66858. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66859. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66860. /**
  66861. * Block used to get the derivative value on x and y of a given input
  66862. */
  66863. export class DerivativeBlock extends NodeMaterialBlock {
  66864. /**
  66865. * Create a new DerivativeBlock
  66866. * @param name defines the block name
  66867. */
  66868. constructor(name: string);
  66869. /**
  66870. * Gets the current class name
  66871. * @returns the class name
  66872. */
  66873. getClassName(): string;
  66874. /**
  66875. * Gets the input component
  66876. */
  66877. get input(): NodeMaterialConnectionPoint;
  66878. /**
  66879. * Gets the derivative output on x
  66880. */
  66881. get dx(): NodeMaterialConnectionPoint;
  66882. /**
  66883. * Gets the derivative output on y
  66884. */
  66885. get dy(): NodeMaterialConnectionPoint;
  66886. protected _buildBlock(state: NodeMaterialBuildState): this;
  66887. }
  66888. }
  66889. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66890. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66891. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66892. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66893. /**
  66894. * Block used to make gl_FragCoord available
  66895. */
  66896. export class FragCoordBlock extends NodeMaterialBlock {
  66897. /**
  66898. * Creates a new FragCoordBlock
  66899. * @param name defines the block name
  66900. */
  66901. constructor(name: string);
  66902. /**
  66903. * Gets the current class name
  66904. * @returns the class name
  66905. */
  66906. getClassName(): string;
  66907. /**
  66908. * Gets the xy component
  66909. */
  66910. get xy(): NodeMaterialConnectionPoint;
  66911. /**
  66912. * Gets the xyz component
  66913. */
  66914. get xyz(): NodeMaterialConnectionPoint;
  66915. /**
  66916. * Gets the xyzw component
  66917. */
  66918. get xyzw(): NodeMaterialConnectionPoint;
  66919. /**
  66920. * Gets the x component
  66921. */
  66922. get x(): NodeMaterialConnectionPoint;
  66923. /**
  66924. * Gets the y component
  66925. */
  66926. get y(): NodeMaterialConnectionPoint;
  66927. /**
  66928. * Gets the z component
  66929. */
  66930. get z(): NodeMaterialConnectionPoint;
  66931. /**
  66932. * Gets the w component
  66933. */
  66934. get output(): NodeMaterialConnectionPoint;
  66935. protected writeOutputs(state: NodeMaterialBuildState): string;
  66936. protected _buildBlock(state: NodeMaterialBuildState): this;
  66937. }
  66938. }
  66939. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66940. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66941. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66943. import { Effect } from "babylonjs/Materials/effect";
  66944. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66945. import { Mesh } from "babylonjs/Meshes/mesh";
  66946. /**
  66947. * Block used to get the screen sizes
  66948. */
  66949. export class ScreenSizeBlock extends NodeMaterialBlock {
  66950. private _varName;
  66951. private _scene;
  66952. /**
  66953. * Creates a new ScreenSizeBlock
  66954. * @param name defines the block name
  66955. */
  66956. constructor(name: string);
  66957. /**
  66958. * Gets the current class name
  66959. * @returns the class name
  66960. */
  66961. getClassName(): string;
  66962. /**
  66963. * Gets the xy component
  66964. */
  66965. get xy(): NodeMaterialConnectionPoint;
  66966. /**
  66967. * Gets the x component
  66968. */
  66969. get x(): NodeMaterialConnectionPoint;
  66970. /**
  66971. * Gets the y component
  66972. */
  66973. get y(): NodeMaterialConnectionPoint;
  66974. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66975. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66976. protected _buildBlock(state: NodeMaterialBuildState): this;
  66977. }
  66978. }
  66979. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66980. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66981. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66982. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66983. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66984. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66985. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66986. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66987. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66988. }
  66989. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66990. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66991. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66992. import { Mesh } from "babylonjs/Meshes/mesh";
  66993. import { Effect } from "babylonjs/Materials/effect";
  66994. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66995. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66996. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66997. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66998. /**
  66999. * Block used to add support for scene fog
  67000. */
  67001. export class FogBlock extends NodeMaterialBlock {
  67002. private _fogDistanceName;
  67003. private _fogParameters;
  67004. /**
  67005. * Create a new FogBlock
  67006. * @param name defines the block name
  67007. */
  67008. constructor(name: string);
  67009. /**
  67010. * Gets the current class name
  67011. * @returns the class name
  67012. */
  67013. getClassName(): string;
  67014. /**
  67015. * Gets the world position input component
  67016. */
  67017. get worldPosition(): NodeMaterialConnectionPoint;
  67018. /**
  67019. * Gets the view input component
  67020. */
  67021. get view(): NodeMaterialConnectionPoint;
  67022. /**
  67023. * Gets the color input component
  67024. */
  67025. get input(): NodeMaterialConnectionPoint;
  67026. /**
  67027. * Gets the fog color input component
  67028. */
  67029. get fogColor(): NodeMaterialConnectionPoint;
  67030. /**
  67031. * Gets the output component
  67032. */
  67033. get output(): NodeMaterialConnectionPoint;
  67034. autoConfigure(material: NodeMaterial): void;
  67035. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67036. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67037. protected _buildBlock(state: NodeMaterialBuildState): this;
  67038. }
  67039. }
  67040. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  67041. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67042. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67043. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67044. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67045. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67046. import { Effect } from "babylonjs/Materials/effect";
  67047. import { Mesh } from "babylonjs/Meshes/mesh";
  67048. import { Light } from "babylonjs/Lights/light";
  67049. import { Nullable } from "babylonjs/types";
  67050. import { Scene } from "babylonjs/scene";
  67051. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  67052. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  67053. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  67054. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67055. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  67056. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  67057. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  67058. /**
  67059. * Block used to add light in the fragment shader
  67060. */
  67061. export class LightBlock extends NodeMaterialBlock {
  67062. private _lightId;
  67063. /**
  67064. * Gets or sets the light associated with this block
  67065. */
  67066. light: Nullable<Light>;
  67067. /**
  67068. * Create a new LightBlock
  67069. * @param name defines the block name
  67070. */
  67071. constructor(name: string);
  67072. /**
  67073. * Gets the current class name
  67074. * @returns the class name
  67075. */
  67076. getClassName(): string;
  67077. /**
  67078. * Gets the world position input component
  67079. */
  67080. get worldPosition(): NodeMaterialConnectionPoint;
  67081. /**
  67082. * Gets the world normal input component
  67083. */
  67084. get worldNormal(): NodeMaterialConnectionPoint;
  67085. /**
  67086. * Gets the camera (or eye) position component
  67087. */
  67088. get cameraPosition(): NodeMaterialConnectionPoint;
  67089. /**
  67090. * Gets the glossiness component
  67091. */
  67092. get glossiness(): NodeMaterialConnectionPoint;
  67093. /**
  67094. * Gets the glossinness power component
  67095. */
  67096. get glossPower(): NodeMaterialConnectionPoint;
  67097. /**
  67098. * Gets the diffuse color component
  67099. */
  67100. get diffuseColor(): NodeMaterialConnectionPoint;
  67101. /**
  67102. * Gets the specular color component
  67103. */
  67104. get specularColor(): NodeMaterialConnectionPoint;
  67105. /**
  67106. * Gets the view matrix component
  67107. */
  67108. get view(): NodeMaterialConnectionPoint;
  67109. /**
  67110. * Gets the diffuse output component
  67111. */
  67112. get diffuseOutput(): NodeMaterialConnectionPoint;
  67113. /**
  67114. * Gets the specular output component
  67115. */
  67116. get specularOutput(): NodeMaterialConnectionPoint;
  67117. /**
  67118. * Gets the shadow output component
  67119. */
  67120. get shadow(): NodeMaterialConnectionPoint;
  67121. autoConfigure(material: NodeMaterial): void;
  67122. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67123. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67124. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67125. private _injectVertexCode;
  67126. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67127. serialize(): any;
  67128. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67129. }
  67130. }
  67131. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  67132. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67133. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67134. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67135. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67136. /**
  67137. * Block used to read a reflection texture from a sampler
  67138. */
  67139. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  67140. /**
  67141. * Create a new ReflectionTextureBlock
  67142. * @param name defines the block name
  67143. */
  67144. constructor(name: string);
  67145. /**
  67146. * Gets the current class name
  67147. * @returns the class name
  67148. */
  67149. getClassName(): string;
  67150. /**
  67151. * Gets the world position input component
  67152. */
  67153. get position(): NodeMaterialConnectionPoint;
  67154. /**
  67155. * Gets the world position input component
  67156. */
  67157. get worldPosition(): NodeMaterialConnectionPoint;
  67158. /**
  67159. * Gets the world normal input component
  67160. */
  67161. get worldNormal(): NodeMaterialConnectionPoint;
  67162. /**
  67163. * Gets the world input component
  67164. */
  67165. get world(): NodeMaterialConnectionPoint;
  67166. /**
  67167. * Gets the camera (or eye) position component
  67168. */
  67169. get cameraPosition(): NodeMaterialConnectionPoint;
  67170. /**
  67171. * Gets the view input component
  67172. */
  67173. get view(): NodeMaterialConnectionPoint;
  67174. /**
  67175. * Gets the rgb output component
  67176. */
  67177. get rgb(): NodeMaterialConnectionPoint;
  67178. /**
  67179. * Gets the rgba output component
  67180. */
  67181. get rgba(): NodeMaterialConnectionPoint;
  67182. /**
  67183. * Gets the r output component
  67184. */
  67185. get r(): NodeMaterialConnectionPoint;
  67186. /**
  67187. * Gets the g output component
  67188. */
  67189. get g(): NodeMaterialConnectionPoint;
  67190. /**
  67191. * Gets the b output component
  67192. */
  67193. get b(): NodeMaterialConnectionPoint;
  67194. /**
  67195. * Gets the a output component
  67196. */
  67197. get a(): NodeMaterialConnectionPoint;
  67198. autoConfigure(material: NodeMaterial): void;
  67199. protected _buildBlock(state: NodeMaterialBuildState): this;
  67200. }
  67201. }
  67202. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  67203. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  67204. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  67205. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  67206. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  67207. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  67208. }
  67209. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  67210. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  67211. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  67212. }
  67213. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  67214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67215. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67216. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67217. /**
  67218. * Block used to add 2 vectors
  67219. */
  67220. export class AddBlock extends NodeMaterialBlock {
  67221. /**
  67222. * Creates a new AddBlock
  67223. * @param name defines the block name
  67224. */
  67225. constructor(name: string);
  67226. /**
  67227. * Gets the current class name
  67228. * @returns the class name
  67229. */
  67230. getClassName(): string;
  67231. /**
  67232. * Gets the left operand input component
  67233. */
  67234. get left(): NodeMaterialConnectionPoint;
  67235. /**
  67236. * Gets the right operand input component
  67237. */
  67238. get right(): NodeMaterialConnectionPoint;
  67239. /**
  67240. * Gets the output component
  67241. */
  67242. get output(): NodeMaterialConnectionPoint;
  67243. protected _buildBlock(state: NodeMaterialBuildState): this;
  67244. }
  67245. }
  67246. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  67247. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67248. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67249. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67250. /**
  67251. * Block used to scale a vector by a float
  67252. */
  67253. export class ScaleBlock extends NodeMaterialBlock {
  67254. /**
  67255. * Creates a new ScaleBlock
  67256. * @param name defines the block name
  67257. */
  67258. constructor(name: string);
  67259. /**
  67260. * Gets the current class name
  67261. * @returns the class name
  67262. */
  67263. getClassName(): string;
  67264. /**
  67265. * Gets the input component
  67266. */
  67267. get input(): NodeMaterialConnectionPoint;
  67268. /**
  67269. * Gets the factor input component
  67270. */
  67271. get factor(): NodeMaterialConnectionPoint;
  67272. /**
  67273. * Gets the output component
  67274. */
  67275. get output(): NodeMaterialConnectionPoint;
  67276. protected _buildBlock(state: NodeMaterialBuildState): this;
  67277. }
  67278. }
  67279. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  67280. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67281. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67282. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67283. import { Scene } from "babylonjs/scene";
  67284. /**
  67285. * Block used to clamp a float
  67286. */
  67287. export class ClampBlock extends NodeMaterialBlock {
  67288. /** Gets or sets the minimum range */
  67289. minimum: number;
  67290. /** Gets or sets the maximum range */
  67291. maximum: number;
  67292. /**
  67293. * Creates a new ClampBlock
  67294. * @param name defines the block name
  67295. */
  67296. constructor(name: string);
  67297. /**
  67298. * Gets the current class name
  67299. * @returns the class name
  67300. */
  67301. getClassName(): string;
  67302. /**
  67303. * Gets the value input component
  67304. */
  67305. get value(): NodeMaterialConnectionPoint;
  67306. /**
  67307. * Gets the output component
  67308. */
  67309. get output(): NodeMaterialConnectionPoint;
  67310. protected _buildBlock(state: NodeMaterialBuildState): this;
  67311. protected _dumpPropertiesCode(): string;
  67312. serialize(): any;
  67313. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67314. }
  67315. }
  67316. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  67317. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67318. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67319. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67320. /**
  67321. * Block used to apply a cross product between 2 vectors
  67322. */
  67323. export class CrossBlock extends NodeMaterialBlock {
  67324. /**
  67325. * Creates a new CrossBlock
  67326. * @param name defines the block name
  67327. */
  67328. constructor(name: string);
  67329. /**
  67330. * Gets the current class name
  67331. * @returns the class name
  67332. */
  67333. getClassName(): string;
  67334. /**
  67335. * Gets the left operand input component
  67336. */
  67337. get left(): NodeMaterialConnectionPoint;
  67338. /**
  67339. * Gets the right operand input component
  67340. */
  67341. get right(): NodeMaterialConnectionPoint;
  67342. /**
  67343. * Gets the output component
  67344. */
  67345. get output(): NodeMaterialConnectionPoint;
  67346. protected _buildBlock(state: NodeMaterialBuildState): this;
  67347. }
  67348. }
  67349. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  67350. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67351. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67352. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67353. /**
  67354. * Block used to apply a dot product between 2 vectors
  67355. */
  67356. export class DotBlock extends NodeMaterialBlock {
  67357. /**
  67358. * Creates a new DotBlock
  67359. * @param name defines the block name
  67360. */
  67361. constructor(name: string);
  67362. /**
  67363. * Gets the current class name
  67364. * @returns the class name
  67365. */
  67366. getClassName(): string;
  67367. /**
  67368. * Gets the left operand input component
  67369. */
  67370. get left(): NodeMaterialConnectionPoint;
  67371. /**
  67372. * Gets the right operand input component
  67373. */
  67374. get right(): NodeMaterialConnectionPoint;
  67375. /**
  67376. * Gets the output component
  67377. */
  67378. get output(): NodeMaterialConnectionPoint;
  67379. protected _buildBlock(state: NodeMaterialBuildState): this;
  67380. }
  67381. }
  67382. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  67383. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67384. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67385. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67386. /**
  67387. * Block used to normalize a vector
  67388. */
  67389. export class NormalizeBlock extends NodeMaterialBlock {
  67390. /**
  67391. * Creates a new NormalizeBlock
  67392. * @param name defines the block name
  67393. */
  67394. constructor(name: string);
  67395. /**
  67396. * Gets the current class name
  67397. * @returns the class name
  67398. */
  67399. getClassName(): string;
  67400. /**
  67401. * Gets the input component
  67402. */
  67403. get input(): NodeMaterialConnectionPoint;
  67404. /**
  67405. * Gets the output component
  67406. */
  67407. get output(): NodeMaterialConnectionPoint;
  67408. protected _buildBlock(state: NodeMaterialBuildState): this;
  67409. }
  67410. }
  67411. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  67412. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67413. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67414. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67415. /**
  67416. * Block used to create a Color3/4 out of individual inputs (one for each component)
  67417. */
  67418. export class ColorMergerBlock extends NodeMaterialBlock {
  67419. /**
  67420. * Create a new ColorMergerBlock
  67421. * @param name defines the block name
  67422. */
  67423. constructor(name: string);
  67424. /**
  67425. * Gets the current class name
  67426. * @returns the class name
  67427. */
  67428. getClassName(): string;
  67429. /**
  67430. * Gets the rgb component (input)
  67431. */
  67432. get rgbIn(): NodeMaterialConnectionPoint;
  67433. /**
  67434. * Gets the r component (input)
  67435. */
  67436. get r(): NodeMaterialConnectionPoint;
  67437. /**
  67438. * Gets the g component (input)
  67439. */
  67440. get g(): NodeMaterialConnectionPoint;
  67441. /**
  67442. * Gets the b component (input)
  67443. */
  67444. get b(): NodeMaterialConnectionPoint;
  67445. /**
  67446. * Gets the a component (input)
  67447. */
  67448. get a(): NodeMaterialConnectionPoint;
  67449. /**
  67450. * Gets the rgba component (output)
  67451. */
  67452. get rgba(): NodeMaterialConnectionPoint;
  67453. /**
  67454. * Gets the rgb component (output)
  67455. */
  67456. get rgbOut(): NodeMaterialConnectionPoint;
  67457. /**
  67458. * Gets the rgb component (output)
  67459. * @deprecated Please use rgbOut instead.
  67460. */
  67461. get rgb(): NodeMaterialConnectionPoint;
  67462. protected _buildBlock(state: NodeMaterialBuildState): this;
  67463. }
  67464. }
  67465. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  67466. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67467. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67469. /**
  67470. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  67471. */
  67472. export class VectorSplitterBlock extends NodeMaterialBlock {
  67473. /**
  67474. * Create a new VectorSplitterBlock
  67475. * @param name defines the block name
  67476. */
  67477. constructor(name: string);
  67478. /**
  67479. * Gets the current class name
  67480. * @returns the class name
  67481. */
  67482. getClassName(): string;
  67483. /**
  67484. * Gets the xyzw component (input)
  67485. */
  67486. get xyzw(): NodeMaterialConnectionPoint;
  67487. /**
  67488. * Gets the xyz component (input)
  67489. */
  67490. get xyzIn(): NodeMaterialConnectionPoint;
  67491. /**
  67492. * Gets the xy component (input)
  67493. */
  67494. get xyIn(): NodeMaterialConnectionPoint;
  67495. /**
  67496. * Gets the xyz component (output)
  67497. */
  67498. get xyzOut(): NodeMaterialConnectionPoint;
  67499. /**
  67500. * Gets the xy component (output)
  67501. */
  67502. get xyOut(): NodeMaterialConnectionPoint;
  67503. /**
  67504. * Gets the x component (output)
  67505. */
  67506. get x(): NodeMaterialConnectionPoint;
  67507. /**
  67508. * Gets the y component (output)
  67509. */
  67510. get y(): NodeMaterialConnectionPoint;
  67511. /**
  67512. * Gets the z component (output)
  67513. */
  67514. get z(): NodeMaterialConnectionPoint;
  67515. /**
  67516. * Gets the w component (output)
  67517. */
  67518. get w(): NodeMaterialConnectionPoint;
  67519. protected _inputRename(name: string): string;
  67520. protected _outputRename(name: string): string;
  67521. protected _buildBlock(state: NodeMaterialBuildState): this;
  67522. }
  67523. }
  67524. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  67525. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67526. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67527. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67528. /**
  67529. * Block used to lerp between 2 values
  67530. */
  67531. export class LerpBlock extends NodeMaterialBlock {
  67532. /**
  67533. * Creates a new LerpBlock
  67534. * @param name defines the block name
  67535. */
  67536. constructor(name: string);
  67537. /**
  67538. * Gets the current class name
  67539. * @returns the class name
  67540. */
  67541. getClassName(): string;
  67542. /**
  67543. * Gets the left operand input component
  67544. */
  67545. get left(): NodeMaterialConnectionPoint;
  67546. /**
  67547. * Gets the right operand input component
  67548. */
  67549. get right(): NodeMaterialConnectionPoint;
  67550. /**
  67551. * Gets the gradient operand input component
  67552. */
  67553. get gradient(): NodeMaterialConnectionPoint;
  67554. /**
  67555. * Gets the output component
  67556. */
  67557. get output(): NodeMaterialConnectionPoint;
  67558. protected _buildBlock(state: NodeMaterialBuildState): this;
  67559. }
  67560. }
  67561. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  67562. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67563. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67564. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67565. /**
  67566. * Block used to divide 2 vectors
  67567. */
  67568. export class DivideBlock extends NodeMaterialBlock {
  67569. /**
  67570. * Creates a new DivideBlock
  67571. * @param name defines the block name
  67572. */
  67573. constructor(name: string);
  67574. /**
  67575. * Gets the current class name
  67576. * @returns the class name
  67577. */
  67578. getClassName(): string;
  67579. /**
  67580. * Gets the left operand input component
  67581. */
  67582. get left(): NodeMaterialConnectionPoint;
  67583. /**
  67584. * Gets the right operand input component
  67585. */
  67586. get right(): NodeMaterialConnectionPoint;
  67587. /**
  67588. * Gets the output component
  67589. */
  67590. get output(): NodeMaterialConnectionPoint;
  67591. protected _buildBlock(state: NodeMaterialBuildState): this;
  67592. }
  67593. }
  67594. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  67595. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67596. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67597. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67598. /**
  67599. * Block used to subtract 2 vectors
  67600. */
  67601. export class SubtractBlock extends NodeMaterialBlock {
  67602. /**
  67603. * Creates a new SubtractBlock
  67604. * @param name defines the block name
  67605. */
  67606. constructor(name: string);
  67607. /**
  67608. * Gets the current class name
  67609. * @returns the class name
  67610. */
  67611. getClassName(): string;
  67612. /**
  67613. * Gets the left operand input component
  67614. */
  67615. get left(): NodeMaterialConnectionPoint;
  67616. /**
  67617. * Gets the right operand input component
  67618. */
  67619. get right(): NodeMaterialConnectionPoint;
  67620. /**
  67621. * Gets the output component
  67622. */
  67623. get output(): NodeMaterialConnectionPoint;
  67624. protected _buildBlock(state: NodeMaterialBuildState): this;
  67625. }
  67626. }
  67627. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  67628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67631. /**
  67632. * Block used to step a value
  67633. */
  67634. export class StepBlock extends NodeMaterialBlock {
  67635. /**
  67636. * Creates a new StepBlock
  67637. * @param name defines the block name
  67638. */
  67639. constructor(name: string);
  67640. /**
  67641. * Gets the current class name
  67642. * @returns the class name
  67643. */
  67644. getClassName(): string;
  67645. /**
  67646. * Gets the value operand input component
  67647. */
  67648. get value(): NodeMaterialConnectionPoint;
  67649. /**
  67650. * Gets the edge operand input component
  67651. */
  67652. get edge(): NodeMaterialConnectionPoint;
  67653. /**
  67654. * Gets the output component
  67655. */
  67656. get output(): NodeMaterialConnectionPoint;
  67657. protected _buildBlock(state: NodeMaterialBuildState): this;
  67658. }
  67659. }
  67660. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  67661. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67662. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67663. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67664. /**
  67665. * Block used to get the opposite (1 - x) of a value
  67666. */
  67667. export class OneMinusBlock extends NodeMaterialBlock {
  67668. /**
  67669. * Creates a new OneMinusBlock
  67670. * @param name defines the block name
  67671. */
  67672. constructor(name: string);
  67673. /**
  67674. * Gets the current class name
  67675. * @returns the class name
  67676. */
  67677. getClassName(): string;
  67678. /**
  67679. * Gets the input component
  67680. */
  67681. get input(): NodeMaterialConnectionPoint;
  67682. /**
  67683. * Gets the output component
  67684. */
  67685. get output(): NodeMaterialConnectionPoint;
  67686. protected _buildBlock(state: NodeMaterialBuildState): this;
  67687. }
  67688. }
  67689. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  67690. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67691. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67692. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67693. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67694. /**
  67695. * Block used to get the view direction
  67696. */
  67697. export class ViewDirectionBlock extends NodeMaterialBlock {
  67698. /**
  67699. * Creates a new ViewDirectionBlock
  67700. * @param name defines the block name
  67701. */
  67702. constructor(name: string);
  67703. /**
  67704. * Gets the current class name
  67705. * @returns the class name
  67706. */
  67707. getClassName(): string;
  67708. /**
  67709. * Gets the world position component
  67710. */
  67711. get worldPosition(): NodeMaterialConnectionPoint;
  67712. /**
  67713. * Gets the camera position component
  67714. */
  67715. get cameraPosition(): NodeMaterialConnectionPoint;
  67716. /**
  67717. * Gets the output component
  67718. */
  67719. get output(): NodeMaterialConnectionPoint;
  67720. autoConfigure(material: NodeMaterial): void;
  67721. protected _buildBlock(state: NodeMaterialBuildState): this;
  67722. }
  67723. }
  67724. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  67725. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67726. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67728. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67729. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  67730. /**
  67731. * Block used to compute fresnel value
  67732. */
  67733. export class FresnelBlock extends NodeMaterialBlock {
  67734. /**
  67735. * Create a new FresnelBlock
  67736. * @param name defines the block name
  67737. */
  67738. constructor(name: string);
  67739. /**
  67740. * Gets the current class name
  67741. * @returns the class name
  67742. */
  67743. getClassName(): string;
  67744. /**
  67745. * Gets the world normal input component
  67746. */
  67747. get worldNormal(): NodeMaterialConnectionPoint;
  67748. /**
  67749. * Gets the view direction input component
  67750. */
  67751. get viewDirection(): NodeMaterialConnectionPoint;
  67752. /**
  67753. * Gets the bias input component
  67754. */
  67755. get bias(): NodeMaterialConnectionPoint;
  67756. /**
  67757. * Gets the camera (or eye) position component
  67758. */
  67759. get power(): NodeMaterialConnectionPoint;
  67760. /**
  67761. * Gets the fresnel output component
  67762. */
  67763. get fresnel(): NodeMaterialConnectionPoint;
  67764. autoConfigure(material: NodeMaterial): void;
  67765. protected _buildBlock(state: NodeMaterialBuildState): this;
  67766. }
  67767. }
  67768. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  67769. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67770. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67771. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67772. /**
  67773. * Block used to get the max of 2 values
  67774. */
  67775. export class MaxBlock extends NodeMaterialBlock {
  67776. /**
  67777. * Creates a new MaxBlock
  67778. * @param name defines the block name
  67779. */
  67780. constructor(name: string);
  67781. /**
  67782. * Gets the current class name
  67783. * @returns the class name
  67784. */
  67785. getClassName(): string;
  67786. /**
  67787. * Gets the left operand input component
  67788. */
  67789. get left(): NodeMaterialConnectionPoint;
  67790. /**
  67791. * Gets the right operand input component
  67792. */
  67793. get right(): NodeMaterialConnectionPoint;
  67794. /**
  67795. * Gets the output component
  67796. */
  67797. get output(): NodeMaterialConnectionPoint;
  67798. protected _buildBlock(state: NodeMaterialBuildState): this;
  67799. }
  67800. }
  67801. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  67802. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67803. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67804. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67805. /**
  67806. * Block used to get the min of 2 values
  67807. */
  67808. export class MinBlock extends NodeMaterialBlock {
  67809. /**
  67810. * Creates a new MinBlock
  67811. * @param name defines the block name
  67812. */
  67813. constructor(name: string);
  67814. /**
  67815. * Gets the current class name
  67816. * @returns the class name
  67817. */
  67818. getClassName(): string;
  67819. /**
  67820. * Gets the left operand input component
  67821. */
  67822. get left(): NodeMaterialConnectionPoint;
  67823. /**
  67824. * Gets the right operand input component
  67825. */
  67826. get right(): NodeMaterialConnectionPoint;
  67827. /**
  67828. * Gets the output component
  67829. */
  67830. get output(): NodeMaterialConnectionPoint;
  67831. protected _buildBlock(state: NodeMaterialBuildState): this;
  67832. }
  67833. }
  67834. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  67835. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67836. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67837. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67838. /**
  67839. * Block used to get the distance between 2 values
  67840. */
  67841. export class DistanceBlock extends NodeMaterialBlock {
  67842. /**
  67843. * Creates a new DistanceBlock
  67844. * @param name defines the block name
  67845. */
  67846. constructor(name: string);
  67847. /**
  67848. * Gets the current class name
  67849. * @returns the class name
  67850. */
  67851. getClassName(): string;
  67852. /**
  67853. * Gets the left operand input component
  67854. */
  67855. get left(): NodeMaterialConnectionPoint;
  67856. /**
  67857. * Gets the right operand input component
  67858. */
  67859. get right(): NodeMaterialConnectionPoint;
  67860. /**
  67861. * Gets the output component
  67862. */
  67863. get output(): NodeMaterialConnectionPoint;
  67864. protected _buildBlock(state: NodeMaterialBuildState): this;
  67865. }
  67866. }
  67867. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67868. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67869. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67870. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67871. /**
  67872. * Block used to get the length of a vector
  67873. */
  67874. export class LengthBlock extends NodeMaterialBlock {
  67875. /**
  67876. * Creates a new LengthBlock
  67877. * @param name defines the block name
  67878. */
  67879. constructor(name: string);
  67880. /**
  67881. * Gets the current class name
  67882. * @returns the class name
  67883. */
  67884. getClassName(): string;
  67885. /**
  67886. * Gets the value input component
  67887. */
  67888. get value(): NodeMaterialConnectionPoint;
  67889. /**
  67890. * Gets the output component
  67891. */
  67892. get output(): NodeMaterialConnectionPoint;
  67893. protected _buildBlock(state: NodeMaterialBuildState): this;
  67894. }
  67895. }
  67896. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  67897. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67898. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67899. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67900. /**
  67901. * Block used to get negative version of a value (i.e. x * -1)
  67902. */
  67903. export class NegateBlock extends NodeMaterialBlock {
  67904. /**
  67905. * Creates a new NegateBlock
  67906. * @param name defines the block name
  67907. */
  67908. constructor(name: string);
  67909. /**
  67910. * Gets the current class name
  67911. * @returns the class name
  67912. */
  67913. getClassName(): string;
  67914. /**
  67915. * Gets the value input component
  67916. */
  67917. get value(): NodeMaterialConnectionPoint;
  67918. /**
  67919. * Gets the output component
  67920. */
  67921. get output(): NodeMaterialConnectionPoint;
  67922. protected _buildBlock(state: NodeMaterialBuildState): this;
  67923. }
  67924. }
  67925. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67926. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67927. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67928. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67929. /**
  67930. * Block used to get the value of the first parameter raised to the power of the second
  67931. */
  67932. export class PowBlock extends NodeMaterialBlock {
  67933. /**
  67934. * Creates a new PowBlock
  67935. * @param name defines the block name
  67936. */
  67937. constructor(name: string);
  67938. /**
  67939. * Gets the current class name
  67940. * @returns the class name
  67941. */
  67942. getClassName(): string;
  67943. /**
  67944. * Gets the value operand input component
  67945. */
  67946. get value(): NodeMaterialConnectionPoint;
  67947. /**
  67948. * Gets the power operand input component
  67949. */
  67950. get power(): NodeMaterialConnectionPoint;
  67951. /**
  67952. * Gets the output component
  67953. */
  67954. get output(): NodeMaterialConnectionPoint;
  67955. protected _buildBlock(state: NodeMaterialBuildState): this;
  67956. }
  67957. }
  67958. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  67959. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67960. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67961. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67962. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67963. /**
  67964. * Block used to get a random number
  67965. */
  67966. export class RandomNumberBlock extends NodeMaterialBlock {
  67967. /**
  67968. * Creates a new RandomNumberBlock
  67969. * @param name defines the block name
  67970. */
  67971. constructor(name: string);
  67972. /**
  67973. * Gets the current class name
  67974. * @returns the class name
  67975. */
  67976. getClassName(): string;
  67977. /**
  67978. * Gets the seed input component
  67979. */
  67980. get seed(): NodeMaterialConnectionPoint;
  67981. /**
  67982. * Gets the output component
  67983. */
  67984. get output(): NodeMaterialConnectionPoint;
  67985. protected _buildBlock(state: NodeMaterialBuildState): this;
  67986. }
  67987. }
  67988. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67989. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67990. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67991. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67992. /**
  67993. * Block used to compute arc tangent of 2 values
  67994. */
  67995. export class ArcTan2Block extends NodeMaterialBlock {
  67996. /**
  67997. * Creates a new ArcTan2Block
  67998. * @param name defines the block name
  67999. */
  68000. constructor(name: string);
  68001. /**
  68002. * Gets the current class name
  68003. * @returns the class name
  68004. */
  68005. getClassName(): string;
  68006. /**
  68007. * Gets the x operand input component
  68008. */
  68009. get x(): NodeMaterialConnectionPoint;
  68010. /**
  68011. * Gets the y operand input component
  68012. */
  68013. get y(): NodeMaterialConnectionPoint;
  68014. /**
  68015. * Gets the output component
  68016. */
  68017. get output(): NodeMaterialConnectionPoint;
  68018. protected _buildBlock(state: NodeMaterialBuildState): this;
  68019. }
  68020. }
  68021. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  68022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68023. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68024. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68025. /**
  68026. * Block used to smooth step a value
  68027. */
  68028. export class SmoothStepBlock extends NodeMaterialBlock {
  68029. /**
  68030. * Creates a new SmoothStepBlock
  68031. * @param name defines the block name
  68032. */
  68033. constructor(name: string);
  68034. /**
  68035. * Gets the current class name
  68036. * @returns the class name
  68037. */
  68038. getClassName(): string;
  68039. /**
  68040. * Gets the value operand input component
  68041. */
  68042. get value(): NodeMaterialConnectionPoint;
  68043. /**
  68044. * Gets the first edge operand input component
  68045. */
  68046. get edge0(): NodeMaterialConnectionPoint;
  68047. /**
  68048. * Gets the second edge operand input component
  68049. */
  68050. get edge1(): NodeMaterialConnectionPoint;
  68051. /**
  68052. * Gets the output component
  68053. */
  68054. get output(): NodeMaterialConnectionPoint;
  68055. protected _buildBlock(state: NodeMaterialBuildState): this;
  68056. }
  68057. }
  68058. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  68059. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68060. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68061. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68062. /**
  68063. * Block used to get the reciprocal (1 / x) of a value
  68064. */
  68065. export class ReciprocalBlock extends NodeMaterialBlock {
  68066. /**
  68067. * Creates a new ReciprocalBlock
  68068. * @param name defines the block name
  68069. */
  68070. constructor(name: string);
  68071. /**
  68072. * Gets the current class name
  68073. * @returns the class name
  68074. */
  68075. getClassName(): string;
  68076. /**
  68077. * Gets the input component
  68078. */
  68079. get input(): NodeMaterialConnectionPoint;
  68080. /**
  68081. * Gets the output component
  68082. */
  68083. get output(): NodeMaterialConnectionPoint;
  68084. protected _buildBlock(state: NodeMaterialBuildState): this;
  68085. }
  68086. }
  68087. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  68088. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68089. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68090. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68091. /**
  68092. * Block used to replace a color by another one
  68093. */
  68094. export class ReplaceColorBlock extends NodeMaterialBlock {
  68095. /**
  68096. * Creates a new ReplaceColorBlock
  68097. * @param name defines the block name
  68098. */
  68099. constructor(name: string);
  68100. /**
  68101. * Gets the current class name
  68102. * @returns the class name
  68103. */
  68104. getClassName(): string;
  68105. /**
  68106. * Gets the value input component
  68107. */
  68108. get value(): NodeMaterialConnectionPoint;
  68109. /**
  68110. * Gets the reference input component
  68111. */
  68112. get reference(): NodeMaterialConnectionPoint;
  68113. /**
  68114. * Gets the distance input component
  68115. */
  68116. get distance(): NodeMaterialConnectionPoint;
  68117. /**
  68118. * Gets the replacement input component
  68119. */
  68120. get replacement(): NodeMaterialConnectionPoint;
  68121. /**
  68122. * Gets the output component
  68123. */
  68124. get output(): NodeMaterialConnectionPoint;
  68125. protected _buildBlock(state: NodeMaterialBuildState): this;
  68126. }
  68127. }
  68128. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  68129. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68130. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68132. /**
  68133. * Block used to posterize a value
  68134. * @see https://en.wikipedia.org/wiki/Posterization
  68135. */
  68136. export class PosterizeBlock extends NodeMaterialBlock {
  68137. /**
  68138. * Creates a new PosterizeBlock
  68139. * @param name defines the block name
  68140. */
  68141. constructor(name: string);
  68142. /**
  68143. * Gets the current class name
  68144. * @returns the class name
  68145. */
  68146. getClassName(): string;
  68147. /**
  68148. * Gets the value input component
  68149. */
  68150. get value(): NodeMaterialConnectionPoint;
  68151. /**
  68152. * Gets the steps input component
  68153. */
  68154. get steps(): NodeMaterialConnectionPoint;
  68155. /**
  68156. * Gets the output component
  68157. */
  68158. get output(): NodeMaterialConnectionPoint;
  68159. protected _buildBlock(state: NodeMaterialBuildState): this;
  68160. }
  68161. }
  68162. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  68163. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68164. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68165. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68166. import { Scene } from "babylonjs/scene";
  68167. /**
  68168. * Operations supported by the Wave block
  68169. */
  68170. export enum WaveBlockKind {
  68171. /** SawTooth */
  68172. SawTooth = 0,
  68173. /** Square */
  68174. Square = 1,
  68175. /** Triangle */
  68176. Triangle = 2
  68177. }
  68178. /**
  68179. * Block used to apply wave operation to floats
  68180. */
  68181. export class WaveBlock extends NodeMaterialBlock {
  68182. /**
  68183. * Gets or sets the kibnd of wave to be applied by the block
  68184. */
  68185. kind: WaveBlockKind;
  68186. /**
  68187. * Creates a new WaveBlock
  68188. * @param name defines the block name
  68189. */
  68190. constructor(name: string);
  68191. /**
  68192. * Gets the current class name
  68193. * @returns the class name
  68194. */
  68195. getClassName(): string;
  68196. /**
  68197. * Gets the input component
  68198. */
  68199. get input(): NodeMaterialConnectionPoint;
  68200. /**
  68201. * Gets the output component
  68202. */
  68203. get output(): NodeMaterialConnectionPoint;
  68204. protected _buildBlock(state: NodeMaterialBuildState): this;
  68205. serialize(): any;
  68206. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68207. }
  68208. }
  68209. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  68210. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68211. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68212. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68213. import { Color3 } from "babylonjs/Maths/math.color";
  68214. import { Scene } from "babylonjs/scene";
  68215. import { Observable } from "babylonjs/Misc/observable";
  68216. /**
  68217. * Class used to store a color step for the GradientBlock
  68218. */
  68219. export class GradientBlockColorStep {
  68220. private _step;
  68221. /**
  68222. * Gets value indicating which step this color is associated with (between 0 and 1)
  68223. */
  68224. get step(): number;
  68225. /**
  68226. * Sets a value indicating which step this color is associated with (between 0 and 1)
  68227. */
  68228. set step(val: number);
  68229. private _color;
  68230. /**
  68231. * Gets the color associated with this step
  68232. */
  68233. get color(): Color3;
  68234. /**
  68235. * Sets the color associated with this step
  68236. */
  68237. set color(val: Color3);
  68238. /**
  68239. * Creates a new GradientBlockColorStep
  68240. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  68241. * @param color defines the color associated with this step
  68242. */
  68243. constructor(step: number, color: Color3);
  68244. }
  68245. /**
  68246. * Block used to return a color from a gradient based on an input value between 0 and 1
  68247. */
  68248. export class GradientBlock extends NodeMaterialBlock {
  68249. /**
  68250. * Gets or sets the list of color steps
  68251. */
  68252. colorSteps: GradientBlockColorStep[];
  68253. /** Gets an observable raised when the value is changed */
  68254. onValueChangedObservable: Observable<GradientBlock>;
  68255. /** calls observable when the value is changed*/
  68256. colorStepsUpdated(): void;
  68257. /**
  68258. * Creates a new GradientBlock
  68259. * @param name defines the block name
  68260. */
  68261. constructor(name: string);
  68262. /**
  68263. * Gets the current class name
  68264. * @returns the class name
  68265. */
  68266. getClassName(): string;
  68267. /**
  68268. * Gets the gradient input component
  68269. */
  68270. get gradient(): NodeMaterialConnectionPoint;
  68271. /**
  68272. * Gets the output component
  68273. */
  68274. get output(): NodeMaterialConnectionPoint;
  68275. private _writeColorConstant;
  68276. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68277. serialize(): any;
  68278. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68279. protected _dumpPropertiesCode(): string;
  68280. }
  68281. }
  68282. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  68283. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68284. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68285. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68286. /**
  68287. * Block used to normalize lerp between 2 values
  68288. */
  68289. export class NLerpBlock extends NodeMaterialBlock {
  68290. /**
  68291. * Creates a new NLerpBlock
  68292. * @param name defines the block name
  68293. */
  68294. constructor(name: string);
  68295. /**
  68296. * Gets the current class name
  68297. * @returns the class name
  68298. */
  68299. getClassName(): string;
  68300. /**
  68301. * Gets the left operand input component
  68302. */
  68303. get left(): NodeMaterialConnectionPoint;
  68304. /**
  68305. * Gets the right operand input component
  68306. */
  68307. get right(): NodeMaterialConnectionPoint;
  68308. /**
  68309. * Gets the gradient operand input component
  68310. */
  68311. get gradient(): NodeMaterialConnectionPoint;
  68312. /**
  68313. * Gets the output component
  68314. */
  68315. get output(): NodeMaterialConnectionPoint;
  68316. protected _buildBlock(state: NodeMaterialBuildState): this;
  68317. }
  68318. }
  68319. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  68320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68323. import { Scene } from "babylonjs/scene";
  68324. /**
  68325. * block used to Generate a Worley Noise 3D Noise Pattern
  68326. */
  68327. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  68328. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  68329. manhattanDistance: boolean;
  68330. /**
  68331. * Creates a new WorleyNoise3DBlock
  68332. * @param name defines the block name
  68333. */
  68334. constructor(name: string);
  68335. /**
  68336. * Gets the current class name
  68337. * @returns the class name
  68338. */
  68339. getClassName(): string;
  68340. /**
  68341. * Gets the seed input component
  68342. */
  68343. get seed(): NodeMaterialConnectionPoint;
  68344. /**
  68345. * Gets the jitter input component
  68346. */
  68347. get jitter(): NodeMaterialConnectionPoint;
  68348. /**
  68349. * Gets the output component
  68350. */
  68351. get output(): NodeMaterialConnectionPoint;
  68352. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68353. /**
  68354. * Exposes the properties to the UI?
  68355. */
  68356. protected _dumpPropertiesCode(): string;
  68357. /**
  68358. * Exposes the properties to the Seralize?
  68359. */
  68360. serialize(): any;
  68361. /**
  68362. * Exposes the properties to the deseralize?
  68363. */
  68364. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68365. }
  68366. }
  68367. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  68368. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68369. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68370. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68371. /**
  68372. * block used to Generate a Simplex Perlin 3d Noise Pattern
  68373. */
  68374. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  68375. /**
  68376. * Creates a new SimplexPerlin3DBlock
  68377. * @param name defines the block name
  68378. */
  68379. constructor(name: string);
  68380. /**
  68381. * Gets the current class name
  68382. * @returns the class name
  68383. */
  68384. getClassName(): string;
  68385. /**
  68386. * Gets the seed operand input component
  68387. */
  68388. get seed(): NodeMaterialConnectionPoint;
  68389. /**
  68390. * Gets the output component
  68391. */
  68392. get output(): NodeMaterialConnectionPoint;
  68393. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  68394. }
  68395. }
  68396. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  68397. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68398. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68399. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68400. /**
  68401. * Block used to blend normals
  68402. */
  68403. export class NormalBlendBlock extends NodeMaterialBlock {
  68404. /**
  68405. * Creates a new NormalBlendBlock
  68406. * @param name defines the block name
  68407. */
  68408. constructor(name: string);
  68409. /**
  68410. * Gets the current class name
  68411. * @returns the class name
  68412. */
  68413. getClassName(): string;
  68414. /**
  68415. * Gets the first input component
  68416. */
  68417. get normalMap0(): NodeMaterialConnectionPoint;
  68418. /**
  68419. * Gets the second input component
  68420. */
  68421. get normalMap1(): NodeMaterialConnectionPoint;
  68422. /**
  68423. * Gets the output component
  68424. */
  68425. get output(): NodeMaterialConnectionPoint;
  68426. protected _buildBlock(state: NodeMaterialBuildState): this;
  68427. }
  68428. }
  68429. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  68430. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68431. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68432. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68433. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  68434. /**
  68435. * Block used to rotate a 2d vector by a given angle
  68436. */
  68437. export class Rotate2dBlock extends NodeMaterialBlock {
  68438. /**
  68439. * Creates a new Rotate2dBlock
  68440. * @param name defines the block name
  68441. */
  68442. constructor(name: string);
  68443. /**
  68444. * Gets the current class name
  68445. * @returns the class name
  68446. */
  68447. getClassName(): string;
  68448. /**
  68449. * Gets the input vector
  68450. */
  68451. get input(): NodeMaterialConnectionPoint;
  68452. /**
  68453. * Gets the input angle
  68454. */
  68455. get angle(): NodeMaterialConnectionPoint;
  68456. /**
  68457. * Gets the output component
  68458. */
  68459. get output(): NodeMaterialConnectionPoint;
  68460. autoConfigure(material: NodeMaterial): void;
  68461. protected _buildBlock(state: NodeMaterialBuildState): this;
  68462. }
  68463. }
  68464. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  68465. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68466. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68467. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68468. /**
  68469. * Block used to get the reflected vector from a direction and a normal
  68470. */
  68471. export class ReflectBlock extends NodeMaterialBlock {
  68472. /**
  68473. * Creates a new ReflectBlock
  68474. * @param name defines the block name
  68475. */
  68476. constructor(name: string);
  68477. /**
  68478. * Gets the current class name
  68479. * @returns the class name
  68480. */
  68481. getClassName(): string;
  68482. /**
  68483. * Gets the incident component
  68484. */
  68485. get incident(): NodeMaterialConnectionPoint;
  68486. /**
  68487. * Gets the normal component
  68488. */
  68489. get normal(): NodeMaterialConnectionPoint;
  68490. /**
  68491. * Gets the output component
  68492. */
  68493. get output(): NodeMaterialConnectionPoint;
  68494. protected _buildBlock(state: NodeMaterialBuildState): this;
  68495. }
  68496. }
  68497. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  68498. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68500. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68501. /**
  68502. * Block used to get the refracted vector from a direction and a normal
  68503. */
  68504. export class RefractBlock extends NodeMaterialBlock {
  68505. /**
  68506. * Creates a new RefractBlock
  68507. * @param name defines the block name
  68508. */
  68509. constructor(name: string);
  68510. /**
  68511. * Gets the current class name
  68512. * @returns the class name
  68513. */
  68514. getClassName(): string;
  68515. /**
  68516. * Gets the incident component
  68517. */
  68518. get incident(): NodeMaterialConnectionPoint;
  68519. /**
  68520. * Gets the normal component
  68521. */
  68522. get normal(): NodeMaterialConnectionPoint;
  68523. /**
  68524. * Gets the index of refraction component
  68525. */
  68526. get ior(): NodeMaterialConnectionPoint;
  68527. /**
  68528. * Gets the output component
  68529. */
  68530. get output(): NodeMaterialConnectionPoint;
  68531. protected _buildBlock(state: NodeMaterialBuildState): this;
  68532. }
  68533. }
  68534. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  68535. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68536. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68537. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68538. /**
  68539. * Block used to desaturate a color
  68540. */
  68541. export class DesaturateBlock extends NodeMaterialBlock {
  68542. /**
  68543. * Creates a new DesaturateBlock
  68544. * @param name defines the block name
  68545. */
  68546. constructor(name: string);
  68547. /**
  68548. * Gets the current class name
  68549. * @returns the class name
  68550. */
  68551. getClassName(): string;
  68552. /**
  68553. * Gets the color operand input component
  68554. */
  68555. get color(): NodeMaterialConnectionPoint;
  68556. /**
  68557. * Gets the level operand input component
  68558. */
  68559. get level(): NodeMaterialConnectionPoint;
  68560. /**
  68561. * Gets the output component
  68562. */
  68563. get output(): NodeMaterialConnectionPoint;
  68564. protected _buildBlock(state: NodeMaterialBuildState): this;
  68565. }
  68566. }
  68567. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  68568. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68569. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68570. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68571. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68572. import { Nullable } from "babylonjs/types";
  68573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68574. import { Scene } from "babylonjs/scene";
  68575. /**
  68576. * Block used to implement the ambient occlusion module of the PBR material
  68577. */
  68578. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  68579. /**
  68580. * Create a new AmbientOcclusionBlock
  68581. * @param name defines the block name
  68582. */
  68583. constructor(name: string);
  68584. /**
  68585. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  68586. */
  68587. useAmbientInGrayScale: boolean;
  68588. /**
  68589. * Initialize the block and prepare the context for build
  68590. * @param state defines the state that will be used for the build
  68591. */
  68592. initialize(state: NodeMaterialBuildState): void;
  68593. /**
  68594. * Gets the current class name
  68595. * @returns the class name
  68596. */
  68597. getClassName(): string;
  68598. /**
  68599. * Gets the texture input component
  68600. */
  68601. get texture(): NodeMaterialConnectionPoint;
  68602. /**
  68603. * Gets the texture intensity component
  68604. */
  68605. get intensity(): NodeMaterialConnectionPoint;
  68606. /**
  68607. * Gets the direct light intensity input component
  68608. */
  68609. get directLightIntensity(): NodeMaterialConnectionPoint;
  68610. /**
  68611. * Gets the ambient occlusion object output component
  68612. */
  68613. get ambientOcc(): NodeMaterialConnectionPoint;
  68614. /**
  68615. * Gets the main code of the block (fragment side)
  68616. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  68617. * @returns the shader code
  68618. */
  68619. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  68620. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68621. protected _buildBlock(state: NodeMaterialBuildState): this;
  68622. protected _dumpPropertiesCode(): string;
  68623. serialize(): any;
  68624. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68625. }
  68626. }
  68627. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  68628. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68629. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68630. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68631. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  68632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68633. import { Nullable } from "babylonjs/types";
  68634. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  68635. import { Mesh } from "babylonjs/Meshes/mesh";
  68636. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68637. import { Effect } from "babylonjs/Materials/effect";
  68638. import { Scene } from "babylonjs/scene";
  68639. /**
  68640. * Block used to implement the reflection module of the PBR material
  68641. */
  68642. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  68643. /** @hidden */
  68644. _defineLODReflectionAlpha: string;
  68645. /** @hidden */
  68646. _defineLinearSpecularReflection: string;
  68647. private _vEnvironmentIrradianceName;
  68648. /** @hidden */
  68649. _vReflectionMicrosurfaceInfosName: string;
  68650. /** @hidden */
  68651. _vReflectionInfosName: string;
  68652. /** @hidden */
  68653. _vReflectionFilteringInfoName: string;
  68654. private _scene;
  68655. /**
  68656. * The three properties below are set by the main PBR block prior to calling methods of this class.
  68657. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68658. * It's less burden on the user side in the editor part.
  68659. */
  68660. /** @hidden */
  68661. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68662. /** @hidden */
  68663. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68664. /** @hidden */
  68665. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  68666. /**
  68667. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  68668. * diffuse part of the IBL.
  68669. */
  68670. useSphericalHarmonics: boolean;
  68671. /**
  68672. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  68673. */
  68674. forceIrradianceInFragment: boolean;
  68675. /**
  68676. * Create a new ReflectionBlock
  68677. * @param name defines the block name
  68678. */
  68679. constructor(name: string);
  68680. /**
  68681. * Gets the current class name
  68682. * @returns the class name
  68683. */
  68684. getClassName(): string;
  68685. /**
  68686. * Gets the position input component
  68687. */
  68688. get position(): NodeMaterialConnectionPoint;
  68689. /**
  68690. * Gets the world position input component
  68691. */
  68692. get worldPosition(): NodeMaterialConnectionPoint;
  68693. /**
  68694. * Gets the world normal input component
  68695. */
  68696. get worldNormal(): NodeMaterialConnectionPoint;
  68697. /**
  68698. * Gets the world input component
  68699. */
  68700. get world(): NodeMaterialConnectionPoint;
  68701. /**
  68702. * Gets the camera (or eye) position component
  68703. */
  68704. get cameraPosition(): NodeMaterialConnectionPoint;
  68705. /**
  68706. * Gets the view input component
  68707. */
  68708. get view(): NodeMaterialConnectionPoint;
  68709. /**
  68710. * Gets the color input component
  68711. */
  68712. get color(): NodeMaterialConnectionPoint;
  68713. /**
  68714. * Gets the reflection object output component
  68715. */
  68716. get reflection(): NodeMaterialConnectionPoint;
  68717. /**
  68718. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  68719. */
  68720. get hasTexture(): boolean;
  68721. /**
  68722. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  68723. */
  68724. get reflectionColor(): string;
  68725. protected _getTexture(): Nullable<BaseTexture>;
  68726. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68727. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68728. /**
  68729. * Gets the code to inject in the vertex shader
  68730. * @param state current state of the node material building
  68731. * @returns the shader code
  68732. */
  68733. handleVertexSide(state: NodeMaterialBuildState): string;
  68734. /**
  68735. * Gets the main code of the block (fragment side)
  68736. * @param state current state of the node material building
  68737. * @param normalVarName name of the existing variable corresponding to the normal
  68738. * @returns the shader code
  68739. */
  68740. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  68741. protected _buildBlock(state: NodeMaterialBuildState): this;
  68742. protected _dumpPropertiesCode(): string;
  68743. serialize(): any;
  68744. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68745. }
  68746. }
  68747. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  68748. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68749. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68750. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68751. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68753. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68754. import { Scene } from "babylonjs/scene";
  68755. import { Nullable } from "babylonjs/types";
  68756. /**
  68757. * Block used to implement the sheen module of the PBR material
  68758. */
  68759. export class SheenBlock extends NodeMaterialBlock {
  68760. /**
  68761. * Create a new SheenBlock
  68762. * @param name defines the block name
  68763. */
  68764. constructor(name: string);
  68765. /**
  68766. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  68767. * It allows the strength of the sheen effect to not depend on the base color of the material,
  68768. * making it easier to setup and tweak the effect
  68769. */
  68770. albedoScaling: boolean;
  68771. /**
  68772. * Defines if the sheen is linked to the sheen color.
  68773. */
  68774. linkSheenWithAlbedo: boolean;
  68775. /**
  68776. * Initialize the block and prepare the context for build
  68777. * @param state defines the state that will be used for the build
  68778. */
  68779. initialize(state: NodeMaterialBuildState): void;
  68780. /**
  68781. * Gets the current class name
  68782. * @returns the class name
  68783. */
  68784. getClassName(): string;
  68785. /**
  68786. * Gets the intensity input component
  68787. */
  68788. get intensity(): NodeMaterialConnectionPoint;
  68789. /**
  68790. * Gets the color input component
  68791. */
  68792. get color(): NodeMaterialConnectionPoint;
  68793. /**
  68794. * Gets the roughness input component
  68795. */
  68796. get roughness(): NodeMaterialConnectionPoint;
  68797. /**
  68798. * Gets the sheen object output component
  68799. */
  68800. get sheen(): NodeMaterialConnectionPoint;
  68801. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68802. /**
  68803. * Gets the main code of the block (fragment side)
  68804. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68805. * @returns the shader code
  68806. */
  68807. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68808. protected _buildBlock(state: NodeMaterialBuildState): this;
  68809. protected _dumpPropertiesCode(): string;
  68810. serialize(): any;
  68811. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68812. }
  68813. }
  68814. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68815. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68816. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68817. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68818. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68819. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68820. import { Scene } from "babylonjs/scene";
  68821. import { Nullable } from "babylonjs/types";
  68822. import { Mesh } from "babylonjs/Meshes/mesh";
  68823. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68824. import { Effect } from "babylonjs/Materials/effect";
  68825. /**
  68826. * Block used to implement the reflectivity module of the PBR material
  68827. */
  68828. export class ReflectivityBlock extends NodeMaterialBlock {
  68829. private _metallicReflectanceColor;
  68830. private _metallicF0Factor;
  68831. /** @hidden */
  68832. _vMetallicReflectanceFactorsName: string;
  68833. /**
  68834. * The property below is set by the main PBR block prior to calling methods of this class.
  68835. */
  68836. /** @hidden */
  68837. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68838. /**
  68839. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68840. */
  68841. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68842. /**
  68843. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68844. */
  68845. useMetallnessFromMetallicTextureBlue: boolean;
  68846. /**
  68847. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68848. */
  68849. useRoughnessFromMetallicTextureAlpha: boolean;
  68850. /**
  68851. * Specifies if the metallic texture contains the roughness information in its green channel.
  68852. */
  68853. useRoughnessFromMetallicTextureGreen: boolean;
  68854. /**
  68855. * Create a new ReflectivityBlock
  68856. * @param name defines the block name
  68857. */
  68858. constructor(name: string);
  68859. /**
  68860. * Initialize the block and prepare the context for build
  68861. * @param state defines the state that will be used for the build
  68862. */
  68863. initialize(state: NodeMaterialBuildState): void;
  68864. /**
  68865. * Gets the current class name
  68866. * @returns the class name
  68867. */
  68868. getClassName(): string;
  68869. /**
  68870. * Gets the metallic input component
  68871. */
  68872. get metallic(): NodeMaterialConnectionPoint;
  68873. /**
  68874. * Gets the roughness input component
  68875. */
  68876. get roughness(): NodeMaterialConnectionPoint;
  68877. /**
  68878. * Gets the texture input component
  68879. */
  68880. get texture(): NodeMaterialConnectionPoint;
  68881. /**
  68882. * Gets the reflectivity object output component
  68883. */
  68884. get reflectivity(): NodeMaterialConnectionPoint;
  68885. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68886. /**
  68887. * Gets the main code of the block (fragment side)
  68888. * @param state current state of the node material building
  68889. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68890. * @returns the shader code
  68891. */
  68892. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68893. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68894. protected _buildBlock(state: NodeMaterialBuildState): this;
  68895. protected _dumpPropertiesCode(): string;
  68896. serialize(): any;
  68897. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68898. }
  68899. }
  68900. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68901. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68902. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68903. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68904. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68905. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68906. /**
  68907. * Block used to implement the anisotropy module of the PBR material
  68908. */
  68909. export class AnisotropyBlock extends NodeMaterialBlock {
  68910. /**
  68911. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68912. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68913. * It's less burden on the user side in the editor part.
  68914. */
  68915. /** @hidden */
  68916. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68917. /** @hidden */
  68918. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68919. /**
  68920. * Create a new AnisotropyBlock
  68921. * @param name defines the block name
  68922. */
  68923. constructor(name: string);
  68924. /**
  68925. * Initialize the block and prepare the context for build
  68926. * @param state defines the state that will be used for the build
  68927. */
  68928. initialize(state: NodeMaterialBuildState): void;
  68929. /**
  68930. * Gets the current class name
  68931. * @returns the class name
  68932. */
  68933. getClassName(): string;
  68934. /**
  68935. * Gets the intensity input component
  68936. */
  68937. get intensity(): NodeMaterialConnectionPoint;
  68938. /**
  68939. * Gets the direction input component
  68940. */
  68941. get direction(): NodeMaterialConnectionPoint;
  68942. /**
  68943. * Gets the texture input component
  68944. */
  68945. get texture(): NodeMaterialConnectionPoint;
  68946. /**
  68947. * Gets the uv input component
  68948. */
  68949. get uv(): NodeMaterialConnectionPoint;
  68950. /**
  68951. * Gets the worldTangent input component
  68952. */
  68953. get worldTangent(): NodeMaterialConnectionPoint;
  68954. /**
  68955. * Gets the anisotropy object output component
  68956. */
  68957. get anisotropy(): NodeMaterialConnectionPoint;
  68958. private _generateTBNSpace;
  68959. /**
  68960. * Gets the main code of the block (fragment side)
  68961. * @param state current state of the node material building
  68962. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68963. * @returns the shader code
  68964. */
  68965. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68966. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68967. protected _buildBlock(state: NodeMaterialBuildState): this;
  68968. }
  68969. }
  68970. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68971. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68972. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68973. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68974. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68976. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68977. import { Nullable } from "babylonjs/types";
  68978. import { Mesh } from "babylonjs/Meshes/mesh";
  68979. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68980. import { Effect } from "babylonjs/Materials/effect";
  68981. /**
  68982. * Block used to implement the clear coat module of the PBR material
  68983. */
  68984. export class ClearCoatBlock extends NodeMaterialBlock {
  68985. private _scene;
  68986. /**
  68987. * Create a new ClearCoatBlock
  68988. * @param name defines the block name
  68989. */
  68990. constructor(name: string);
  68991. /**
  68992. * Initialize the block and prepare the context for build
  68993. * @param state defines the state that will be used for the build
  68994. */
  68995. initialize(state: NodeMaterialBuildState): void;
  68996. /**
  68997. * Gets the current class name
  68998. * @returns the class name
  68999. */
  69000. getClassName(): string;
  69001. /**
  69002. * Gets the intensity input component
  69003. */
  69004. get intensity(): NodeMaterialConnectionPoint;
  69005. /**
  69006. * Gets the roughness input component
  69007. */
  69008. get roughness(): NodeMaterialConnectionPoint;
  69009. /**
  69010. * Gets the ior input component
  69011. */
  69012. get ior(): NodeMaterialConnectionPoint;
  69013. /**
  69014. * Gets the texture input component
  69015. */
  69016. get texture(): NodeMaterialConnectionPoint;
  69017. /**
  69018. * Gets the bump texture input component
  69019. */
  69020. get bumpTexture(): NodeMaterialConnectionPoint;
  69021. /**
  69022. * Gets the uv input component
  69023. */
  69024. get uv(): NodeMaterialConnectionPoint;
  69025. /**
  69026. * Gets the tint color input component
  69027. */
  69028. get tintColor(): NodeMaterialConnectionPoint;
  69029. /**
  69030. * Gets the tint "at distance" input component
  69031. */
  69032. get tintAtDistance(): NodeMaterialConnectionPoint;
  69033. /**
  69034. * Gets the tint thickness input component
  69035. */
  69036. get tintThickness(): NodeMaterialConnectionPoint;
  69037. /**
  69038. * Gets the world tangent input component
  69039. */
  69040. get worldTangent(): NodeMaterialConnectionPoint;
  69041. /**
  69042. * Gets the clear coat object output component
  69043. */
  69044. get clearcoat(): NodeMaterialConnectionPoint;
  69045. autoConfigure(material: NodeMaterial): void;
  69046. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69047. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  69048. private _generateTBNSpace;
  69049. /**
  69050. * Gets the main code of the block (fragment side)
  69051. * @param state current state of the node material building
  69052. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  69053. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69054. * @param worldPosVarName name of the variable holding the world position
  69055. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  69056. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  69057. * @param worldNormalVarName name of the variable holding the world normal
  69058. * @returns the shader code
  69059. */
  69060. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  69061. protected _buildBlock(state: NodeMaterialBuildState): this;
  69062. }
  69063. }
  69064. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  69065. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69066. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69067. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69068. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69070. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69071. import { Nullable } from "babylonjs/types";
  69072. /**
  69073. * Block used to implement the sub surface module of the PBR material
  69074. */
  69075. export class SubSurfaceBlock extends NodeMaterialBlock {
  69076. /**
  69077. * Create a new SubSurfaceBlock
  69078. * @param name defines the block name
  69079. */
  69080. constructor(name: string);
  69081. /**
  69082. * Stores the intensity of the different subsurface effects in the thickness texture.
  69083. * * the green channel is the translucency intensity.
  69084. * * the blue channel is the scattering intensity.
  69085. * * the alpha channel is the refraction intensity.
  69086. */
  69087. useMaskFromThicknessTexture: boolean;
  69088. /**
  69089. * Initialize the block and prepare the context for build
  69090. * @param state defines the state that will be used for the build
  69091. */
  69092. initialize(state: NodeMaterialBuildState): void;
  69093. /**
  69094. * Gets the current class name
  69095. * @returns the class name
  69096. */
  69097. getClassName(): string;
  69098. /**
  69099. * Gets the min thickness input component
  69100. */
  69101. get minThickness(): NodeMaterialConnectionPoint;
  69102. /**
  69103. * Gets the max thickness input component
  69104. */
  69105. get maxThickness(): NodeMaterialConnectionPoint;
  69106. /**
  69107. * Gets the thickness texture component
  69108. */
  69109. get thicknessTexture(): NodeMaterialConnectionPoint;
  69110. /**
  69111. * Gets the tint color input component
  69112. */
  69113. get tintColor(): NodeMaterialConnectionPoint;
  69114. /**
  69115. * Gets the translucency intensity input component
  69116. */
  69117. get translucencyIntensity(): NodeMaterialConnectionPoint;
  69118. /**
  69119. * Gets the translucency diffusion distance input component
  69120. */
  69121. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  69122. /**
  69123. * Gets the refraction object parameters
  69124. */
  69125. get refraction(): NodeMaterialConnectionPoint;
  69126. /**
  69127. * Gets the sub surface object output component
  69128. */
  69129. get subsurface(): NodeMaterialConnectionPoint;
  69130. autoConfigure(material: NodeMaterial): void;
  69131. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69132. /**
  69133. * Gets the main code of the block (fragment side)
  69134. * @param state current state of the node material building
  69135. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  69136. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  69137. * @param worldPosVarName name of the variable holding the world position
  69138. * @returns the shader code
  69139. */
  69140. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  69141. protected _buildBlock(state: NodeMaterialBuildState): this;
  69142. }
  69143. }
  69144. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  69145. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69146. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69147. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69148. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  69149. import { Light } from "babylonjs/Lights/light";
  69150. import { Nullable } from "babylonjs/types";
  69151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69152. import { Effect } from "babylonjs/Materials/effect";
  69153. import { Mesh } from "babylonjs/Meshes/mesh";
  69154. import { Scene } from "babylonjs/scene";
  69155. /**
  69156. * Block used to implement the PBR metallic/roughness model
  69157. */
  69158. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  69159. /**
  69160. * Gets or sets the light associated with this block
  69161. */
  69162. light: Nullable<Light>;
  69163. private _lightId;
  69164. private _scene;
  69165. private _environmentBRDFTexture;
  69166. private _environmentBrdfSamplerName;
  69167. private _vNormalWName;
  69168. private _invertNormalName;
  69169. /**
  69170. * Create a new ReflectionBlock
  69171. * @param name defines the block name
  69172. */
  69173. constructor(name: string);
  69174. /**
  69175. * Intensity of the direct lights e.g. the four lights available in your scene.
  69176. * This impacts both the direct diffuse and specular highlights.
  69177. */
  69178. directIntensity: number;
  69179. /**
  69180. * Intensity of the environment e.g. how much the environment will light the object
  69181. * either through harmonics for rough material or through the refelction for shiny ones.
  69182. */
  69183. environmentIntensity: number;
  69184. /**
  69185. * This is a special control allowing the reduction of the specular highlights coming from the
  69186. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  69187. */
  69188. specularIntensity: number;
  69189. /**
  69190. * Defines the falloff type used in this material.
  69191. * It by default is Physical.
  69192. */
  69193. lightFalloff: number;
  69194. /**
  69195. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  69196. */
  69197. useAlphaFromAlbedoTexture: boolean;
  69198. /**
  69199. * Specifies that alpha test should be used
  69200. */
  69201. useAlphaTest: boolean;
  69202. /**
  69203. * Defines the alpha limits in alpha test mode.
  69204. */
  69205. alphaTestCutoff: number;
  69206. /**
  69207. * Specifies that alpha blending should be used
  69208. */
  69209. useAlphaBlending: boolean;
  69210. /**
  69211. * Defines if the alpha value should be determined via the rgb values.
  69212. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  69213. */
  69214. opacityRGB: boolean;
  69215. /**
  69216. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  69217. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  69218. */
  69219. useRadianceOverAlpha: boolean;
  69220. /**
  69221. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  69222. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  69223. */
  69224. useSpecularOverAlpha: boolean;
  69225. /**
  69226. * Enables specular anti aliasing in the PBR shader.
  69227. * It will both interacts on the Geometry for analytical and IBL lighting.
  69228. * It also prefilter the roughness map based on the bump values.
  69229. */
  69230. enableSpecularAntiAliasing: boolean;
  69231. /**
  69232. * Enables realtime filtering on the texture.
  69233. */
  69234. realTimeFiltering: boolean;
  69235. /**
  69236. * Quality switch for realtime filtering
  69237. */
  69238. realTimeFilteringQuality: number;
  69239. /**
  69240. * Defines if the material uses energy conservation.
  69241. */
  69242. useEnergyConservation: boolean;
  69243. /**
  69244. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  69245. * too much the area relying on ambient texture to define their ambient occlusion.
  69246. */
  69247. useRadianceOcclusion: boolean;
  69248. /**
  69249. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  69250. * makes the reflect vector face the model (under horizon).
  69251. */
  69252. useHorizonOcclusion: boolean;
  69253. /**
  69254. * If set to true, no lighting calculations will be applied.
  69255. */
  69256. unlit: boolean;
  69257. /**
  69258. * Force normal to face away from face.
  69259. */
  69260. forceNormalForward: boolean;
  69261. /**
  69262. * Defines the material debug mode.
  69263. * It helps seeing only some components of the material while troubleshooting.
  69264. */
  69265. debugMode: number;
  69266. /**
  69267. * Specify from where on screen the debug mode should start.
  69268. * The value goes from -1 (full screen) to 1 (not visible)
  69269. * It helps with side by side comparison against the final render
  69270. * This defaults to 0
  69271. */
  69272. debugLimit: number;
  69273. /**
  69274. * As the default viewing range might not be enough (if the ambient is really small for instance)
  69275. * You can use the factor to better multiply the final value.
  69276. */
  69277. debugFactor: number;
  69278. /**
  69279. * Initialize the block and prepare the context for build
  69280. * @param state defines the state that will be used for the build
  69281. */
  69282. initialize(state: NodeMaterialBuildState): void;
  69283. /**
  69284. * Gets the current class name
  69285. * @returns the class name
  69286. */
  69287. getClassName(): string;
  69288. /**
  69289. * Gets the world position input component
  69290. */
  69291. get worldPosition(): NodeMaterialConnectionPoint;
  69292. /**
  69293. * Gets the world normal input component
  69294. */
  69295. get worldNormal(): NodeMaterialConnectionPoint;
  69296. /**
  69297. * Gets the perturbed normal input component
  69298. */
  69299. get perturbedNormal(): NodeMaterialConnectionPoint;
  69300. /**
  69301. * Gets the camera position input component
  69302. */
  69303. get cameraPosition(): NodeMaterialConnectionPoint;
  69304. /**
  69305. * Gets the base color input component
  69306. */
  69307. get baseColor(): NodeMaterialConnectionPoint;
  69308. /**
  69309. * Gets the opacity texture input component
  69310. */
  69311. get opacityTexture(): NodeMaterialConnectionPoint;
  69312. /**
  69313. * Gets the ambient color input component
  69314. */
  69315. get ambientColor(): NodeMaterialConnectionPoint;
  69316. /**
  69317. * Gets the reflectivity object parameters
  69318. */
  69319. get reflectivity(): NodeMaterialConnectionPoint;
  69320. /**
  69321. * Gets the ambient occlusion object parameters
  69322. */
  69323. get ambientOcc(): NodeMaterialConnectionPoint;
  69324. /**
  69325. * Gets the reflection object parameters
  69326. */
  69327. get reflection(): NodeMaterialConnectionPoint;
  69328. /**
  69329. * Gets the sheen object parameters
  69330. */
  69331. get sheen(): NodeMaterialConnectionPoint;
  69332. /**
  69333. * Gets the clear coat object parameters
  69334. */
  69335. get clearcoat(): NodeMaterialConnectionPoint;
  69336. /**
  69337. * Gets the sub surface object parameters
  69338. */
  69339. get subsurface(): NodeMaterialConnectionPoint;
  69340. /**
  69341. * Gets the anisotropy object parameters
  69342. */
  69343. get anisotropy(): NodeMaterialConnectionPoint;
  69344. /**
  69345. * Gets the view matrix parameter
  69346. */
  69347. get view(): NodeMaterialConnectionPoint;
  69348. /**
  69349. * Gets the ambient output component
  69350. */
  69351. get ambient(): NodeMaterialConnectionPoint;
  69352. /**
  69353. * Gets the diffuse output component
  69354. */
  69355. get diffuse(): NodeMaterialConnectionPoint;
  69356. /**
  69357. * Gets the specular output component
  69358. */
  69359. get specular(): NodeMaterialConnectionPoint;
  69360. /**
  69361. * Gets the sheen output component
  69362. */
  69363. get sheenDir(): NodeMaterialConnectionPoint;
  69364. /**
  69365. * Gets the clear coat output component
  69366. */
  69367. get clearcoatDir(): NodeMaterialConnectionPoint;
  69368. /**
  69369. * Gets the indirect diffuse output component
  69370. */
  69371. get diffuseIndirect(): NodeMaterialConnectionPoint;
  69372. /**
  69373. * Gets the indirect specular output component
  69374. */
  69375. get specularIndirect(): NodeMaterialConnectionPoint;
  69376. /**
  69377. * Gets the indirect sheen output component
  69378. */
  69379. get sheenIndirect(): NodeMaterialConnectionPoint;
  69380. /**
  69381. * Gets the indirect clear coat output component
  69382. */
  69383. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  69384. /**
  69385. * Gets the refraction output component
  69386. */
  69387. get refraction(): NodeMaterialConnectionPoint;
  69388. /**
  69389. * Gets the global lighting output component
  69390. */
  69391. get lighting(): NodeMaterialConnectionPoint;
  69392. /**
  69393. * Gets the shadow output component
  69394. */
  69395. get shadow(): NodeMaterialConnectionPoint;
  69396. /**
  69397. * Gets the alpha output component
  69398. */
  69399. get alpha(): NodeMaterialConnectionPoint;
  69400. autoConfigure(material: NodeMaterial): void;
  69401. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  69402. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  69403. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  69404. private _injectVertexCode;
  69405. /**
  69406. * Gets the code corresponding to the albedo/opacity module
  69407. * @returns the shader code
  69408. */
  69409. getAlbedoOpacityCode(): string;
  69410. protected _buildBlock(state: NodeMaterialBuildState): this;
  69411. protected _dumpPropertiesCode(): string;
  69412. serialize(): any;
  69413. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  69414. }
  69415. }
  69416. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  69417. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  69418. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  69419. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  69420. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  69421. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  69422. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  69423. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  69424. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  69425. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  69426. }
  69427. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  69428. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  69429. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  69430. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  69431. }
  69432. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  69433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  69434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  69435. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69436. /**
  69437. * Block used to compute value of one parameter modulo another
  69438. */
  69439. export class ModBlock extends NodeMaterialBlock {
  69440. /**
  69441. * Creates a new ModBlock
  69442. * @param name defines the block name
  69443. */
  69444. constructor(name: string);
  69445. /**
  69446. * Gets the current class name
  69447. * @returns the class name
  69448. */
  69449. getClassName(): string;
  69450. /**
  69451. * Gets the left operand input component
  69452. */
  69453. get left(): NodeMaterialConnectionPoint;
  69454. /**
  69455. * Gets the right operand input component
  69456. */
  69457. get right(): NodeMaterialConnectionPoint;
  69458. /**
  69459. * Gets the output component
  69460. */
  69461. get output(): NodeMaterialConnectionPoint;
  69462. protected _buildBlock(state: NodeMaterialBuildState): this;
  69463. }
  69464. }
  69465. declare module "babylonjs/Materials/Node/Blocks/index" {
  69466. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  69467. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  69468. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  69469. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  69470. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  69471. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  69472. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  69473. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  69474. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  69475. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  69476. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  69477. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  69478. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  69479. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  69480. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  69481. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  69482. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  69483. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  69484. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  69485. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  69486. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  69487. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  69488. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  69489. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  69490. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  69491. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  69492. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  69493. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  69494. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  69495. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  69496. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  69497. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  69498. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  69499. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  69500. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  69501. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  69502. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  69503. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  69504. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  69505. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  69506. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  69507. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  69508. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  69509. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  69510. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  69511. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  69512. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  69513. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  69514. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  69515. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  69516. }
  69517. declare module "babylonjs/Materials/Node/Optimizers/index" {
  69518. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  69519. }
  69520. declare module "babylonjs/Materials/Node/index" {
  69521. export * from "babylonjs/Materials/Node/Enums/index";
  69522. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  69523. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  69524. export * from "babylonjs/Materials/Node/nodeMaterial";
  69525. export * from "babylonjs/Materials/Node/Blocks/index";
  69526. export * from "babylonjs/Materials/Node/Optimizers/index";
  69527. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  69528. }
  69529. declare module "babylonjs/Materials/index" {
  69530. export * from "babylonjs/Materials/Background/index";
  69531. export * from "babylonjs/Materials/colorCurves";
  69532. export * from "babylonjs/Materials/iEffectFallbacks";
  69533. export * from "babylonjs/Materials/effectFallbacks";
  69534. export * from "babylonjs/Materials/effect";
  69535. export * from "babylonjs/Materials/fresnelParameters";
  69536. export * from "babylonjs/Materials/imageProcessingConfiguration";
  69537. export * from "babylonjs/Materials/material";
  69538. export * from "babylonjs/Materials/materialDefines";
  69539. export * from "babylonjs/Materials/thinMaterialHelper";
  69540. export * from "babylonjs/Materials/materialHelper";
  69541. export * from "babylonjs/Materials/multiMaterial";
  69542. export * from "babylonjs/Materials/PBR/index";
  69543. export * from "babylonjs/Materials/pushMaterial";
  69544. export * from "babylonjs/Materials/shaderMaterial";
  69545. export * from "babylonjs/Materials/standardMaterial";
  69546. export * from "babylonjs/Materials/Textures/index";
  69547. export * from "babylonjs/Materials/uniformBuffer";
  69548. export * from "babylonjs/Materials/materialFlags";
  69549. export * from "babylonjs/Materials/Node/index";
  69550. export * from "babylonjs/Materials/effectRenderer";
  69551. export * from "babylonjs/Materials/shadowDepthWrapper";
  69552. }
  69553. declare module "babylonjs/Maths/index" {
  69554. export * from "babylonjs/Maths/math.scalar";
  69555. export * from "babylonjs/Maths/math";
  69556. export * from "babylonjs/Maths/sphericalPolynomial";
  69557. }
  69558. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  69559. import { IDisposable } from "babylonjs/scene";
  69560. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69561. /**
  69562. * Configuration for Draco compression
  69563. */
  69564. export interface IDracoCompressionConfiguration {
  69565. /**
  69566. * Configuration for the decoder.
  69567. */
  69568. decoder: {
  69569. /**
  69570. * The url to the WebAssembly module.
  69571. */
  69572. wasmUrl?: string;
  69573. /**
  69574. * The url to the WebAssembly binary.
  69575. */
  69576. wasmBinaryUrl?: string;
  69577. /**
  69578. * The url to the fallback JavaScript module.
  69579. */
  69580. fallbackUrl?: string;
  69581. };
  69582. }
  69583. /**
  69584. * Draco compression (https://google.github.io/draco/)
  69585. *
  69586. * This class wraps the Draco module.
  69587. *
  69588. * **Encoder**
  69589. *
  69590. * The encoder is not currently implemented.
  69591. *
  69592. * **Decoder**
  69593. *
  69594. * 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.
  69595. *
  69596. * To update the configuration, use the following code:
  69597. * ```javascript
  69598. * DracoCompression.Configuration = {
  69599. * decoder: {
  69600. * wasmUrl: "<url to the WebAssembly library>",
  69601. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  69602. * fallbackUrl: "<url to the fallback JavaScript library>",
  69603. * }
  69604. * };
  69605. * ```
  69606. *
  69607. * 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.
  69608. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  69609. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  69610. *
  69611. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  69612. * ```javascript
  69613. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  69614. * ```
  69615. *
  69616. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  69617. */
  69618. export class DracoCompression implements IDisposable {
  69619. private _workerPoolPromise?;
  69620. private _decoderModulePromise?;
  69621. /**
  69622. * The configuration. Defaults to the following urls:
  69623. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  69624. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  69625. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  69626. */
  69627. static Configuration: IDracoCompressionConfiguration;
  69628. /**
  69629. * Returns true if the decoder configuration is available.
  69630. */
  69631. static get DecoderAvailable(): boolean;
  69632. /**
  69633. * Default number of workers to create when creating the draco compression object.
  69634. */
  69635. static DefaultNumWorkers: number;
  69636. private static GetDefaultNumWorkers;
  69637. private static _Default;
  69638. /**
  69639. * Default instance for the draco compression object.
  69640. */
  69641. static get Default(): DracoCompression;
  69642. /**
  69643. * Constructor
  69644. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  69645. */
  69646. constructor(numWorkers?: number);
  69647. /**
  69648. * Stop all async operations and release resources.
  69649. */
  69650. dispose(): void;
  69651. /**
  69652. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  69653. * @returns a promise that resolves when ready
  69654. */
  69655. whenReadyAsync(): Promise<void>;
  69656. /**
  69657. * Decode Draco compressed mesh data to vertex data.
  69658. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  69659. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  69660. * @returns A promise that resolves with the decoded vertex data
  69661. */
  69662. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  69663. [kind: string]: number;
  69664. }): Promise<VertexData>;
  69665. }
  69666. }
  69667. declare module "babylonjs/Meshes/Compression/index" {
  69668. export * from "babylonjs/Meshes/Compression/dracoCompression";
  69669. }
  69670. declare module "babylonjs/Meshes/csg" {
  69671. import { Nullable } from "babylonjs/types";
  69672. import { Scene } from "babylonjs/scene";
  69673. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  69674. import { Mesh } from "babylonjs/Meshes/mesh";
  69675. import { Material } from "babylonjs/Materials/material";
  69676. /**
  69677. * Class for building Constructive Solid Geometry
  69678. */
  69679. export class CSG {
  69680. private polygons;
  69681. /**
  69682. * The world matrix
  69683. */
  69684. matrix: Matrix;
  69685. /**
  69686. * Stores the position
  69687. */
  69688. position: Vector3;
  69689. /**
  69690. * Stores the rotation
  69691. */
  69692. rotation: Vector3;
  69693. /**
  69694. * Stores the rotation quaternion
  69695. */
  69696. rotationQuaternion: Nullable<Quaternion>;
  69697. /**
  69698. * Stores the scaling vector
  69699. */
  69700. scaling: Vector3;
  69701. /**
  69702. * Convert the Mesh to CSG
  69703. * @param mesh The Mesh to convert to CSG
  69704. * @returns A new CSG from the Mesh
  69705. */
  69706. static FromMesh(mesh: Mesh): CSG;
  69707. /**
  69708. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  69709. * @param polygons Polygons used to construct a CSG solid
  69710. */
  69711. private static FromPolygons;
  69712. /**
  69713. * Clones, or makes a deep copy, of the CSG
  69714. * @returns A new CSG
  69715. */
  69716. clone(): CSG;
  69717. /**
  69718. * Unions this CSG with another CSG
  69719. * @param csg The CSG to union against this CSG
  69720. * @returns The unioned CSG
  69721. */
  69722. union(csg: CSG): CSG;
  69723. /**
  69724. * Unions this CSG with another CSG in place
  69725. * @param csg The CSG to union against this CSG
  69726. */
  69727. unionInPlace(csg: CSG): void;
  69728. /**
  69729. * Subtracts this CSG with another CSG
  69730. * @param csg The CSG to subtract against this CSG
  69731. * @returns A new CSG
  69732. */
  69733. subtract(csg: CSG): CSG;
  69734. /**
  69735. * Subtracts this CSG with another CSG in place
  69736. * @param csg The CSG to subtact against this CSG
  69737. */
  69738. subtractInPlace(csg: CSG): void;
  69739. /**
  69740. * Intersect this CSG with another CSG
  69741. * @param csg The CSG to intersect against this CSG
  69742. * @returns A new CSG
  69743. */
  69744. intersect(csg: CSG): CSG;
  69745. /**
  69746. * Intersects this CSG with another CSG in place
  69747. * @param csg The CSG to intersect against this CSG
  69748. */
  69749. intersectInPlace(csg: CSG): void;
  69750. /**
  69751. * Return a new CSG solid with solid and empty space switched. This solid is
  69752. * not modified.
  69753. * @returns A new CSG solid with solid and empty space switched
  69754. */
  69755. inverse(): CSG;
  69756. /**
  69757. * Inverses the CSG in place
  69758. */
  69759. inverseInPlace(): void;
  69760. /**
  69761. * This is used to keep meshes transformations so they can be restored
  69762. * when we build back a Babylon Mesh
  69763. * NB : All CSG operations are performed in world coordinates
  69764. * @param csg The CSG to copy the transform attributes from
  69765. * @returns This CSG
  69766. */
  69767. copyTransformAttributes(csg: CSG): CSG;
  69768. /**
  69769. * Build Raw mesh from CSG
  69770. * Coordinates here are in world space
  69771. * @param name The name of the mesh geometry
  69772. * @param scene The Scene
  69773. * @param keepSubMeshes Specifies if the submeshes should be kept
  69774. * @returns A new Mesh
  69775. */
  69776. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69777. /**
  69778. * Build Mesh from CSG taking material and transforms into account
  69779. * @param name The name of the Mesh
  69780. * @param material The material of the Mesh
  69781. * @param scene The Scene
  69782. * @param keepSubMeshes Specifies if submeshes should be kept
  69783. * @returns The new Mesh
  69784. */
  69785. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  69786. }
  69787. }
  69788. declare module "babylonjs/Meshes/trailMesh" {
  69789. import { Mesh } from "babylonjs/Meshes/mesh";
  69790. import { Scene } from "babylonjs/scene";
  69791. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69792. /**
  69793. * Class used to create a trail following a mesh
  69794. */
  69795. export class TrailMesh extends Mesh {
  69796. private _generator;
  69797. private _autoStart;
  69798. private _running;
  69799. private _diameter;
  69800. private _length;
  69801. private _sectionPolygonPointsCount;
  69802. private _sectionVectors;
  69803. private _sectionNormalVectors;
  69804. private _beforeRenderObserver;
  69805. /**
  69806. * @constructor
  69807. * @param name The value used by scene.getMeshByName() to do a lookup.
  69808. * @param generator The mesh or transform node to generate a trail.
  69809. * @param scene The scene to add this mesh to.
  69810. * @param diameter Diameter of trailing mesh. Default is 1.
  69811. * @param length Length of trailing mesh. Default is 60.
  69812. * @param autoStart Automatically start trailing mesh. Default true.
  69813. */
  69814. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69815. /**
  69816. * "TrailMesh"
  69817. * @returns "TrailMesh"
  69818. */
  69819. getClassName(): string;
  69820. private _createMesh;
  69821. /**
  69822. * Start trailing mesh.
  69823. */
  69824. start(): void;
  69825. /**
  69826. * Stop trailing mesh.
  69827. */
  69828. stop(): void;
  69829. /**
  69830. * Update trailing mesh geometry.
  69831. */
  69832. update(): void;
  69833. /**
  69834. * Returns a new TrailMesh object.
  69835. * @param name is a string, the name given to the new mesh
  69836. * @param newGenerator use new generator object for cloned trail mesh
  69837. * @returns a new mesh
  69838. */
  69839. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69840. /**
  69841. * Serializes this trail mesh
  69842. * @param serializationObject object to write serialization to
  69843. */
  69844. serialize(serializationObject: any): void;
  69845. /**
  69846. * Parses a serialized trail mesh
  69847. * @param parsedMesh the serialized mesh
  69848. * @param scene the scene to create the trail mesh in
  69849. * @returns the created trail mesh
  69850. */
  69851. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69852. }
  69853. }
  69854. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69855. import { Nullable } from "babylonjs/types";
  69856. import { Scene } from "babylonjs/scene";
  69857. import { Vector4 } from "babylonjs/Maths/math.vector";
  69858. import { Color4 } from "babylonjs/Maths/math.color";
  69859. import { Mesh } from "babylonjs/Meshes/mesh";
  69860. /**
  69861. * Class containing static functions to help procedurally build meshes
  69862. */
  69863. export class TiledBoxBuilder {
  69864. /**
  69865. * Creates a box mesh
  69866. * 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)
  69867. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69869. * * 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
  69870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69871. * @param name defines the name of the mesh
  69872. * @param options defines the options used to create the mesh
  69873. * @param scene defines the hosting scene
  69874. * @returns the box mesh
  69875. */
  69876. static CreateTiledBox(name: string, options: {
  69877. pattern?: number;
  69878. width?: number;
  69879. height?: number;
  69880. depth?: number;
  69881. tileSize?: number;
  69882. tileWidth?: number;
  69883. tileHeight?: number;
  69884. alignHorizontal?: number;
  69885. alignVertical?: number;
  69886. faceUV?: Vector4[];
  69887. faceColors?: Color4[];
  69888. sideOrientation?: number;
  69889. updatable?: boolean;
  69890. }, scene?: Nullable<Scene>): Mesh;
  69891. }
  69892. }
  69893. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69894. import { Vector4 } from "babylonjs/Maths/math.vector";
  69895. import { Mesh } from "babylonjs/Meshes/mesh";
  69896. /**
  69897. * Class containing static functions to help procedurally build meshes
  69898. */
  69899. export class TorusKnotBuilder {
  69900. /**
  69901. * Creates a torus knot mesh
  69902. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69903. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69904. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69905. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69907. * * 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
  69908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69909. * @param name defines the name of the mesh
  69910. * @param options defines the options used to create the mesh
  69911. * @param scene defines the hosting scene
  69912. * @returns the torus knot mesh
  69913. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69914. */
  69915. static CreateTorusKnot(name: string, options: {
  69916. radius?: number;
  69917. tube?: number;
  69918. radialSegments?: number;
  69919. tubularSegments?: number;
  69920. p?: number;
  69921. q?: number;
  69922. updatable?: boolean;
  69923. sideOrientation?: number;
  69924. frontUVs?: Vector4;
  69925. backUVs?: Vector4;
  69926. }, scene: any): Mesh;
  69927. }
  69928. }
  69929. declare module "babylonjs/Meshes/polygonMesh" {
  69930. import { Scene } from "babylonjs/scene";
  69931. import { Vector2 } from "babylonjs/Maths/math.vector";
  69932. import { Mesh } from "babylonjs/Meshes/mesh";
  69933. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69934. import { Path2 } from "babylonjs/Maths/math.path";
  69935. /**
  69936. * Polygon
  69937. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69938. */
  69939. export class Polygon {
  69940. /**
  69941. * Creates a rectangle
  69942. * @param xmin bottom X coord
  69943. * @param ymin bottom Y coord
  69944. * @param xmax top X coord
  69945. * @param ymax top Y coord
  69946. * @returns points that make the resulting rectation
  69947. */
  69948. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69949. /**
  69950. * Creates a circle
  69951. * @param radius radius of circle
  69952. * @param cx scale in x
  69953. * @param cy scale in y
  69954. * @param numberOfSides number of sides that make up the circle
  69955. * @returns points that make the resulting circle
  69956. */
  69957. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69958. /**
  69959. * Creates a polygon from input string
  69960. * @param input Input polygon data
  69961. * @returns the parsed points
  69962. */
  69963. static Parse(input: string): Vector2[];
  69964. /**
  69965. * Starts building a polygon from x and y coordinates
  69966. * @param x x coordinate
  69967. * @param y y coordinate
  69968. * @returns the started path2
  69969. */
  69970. static StartingAt(x: number, y: number): Path2;
  69971. }
  69972. /**
  69973. * Builds a polygon
  69974. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69975. */
  69976. export class PolygonMeshBuilder {
  69977. private _points;
  69978. private _outlinepoints;
  69979. private _holes;
  69980. private _name;
  69981. private _scene;
  69982. private _epoints;
  69983. private _eholes;
  69984. private _addToepoint;
  69985. /**
  69986. * Babylon reference to the earcut plugin.
  69987. */
  69988. bjsEarcut: any;
  69989. /**
  69990. * Creates a PolygonMeshBuilder
  69991. * @param name name of the builder
  69992. * @param contours Path of the polygon
  69993. * @param scene scene to add to when creating the mesh
  69994. * @param earcutInjection can be used to inject your own earcut reference
  69995. */
  69996. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69997. /**
  69998. * Adds a whole within the polygon
  69999. * @param hole Array of points defining the hole
  70000. * @returns this
  70001. */
  70002. addHole(hole: Vector2[]): PolygonMeshBuilder;
  70003. /**
  70004. * Creates the polygon
  70005. * @param updatable If the mesh should be updatable
  70006. * @param depth The depth of the mesh created
  70007. * @returns the created mesh
  70008. */
  70009. build(updatable?: boolean, depth?: number): Mesh;
  70010. /**
  70011. * Creates the polygon
  70012. * @param depth The depth of the mesh created
  70013. * @returns the created VertexData
  70014. */
  70015. buildVertexData(depth?: number): VertexData;
  70016. /**
  70017. * Adds a side to the polygon
  70018. * @param positions points that make the polygon
  70019. * @param normals normals of the polygon
  70020. * @param uvs uvs of the polygon
  70021. * @param indices indices of the polygon
  70022. * @param bounds bounds of the polygon
  70023. * @param points points of the polygon
  70024. * @param depth depth of the polygon
  70025. * @param flip flip of the polygon
  70026. */
  70027. private addSide;
  70028. }
  70029. }
  70030. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  70031. import { Scene } from "babylonjs/scene";
  70032. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70033. import { Color4 } from "babylonjs/Maths/math.color";
  70034. import { Mesh } from "babylonjs/Meshes/mesh";
  70035. import { Nullable } from "babylonjs/types";
  70036. /**
  70037. * Class containing static functions to help procedurally build meshes
  70038. */
  70039. export class PolygonBuilder {
  70040. /**
  70041. * Creates a polygon mesh
  70042. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70043. * * 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
  70044. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70046. * * 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)
  70047. * * Remember you can only change the shape positions, not their number when updating a polygon
  70048. * @param name defines the name of the mesh
  70049. * @param options defines the options used to create the mesh
  70050. * @param scene defines the hosting scene
  70051. * @param earcutInjection can be used to inject your own earcut reference
  70052. * @returns the polygon mesh
  70053. */
  70054. static CreatePolygon(name: string, options: {
  70055. shape: Vector3[];
  70056. holes?: Vector3[][];
  70057. depth?: number;
  70058. faceUV?: Vector4[];
  70059. faceColors?: Color4[];
  70060. updatable?: boolean;
  70061. sideOrientation?: number;
  70062. frontUVs?: Vector4;
  70063. backUVs?: Vector4;
  70064. wrap?: boolean;
  70065. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70066. /**
  70067. * Creates an extruded polygon mesh, with depth in the Y direction.
  70068. * * 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)
  70069. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70070. * @param name defines the name of the mesh
  70071. * @param options defines the options used to create the mesh
  70072. * @param scene defines the hosting scene
  70073. * @param earcutInjection can be used to inject your own earcut reference
  70074. * @returns the polygon mesh
  70075. */
  70076. static ExtrudePolygon(name: string, options: {
  70077. shape: Vector3[];
  70078. holes?: Vector3[][];
  70079. depth?: number;
  70080. faceUV?: Vector4[];
  70081. faceColors?: Color4[];
  70082. updatable?: boolean;
  70083. sideOrientation?: number;
  70084. frontUVs?: Vector4;
  70085. backUVs?: Vector4;
  70086. wrap?: boolean;
  70087. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70088. }
  70089. }
  70090. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  70091. import { Scene } from "babylonjs/scene";
  70092. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70093. import { Mesh } from "babylonjs/Meshes/mesh";
  70094. import { Nullable } from "babylonjs/types";
  70095. /**
  70096. * Class containing static functions to help procedurally build meshes
  70097. */
  70098. export class LatheBuilder {
  70099. /**
  70100. * Creates lathe mesh.
  70101. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70102. * * 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
  70103. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70104. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70105. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70106. * * 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
  70107. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70108. * * 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
  70109. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70110. * * 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
  70111. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70113. * @param name defines the name of the mesh
  70114. * @param options defines the options used to create the mesh
  70115. * @param scene defines the hosting scene
  70116. * @returns the lathe mesh
  70117. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70118. */
  70119. static CreateLathe(name: string, options: {
  70120. shape: Vector3[];
  70121. radius?: number;
  70122. tessellation?: number;
  70123. clip?: number;
  70124. arc?: number;
  70125. closed?: boolean;
  70126. updatable?: boolean;
  70127. sideOrientation?: number;
  70128. frontUVs?: Vector4;
  70129. backUVs?: Vector4;
  70130. cap?: number;
  70131. invertUV?: boolean;
  70132. }, scene?: Nullable<Scene>): Mesh;
  70133. }
  70134. }
  70135. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  70136. import { Nullable } from "babylonjs/types";
  70137. import { Scene } from "babylonjs/scene";
  70138. import { Vector4 } from "babylonjs/Maths/math.vector";
  70139. import { Mesh } from "babylonjs/Meshes/mesh";
  70140. /**
  70141. * Class containing static functions to help procedurally build meshes
  70142. */
  70143. export class TiledPlaneBuilder {
  70144. /**
  70145. * Creates a tiled plane mesh
  70146. * * The parameter `pattern` will, depending on value, do nothing or
  70147. * * * flip (reflect about central vertical) alternate tiles across and up
  70148. * * * flip every tile on alternate rows
  70149. * * * rotate (180 degs) alternate tiles across and up
  70150. * * * rotate every tile on alternate rows
  70151. * * * flip and rotate alternate tiles across and up
  70152. * * * flip and rotate every tile on alternate rows
  70153. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  70154. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  70155. * * 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
  70156. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70157. * * 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)
  70158. * * 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)
  70159. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70160. * @param name defines the name of the mesh
  70161. * @param options defines the options used to create the mesh
  70162. * @param scene defines the hosting scene
  70163. * @returns the box mesh
  70164. */
  70165. static CreateTiledPlane(name: string, options: {
  70166. pattern?: number;
  70167. tileSize?: number;
  70168. tileWidth?: number;
  70169. tileHeight?: number;
  70170. size?: number;
  70171. width?: number;
  70172. height?: number;
  70173. alignHorizontal?: number;
  70174. alignVertical?: number;
  70175. sideOrientation?: number;
  70176. frontUVs?: Vector4;
  70177. backUVs?: Vector4;
  70178. updatable?: boolean;
  70179. }, scene?: Nullable<Scene>): Mesh;
  70180. }
  70181. }
  70182. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  70183. import { Nullable } from "babylonjs/types";
  70184. import { Scene } from "babylonjs/scene";
  70185. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  70186. import { Mesh } from "babylonjs/Meshes/mesh";
  70187. /**
  70188. * Class containing static functions to help procedurally build meshes
  70189. */
  70190. export class TubeBuilder {
  70191. /**
  70192. * Creates a tube mesh.
  70193. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70194. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70195. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70196. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70197. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70198. * * 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)
  70199. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70200. * * 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
  70201. * * 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
  70202. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70203. * * 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
  70204. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70206. * @param name defines the name of the mesh
  70207. * @param options defines the options used to create the mesh
  70208. * @param scene defines the hosting scene
  70209. * @returns the tube mesh
  70210. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70211. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70212. */
  70213. static CreateTube(name: string, options: {
  70214. path: Vector3[];
  70215. radius?: number;
  70216. tessellation?: number;
  70217. radiusFunction?: {
  70218. (i: number, distance: number): number;
  70219. };
  70220. cap?: number;
  70221. arc?: number;
  70222. updatable?: boolean;
  70223. sideOrientation?: number;
  70224. frontUVs?: Vector4;
  70225. backUVs?: Vector4;
  70226. instance?: Mesh;
  70227. invertUV?: boolean;
  70228. }, scene?: Nullable<Scene>): Mesh;
  70229. }
  70230. }
  70231. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  70232. import { Scene } from "babylonjs/scene";
  70233. import { Vector4 } from "babylonjs/Maths/math.vector";
  70234. import { Mesh } from "babylonjs/Meshes/mesh";
  70235. import { Nullable } from "babylonjs/types";
  70236. /**
  70237. * Class containing static functions to help procedurally build meshes
  70238. */
  70239. export class IcoSphereBuilder {
  70240. /**
  70241. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70242. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70243. * * 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`)
  70244. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70245. * * 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
  70246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70247. * * 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
  70248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70249. * @param name defines the name of the mesh
  70250. * @param options defines the options used to create the mesh
  70251. * @param scene defines the hosting scene
  70252. * @returns the icosahedron mesh
  70253. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70254. */
  70255. static CreateIcoSphere(name: string, options: {
  70256. radius?: number;
  70257. radiusX?: number;
  70258. radiusY?: number;
  70259. radiusZ?: number;
  70260. flat?: boolean;
  70261. subdivisions?: number;
  70262. sideOrientation?: number;
  70263. frontUVs?: Vector4;
  70264. backUVs?: Vector4;
  70265. updatable?: boolean;
  70266. }, scene?: Nullable<Scene>): Mesh;
  70267. }
  70268. }
  70269. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  70270. import { Vector3 } from "babylonjs/Maths/math.vector";
  70271. import { Mesh } from "babylonjs/Meshes/mesh";
  70272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70273. /**
  70274. * Class containing static functions to help procedurally build meshes
  70275. */
  70276. export class DecalBuilder {
  70277. /**
  70278. * Creates a decal mesh.
  70279. * 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
  70280. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70281. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70282. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70283. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70284. * @param name defines the name of the mesh
  70285. * @param sourceMesh defines the mesh where the decal must be applied
  70286. * @param options defines the options used to create the mesh
  70287. * @param scene defines the hosting scene
  70288. * @returns the decal mesh
  70289. * @see https://doc.babylonjs.com/how_to/decals
  70290. */
  70291. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70292. position?: Vector3;
  70293. normal?: Vector3;
  70294. size?: Vector3;
  70295. angle?: number;
  70296. }): Mesh;
  70297. }
  70298. }
  70299. declare module "babylonjs/Meshes/meshBuilder" {
  70300. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  70301. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  70302. import { Nullable } from "babylonjs/types";
  70303. import { Scene } from "babylonjs/scene";
  70304. import { Mesh } from "babylonjs/Meshes/mesh";
  70305. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  70306. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  70307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70308. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  70309. import { Plane } from "babylonjs/Maths/math.plane";
  70310. /**
  70311. * Class containing static functions to help procedurally build meshes
  70312. */
  70313. export class MeshBuilder {
  70314. /**
  70315. * Creates a box mesh
  70316. * * The parameter `size` sets the size (float) of each box side (default 1)
  70317. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  70318. * * 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)
  70319. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70320. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70321. * * 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
  70322. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70323. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  70324. * @param name defines the name of the mesh
  70325. * @param options defines the options used to create the mesh
  70326. * @param scene defines the hosting scene
  70327. * @returns the box mesh
  70328. */
  70329. static CreateBox(name: string, options: {
  70330. size?: number;
  70331. width?: number;
  70332. height?: number;
  70333. depth?: number;
  70334. faceUV?: Vector4[];
  70335. faceColors?: Color4[];
  70336. sideOrientation?: number;
  70337. frontUVs?: Vector4;
  70338. backUVs?: Vector4;
  70339. wrap?: boolean;
  70340. topBaseAt?: number;
  70341. bottomBaseAt?: number;
  70342. updatable?: boolean;
  70343. }, scene?: Nullable<Scene>): Mesh;
  70344. /**
  70345. * Creates a tiled box mesh
  70346. * * faceTiles sets the pattern, tile size and number of tiles for a face
  70347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70348. * @param name defines the name of the mesh
  70349. * @param options defines the options used to create the mesh
  70350. * @param scene defines the hosting scene
  70351. * @returns the tiled box mesh
  70352. */
  70353. static CreateTiledBox(name: string, options: {
  70354. pattern?: number;
  70355. size?: number;
  70356. width?: number;
  70357. height?: number;
  70358. depth: number;
  70359. tileSize?: number;
  70360. tileWidth?: number;
  70361. tileHeight?: number;
  70362. faceUV?: Vector4[];
  70363. faceColors?: Color4[];
  70364. alignHorizontal?: number;
  70365. alignVertical?: number;
  70366. sideOrientation?: number;
  70367. updatable?: boolean;
  70368. }, scene?: Nullable<Scene>): Mesh;
  70369. /**
  70370. * Creates a sphere mesh
  70371. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  70372. * * 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`)
  70373. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  70374. * * 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
  70375. * * 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)
  70376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70377. * * 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
  70378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70379. * @param name defines the name of the mesh
  70380. * @param options defines the options used to create the mesh
  70381. * @param scene defines the hosting scene
  70382. * @returns the sphere mesh
  70383. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  70384. */
  70385. static CreateSphere(name: string, options: {
  70386. segments?: number;
  70387. diameter?: number;
  70388. diameterX?: number;
  70389. diameterY?: number;
  70390. diameterZ?: number;
  70391. arc?: number;
  70392. slice?: number;
  70393. sideOrientation?: number;
  70394. frontUVs?: Vector4;
  70395. backUVs?: Vector4;
  70396. updatable?: boolean;
  70397. }, scene?: Nullable<Scene>): Mesh;
  70398. /**
  70399. * Creates a plane polygonal mesh. By default, this is a disc
  70400. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  70401. * * 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
  70402. * * 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
  70403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70404. * * 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
  70405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70406. * @param name defines the name of the mesh
  70407. * @param options defines the options used to create the mesh
  70408. * @param scene defines the hosting scene
  70409. * @returns the plane polygonal mesh
  70410. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  70411. */
  70412. static CreateDisc(name: string, options: {
  70413. radius?: number;
  70414. tessellation?: number;
  70415. arc?: number;
  70416. updatable?: boolean;
  70417. sideOrientation?: number;
  70418. frontUVs?: Vector4;
  70419. backUVs?: Vector4;
  70420. }, scene?: Nullable<Scene>): Mesh;
  70421. /**
  70422. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  70423. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  70424. * * 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`)
  70425. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  70426. * * 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
  70427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70428. * * 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
  70429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70430. * @param name defines the name of the mesh
  70431. * @param options defines the options used to create the mesh
  70432. * @param scene defines the hosting scene
  70433. * @returns the icosahedron mesh
  70434. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  70435. */
  70436. static CreateIcoSphere(name: string, options: {
  70437. radius?: number;
  70438. radiusX?: number;
  70439. radiusY?: number;
  70440. radiusZ?: number;
  70441. flat?: boolean;
  70442. subdivisions?: number;
  70443. sideOrientation?: number;
  70444. frontUVs?: Vector4;
  70445. backUVs?: Vector4;
  70446. updatable?: boolean;
  70447. }, scene?: Nullable<Scene>): Mesh;
  70448. /**
  70449. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70450. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  70451. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  70452. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  70453. * * 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
  70454. * * 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
  70455. * * 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
  70456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70457. * * 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
  70458. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70459. * * 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
  70460. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  70461. * * 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
  70462. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  70463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70464. * @param name defines the name of the mesh
  70465. * @param options defines the options used to create the mesh
  70466. * @param scene defines the hosting scene
  70467. * @returns the ribbon mesh
  70468. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  70469. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70470. */
  70471. static CreateRibbon(name: string, options: {
  70472. pathArray: Vector3[][];
  70473. closeArray?: boolean;
  70474. closePath?: boolean;
  70475. offset?: number;
  70476. updatable?: boolean;
  70477. sideOrientation?: number;
  70478. frontUVs?: Vector4;
  70479. backUVs?: Vector4;
  70480. instance?: Mesh;
  70481. invertUV?: boolean;
  70482. uvs?: Vector2[];
  70483. colors?: Color4[];
  70484. }, scene?: Nullable<Scene>): Mesh;
  70485. /**
  70486. * Creates a cylinder or a cone mesh
  70487. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  70488. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  70489. * * 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.
  70490. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  70491. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  70492. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  70493. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  70494. * * 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).
  70495. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  70496. * * 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).
  70497. * * 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
  70498. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  70499. * * 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
  70500. * * 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.
  70501. * * If `enclose` is false, a ring surface is one element.
  70502. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  70503. * * 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
  70504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70505. * * 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
  70506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70507. * @param name defines the name of the mesh
  70508. * @param options defines the options used to create the mesh
  70509. * @param scene defines the hosting scene
  70510. * @returns the cylinder mesh
  70511. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  70512. */
  70513. static CreateCylinder(name: string, options: {
  70514. height?: number;
  70515. diameterTop?: number;
  70516. diameterBottom?: number;
  70517. diameter?: number;
  70518. tessellation?: number;
  70519. subdivisions?: number;
  70520. arc?: number;
  70521. faceColors?: Color4[];
  70522. faceUV?: Vector4[];
  70523. updatable?: boolean;
  70524. hasRings?: boolean;
  70525. enclose?: boolean;
  70526. cap?: number;
  70527. sideOrientation?: number;
  70528. frontUVs?: Vector4;
  70529. backUVs?: Vector4;
  70530. }, scene?: Nullable<Scene>): Mesh;
  70531. /**
  70532. * Creates a torus mesh
  70533. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  70534. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  70535. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  70536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70537. * * 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
  70538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70539. * @param name defines the name of the mesh
  70540. * @param options defines the options used to create the mesh
  70541. * @param scene defines the hosting scene
  70542. * @returns the torus mesh
  70543. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  70544. */
  70545. static CreateTorus(name: string, options: {
  70546. diameter?: number;
  70547. thickness?: number;
  70548. tessellation?: number;
  70549. updatable?: boolean;
  70550. sideOrientation?: number;
  70551. frontUVs?: Vector4;
  70552. backUVs?: Vector4;
  70553. }, scene?: Nullable<Scene>): Mesh;
  70554. /**
  70555. * Creates a torus knot mesh
  70556. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  70557. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  70558. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  70559. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  70560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70561. * * 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
  70562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70563. * @param name defines the name of the mesh
  70564. * @param options defines the options used to create the mesh
  70565. * @param scene defines the hosting scene
  70566. * @returns the torus knot mesh
  70567. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  70568. */
  70569. static CreateTorusKnot(name: string, options: {
  70570. radius?: number;
  70571. tube?: number;
  70572. radialSegments?: number;
  70573. tubularSegments?: number;
  70574. p?: number;
  70575. q?: number;
  70576. updatable?: boolean;
  70577. sideOrientation?: number;
  70578. frontUVs?: Vector4;
  70579. backUVs?: Vector4;
  70580. }, scene?: Nullable<Scene>): Mesh;
  70581. /**
  70582. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  70583. * * 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
  70584. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  70585. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  70586. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  70587. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  70588. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  70589. * * 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
  70590. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  70591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70592. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  70593. * @param name defines the name of the new line system
  70594. * @param options defines the options used to create the line system
  70595. * @param scene defines the hosting scene
  70596. * @returns a new line system mesh
  70597. */
  70598. static CreateLineSystem(name: string, options: {
  70599. lines: Vector3[][];
  70600. updatable?: boolean;
  70601. instance?: Nullable<LinesMesh>;
  70602. colors?: Nullable<Color4[][]>;
  70603. useVertexAlpha?: boolean;
  70604. }, scene: Nullable<Scene>): LinesMesh;
  70605. /**
  70606. * Creates a line mesh
  70607. * 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
  70608. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70609. * * The parameter `points` is an array successive Vector3
  70610. * * 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
  70611. * * The optional parameter `colors` is an array of successive Color4, one per line point
  70612. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  70613. * * When updating an instance, remember that only point positions can change, not the number of points
  70614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  70616. * @param name defines the name of the new line system
  70617. * @param options defines the options used to create the line system
  70618. * @param scene defines the hosting scene
  70619. * @returns a new line mesh
  70620. */
  70621. static CreateLines(name: string, options: {
  70622. points: Vector3[];
  70623. updatable?: boolean;
  70624. instance?: Nullable<LinesMesh>;
  70625. colors?: Color4[];
  70626. useVertexAlpha?: boolean;
  70627. }, scene?: Nullable<Scene>): LinesMesh;
  70628. /**
  70629. * Creates a dashed line mesh
  70630. * * 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
  70631. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  70632. * * The parameter `points` is an array successive Vector3
  70633. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  70634. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  70635. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  70636. * * 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
  70637. * * When updating an instance, remember that only point positions can change, not the number of points
  70638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70639. * @param name defines the name of the mesh
  70640. * @param options defines the options used to create the mesh
  70641. * @param scene defines the hosting scene
  70642. * @returns the dashed line mesh
  70643. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  70644. */
  70645. static CreateDashedLines(name: string, options: {
  70646. points: Vector3[];
  70647. dashSize?: number;
  70648. gapSize?: number;
  70649. dashNb?: number;
  70650. updatable?: boolean;
  70651. instance?: LinesMesh;
  70652. }, scene?: Nullable<Scene>): LinesMesh;
  70653. /**
  70654. * 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.
  70655. * * 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.
  70656. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70657. * * 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.
  70658. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  70659. * * 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
  70660. * * 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
  70661. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  70662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70663. * * 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
  70664. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  70665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70666. * @param name defines the name of the mesh
  70667. * @param options defines the options used to create the mesh
  70668. * @param scene defines the hosting scene
  70669. * @returns the extruded shape mesh
  70670. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70671. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70672. */
  70673. static ExtrudeShape(name: string, options: {
  70674. shape: Vector3[];
  70675. path: Vector3[];
  70676. scale?: number;
  70677. rotation?: number;
  70678. cap?: number;
  70679. updatable?: boolean;
  70680. sideOrientation?: number;
  70681. frontUVs?: Vector4;
  70682. backUVs?: Vector4;
  70683. instance?: Mesh;
  70684. invertUV?: boolean;
  70685. }, scene?: Nullable<Scene>): Mesh;
  70686. /**
  70687. * Creates an custom extruded shape mesh.
  70688. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  70689. * * 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.
  70690. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  70691. * * 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
  70692. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  70693. * * 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
  70694. * * It must returns a float value that will be the scale value applied to the shape on each path point
  70695. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  70696. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  70697. * * 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
  70698. * * 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
  70699. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  70700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70701. * * 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
  70702. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70704. * @param name defines the name of the mesh
  70705. * @param options defines the options used to create the mesh
  70706. * @param scene defines the hosting scene
  70707. * @returns the custom extruded shape mesh
  70708. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  70709. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70710. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  70711. */
  70712. static ExtrudeShapeCustom(name: string, options: {
  70713. shape: Vector3[];
  70714. path: Vector3[];
  70715. scaleFunction?: any;
  70716. rotationFunction?: any;
  70717. ribbonCloseArray?: boolean;
  70718. ribbonClosePath?: boolean;
  70719. cap?: number;
  70720. updatable?: boolean;
  70721. sideOrientation?: number;
  70722. frontUVs?: Vector4;
  70723. backUVs?: Vector4;
  70724. instance?: Mesh;
  70725. invertUV?: boolean;
  70726. }, scene?: Nullable<Scene>): Mesh;
  70727. /**
  70728. * Creates lathe mesh.
  70729. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  70730. * * 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
  70731. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  70732. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  70733. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  70734. * * 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
  70735. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  70736. * * 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
  70737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70738. * * 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
  70739. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70741. * @param name defines the name of the mesh
  70742. * @param options defines the options used to create the mesh
  70743. * @param scene defines the hosting scene
  70744. * @returns the lathe mesh
  70745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  70746. */
  70747. static CreateLathe(name: string, options: {
  70748. shape: Vector3[];
  70749. radius?: number;
  70750. tessellation?: number;
  70751. clip?: number;
  70752. arc?: number;
  70753. closed?: boolean;
  70754. updatable?: boolean;
  70755. sideOrientation?: number;
  70756. frontUVs?: Vector4;
  70757. backUVs?: Vector4;
  70758. cap?: number;
  70759. invertUV?: boolean;
  70760. }, scene?: Nullable<Scene>): Mesh;
  70761. /**
  70762. * Creates a tiled plane mesh
  70763. * * You can set a limited pattern arrangement with the tiles
  70764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70765. * * 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
  70766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70767. * @param name defines the name of the mesh
  70768. * @param options defines the options used to create the mesh
  70769. * @param scene defines the hosting scene
  70770. * @returns the plane mesh
  70771. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70772. */
  70773. static CreateTiledPlane(name: string, options: {
  70774. pattern?: number;
  70775. tileSize?: number;
  70776. tileWidth?: number;
  70777. tileHeight?: number;
  70778. size?: number;
  70779. width?: number;
  70780. height?: number;
  70781. alignHorizontal?: number;
  70782. alignVertical?: number;
  70783. sideOrientation?: number;
  70784. frontUVs?: Vector4;
  70785. backUVs?: Vector4;
  70786. updatable?: boolean;
  70787. }, scene?: Nullable<Scene>): Mesh;
  70788. /**
  70789. * Creates a plane mesh
  70790. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  70791. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  70792. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  70793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70794. * * 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
  70795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70796. * @param name defines the name of the mesh
  70797. * @param options defines the options used to create the mesh
  70798. * @param scene defines the hosting scene
  70799. * @returns the plane mesh
  70800. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  70801. */
  70802. static CreatePlane(name: string, options: {
  70803. size?: number;
  70804. width?: number;
  70805. height?: number;
  70806. sideOrientation?: number;
  70807. frontUVs?: Vector4;
  70808. backUVs?: Vector4;
  70809. updatable?: boolean;
  70810. sourcePlane?: Plane;
  70811. }, scene?: Nullable<Scene>): Mesh;
  70812. /**
  70813. * Creates a ground mesh
  70814. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70815. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70817. * @param name defines the name of the mesh
  70818. * @param options defines the options used to create the mesh
  70819. * @param scene defines the hosting scene
  70820. * @returns the ground mesh
  70821. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70822. */
  70823. static CreateGround(name: string, options: {
  70824. width?: number;
  70825. height?: number;
  70826. subdivisions?: number;
  70827. subdivisionsX?: number;
  70828. subdivisionsY?: number;
  70829. updatable?: boolean;
  70830. }, scene?: Nullable<Scene>): Mesh;
  70831. /**
  70832. * Creates a tiled ground mesh
  70833. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70834. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70835. * * 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
  70836. * * 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
  70837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70838. * @param name defines the name of the mesh
  70839. * @param options defines the options used to create the mesh
  70840. * @param scene defines the hosting scene
  70841. * @returns the tiled ground mesh
  70842. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70843. */
  70844. static CreateTiledGround(name: string, options: {
  70845. xmin: number;
  70846. zmin: number;
  70847. xmax: number;
  70848. zmax: number;
  70849. subdivisions?: {
  70850. w: number;
  70851. h: number;
  70852. };
  70853. precision?: {
  70854. w: number;
  70855. h: number;
  70856. };
  70857. updatable?: boolean;
  70858. }, scene?: Nullable<Scene>): Mesh;
  70859. /**
  70860. * Creates a ground mesh from a height map
  70861. * * The parameter `url` sets the URL of the height map image resource.
  70862. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70863. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70864. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70865. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70866. * * 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.
  70867. * * 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).
  70868. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70870. * @param name defines the name of the mesh
  70871. * @param url defines the url to the height map
  70872. * @param options defines the options used to create the mesh
  70873. * @param scene defines the hosting scene
  70874. * @returns the ground mesh
  70875. * @see https://doc.babylonjs.com/babylon101/height_map
  70876. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70877. */
  70878. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70879. width?: number;
  70880. height?: number;
  70881. subdivisions?: number;
  70882. minHeight?: number;
  70883. maxHeight?: number;
  70884. colorFilter?: Color3;
  70885. alphaFilter?: number;
  70886. updatable?: boolean;
  70887. onReady?: (mesh: GroundMesh) => void;
  70888. }, scene?: Nullable<Scene>): GroundMesh;
  70889. /**
  70890. * Creates a polygon mesh
  70891. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70892. * * 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
  70893. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70895. * * 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)
  70896. * * Remember you can only change the shape positions, not their number when updating a polygon
  70897. * @param name defines the name of the mesh
  70898. * @param options defines the options used to create the mesh
  70899. * @param scene defines the hosting scene
  70900. * @param earcutInjection can be used to inject your own earcut reference
  70901. * @returns the polygon mesh
  70902. */
  70903. static CreatePolygon(name: string, options: {
  70904. shape: Vector3[];
  70905. holes?: Vector3[][];
  70906. depth?: number;
  70907. faceUV?: Vector4[];
  70908. faceColors?: Color4[];
  70909. updatable?: boolean;
  70910. sideOrientation?: number;
  70911. frontUVs?: Vector4;
  70912. backUVs?: Vector4;
  70913. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70914. /**
  70915. * Creates an extruded polygon mesh, with depth in the Y direction.
  70916. * * 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)
  70917. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70918. * @param name defines the name of the mesh
  70919. * @param options defines the options used to create the mesh
  70920. * @param scene defines the hosting scene
  70921. * @param earcutInjection can be used to inject your own earcut reference
  70922. * @returns the polygon mesh
  70923. */
  70924. static ExtrudePolygon(name: string, options: {
  70925. shape: Vector3[];
  70926. holes?: Vector3[][];
  70927. depth?: number;
  70928. faceUV?: Vector4[];
  70929. faceColors?: Color4[];
  70930. updatable?: boolean;
  70931. sideOrientation?: number;
  70932. frontUVs?: Vector4;
  70933. backUVs?: Vector4;
  70934. wrap?: boolean;
  70935. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70936. /**
  70937. * Creates a tube mesh.
  70938. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70939. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70940. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70941. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70942. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70943. * * 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)
  70944. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70945. * * 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
  70946. * * 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
  70947. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70948. * * 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
  70949. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70950. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70951. * @param name defines the name of the mesh
  70952. * @param options defines the options used to create the mesh
  70953. * @param scene defines the hosting scene
  70954. * @returns the tube mesh
  70955. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70956. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70957. */
  70958. static CreateTube(name: string, options: {
  70959. path: Vector3[];
  70960. radius?: number;
  70961. tessellation?: number;
  70962. radiusFunction?: {
  70963. (i: number, distance: number): number;
  70964. };
  70965. cap?: number;
  70966. arc?: number;
  70967. updatable?: boolean;
  70968. sideOrientation?: number;
  70969. frontUVs?: Vector4;
  70970. backUVs?: Vector4;
  70971. instance?: Mesh;
  70972. invertUV?: boolean;
  70973. }, scene?: Nullable<Scene>): Mesh;
  70974. /**
  70975. * Creates a polyhedron mesh
  70976. * * 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
  70977. * * The parameter `size` (positive float, default 1) sets the polygon size
  70978. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70979. * * 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`
  70980. * * 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
  70981. * * 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)`)
  70982. * * 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
  70983. * * 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
  70984. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70985. * * 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
  70986. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70987. * @param name defines the name of the mesh
  70988. * @param options defines the options used to create the mesh
  70989. * @param scene defines the hosting scene
  70990. * @returns the polyhedron mesh
  70991. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70992. */
  70993. static CreatePolyhedron(name: string, options: {
  70994. type?: number;
  70995. size?: number;
  70996. sizeX?: number;
  70997. sizeY?: number;
  70998. sizeZ?: number;
  70999. custom?: any;
  71000. faceUV?: Vector4[];
  71001. faceColors?: Color4[];
  71002. flat?: boolean;
  71003. updatable?: boolean;
  71004. sideOrientation?: number;
  71005. frontUVs?: Vector4;
  71006. backUVs?: Vector4;
  71007. }, scene?: Nullable<Scene>): Mesh;
  71008. /**
  71009. * Creates a decal mesh.
  71010. * 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
  71011. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  71012. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  71013. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  71014. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  71015. * @param name defines the name of the mesh
  71016. * @param sourceMesh defines the mesh where the decal must be applied
  71017. * @param options defines the options used to create the mesh
  71018. * @param scene defines the hosting scene
  71019. * @returns the decal mesh
  71020. * @see https://doc.babylonjs.com/how_to/decals
  71021. */
  71022. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  71023. position?: Vector3;
  71024. normal?: Vector3;
  71025. size?: Vector3;
  71026. angle?: number;
  71027. }): Mesh;
  71028. /**
  71029. * Creates a Capsule Mesh
  71030. * @param name defines the name of the mesh.
  71031. * @param options the constructors options used to shape the mesh.
  71032. * @param scene defines the scene the mesh is scoped to.
  71033. * @returns the capsule mesh
  71034. * @see https://doc.babylonjs.com/how_to/capsule_shape
  71035. */
  71036. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  71037. }
  71038. }
  71039. declare module "babylonjs/Meshes/meshSimplification" {
  71040. import { Mesh } from "babylonjs/Meshes/mesh";
  71041. /**
  71042. * A simplifier interface for future simplification implementations
  71043. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71044. */
  71045. export interface ISimplifier {
  71046. /**
  71047. * Simplification of a given mesh according to the given settings.
  71048. * Since this requires computation, it is assumed that the function runs async.
  71049. * @param settings The settings of the simplification, including quality and distance
  71050. * @param successCallback A callback that will be called after the mesh was simplified.
  71051. * @param errorCallback in case of an error, this callback will be called. optional.
  71052. */
  71053. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  71054. }
  71055. /**
  71056. * Expected simplification settings.
  71057. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  71058. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71059. */
  71060. export interface ISimplificationSettings {
  71061. /**
  71062. * Gets or sets the expected quality
  71063. */
  71064. quality: number;
  71065. /**
  71066. * Gets or sets the distance when this optimized version should be used
  71067. */
  71068. distance: number;
  71069. /**
  71070. * Gets an already optimized mesh
  71071. */
  71072. optimizeMesh?: boolean;
  71073. }
  71074. /**
  71075. * Class used to specify simplification options
  71076. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71077. */
  71078. export class SimplificationSettings implements ISimplificationSettings {
  71079. /** expected quality */
  71080. quality: number;
  71081. /** distance when this optimized version should be used */
  71082. distance: number;
  71083. /** already optimized mesh */
  71084. optimizeMesh?: boolean | undefined;
  71085. /**
  71086. * Creates a SimplificationSettings
  71087. * @param quality expected quality
  71088. * @param distance distance when this optimized version should be used
  71089. * @param optimizeMesh already optimized mesh
  71090. */
  71091. constructor(
  71092. /** expected quality */
  71093. quality: number,
  71094. /** distance when this optimized version should be used */
  71095. distance: number,
  71096. /** already optimized mesh */
  71097. optimizeMesh?: boolean | undefined);
  71098. }
  71099. /**
  71100. * Interface used to define a simplification task
  71101. */
  71102. export interface ISimplificationTask {
  71103. /**
  71104. * Array of settings
  71105. */
  71106. settings: Array<ISimplificationSettings>;
  71107. /**
  71108. * Simplification type
  71109. */
  71110. simplificationType: SimplificationType;
  71111. /**
  71112. * Mesh to simplify
  71113. */
  71114. mesh: Mesh;
  71115. /**
  71116. * Callback called on success
  71117. */
  71118. successCallback?: () => void;
  71119. /**
  71120. * Defines if parallel processing can be used
  71121. */
  71122. parallelProcessing: boolean;
  71123. }
  71124. /**
  71125. * Queue used to order the simplification tasks
  71126. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71127. */
  71128. export class SimplificationQueue {
  71129. private _simplificationArray;
  71130. /**
  71131. * Gets a boolean indicating that the process is still running
  71132. */
  71133. running: boolean;
  71134. /**
  71135. * Creates a new queue
  71136. */
  71137. constructor();
  71138. /**
  71139. * Adds a new simplification task
  71140. * @param task defines a task to add
  71141. */
  71142. addTask(task: ISimplificationTask): void;
  71143. /**
  71144. * Execute next task
  71145. */
  71146. executeNext(): void;
  71147. /**
  71148. * Execute a simplification task
  71149. * @param task defines the task to run
  71150. */
  71151. runSimplification(task: ISimplificationTask): void;
  71152. private getSimplifier;
  71153. }
  71154. /**
  71155. * The implemented types of simplification
  71156. * At the moment only Quadratic Error Decimation is implemented
  71157. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71158. */
  71159. export enum SimplificationType {
  71160. /** Quadratic error decimation */
  71161. QUADRATIC = 0
  71162. }
  71163. /**
  71164. * An implementation of the Quadratic Error simplification algorithm.
  71165. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  71166. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  71167. * @author RaananW
  71168. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71169. */
  71170. export class QuadraticErrorSimplification implements ISimplifier {
  71171. private _mesh;
  71172. private triangles;
  71173. private vertices;
  71174. private references;
  71175. private _reconstructedMesh;
  71176. /** Gets or sets the number pf sync interations */
  71177. syncIterations: number;
  71178. /** Gets or sets the aggressiveness of the simplifier */
  71179. aggressiveness: number;
  71180. /** Gets or sets the number of allowed iterations for decimation */
  71181. decimationIterations: number;
  71182. /** Gets or sets the espilon to use for bounding box computation */
  71183. boundingBoxEpsilon: number;
  71184. /**
  71185. * Creates a new QuadraticErrorSimplification
  71186. * @param _mesh defines the target mesh
  71187. */
  71188. constructor(_mesh: Mesh);
  71189. /**
  71190. * Simplification of a given mesh according to the given settings.
  71191. * Since this requires computation, it is assumed that the function runs async.
  71192. * @param settings The settings of the simplification, including quality and distance
  71193. * @param successCallback A callback that will be called after the mesh was simplified.
  71194. */
  71195. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  71196. private runDecimation;
  71197. private initWithMesh;
  71198. private init;
  71199. private reconstructMesh;
  71200. private initDecimatedMesh;
  71201. private isFlipped;
  71202. private updateTriangles;
  71203. private identifyBorder;
  71204. private updateMesh;
  71205. private vertexError;
  71206. private calculateError;
  71207. }
  71208. }
  71209. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  71210. import { Scene } from "babylonjs/scene";
  71211. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  71212. import { ISceneComponent } from "babylonjs/sceneComponent";
  71213. module "babylonjs/scene" {
  71214. interface Scene {
  71215. /** @hidden (Backing field) */
  71216. _simplificationQueue: SimplificationQueue;
  71217. /**
  71218. * Gets or sets the simplification queue attached to the scene
  71219. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  71220. */
  71221. simplificationQueue: SimplificationQueue;
  71222. }
  71223. }
  71224. module "babylonjs/Meshes/mesh" {
  71225. interface Mesh {
  71226. /**
  71227. * Simplify the mesh according to the given array of settings.
  71228. * Function will return immediately and will simplify async
  71229. * @param settings a collection of simplification settings
  71230. * @param parallelProcessing should all levels calculate parallel or one after the other
  71231. * @param simplificationType the type of simplification to run
  71232. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  71233. * @returns the current mesh
  71234. */
  71235. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  71236. }
  71237. }
  71238. /**
  71239. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  71240. * created in a scene
  71241. */
  71242. export class SimplicationQueueSceneComponent implements ISceneComponent {
  71243. /**
  71244. * The component name helpfull to identify the component in the list of scene components.
  71245. */
  71246. readonly name: string;
  71247. /**
  71248. * The scene the component belongs to.
  71249. */
  71250. scene: Scene;
  71251. /**
  71252. * Creates a new instance of the component for the given scene
  71253. * @param scene Defines the scene to register the component in
  71254. */
  71255. constructor(scene: Scene);
  71256. /**
  71257. * Registers the component in a given scene
  71258. */
  71259. register(): void;
  71260. /**
  71261. * Rebuilds the elements related to this component in case of
  71262. * context lost for instance.
  71263. */
  71264. rebuild(): void;
  71265. /**
  71266. * Disposes the component and the associated ressources
  71267. */
  71268. dispose(): void;
  71269. private _beforeCameraUpdate;
  71270. }
  71271. }
  71272. declare module "babylonjs/Meshes/Builders/index" {
  71273. export * from "babylonjs/Meshes/Builders/boxBuilder";
  71274. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  71275. export * from "babylonjs/Meshes/Builders/discBuilder";
  71276. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  71277. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  71278. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  71279. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  71280. export * from "babylonjs/Meshes/Builders/torusBuilder";
  71281. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  71282. export * from "babylonjs/Meshes/Builders/linesBuilder";
  71283. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  71284. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  71285. export * from "babylonjs/Meshes/Builders/latheBuilder";
  71286. export * from "babylonjs/Meshes/Builders/planeBuilder";
  71287. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  71288. export * from "babylonjs/Meshes/Builders/groundBuilder";
  71289. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  71290. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  71291. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71292. export * from "babylonjs/Meshes/Builders/decalBuilder";
  71293. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  71294. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  71295. }
  71296. declare module "babylonjs/Meshes/thinInstanceMesh" {
  71297. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  71298. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  71299. import { Matrix } from "babylonjs/Maths/math.vector";
  71300. module "babylonjs/Meshes/mesh" {
  71301. interface Mesh {
  71302. /**
  71303. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  71304. */
  71305. thinInstanceEnablePicking: boolean;
  71306. /**
  71307. * Creates a new thin instance
  71308. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  71309. * @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
  71310. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  71311. */
  71312. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  71313. /**
  71314. * Adds the transformation (matrix) of the current mesh as a thin instance
  71315. * @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
  71316. * @returns the thin instance index number
  71317. */
  71318. thinInstanceAddSelf(refresh: boolean): number;
  71319. /**
  71320. * Registers a custom attribute to be used with thin instances
  71321. * @param kind name of the attribute
  71322. * @param stride size in floats of the attribute
  71323. */
  71324. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  71325. /**
  71326. * Sets the matrix of a thin instance
  71327. * @param index index of the thin instance
  71328. * @param matrix matrix to set
  71329. * @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
  71330. */
  71331. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  71332. /**
  71333. * Sets the value of a custom attribute for a thin instance
  71334. * @param kind name of the attribute
  71335. * @param index index of the thin instance
  71336. * @param value value to set
  71337. * @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
  71338. */
  71339. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  71340. /**
  71341. * 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.
  71342. */
  71343. thinInstanceCount: number;
  71344. /**
  71345. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  71346. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  71347. * @param buffer buffer to set
  71348. * @param stride size in floats of each value of the buffer
  71349. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  71350. */
  71351. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  71352. /**
  71353. * Gets the list of world matrices
  71354. * @return an array containing all the world matrices from the thin instances
  71355. */
  71356. thinInstanceGetWorldMatrices(): Matrix[];
  71357. /**
  71358. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  71359. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71360. */
  71361. thinInstanceBufferUpdated(kind: string): void;
  71362. /**
  71363. * Applies a partial update to a buffer directly on the GPU
  71364. * 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
  71365. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  71366. * @param data the data to set in the GPU buffer
  71367. * @param offset the offset in the GPU buffer where to update the data
  71368. */
  71369. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  71370. /**
  71371. * Refreshes the bounding info, taking into account all the thin instances defined
  71372. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  71373. */
  71374. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  71375. /** @hidden */
  71376. _thinInstanceInitializeUserStorage(): void;
  71377. /** @hidden */
  71378. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  71379. /** @hidden */
  71380. _userThinInstanceBuffersStorage: {
  71381. data: {
  71382. [key: string]: Float32Array;
  71383. };
  71384. sizes: {
  71385. [key: string]: number;
  71386. };
  71387. vertexBuffers: {
  71388. [key: string]: Nullable<VertexBuffer>;
  71389. };
  71390. strides: {
  71391. [key: string]: number;
  71392. };
  71393. };
  71394. }
  71395. }
  71396. }
  71397. declare module "babylonjs/Meshes/index" {
  71398. export * from "babylonjs/Meshes/abstractMesh";
  71399. export * from "babylonjs/Meshes/buffer";
  71400. export * from "babylonjs/Meshes/Compression/index";
  71401. export * from "babylonjs/Meshes/csg";
  71402. export * from "babylonjs/Meshes/geometry";
  71403. export * from "babylonjs/Meshes/groundMesh";
  71404. export * from "babylonjs/Meshes/trailMesh";
  71405. export * from "babylonjs/Meshes/instancedMesh";
  71406. export * from "babylonjs/Meshes/linesMesh";
  71407. export * from "babylonjs/Meshes/mesh";
  71408. export * from "babylonjs/Meshes/mesh.vertexData";
  71409. export * from "babylonjs/Meshes/meshBuilder";
  71410. export * from "babylonjs/Meshes/meshSimplification";
  71411. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  71412. export * from "babylonjs/Meshes/polygonMesh";
  71413. export * from "babylonjs/Meshes/subMesh";
  71414. export * from "babylonjs/Meshes/meshLODLevel";
  71415. export * from "babylonjs/Meshes/transformNode";
  71416. export * from "babylonjs/Meshes/Builders/index";
  71417. export * from "babylonjs/Meshes/dataBuffer";
  71418. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  71419. import "babylonjs/Meshes/thinInstanceMesh";
  71420. export * from "babylonjs/Meshes/thinInstanceMesh";
  71421. }
  71422. declare module "babylonjs/Morph/index" {
  71423. export * from "babylonjs/Morph/morphTarget";
  71424. export * from "babylonjs/Morph/morphTargetManager";
  71425. }
  71426. declare module "babylonjs/Navigation/INavigationEngine" {
  71427. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71428. import { Vector3 } from "babylonjs/Maths/math";
  71429. import { Mesh } from "babylonjs/Meshes/mesh";
  71430. import { Scene } from "babylonjs/scene";
  71431. /**
  71432. * Navigation plugin interface to add navigation constrained by a navigation mesh
  71433. */
  71434. export interface INavigationEnginePlugin {
  71435. /**
  71436. * plugin name
  71437. */
  71438. name: string;
  71439. /**
  71440. * Creates a navigation mesh
  71441. * @param meshes array of all the geometry used to compute the navigatio mesh
  71442. * @param parameters bunch of parameters used to filter geometry
  71443. */
  71444. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71445. /**
  71446. * Create a navigation mesh debug mesh
  71447. * @param scene is where the mesh will be added
  71448. * @returns debug display mesh
  71449. */
  71450. createDebugNavMesh(scene: Scene): Mesh;
  71451. /**
  71452. * Get a navigation mesh constrained position, closest to the parameter position
  71453. * @param position world position
  71454. * @returns the closest point to position constrained by the navigation mesh
  71455. */
  71456. getClosestPoint(position: Vector3): Vector3;
  71457. /**
  71458. * Get a navigation mesh constrained position, closest to the parameter position
  71459. * @param position world position
  71460. * @param result output the closest point to position constrained by the navigation mesh
  71461. */
  71462. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71463. /**
  71464. * Get a navigation mesh constrained position, within a particular radius
  71465. * @param position world position
  71466. * @param maxRadius the maximum distance to the constrained world position
  71467. * @returns the closest point to position constrained by the navigation mesh
  71468. */
  71469. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71470. /**
  71471. * Get a navigation mesh constrained position, within a particular radius
  71472. * @param position world position
  71473. * @param maxRadius the maximum distance to the constrained world position
  71474. * @param result output the closest point to position constrained by the navigation mesh
  71475. */
  71476. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71477. /**
  71478. * Compute the final position from a segment made of destination-position
  71479. * @param position world position
  71480. * @param destination world position
  71481. * @returns the resulting point along the navmesh
  71482. */
  71483. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71484. /**
  71485. * Compute the final position from a segment made of destination-position
  71486. * @param position world position
  71487. * @param destination world position
  71488. * @param result output the resulting point along the navmesh
  71489. */
  71490. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71491. /**
  71492. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71493. * @param start world position
  71494. * @param end world position
  71495. * @returns array containing world position composing the path
  71496. */
  71497. computePath(start: Vector3, end: Vector3): Vector3[];
  71498. /**
  71499. * If this plugin is supported
  71500. * @returns true if plugin is supported
  71501. */
  71502. isSupported(): boolean;
  71503. /**
  71504. * Create a new Crowd so you can add agents
  71505. * @param maxAgents the maximum agent count in the crowd
  71506. * @param maxAgentRadius the maximum radius an agent can have
  71507. * @param scene to attach the crowd to
  71508. * @returns the crowd you can add agents to
  71509. */
  71510. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71511. /**
  71512. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71513. * The queries will try to find a solution within those bounds
  71514. * default is (1,1,1)
  71515. * @param extent x,y,z value that define the extent around the queries point of reference
  71516. */
  71517. setDefaultQueryExtent(extent: Vector3): void;
  71518. /**
  71519. * Get the Bounding box extent specified by setDefaultQueryExtent
  71520. * @returns the box extent values
  71521. */
  71522. getDefaultQueryExtent(): Vector3;
  71523. /**
  71524. * build the navmesh from a previously saved state using getNavmeshData
  71525. * @param data the Uint8Array returned by getNavmeshData
  71526. */
  71527. buildFromNavmeshData(data: Uint8Array): void;
  71528. /**
  71529. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71530. * @returns data the Uint8Array that can be saved and reused
  71531. */
  71532. getNavmeshData(): Uint8Array;
  71533. /**
  71534. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71535. * @param result output the box extent values
  71536. */
  71537. getDefaultQueryExtentToRef(result: Vector3): void;
  71538. /**
  71539. * Release all resources
  71540. */
  71541. dispose(): void;
  71542. }
  71543. /**
  71544. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  71545. */
  71546. export interface ICrowd {
  71547. /**
  71548. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71549. * You can attach anything to that node. The node position is updated in the scene update tick.
  71550. * @param pos world position that will be constrained by the navigation mesh
  71551. * @param parameters agent parameters
  71552. * @param transform hooked to the agent that will be update by the scene
  71553. * @returns agent index
  71554. */
  71555. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71556. /**
  71557. * Returns the agent position in world space
  71558. * @param index agent index returned by addAgent
  71559. * @returns world space position
  71560. */
  71561. getAgentPosition(index: number): Vector3;
  71562. /**
  71563. * Gets the agent position result in world space
  71564. * @param index agent index returned by addAgent
  71565. * @param result output world space position
  71566. */
  71567. getAgentPositionToRef(index: number, result: Vector3): void;
  71568. /**
  71569. * Gets the agent velocity in world space
  71570. * @param index agent index returned by addAgent
  71571. * @returns world space velocity
  71572. */
  71573. getAgentVelocity(index: number): Vector3;
  71574. /**
  71575. * Gets the agent velocity result in world space
  71576. * @param index agent index returned by addAgent
  71577. * @param result output world space velocity
  71578. */
  71579. getAgentVelocityToRef(index: number, result: Vector3): void;
  71580. /**
  71581. * Gets the agent next target point on the path
  71582. * @param index agent index returned by addAgent
  71583. * @returns world space position
  71584. */
  71585. getAgentNextTargetPath(index: number): Vector3;
  71586. /**
  71587. * Gets the agent next target point on the path
  71588. * @param index agent index returned by addAgent
  71589. * @param result output world space position
  71590. */
  71591. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71592. /**
  71593. * remove a particular agent previously created
  71594. * @param index agent index returned by addAgent
  71595. */
  71596. removeAgent(index: number): void;
  71597. /**
  71598. * get the list of all agents attached to this crowd
  71599. * @returns list of agent indices
  71600. */
  71601. getAgents(): number[];
  71602. /**
  71603. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71604. * @param deltaTime in seconds
  71605. */
  71606. update(deltaTime: number): void;
  71607. /**
  71608. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71609. * @param index agent index returned by addAgent
  71610. * @param destination targeted world position
  71611. */
  71612. agentGoto(index: number, destination: Vector3): void;
  71613. /**
  71614. * Teleport the agent to a new position
  71615. * @param index agent index returned by addAgent
  71616. * @param destination targeted world position
  71617. */
  71618. agentTeleport(index: number, destination: Vector3): void;
  71619. /**
  71620. * Update agent parameters
  71621. * @param index agent index returned by addAgent
  71622. * @param parameters agent parameters
  71623. */
  71624. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71625. /**
  71626. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71627. * The queries will try to find a solution within those bounds
  71628. * default is (1,1,1)
  71629. * @param extent x,y,z value that define the extent around the queries point of reference
  71630. */
  71631. setDefaultQueryExtent(extent: Vector3): void;
  71632. /**
  71633. * Get the Bounding box extent specified by setDefaultQueryExtent
  71634. * @returns the box extent values
  71635. */
  71636. getDefaultQueryExtent(): Vector3;
  71637. /**
  71638. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71639. * @param result output the box extent values
  71640. */
  71641. getDefaultQueryExtentToRef(result: Vector3): void;
  71642. /**
  71643. * Release all resources
  71644. */
  71645. dispose(): void;
  71646. }
  71647. /**
  71648. * Configures an agent
  71649. */
  71650. export interface IAgentParameters {
  71651. /**
  71652. * Agent radius. [Limit: >= 0]
  71653. */
  71654. radius: number;
  71655. /**
  71656. * Agent height. [Limit: > 0]
  71657. */
  71658. height: number;
  71659. /**
  71660. * Maximum allowed acceleration. [Limit: >= 0]
  71661. */
  71662. maxAcceleration: number;
  71663. /**
  71664. * Maximum allowed speed. [Limit: >= 0]
  71665. */
  71666. maxSpeed: number;
  71667. /**
  71668. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  71669. */
  71670. collisionQueryRange: number;
  71671. /**
  71672. * The path visibility optimization range. [Limit: > 0]
  71673. */
  71674. pathOptimizationRange: number;
  71675. /**
  71676. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  71677. */
  71678. separationWeight: number;
  71679. }
  71680. /**
  71681. * Configures the navigation mesh creation
  71682. */
  71683. export interface INavMeshParameters {
  71684. /**
  71685. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  71686. */
  71687. cs: number;
  71688. /**
  71689. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  71690. */
  71691. ch: number;
  71692. /**
  71693. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  71694. */
  71695. walkableSlopeAngle: number;
  71696. /**
  71697. * Minimum floor to 'ceiling' height that will still allow the floor area to
  71698. * be considered walkable. [Limit: >= 3] [Units: vx]
  71699. */
  71700. walkableHeight: number;
  71701. /**
  71702. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  71703. */
  71704. walkableClimb: number;
  71705. /**
  71706. * The distance to erode/shrink the walkable area of the heightfield away from
  71707. * obstructions. [Limit: >=0] [Units: vx]
  71708. */
  71709. walkableRadius: number;
  71710. /**
  71711. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  71712. */
  71713. maxEdgeLen: number;
  71714. /**
  71715. * The maximum distance a simplfied contour's border edges should deviate
  71716. * the original raw contour. [Limit: >=0] [Units: vx]
  71717. */
  71718. maxSimplificationError: number;
  71719. /**
  71720. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  71721. */
  71722. minRegionArea: number;
  71723. /**
  71724. * Any regions with a span count smaller than this value will, if possible,
  71725. * be merged with larger regions. [Limit: >=0] [Units: vx]
  71726. */
  71727. mergeRegionArea: number;
  71728. /**
  71729. * The maximum number of vertices allowed for polygons generated during the
  71730. * contour to polygon conversion process. [Limit: >= 3]
  71731. */
  71732. maxVertsPerPoly: number;
  71733. /**
  71734. * Sets the sampling distance to use when generating the detail mesh.
  71735. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  71736. */
  71737. detailSampleDist: number;
  71738. /**
  71739. * The maximum distance the detail mesh surface should deviate from heightfield
  71740. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  71741. */
  71742. detailSampleMaxError: number;
  71743. }
  71744. }
  71745. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  71746. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  71747. import { Mesh } from "babylonjs/Meshes/mesh";
  71748. import { Scene } from "babylonjs/scene";
  71749. import { Vector3 } from "babylonjs/Maths/math";
  71750. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71751. /**
  71752. * RecastJS navigation plugin
  71753. */
  71754. export class RecastJSPlugin implements INavigationEnginePlugin {
  71755. /**
  71756. * Reference to the Recast library
  71757. */
  71758. bjsRECAST: any;
  71759. /**
  71760. * plugin name
  71761. */
  71762. name: string;
  71763. /**
  71764. * the first navmesh created. We might extend this to support multiple navmeshes
  71765. */
  71766. navMesh: any;
  71767. /**
  71768. * Initializes the recastJS plugin
  71769. * @param recastInjection can be used to inject your own recast reference
  71770. */
  71771. constructor(recastInjection?: any);
  71772. /**
  71773. * Creates a navigation mesh
  71774. * @param meshes array of all the geometry used to compute the navigatio mesh
  71775. * @param parameters bunch of parameters used to filter geometry
  71776. */
  71777. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  71778. /**
  71779. * Create a navigation mesh debug mesh
  71780. * @param scene is where the mesh will be added
  71781. * @returns debug display mesh
  71782. */
  71783. createDebugNavMesh(scene: Scene): Mesh;
  71784. /**
  71785. * Get a navigation mesh constrained position, closest to the parameter position
  71786. * @param position world position
  71787. * @returns the closest point to position constrained by the navigation mesh
  71788. */
  71789. getClosestPoint(position: Vector3): Vector3;
  71790. /**
  71791. * Get a navigation mesh constrained position, closest to the parameter position
  71792. * @param position world position
  71793. * @param result output the closest point to position constrained by the navigation mesh
  71794. */
  71795. getClosestPointToRef(position: Vector3, result: Vector3): void;
  71796. /**
  71797. * Get a navigation mesh constrained position, within a particular radius
  71798. * @param position world position
  71799. * @param maxRadius the maximum distance to the constrained world position
  71800. * @returns the closest point to position constrained by the navigation mesh
  71801. */
  71802. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  71803. /**
  71804. * Get a navigation mesh constrained position, within a particular radius
  71805. * @param position world position
  71806. * @param maxRadius the maximum distance to the constrained world position
  71807. * @param result output the closest point to position constrained by the navigation mesh
  71808. */
  71809. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  71810. /**
  71811. * Compute the final position from a segment made of destination-position
  71812. * @param position world position
  71813. * @param destination world position
  71814. * @returns the resulting point along the navmesh
  71815. */
  71816. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71817. /**
  71818. * Compute the final position from a segment made of destination-position
  71819. * @param position world position
  71820. * @param destination world position
  71821. * @param result output the resulting point along the navmesh
  71822. */
  71823. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71824. /**
  71825. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71826. * @param start world position
  71827. * @param end world position
  71828. * @returns array containing world position composing the path
  71829. */
  71830. computePath(start: Vector3, end: Vector3): Vector3[];
  71831. /**
  71832. * Create a new Crowd so you can add agents
  71833. * @param maxAgents the maximum agent count in the crowd
  71834. * @param maxAgentRadius the maximum radius an agent can have
  71835. * @param scene to attach the crowd to
  71836. * @returns the crowd you can add agents to
  71837. */
  71838. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71839. /**
  71840. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71841. * The queries will try to find a solution within those bounds
  71842. * default is (1,1,1)
  71843. * @param extent x,y,z value that define the extent around the queries point of reference
  71844. */
  71845. setDefaultQueryExtent(extent: Vector3): void;
  71846. /**
  71847. * Get the Bounding box extent specified by setDefaultQueryExtent
  71848. * @returns the box extent values
  71849. */
  71850. getDefaultQueryExtent(): Vector3;
  71851. /**
  71852. * build the navmesh from a previously saved state using getNavmeshData
  71853. * @param data the Uint8Array returned by getNavmeshData
  71854. */
  71855. buildFromNavmeshData(data: Uint8Array): void;
  71856. /**
  71857. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71858. * @returns data the Uint8Array that can be saved and reused
  71859. */
  71860. getNavmeshData(): Uint8Array;
  71861. /**
  71862. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71863. * @param result output the box extent values
  71864. */
  71865. getDefaultQueryExtentToRef(result: Vector3): void;
  71866. /**
  71867. * Disposes
  71868. */
  71869. dispose(): void;
  71870. /**
  71871. * If this plugin is supported
  71872. * @returns true if plugin is supported
  71873. */
  71874. isSupported(): boolean;
  71875. }
  71876. /**
  71877. * Recast detour crowd implementation
  71878. */
  71879. export class RecastJSCrowd implements ICrowd {
  71880. /**
  71881. * Recast/detour plugin
  71882. */
  71883. bjsRECASTPlugin: RecastJSPlugin;
  71884. /**
  71885. * Link to the detour crowd
  71886. */
  71887. recastCrowd: any;
  71888. /**
  71889. * One transform per agent
  71890. */
  71891. transforms: TransformNode[];
  71892. /**
  71893. * All agents created
  71894. */
  71895. agents: number[];
  71896. /**
  71897. * Link to the scene is kept to unregister the crowd from the scene
  71898. */
  71899. private _scene;
  71900. /**
  71901. * Observer for crowd updates
  71902. */
  71903. private _onBeforeAnimationsObserver;
  71904. /**
  71905. * Constructor
  71906. * @param plugin recastJS plugin
  71907. * @param maxAgents the maximum agent count in the crowd
  71908. * @param maxAgentRadius the maximum radius an agent can have
  71909. * @param scene to attach the crowd to
  71910. * @returns the crowd you can add agents to
  71911. */
  71912. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71913. /**
  71914. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71915. * You can attach anything to that node. The node position is updated in the scene update tick.
  71916. * @param pos world position that will be constrained by the navigation mesh
  71917. * @param parameters agent parameters
  71918. * @param transform hooked to the agent that will be update by the scene
  71919. * @returns agent index
  71920. */
  71921. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71922. /**
  71923. * Returns the agent position in world space
  71924. * @param index agent index returned by addAgent
  71925. * @returns world space position
  71926. */
  71927. getAgentPosition(index: number): Vector3;
  71928. /**
  71929. * Returns the agent position result in world space
  71930. * @param index agent index returned by addAgent
  71931. * @param result output world space position
  71932. */
  71933. getAgentPositionToRef(index: number, result: Vector3): void;
  71934. /**
  71935. * Returns the agent velocity in world space
  71936. * @param index agent index returned by addAgent
  71937. * @returns world space velocity
  71938. */
  71939. getAgentVelocity(index: number): Vector3;
  71940. /**
  71941. * Returns the agent velocity result in world space
  71942. * @param index agent index returned by addAgent
  71943. * @param result output world space velocity
  71944. */
  71945. getAgentVelocityToRef(index: number, result: Vector3): void;
  71946. /**
  71947. * Returns the agent next target point on the path
  71948. * @param index agent index returned by addAgent
  71949. * @returns world space position
  71950. */
  71951. getAgentNextTargetPath(index: number): Vector3;
  71952. /**
  71953. * Returns the agent next target point on the path
  71954. * @param index agent index returned by addAgent
  71955. * @param result output world space position
  71956. */
  71957. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  71958. /**
  71959. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71960. * @param index agent index returned by addAgent
  71961. * @param destination targeted world position
  71962. */
  71963. agentGoto(index: number, destination: Vector3): void;
  71964. /**
  71965. * Teleport the agent to a new position
  71966. * @param index agent index returned by addAgent
  71967. * @param destination targeted world position
  71968. */
  71969. agentTeleport(index: number, destination: Vector3): void;
  71970. /**
  71971. * Update agent parameters
  71972. * @param index agent index returned by addAgent
  71973. * @param parameters agent parameters
  71974. */
  71975. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71976. /**
  71977. * remove a particular agent previously created
  71978. * @param index agent index returned by addAgent
  71979. */
  71980. removeAgent(index: number): void;
  71981. /**
  71982. * get the list of all agents attached to this crowd
  71983. * @returns list of agent indices
  71984. */
  71985. getAgents(): number[];
  71986. /**
  71987. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71988. * @param deltaTime in seconds
  71989. */
  71990. update(deltaTime: number): void;
  71991. /**
  71992. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71993. * The queries will try to find a solution within those bounds
  71994. * default is (1,1,1)
  71995. * @param extent x,y,z value that define the extent around the queries point of reference
  71996. */
  71997. setDefaultQueryExtent(extent: Vector3): void;
  71998. /**
  71999. * Get the Bounding box extent specified by setDefaultQueryExtent
  72000. * @returns the box extent values
  72001. */
  72002. getDefaultQueryExtent(): Vector3;
  72003. /**
  72004. * Get the Bounding box extent result specified by setDefaultQueryExtent
  72005. * @param result output the box extent values
  72006. */
  72007. getDefaultQueryExtentToRef(result: Vector3): void;
  72008. /**
  72009. * Release all resources
  72010. */
  72011. dispose(): void;
  72012. }
  72013. }
  72014. declare module "babylonjs/Navigation/Plugins/index" {
  72015. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  72016. }
  72017. declare module "babylonjs/Navigation/index" {
  72018. export * from "babylonjs/Navigation/INavigationEngine";
  72019. export * from "babylonjs/Navigation/Plugins/index";
  72020. }
  72021. declare module "babylonjs/Offline/database" {
  72022. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  72023. /**
  72024. * Class used to enable access to IndexedDB
  72025. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  72026. */
  72027. export class Database implements IOfflineProvider {
  72028. private _callbackManifestChecked;
  72029. private _currentSceneUrl;
  72030. private _db;
  72031. private _enableSceneOffline;
  72032. private _enableTexturesOffline;
  72033. private _manifestVersionFound;
  72034. private _mustUpdateRessources;
  72035. private _hasReachedQuota;
  72036. private _isSupported;
  72037. private _idbFactory;
  72038. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  72039. private static IsUASupportingBlobStorage;
  72040. /**
  72041. * Gets a boolean indicating if Database storate is enabled (off by default)
  72042. */
  72043. static IDBStorageEnabled: boolean;
  72044. /**
  72045. * Gets a boolean indicating if scene must be saved in the database
  72046. */
  72047. get enableSceneOffline(): boolean;
  72048. /**
  72049. * Gets a boolean indicating if textures must be saved in the database
  72050. */
  72051. get enableTexturesOffline(): boolean;
  72052. /**
  72053. * Creates a new Database
  72054. * @param urlToScene defines the url to load the scene
  72055. * @param callbackManifestChecked defines the callback to use when manifest is checked
  72056. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  72057. */
  72058. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  72059. private static _ParseURL;
  72060. private static _ReturnFullUrlLocation;
  72061. private _checkManifestFile;
  72062. /**
  72063. * Open the database and make it available
  72064. * @param successCallback defines the callback to call on success
  72065. * @param errorCallback defines the callback to call on error
  72066. */
  72067. open(successCallback: () => void, errorCallback: () => void): void;
  72068. /**
  72069. * Loads an image from the database
  72070. * @param url defines the url to load from
  72071. * @param image defines the target DOM image
  72072. */
  72073. loadImage(url: string, image: HTMLImageElement): void;
  72074. private _loadImageFromDBAsync;
  72075. private _saveImageIntoDBAsync;
  72076. private _checkVersionFromDB;
  72077. private _loadVersionFromDBAsync;
  72078. private _saveVersionIntoDBAsync;
  72079. /**
  72080. * Loads a file from database
  72081. * @param url defines the URL to load from
  72082. * @param sceneLoaded defines a callback to call on success
  72083. * @param progressCallBack defines a callback to call when progress changed
  72084. * @param errorCallback defines a callback to call on error
  72085. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  72086. */
  72087. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  72088. private _loadFileAsync;
  72089. private _saveFileAsync;
  72090. /**
  72091. * Validates if xhr data is correct
  72092. * @param xhr defines the request to validate
  72093. * @param dataType defines the expected data type
  72094. * @returns true if data is correct
  72095. */
  72096. private static _ValidateXHRData;
  72097. }
  72098. }
  72099. declare module "babylonjs/Offline/index" {
  72100. export * from "babylonjs/Offline/database";
  72101. export * from "babylonjs/Offline/IOfflineProvider";
  72102. }
  72103. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  72104. /** @hidden */
  72105. export var gpuUpdateParticlesPixelShader: {
  72106. name: string;
  72107. shader: string;
  72108. };
  72109. }
  72110. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  72111. /** @hidden */
  72112. export var gpuUpdateParticlesVertexShader: {
  72113. name: string;
  72114. shader: string;
  72115. };
  72116. }
  72117. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  72118. /** @hidden */
  72119. export var clipPlaneFragmentDeclaration2: {
  72120. name: string;
  72121. shader: string;
  72122. };
  72123. }
  72124. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  72125. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  72126. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  72127. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72128. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  72129. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  72130. /** @hidden */
  72131. export var gpuRenderParticlesPixelShader: {
  72132. name: string;
  72133. shader: string;
  72134. };
  72135. }
  72136. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  72137. /** @hidden */
  72138. export var clipPlaneVertexDeclaration2: {
  72139. name: string;
  72140. shader: string;
  72141. };
  72142. }
  72143. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  72144. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  72145. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  72146. /** @hidden */
  72147. export var gpuRenderParticlesVertexShader: {
  72148. name: string;
  72149. shader: string;
  72150. };
  72151. }
  72152. declare module "babylonjs/Particles/gpuParticleSystem" {
  72153. import { Nullable } from "babylonjs/types";
  72154. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  72155. import { Observable } from "babylonjs/Misc/observable";
  72156. import { Matrix } from "babylonjs/Maths/math.vector";
  72157. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  72158. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72159. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  72160. import { IDisposable } from "babylonjs/scene";
  72161. import { Effect } from "babylonjs/Materials/effect";
  72162. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  72163. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72164. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  72165. import { Scene } from "babylonjs/scene";
  72166. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  72167. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  72168. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  72169. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  72170. /**
  72171. * This represents a GPU particle system in Babylon
  72172. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  72173. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  72174. */
  72175. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  72176. /**
  72177. * The layer mask we are rendering the particles through.
  72178. */
  72179. layerMask: number;
  72180. private _capacity;
  72181. private _activeCount;
  72182. private _currentActiveCount;
  72183. private _accumulatedCount;
  72184. private _renderEffect;
  72185. private _updateEffect;
  72186. private _buffer0;
  72187. private _buffer1;
  72188. private _spriteBuffer;
  72189. private _updateVAO;
  72190. private _renderVAO;
  72191. private _targetIndex;
  72192. private _sourceBuffer;
  72193. private _targetBuffer;
  72194. private _currentRenderId;
  72195. private _started;
  72196. private _stopped;
  72197. private _timeDelta;
  72198. private _randomTexture;
  72199. private _randomTexture2;
  72200. private _attributesStrideSize;
  72201. private _updateEffectOptions;
  72202. private _randomTextureSize;
  72203. private _actualFrame;
  72204. private _customEffect;
  72205. private readonly _rawTextureWidth;
  72206. /**
  72207. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  72208. */
  72209. static get IsSupported(): boolean;
  72210. /**
  72211. * An event triggered when the system is disposed.
  72212. */
  72213. onDisposeObservable: Observable<IParticleSystem>;
  72214. /**
  72215. * An event triggered when the system is stopped
  72216. */
  72217. onStoppedObservable: Observable<IParticleSystem>;
  72218. /**
  72219. * Gets the maximum number of particles active at the same time.
  72220. * @returns The max number of active particles.
  72221. */
  72222. getCapacity(): number;
  72223. /**
  72224. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  72225. * to override the particles.
  72226. */
  72227. forceDepthWrite: boolean;
  72228. /**
  72229. * Gets or set the number of active particles
  72230. */
  72231. get activeParticleCount(): number;
  72232. set activeParticleCount(value: number);
  72233. private _preWarmDone;
  72234. /**
  72235. * Specifies if the particles are updated in emitter local space or world space.
  72236. */
  72237. isLocal: boolean;
  72238. /** Gets or sets a matrix to use to compute projection */
  72239. defaultProjectionMatrix: Matrix;
  72240. /**
  72241. * Is this system ready to be used/rendered
  72242. * @return true if the system is ready
  72243. */
  72244. isReady(): boolean;
  72245. /**
  72246. * Gets if the system has been started. (Note: this will still be true after stop is called)
  72247. * @returns True if it has been started, otherwise false.
  72248. */
  72249. isStarted(): boolean;
  72250. /**
  72251. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  72252. * @returns True if it has been stopped, otherwise false.
  72253. */
  72254. isStopped(): boolean;
  72255. /**
  72256. * Gets a boolean indicating that the system is stopping
  72257. * @returns true if the system is currently stopping
  72258. */
  72259. isStopping(): boolean;
  72260. /**
  72261. * Gets the number of particles active at the same time.
  72262. * @returns The number of active particles.
  72263. */
  72264. getActiveCount(): number;
  72265. /**
  72266. * Starts the particle system and begins to emit
  72267. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  72268. */
  72269. start(delay?: number): void;
  72270. /**
  72271. * Stops the particle system.
  72272. */
  72273. stop(): void;
  72274. /**
  72275. * Remove all active particles
  72276. */
  72277. reset(): void;
  72278. /**
  72279. * Returns the string "GPUParticleSystem"
  72280. * @returns a string containing the class name
  72281. */
  72282. getClassName(): string;
  72283. /**
  72284. * Gets the custom effect used to render the particles
  72285. * @param blendMode Blend mode for which the effect should be retrieved
  72286. * @returns The effect
  72287. */
  72288. getCustomEffect(blendMode?: number): Nullable<Effect>;
  72289. /**
  72290. * Sets the custom effect used to render the particles
  72291. * @param effect The effect to set
  72292. * @param blendMode Blend mode for which the effect should be set
  72293. */
  72294. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  72295. /** @hidden */
  72296. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  72297. /**
  72298. * Observable that will be called just before the particles are drawn
  72299. */
  72300. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  72301. /**
  72302. * Gets the name of the particle vertex shader
  72303. */
  72304. get vertexShaderName(): string;
  72305. private _colorGradientsTexture;
  72306. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  72307. /**
  72308. * Adds a new color gradient
  72309. * @param gradient defines the gradient to use (between 0 and 1)
  72310. * @param color1 defines the color to affect to the specified gradient
  72311. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  72312. * @returns the current particle system
  72313. */
  72314. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  72315. private _refreshColorGradient;
  72316. /** Force the system to rebuild all gradients that need to be resync */
  72317. forceRefreshGradients(): void;
  72318. /**
  72319. * Remove a specific color gradient
  72320. * @param gradient defines the gradient to remove
  72321. * @returns the current particle system
  72322. */
  72323. removeColorGradient(gradient: number): GPUParticleSystem;
  72324. private _angularSpeedGradientsTexture;
  72325. private _sizeGradientsTexture;
  72326. private _velocityGradientsTexture;
  72327. private _limitVelocityGradientsTexture;
  72328. private _dragGradientsTexture;
  72329. private _addFactorGradient;
  72330. /**
  72331. * Adds a new size gradient
  72332. * @param gradient defines the gradient to use (between 0 and 1)
  72333. * @param factor defines the size factor to affect to the specified gradient
  72334. * @returns the current particle system
  72335. */
  72336. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  72337. /**
  72338. * Remove a specific size gradient
  72339. * @param gradient defines the gradient to remove
  72340. * @returns the current particle system
  72341. */
  72342. removeSizeGradient(gradient: number): GPUParticleSystem;
  72343. private _refreshFactorGradient;
  72344. /**
  72345. * Adds a new angular speed gradient
  72346. * @param gradient defines the gradient to use (between 0 and 1)
  72347. * @param factor defines the angular speed to affect to the specified gradient
  72348. * @returns the current particle system
  72349. */
  72350. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  72351. /**
  72352. * Remove a specific angular speed gradient
  72353. * @param gradient defines the gradient to remove
  72354. * @returns the current particle system
  72355. */
  72356. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  72357. /**
  72358. * Adds a new velocity gradient
  72359. * @param gradient defines the gradient to use (between 0 and 1)
  72360. * @param factor defines the velocity to affect to the specified gradient
  72361. * @returns the current particle system
  72362. */
  72363. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72364. /**
  72365. * Remove a specific velocity gradient
  72366. * @param gradient defines the gradient to remove
  72367. * @returns the current particle system
  72368. */
  72369. removeVelocityGradient(gradient: number): GPUParticleSystem;
  72370. /**
  72371. * Adds a new limit velocity gradient
  72372. * @param gradient defines the gradient to use (between 0 and 1)
  72373. * @param factor defines the limit velocity value to affect to the specified gradient
  72374. * @returns the current particle system
  72375. */
  72376. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  72377. /**
  72378. * Remove a specific limit velocity gradient
  72379. * @param gradient defines the gradient to remove
  72380. * @returns the current particle system
  72381. */
  72382. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  72383. /**
  72384. * Adds a new drag gradient
  72385. * @param gradient defines the gradient to use (between 0 and 1)
  72386. * @param factor defines the drag value to affect to the specified gradient
  72387. * @returns the current particle system
  72388. */
  72389. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  72390. /**
  72391. * Remove a specific drag gradient
  72392. * @param gradient defines the gradient to remove
  72393. * @returns the current particle system
  72394. */
  72395. removeDragGradient(gradient: number): GPUParticleSystem;
  72396. /**
  72397. * Not supported by GPUParticleSystem
  72398. * @param gradient defines the gradient to use (between 0 and 1)
  72399. * @param factor defines the emit rate value to affect to the specified gradient
  72400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72401. * @returns the current particle system
  72402. */
  72403. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72404. /**
  72405. * Not supported by GPUParticleSystem
  72406. * @param gradient defines the gradient to remove
  72407. * @returns the current particle system
  72408. */
  72409. removeEmitRateGradient(gradient: number): IParticleSystem;
  72410. /**
  72411. * Not supported by GPUParticleSystem
  72412. * @param gradient defines the gradient to use (between 0 and 1)
  72413. * @param factor defines the start size value to affect to the specified gradient
  72414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72415. * @returns the current particle system
  72416. */
  72417. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72418. /**
  72419. * Not supported by GPUParticleSystem
  72420. * @param gradient defines the gradient to remove
  72421. * @returns the current particle system
  72422. */
  72423. removeStartSizeGradient(gradient: number): IParticleSystem;
  72424. /**
  72425. * Not supported by GPUParticleSystem
  72426. * @param gradient defines the gradient to use (between 0 and 1)
  72427. * @param min defines the color remap minimal range
  72428. * @param max defines the color remap maximal range
  72429. * @returns the current particle system
  72430. */
  72431. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72432. /**
  72433. * Not supported by GPUParticleSystem
  72434. * @param gradient defines the gradient to remove
  72435. * @returns the current particle system
  72436. */
  72437. removeColorRemapGradient(): IParticleSystem;
  72438. /**
  72439. * Not supported by GPUParticleSystem
  72440. * @param gradient defines the gradient to use (between 0 and 1)
  72441. * @param min defines the alpha remap minimal range
  72442. * @param max defines the alpha remap maximal range
  72443. * @returns the current particle system
  72444. */
  72445. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  72446. /**
  72447. * Not supported by GPUParticleSystem
  72448. * @param gradient defines the gradient to remove
  72449. * @returns the current particle system
  72450. */
  72451. removeAlphaRemapGradient(): IParticleSystem;
  72452. /**
  72453. * Not supported by GPUParticleSystem
  72454. * @param gradient defines the gradient to use (between 0 and 1)
  72455. * @param color defines the color to affect to the specified gradient
  72456. * @returns the current particle system
  72457. */
  72458. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  72459. /**
  72460. * Not supported by GPUParticleSystem
  72461. * @param gradient defines the gradient to remove
  72462. * @returns the current particle system
  72463. */
  72464. removeRampGradient(): IParticleSystem;
  72465. /**
  72466. * Not supported by GPUParticleSystem
  72467. * @returns the list of ramp gradients
  72468. */
  72469. getRampGradients(): Nullable<Array<Color3Gradient>>;
  72470. /**
  72471. * Not supported by GPUParticleSystem
  72472. * Gets or sets a boolean indicating that ramp gradients must be used
  72473. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  72474. */
  72475. get useRampGradients(): boolean;
  72476. set useRampGradients(value: boolean);
  72477. /**
  72478. * Not supported by GPUParticleSystem
  72479. * @param gradient defines the gradient to use (between 0 and 1)
  72480. * @param factor defines the life time factor to affect to the specified gradient
  72481. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  72482. * @returns the current particle system
  72483. */
  72484. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  72485. /**
  72486. * Not supported by GPUParticleSystem
  72487. * @param gradient defines the gradient to remove
  72488. * @returns the current particle system
  72489. */
  72490. removeLifeTimeGradient(gradient: number): IParticleSystem;
  72491. /**
  72492. * Instantiates a GPU particle system.
  72493. * 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.
  72494. * @param name The name of the particle system
  72495. * @param options The options used to create the system
  72496. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  72497. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  72498. * @param customEffect a custom effect used to change the way particles are rendered by default
  72499. */
  72500. constructor(name: string, options: Partial<{
  72501. capacity: number;
  72502. randomTextureSize: number;
  72503. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  72504. protected _reset(): void;
  72505. private _createUpdateVAO;
  72506. private _createRenderVAO;
  72507. private _initialize;
  72508. /** @hidden */
  72509. _recreateUpdateEffect(): void;
  72510. private _getEffect;
  72511. /**
  72512. * Fill the defines array according to the current settings of the particle system
  72513. * @param defines Array to be updated
  72514. * @param blendMode blend mode to take into account when updating the array
  72515. */
  72516. fillDefines(defines: Array<string>, blendMode?: number): void;
  72517. /**
  72518. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  72519. * @param uniforms Uniforms array to fill
  72520. * @param attributes Attributes array to fill
  72521. * @param samplers Samplers array to fill
  72522. */
  72523. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  72524. /** @hidden */
  72525. _recreateRenderEffect(): Effect;
  72526. /**
  72527. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  72528. * @param preWarm defines if we are in the pre-warmimg phase
  72529. */
  72530. animate(preWarm?: boolean): void;
  72531. private _createFactorGradientTexture;
  72532. private _createSizeGradientTexture;
  72533. private _createAngularSpeedGradientTexture;
  72534. private _createVelocityGradientTexture;
  72535. private _createLimitVelocityGradientTexture;
  72536. private _createDragGradientTexture;
  72537. private _createColorGradientTexture;
  72538. /**
  72539. * Renders the particle system in its current state
  72540. * @param preWarm defines if the system should only update the particles but not render them
  72541. * @returns the current number of particles
  72542. */
  72543. render(preWarm?: boolean): number;
  72544. /**
  72545. * Rebuilds the particle system
  72546. */
  72547. rebuild(): void;
  72548. private _releaseBuffers;
  72549. private _releaseVAOs;
  72550. /**
  72551. * Disposes the particle system and free the associated resources
  72552. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  72553. */
  72554. dispose(disposeTexture?: boolean): void;
  72555. /**
  72556. * Clones the particle system.
  72557. * @param name The name of the cloned object
  72558. * @param newEmitter The new emitter to use
  72559. * @returns the cloned particle system
  72560. */
  72561. clone(name: string, newEmitter: any): GPUParticleSystem;
  72562. /**
  72563. * Serializes the particle system to a JSON object
  72564. * @param serializeTexture defines if the texture must be serialized as well
  72565. * @returns the JSON object
  72566. */
  72567. serialize(serializeTexture?: boolean): any;
  72568. /**
  72569. * Parses a JSON object to create a GPU particle system.
  72570. * @param parsedParticleSystem The JSON object to parse
  72571. * @param sceneOrEngine The scene or the engine to create the particle system in
  72572. * @param rootUrl The root url to use to load external dependencies like texture
  72573. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  72574. * @returns the parsed GPU particle system
  72575. */
  72576. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  72577. }
  72578. }
  72579. declare module "babylonjs/Particles/particleSystemSet" {
  72580. import { Nullable } from "babylonjs/types";
  72581. import { Color3 } from "babylonjs/Maths/math.color";
  72582. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72584. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72585. import { Scene, IDisposable } from "babylonjs/scene";
  72586. /**
  72587. * Represents a set of particle systems working together to create a specific effect
  72588. */
  72589. export class ParticleSystemSet implements IDisposable {
  72590. /**
  72591. * Gets or sets base Assets URL
  72592. */
  72593. static BaseAssetsUrl: string;
  72594. private _emitterCreationOptions;
  72595. private _emitterNode;
  72596. /**
  72597. * Gets the particle system list
  72598. */
  72599. systems: IParticleSystem[];
  72600. /**
  72601. * Gets the emitter node used with this set
  72602. */
  72603. get emitterNode(): Nullable<TransformNode>;
  72604. /**
  72605. * Creates a new emitter mesh as a sphere
  72606. * @param options defines the options used to create the sphere
  72607. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  72608. * @param scene defines the hosting scene
  72609. */
  72610. setEmitterAsSphere(options: {
  72611. diameter: number;
  72612. segments: number;
  72613. color: Color3;
  72614. }, renderingGroupId: number, scene: Scene): void;
  72615. /**
  72616. * Starts all particle systems of the set
  72617. * @param emitter defines an optional mesh to use as emitter for the particle systems
  72618. */
  72619. start(emitter?: AbstractMesh): void;
  72620. /**
  72621. * Release all associated resources
  72622. */
  72623. dispose(): void;
  72624. /**
  72625. * Serialize the set into a JSON compatible object
  72626. * @param serializeTexture defines if the texture must be serialized as well
  72627. * @returns a JSON compatible representation of the set
  72628. */
  72629. serialize(serializeTexture?: boolean): any;
  72630. /**
  72631. * Parse a new ParticleSystemSet from a serialized source
  72632. * @param data defines a JSON compatible representation of the set
  72633. * @param scene defines the hosting scene
  72634. * @param gpu defines if we want GPU particles or CPU particles
  72635. * @returns a new ParticleSystemSet
  72636. */
  72637. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  72638. }
  72639. }
  72640. declare module "babylonjs/Particles/particleHelper" {
  72641. import { Nullable } from "babylonjs/types";
  72642. import { Scene } from "babylonjs/scene";
  72643. import { Vector3 } from "babylonjs/Maths/math.vector";
  72644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72645. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72646. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  72647. /**
  72648. * This class is made for on one-liner static method to help creating particle system set.
  72649. */
  72650. export class ParticleHelper {
  72651. /**
  72652. * Gets or sets base Assets URL
  72653. */
  72654. static BaseAssetsUrl: string;
  72655. /** Define the Url to load snippets */
  72656. static SnippetUrl: string;
  72657. /**
  72658. * Create a default particle system that you can tweak
  72659. * @param emitter defines the emitter to use
  72660. * @param capacity defines the system capacity (default is 500 particles)
  72661. * @param scene defines the hosting scene
  72662. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  72663. * @returns the new Particle system
  72664. */
  72665. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  72666. /**
  72667. * This is the main static method (one-liner) of this helper to create different particle systems
  72668. * @param type This string represents the type to the particle system to create
  72669. * @param scene The scene where the particle system should live
  72670. * @param gpu If the system will use gpu
  72671. * @returns the ParticleSystemSet created
  72672. */
  72673. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  72674. /**
  72675. * Static function used to export a particle system to a ParticleSystemSet variable.
  72676. * Please note that the emitter shape is not exported
  72677. * @param systems defines the particle systems to export
  72678. * @returns the created particle system set
  72679. */
  72680. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  72681. /**
  72682. * Creates a particle system from a snippet saved in a remote file
  72683. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  72684. * @param url defines the url to load from
  72685. * @param scene defines the hosting scene
  72686. * @param gpu If the system will use gpu
  72687. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72688. * @returns a promise that will resolve to the new particle system
  72689. */
  72690. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72691. /**
  72692. * Creates a particle system from a snippet saved by the particle system editor
  72693. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  72694. * @param scene defines the hosting scene
  72695. * @param gpu If the system will use gpu
  72696. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  72697. * @returns a promise that will resolve to the new particle system
  72698. */
  72699. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  72700. }
  72701. }
  72702. declare module "babylonjs/Particles/particleSystemComponent" {
  72703. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  72704. import { Effect } from "babylonjs/Materials/effect";
  72705. import "babylonjs/Shaders/particles.vertex";
  72706. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  72707. module "babylonjs/Engines/engine" {
  72708. interface Engine {
  72709. /**
  72710. * Create an effect to use with particle systems.
  72711. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  72712. * the particle system for which you want to create a custom effect in the last parameter
  72713. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  72714. * @param uniformsNames defines a list of attribute names
  72715. * @param samplers defines an array of string used to represent textures
  72716. * @param defines defines the string containing the defines to use to compile the shaders
  72717. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  72718. * @param onCompiled defines a function to call when the effect creation is successful
  72719. * @param onError defines a function to call when the effect creation has failed
  72720. * @param particleSystem the particle system you want to create the effect for
  72721. * @returns the new Effect
  72722. */
  72723. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  72724. }
  72725. }
  72726. module "babylonjs/Meshes/mesh" {
  72727. interface Mesh {
  72728. /**
  72729. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  72730. * @returns an array of IParticleSystem
  72731. */
  72732. getEmittedParticleSystems(): IParticleSystem[];
  72733. /**
  72734. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  72735. * @returns an array of IParticleSystem
  72736. */
  72737. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  72738. }
  72739. }
  72740. }
  72741. declare module "babylonjs/Particles/pointsCloudSystem" {
  72742. import { Color4 } from "babylonjs/Maths/math";
  72743. import { Mesh } from "babylonjs/Meshes/mesh";
  72744. import { Scene, IDisposable } from "babylonjs/scene";
  72745. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  72746. /** Defines the 4 color options */
  72747. export enum PointColor {
  72748. /** color value */
  72749. Color = 2,
  72750. /** uv value */
  72751. UV = 1,
  72752. /** random value */
  72753. Random = 0,
  72754. /** stated value */
  72755. Stated = 3
  72756. }
  72757. /**
  72758. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  72759. * 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.
  72760. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  72761. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  72762. *
  72763. * Full documentation here : TO BE ENTERED
  72764. */
  72765. export class PointsCloudSystem implements IDisposable {
  72766. /**
  72767. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  72768. * Example : var p = SPS.particles[i];
  72769. */
  72770. particles: CloudPoint[];
  72771. /**
  72772. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  72773. */
  72774. nbParticles: number;
  72775. /**
  72776. * This a counter for your own usage. It's not set by any SPS functions.
  72777. */
  72778. counter: number;
  72779. /**
  72780. * The PCS name. This name is also given to the underlying mesh.
  72781. */
  72782. name: string;
  72783. /**
  72784. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  72785. */
  72786. mesh: Mesh;
  72787. /**
  72788. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  72789. * Please read :
  72790. */
  72791. vars: any;
  72792. /**
  72793. * @hidden
  72794. */
  72795. _size: number;
  72796. private _scene;
  72797. private _promises;
  72798. private _positions;
  72799. private _indices;
  72800. private _normals;
  72801. private _colors;
  72802. private _uvs;
  72803. private _indices32;
  72804. private _positions32;
  72805. private _colors32;
  72806. private _uvs32;
  72807. private _updatable;
  72808. private _isVisibilityBoxLocked;
  72809. private _alwaysVisible;
  72810. private _groups;
  72811. private _groupCounter;
  72812. private _computeParticleColor;
  72813. private _computeParticleTexture;
  72814. private _computeParticleRotation;
  72815. private _computeBoundingBox;
  72816. private _isReady;
  72817. /**
  72818. * Creates a PCS (Points Cloud System) object
  72819. * @param name (String) is the PCS name, this will be the underlying mesh name
  72820. * @param pointSize (number) is the size for each point
  72821. * @param scene (Scene) is the scene in which the PCS is added
  72822. * @param options defines the options of the PCS e.g.
  72823. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  72824. */
  72825. constructor(name: string, pointSize: number, scene: Scene, options?: {
  72826. updatable?: boolean;
  72827. });
  72828. /**
  72829. * Builds the PCS underlying mesh. Returns a standard Mesh.
  72830. * If no points were added to the PCS, the returned mesh is just a single point.
  72831. * @returns a promise for the created mesh
  72832. */
  72833. buildMeshAsync(): Promise<Mesh>;
  72834. /**
  72835. * @hidden
  72836. */
  72837. private _buildMesh;
  72838. private _addParticle;
  72839. private _randomUnitVector;
  72840. private _getColorIndicesForCoord;
  72841. private _setPointsColorOrUV;
  72842. private _colorFromTexture;
  72843. private _calculateDensity;
  72844. /**
  72845. * Adds points to the PCS in random positions within a unit sphere
  72846. * @param nb (positive integer) the number of particles to be created from this model
  72847. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72848. * @returns the number of groups in the system
  72849. */
  72850. addPoints(nb: number, pointFunction?: any): number;
  72851. /**
  72852. * Adds points to the PCS from the surface of the model shape
  72853. * @param mesh is any Mesh object that will be used as a surface model for the points
  72854. * @param nb (positive integer) the number of particles to be created from this model
  72855. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72856. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72857. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72858. * @returns the number of groups in the system
  72859. */
  72860. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72861. /**
  72862. * Adds points to the PCS inside the model shape
  72863. * @param mesh is any Mesh object that will be used as a surface model for the points
  72864. * @param nb (positive integer) the number of particles to be created from this model
  72865. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72866. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72867. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72868. * @returns the number of groups in the system
  72869. */
  72870. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72871. /**
  72872. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72873. * This method calls `updateParticle()` for each particle of the SPS.
  72874. * For an animated SPS, it is usually called within the render loop.
  72875. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72876. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72877. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72878. * @returns the PCS.
  72879. */
  72880. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72881. /**
  72882. * Disposes the PCS.
  72883. */
  72884. dispose(): void;
  72885. /**
  72886. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72887. * doc :
  72888. * @returns the PCS.
  72889. */
  72890. refreshVisibleSize(): PointsCloudSystem;
  72891. /**
  72892. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72893. * @param size the size (float) of the visibility box
  72894. * note : this doesn't lock the PCS mesh bounding box.
  72895. * doc :
  72896. */
  72897. setVisibilityBox(size: number): void;
  72898. /**
  72899. * Gets whether the PCS is always visible or not
  72900. * doc :
  72901. */
  72902. get isAlwaysVisible(): boolean;
  72903. /**
  72904. * Sets the PCS as always visible or not
  72905. * doc :
  72906. */
  72907. set isAlwaysVisible(val: boolean);
  72908. /**
  72909. * Tells to `setParticles()` to compute the particle rotations or not
  72910. * Default value : false. The PCS is faster when it's set to false
  72911. * Note : particle rotations are only applied to parent particles
  72912. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72913. */
  72914. set computeParticleRotation(val: boolean);
  72915. /**
  72916. * Tells to `setParticles()` to compute the particle colors or not.
  72917. * Default value : true. The PCS is faster when it's set to false.
  72918. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72919. */
  72920. set computeParticleColor(val: boolean);
  72921. set computeParticleTexture(val: boolean);
  72922. /**
  72923. * Gets if `setParticles()` computes the particle colors or not.
  72924. * Default value : false. The PCS is faster when it's set to false.
  72925. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72926. */
  72927. get computeParticleColor(): boolean;
  72928. /**
  72929. * Gets if `setParticles()` computes the particle textures or not.
  72930. * Default value : false. The PCS is faster when it's set to false.
  72931. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72932. */
  72933. get computeParticleTexture(): boolean;
  72934. /**
  72935. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72936. */
  72937. set computeBoundingBox(val: boolean);
  72938. /**
  72939. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72940. */
  72941. get computeBoundingBox(): boolean;
  72942. /**
  72943. * This function does nothing. It may be overwritten to set all the particle first values.
  72944. * The PCS doesn't call this function, you may have to call it by your own.
  72945. * doc :
  72946. */
  72947. initParticles(): void;
  72948. /**
  72949. * This function does nothing. It may be overwritten to recycle a particle
  72950. * The PCS doesn't call this function, you can to call it
  72951. * doc :
  72952. * @param particle The particle to recycle
  72953. * @returns the recycled particle
  72954. */
  72955. recycleParticle(particle: CloudPoint): CloudPoint;
  72956. /**
  72957. * Updates a particle : this function should be overwritten by the user.
  72958. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72959. * doc :
  72960. * @example : just set a particle position or velocity and recycle conditions
  72961. * @param particle The particle to update
  72962. * @returns the updated particle
  72963. */
  72964. updateParticle(particle: CloudPoint): CloudPoint;
  72965. /**
  72966. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72967. * This does nothing and may be overwritten by the user.
  72968. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72969. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72970. * @param update the boolean update value actually passed to setParticles()
  72971. */
  72972. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72973. /**
  72974. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72975. * This will be passed three parameters.
  72976. * This does nothing and may be overwritten by the user.
  72977. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72978. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72979. * @param update the boolean update value actually passed to setParticles()
  72980. */
  72981. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72982. }
  72983. }
  72984. declare module "babylonjs/Particles/cloudPoint" {
  72985. import { Nullable } from "babylonjs/types";
  72986. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  72987. import { Mesh } from "babylonjs/Meshes/mesh";
  72988. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  72989. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  72990. /**
  72991. * Represents one particle of a points cloud system.
  72992. */
  72993. export class CloudPoint {
  72994. /**
  72995. * particle global index
  72996. */
  72997. idx: number;
  72998. /**
  72999. * The color of the particle
  73000. */
  73001. color: Nullable<Color4>;
  73002. /**
  73003. * The world space position of the particle.
  73004. */
  73005. position: Vector3;
  73006. /**
  73007. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  73008. */
  73009. rotation: Vector3;
  73010. /**
  73011. * The world space rotation quaternion of the particle.
  73012. */
  73013. rotationQuaternion: Nullable<Quaternion>;
  73014. /**
  73015. * The uv of the particle.
  73016. */
  73017. uv: Nullable<Vector2>;
  73018. /**
  73019. * The current speed of the particle.
  73020. */
  73021. velocity: Vector3;
  73022. /**
  73023. * The pivot point in the particle local space.
  73024. */
  73025. pivot: Vector3;
  73026. /**
  73027. * Must the particle be translated from its pivot point in its local space ?
  73028. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  73029. * Default : false
  73030. */
  73031. translateFromPivot: boolean;
  73032. /**
  73033. * Index of this particle in the global "positions" array (Internal use)
  73034. * @hidden
  73035. */
  73036. _pos: number;
  73037. /**
  73038. * @hidden Index of this particle in the global "indices" array (Internal use)
  73039. */
  73040. _ind: number;
  73041. /**
  73042. * Group this particle belongs to
  73043. */
  73044. _group: PointsGroup;
  73045. /**
  73046. * Group id of this particle
  73047. */
  73048. groupId: number;
  73049. /**
  73050. * Index of the particle in its group id (Internal use)
  73051. */
  73052. idxInGroup: number;
  73053. /**
  73054. * @hidden Particle BoundingInfo object (Internal use)
  73055. */
  73056. _boundingInfo: BoundingInfo;
  73057. /**
  73058. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  73059. */
  73060. _pcs: PointsCloudSystem;
  73061. /**
  73062. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  73063. */
  73064. _stillInvisible: boolean;
  73065. /**
  73066. * @hidden Last computed particle rotation matrix
  73067. */
  73068. _rotationMatrix: number[];
  73069. /**
  73070. * Parent particle Id, if any.
  73071. * Default null.
  73072. */
  73073. parentId: Nullable<number>;
  73074. /**
  73075. * @hidden Internal global position in the PCS.
  73076. */
  73077. _globalPosition: Vector3;
  73078. /**
  73079. * Creates a Point Cloud object.
  73080. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  73081. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  73082. * @param group (PointsGroup) is the group the particle belongs to
  73083. * @param groupId (integer) is the group identifier in the PCS.
  73084. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  73085. * @param pcs defines the PCS it is associated to
  73086. */
  73087. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  73088. /**
  73089. * get point size
  73090. */
  73091. get size(): Vector3;
  73092. /**
  73093. * Set point size
  73094. */
  73095. set size(scale: Vector3);
  73096. /**
  73097. * Legacy support, changed quaternion to rotationQuaternion
  73098. */
  73099. get quaternion(): Nullable<Quaternion>;
  73100. /**
  73101. * Legacy support, changed quaternion to rotationQuaternion
  73102. */
  73103. set quaternion(q: Nullable<Quaternion>);
  73104. /**
  73105. * Returns a boolean. True if the particle intersects a mesh, else false
  73106. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  73107. * @param target is the object (point or mesh) what the intersection is computed against
  73108. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  73109. * @returns true if it intersects
  73110. */
  73111. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  73112. /**
  73113. * get the rotation matrix of the particle
  73114. * @hidden
  73115. */
  73116. getRotationMatrix(m: Matrix): void;
  73117. }
  73118. /**
  73119. * Represents a group of points in a points cloud system
  73120. * * PCS internal tool, don't use it manually.
  73121. */
  73122. export class PointsGroup {
  73123. /**
  73124. * The group id
  73125. * @hidden
  73126. */
  73127. groupID: number;
  73128. /**
  73129. * image data for group (internal use)
  73130. * @hidden
  73131. */
  73132. _groupImageData: Nullable<ArrayBufferView>;
  73133. /**
  73134. * Image Width (internal use)
  73135. * @hidden
  73136. */
  73137. _groupImgWidth: number;
  73138. /**
  73139. * Image Height (internal use)
  73140. * @hidden
  73141. */
  73142. _groupImgHeight: number;
  73143. /**
  73144. * Custom position function (internal use)
  73145. * @hidden
  73146. */
  73147. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  73148. /**
  73149. * density per facet for surface points
  73150. * @hidden
  73151. */
  73152. _groupDensity: number[];
  73153. /**
  73154. * Only when points are colored by texture carries pointer to texture list array
  73155. * @hidden
  73156. */
  73157. _textureNb: number;
  73158. /**
  73159. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  73160. * PCS internal tool, don't use it manually.
  73161. * @hidden
  73162. */
  73163. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  73164. }
  73165. }
  73166. declare module "babylonjs/Particles/index" {
  73167. export * from "babylonjs/Particles/baseParticleSystem";
  73168. export * from "babylonjs/Particles/EmitterTypes/index";
  73169. export * from "babylonjs/Particles/gpuParticleSystem";
  73170. export * from "babylonjs/Particles/IParticleSystem";
  73171. export * from "babylonjs/Particles/particle";
  73172. export * from "babylonjs/Particles/particleHelper";
  73173. export * from "babylonjs/Particles/particleSystem";
  73174. import "babylonjs/Particles/particleSystemComponent";
  73175. export * from "babylonjs/Particles/particleSystemComponent";
  73176. export * from "babylonjs/Particles/particleSystemSet";
  73177. export * from "babylonjs/Particles/solidParticle";
  73178. export * from "babylonjs/Particles/solidParticleSystem";
  73179. export * from "babylonjs/Particles/cloudPoint";
  73180. export * from "babylonjs/Particles/pointsCloudSystem";
  73181. export * from "babylonjs/Particles/subEmitter";
  73182. }
  73183. declare module "babylonjs/Physics/physicsEngineComponent" {
  73184. import { Nullable } from "babylonjs/types";
  73185. import { Observable, Observer } from "babylonjs/Misc/observable";
  73186. import { Vector3 } from "babylonjs/Maths/math.vector";
  73187. import { Mesh } from "babylonjs/Meshes/mesh";
  73188. import { ISceneComponent } from "babylonjs/sceneComponent";
  73189. import { Scene } from "babylonjs/scene";
  73190. import { Node } from "babylonjs/node";
  73191. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  73192. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73193. module "babylonjs/scene" {
  73194. interface Scene {
  73195. /** @hidden (Backing field) */
  73196. _physicsEngine: Nullable<IPhysicsEngine>;
  73197. /** @hidden */
  73198. _physicsTimeAccumulator: number;
  73199. /**
  73200. * Gets the current physics engine
  73201. * @returns a IPhysicsEngine or null if none attached
  73202. */
  73203. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  73204. /**
  73205. * Enables physics to the current scene
  73206. * @param gravity defines the scene's gravity for the physics engine
  73207. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  73208. * @return a boolean indicating if the physics engine was initialized
  73209. */
  73210. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  73211. /**
  73212. * Disables and disposes the physics engine associated with the scene
  73213. */
  73214. disablePhysicsEngine(): void;
  73215. /**
  73216. * Gets a boolean indicating if there is an active physics engine
  73217. * @returns a boolean indicating if there is an active physics engine
  73218. */
  73219. isPhysicsEnabled(): boolean;
  73220. /**
  73221. * Deletes a physics compound impostor
  73222. * @param compound defines the compound to delete
  73223. */
  73224. deleteCompoundImpostor(compound: any): void;
  73225. /**
  73226. * An event triggered when physic simulation is about to be run
  73227. */
  73228. onBeforePhysicsObservable: Observable<Scene>;
  73229. /**
  73230. * An event triggered when physic simulation has been done
  73231. */
  73232. onAfterPhysicsObservable: Observable<Scene>;
  73233. }
  73234. }
  73235. module "babylonjs/Meshes/abstractMesh" {
  73236. interface AbstractMesh {
  73237. /** @hidden */
  73238. _physicsImpostor: Nullable<PhysicsImpostor>;
  73239. /**
  73240. * Gets or sets impostor used for physic simulation
  73241. * @see https://doc.babylonjs.com/features/physics_engine
  73242. */
  73243. physicsImpostor: Nullable<PhysicsImpostor>;
  73244. /**
  73245. * Gets the current physics impostor
  73246. * @see https://doc.babylonjs.com/features/physics_engine
  73247. * @returns a physics impostor or null
  73248. */
  73249. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  73250. /** Apply a physic impulse to the mesh
  73251. * @param force defines the force to apply
  73252. * @param contactPoint defines where to apply the force
  73253. * @returns the current mesh
  73254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  73255. */
  73256. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  73257. /**
  73258. * Creates a physic joint between two meshes
  73259. * @param otherMesh defines the other mesh to use
  73260. * @param pivot1 defines the pivot to use on this mesh
  73261. * @param pivot2 defines the pivot to use on the other mesh
  73262. * @param options defines additional options (can be plugin dependent)
  73263. * @returns the current mesh
  73264. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  73265. */
  73266. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  73267. /** @hidden */
  73268. _disposePhysicsObserver: Nullable<Observer<Node>>;
  73269. }
  73270. }
  73271. /**
  73272. * Defines the physics engine scene component responsible to manage a physics engine
  73273. */
  73274. export class PhysicsEngineSceneComponent implements ISceneComponent {
  73275. /**
  73276. * The component name helpful to identify the component in the list of scene components.
  73277. */
  73278. readonly name: string;
  73279. /**
  73280. * The scene the component belongs to.
  73281. */
  73282. scene: Scene;
  73283. /**
  73284. * Creates a new instance of the component for the given scene
  73285. * @param scene Defines the scene to register the component in
  73286. */
  73287. constructor(scene: Scene);
  73288. /**
  73289. * Registers the component in a given scene
  73290. */
  73291. register(): void;
  73292. /**
  73293. * Rebuilds the elements related to this component in case of
  73294. * context lost for instance.
  73295. */
  73296. rebuild(): void;
  73297. /**
  73298. * Disposes the component and the associated ressources
  73299. */
  73300. dispose(): void;
  73301. }
  73302. }
  73303. declare module "babylonjs/Physics/physicsHelper" {
  73304. import { Nullable } from "babylonjs/types";
  73305. import { Vector3 } from "babylonjs/Maths/math.vector";
  73306. import { Mesh } from "babylonjs/Meshes/mesh";
  73307. import { Scene } from "babylonjs/scene";
  73308. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73309. /**
  73310. * A helper for physics simulations
  73311. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73312. */
  73313. export class PhysicsHelper {
  73314. private _scene;
  73315. private _physicsEngine;
  73316. /**
  73317. * Initializes the Physics helper
  73318. * @param scene Babylon.js scene
  73319. */
  73320. constructor(scene: Scene);
  73321. /**
  73322. * Applies a radial explosion impulse
  73323. * @param origin the origin of the explosion
  73324. * @param radiusOrEventOptions the radius or the options of radial explosion
  73325. * @param strength the explosion strength
  73326. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73327. * @returns A physics radial explosion event, or null
  73328. */
  73329. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73330. /**
  73331. * Applies a radial explosion force
  73332. * @param origin the origin of the explosion
  73333. * @param radiusOrEventOptions the radius or the options of radial explosion
  73334. * @param strength the explosion strength
  73335. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73336. * @returns A physics radial explosion event, or null
  73337. */
  73338. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  73339. /**
  73340. * Creates a gravitational field
  73341. * @param origin the origin of the explosion
  73342. * @param radiusOrEventOptions the radius or the options of radial explosion
  73343. * @param strength the explosion strength
  73344. * @param falloff possible options: Constant & Linear. Defaults to Constant
  73345. * @returns A physics gravitational field event, or null
  73346. */
  73347. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  73348. /**
  73349. * Creates a physics updraft event
  73350. * @param origin the origin of the updraft
  73351. * @param radiusOrEventOptions the radius or the options of the updraft
  73352. * @param strength the strength of the updraft
  73353. * @param height the height of the updraft
  73354. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  73355. * @returns A physics updraft event, or null
  73356. */
  73357. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  73358. /**
  73359. * Creates a physics vortex event
  73360. * @param origin the of the vortex
  73361. * @param radiusOrEventOptions the radius or the options of the vortex
  73362. * @param strength the strength of the vortex
  73363. * @param height the height of the vortex
  73364. * @returns a Physics vortex event, or null
  73365. * A physics vortex event or null
  73366. */
  73367. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  73368. }
  73369. /**
  73370. * Represents a physics radial explosion event
  73371. */
  73372. class PhysicsRadialExplosionEvent {
  73373. private _scene;
  73374. private _options;
  73375. private _sphere;
  73376. private _dataFetched;
  73377. /**
  73378. * Initializes a radial explosioin event
  73379. * @param _scene BabylonJS scene
  73380. * @param _options The options for the vortex event
  73381. */
  73382. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  73383. /**
  73384. * Returns the data related to the radial explosion event (sphere).
  73385. * @returns The radial explosion event data
  73386. */
  73387. getData(): PhysicsRadialExplosionEventData;
  73388. /**
  73389. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  73390. * @param impostor A physics imposter
  73391. * @param origin the origin of the explosion
  73392. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  73393. */
  73394. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  73395. /**
  73396. * Triggers affecterd impostors callbacks
  73397. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  73398. */
  73399. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  73400. /**
  73401. * Disposes the sphere.
  73402. * @param force Specifies if the sphere should be disposed by force
  73403. */
  73404. dispose(force?: boolean): void;
  73405. /*** Helpers ***/
  73406. private _prepareSphere;
  73407. private _intersectsWithSphere;
  73408. }
  73409. /**
  73410. * Represents a gravitational field event
  73411. */
  73412. class PhysicsGravitationalFieldEvent {
  73413. private _physicsHelper;
  73414. private _scene;
  73415. private _origin;
  73416. private _options;
  73417. private _tickCallback;
  73418. private _sphere;
  73419. private _dataFetched;
  73420. /**
  73421. * Initializes the physics gravitational field event
  73422. * @param _physicsHelper A physics helper
  73423. * @param _scene BabylonJS scene
  73424. * @param _origin The origin position of the gravitational field event
  73425. * @param _options The options for the vortex event
  73426. */
  73427. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  73428. /**
  73429. * Returns the data related to the gravitational field event (sphere).
  73430. * @returns A gravitational field event
  73431. */
  73432. getData(): PhysicsGravitationalFieldEventData;
  73433. /**
  73434. * Enables the gravitational field.
  73435. */
  73436. enable(): void;
  73437. /**
  73438. * Disables the gravitational field.
  73439. */
  73440. disable(): void;
  73441. /**
  73442. * Disposes the sphere.
  73443. * @param force The force to dispose from the gravitational field event
  73444. */
  73445. dispose(force?: boolean): void;
  73446. private _tick;
  73447. }
  73448. /**
  73449. * Represents a physics updraft event
  73450. */
  73451. class PhysicsUpdraftEvent {
  73452. private _scene;
  73453. private _origin;
  73454. private _options;
  73455. private _physicsEngine;
  73456. private _originTop;
  73457. private _originDirection;
  73458. private _tickCallback;
  73459. private _cylinder;
  73460. private _cylinderPosition;
  73461. private _dataFetched;
  73462. /**
  73463. * Initializes the physics updraft event
  73464. * @param _scene BabylonJS scene
  73465. * @param _origin The origin position of the updraft
  73466. * @param _options The options for the updraft event
  73467. */
  73468. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  73469. /**
  73470. * Returns the data related to the updraft event (cylinder).
  73471. * @returns A physics updraft event
  73472. */
  73473. getData(): PhysicsUpdraftEventData;
  73474. /**
  73475. * Enables the updraft.
  73476. */
  73477. enable(): void;
  73478. /**
  73479. * Disables the updraft.
  73480. */
  73481. disable(): void;
  73482. /**
  73483. * Disposes the cylinder.
  73484. * @param force Specifies if the updraft should be disposed by force
  73485. */
  73486. dispose(force?: boolean): void;
  73487. private getImpostorHitData;
  73488. private _tick;
  73489. /*** Helpers ***/
  73490. private _prepareCylinder;
  73491. private _intersectsWithCylinder;
  73492. }
  73493. /**
  73494. * Represents a physics vortex event
  73495. */
  73496. class PhysicsVortexEvent {
  73497. private _scene;
  73498. private _origin;
  73499. private _options;
  73500. private _physicsEngine;
  73501. private _originTop;
  73502. private _tickCallback;
  73503. private _cylinder;
  73504. private _cylinderPosition;
  73505. private _dataFetched;
  73506. /**
  73507. * Initializes the physics vortex event
  73508. * @param _scene The BabylonJS scene
  73509. * @param _origin The origin position of the vortex
  73510. * @param _options The options for the vortex event
  73511. */
  73512. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  73513. /**
  73514. * Returns the data related to the vortex event (cylinder).
  73515. * @returns The physics vortex event data
  73516. */
  73517. getData(): PhysicsVortexEventData;
  73518. /**
  73519. * Enables the vortex.
  73520. */
  73521. enable(): void;
  73522. /**
  73523. * Disables the cortex.
  73524. */
  73525. disable(): void;
  73526. /**
  73527. * Disposes the sphere.
  73528. * @param force
  73529. */
  73530. dispose(force?: boolean): void;
  73531. private getImpostorHitData;
  73532. private _tick;
  73533. /*** Helpers ***/
  73534. private _prepareCylinder;
  73535. private _intersectsWithCylinder;
  73536. }
  73537. /**
  73538. * Options fot the radial explosion event
  73539. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73540. */
  73541. export class PhysicsRadialExplosionEventOptions {
  73542. /**
  73543. * The radius of the sphere for the radial explosion.
  73544. */
  73545. radius: number;
  73546. /**
  73547. * The strenth of the explosion.
  73548. */
  73549. strength: number;
  73550. /**
  73551. * The strenght of the force in correspondence to the distance of the affected object
  73552. */
  73553. falloff: PhysicsRadialImpulseFalloff;
  73554. /**
  73555. * Sphere options for the radial explosion.
  73556. */
  73557. sphere: {
  73558. segments: number;
  73559. diameter: number;
  73560. };
  73561. /**
  73562. * Sphere options for the radial explosion.
  73563. */
  73564. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  73565. }
  73566. /**
  73567. * Options fot the updraft event
  73568. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73569. */
  73570. export class PhysicsUpdraftEventOptions {
  73571. /**
  73572. * The radius of the cylinder for the vortex
  73573. */
  73574. radius: number;
  73575. /**
  73576. * The strenth of the updraft.
  73577. */
  73578. strength: number;
  73579. /**
  73580. * The height of the cylinder for the updraft.
  73581. */
  73582. height: number;
  73583. /**
  73584. * The mode for the the updraft.
  73585. */
  73586. updraftMode: PhysicsUpdraftMode;
  73587. }
  73588. /**
  73589. * Options fot the vortex event
  73590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73591. */
  73592. export class PhysicsVortexEventOptions {
  73593. /**
  73594. * The radius of the cylinder for the vortex
  73595. */
  73596. radius: number;
  73597. /**
  73598. * The strenth of the vortex.
  73599. */
  73600. strength: number;
  73601. /**
  73602. * The height of the cylinder for the vortex.
  73603. */
  73604. height: number;
  73605. /**
  73606. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  73607. */
  73608. centripetalForceThreshold: number;
  73609. /**
  73610. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  73611. */
  73612. centripetalForceMultiplier: number;
  73613. /**
  73614. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  73615. */
  73616. centrifugalForceMultiplier: number;
  73617. /**
  73618. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  73619. */
  73620. updraftForceMultiplier: number;
  73621. }
  73622. /**
  73623. * The strenght of the force in correspondence to the distance of the affected object
  73624. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73625. */
  73626. export enum PhysicsRadialImpulseFalloff {
  73627. /** Defines that impulse is constant in strength across it's whole radius */
  73628. Constant = 0,
  73629. /** Defines that impulse gets weaker if it's further from the origin */
  73630. Linear = 1
  73631. }
  73632. /**
  73633. * The strength of the force in correspondence to the distance of the affected object
  73634. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73635. */
  73636. export enum PhysicsUpdraftMode {
  73637. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  73638. Center = 0,
  73639. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  73640. Perpendicular = 1
  73641. }
  73642. /**
  73643. * Interface for a physics hit data
  73644. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73645. */
  73646. export interface PhysicsHitData {
  73647. /**
  73648. * The force applied at the contact point
  73649. */
  73650. force: Vector3;
  73651. /**
  73652. * The contact point
  73653. */
  73654. contactPoint: Vector3;
  73655. /**
  73656. * The distance from the origin to the contact point
  73657. */
  73658. distanceFromOrigin: number;
  73659. }
  73660. /**
  73661. * Interface for radial explosion event data
  73662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73663. */
  73664. export interface PhysicsRadialExplosionEventData {
  73665. /**
  73666. * A sphere used for the radial explosion event
  73667. */
  73668. sphere: Mesh;
  73669. }
  73670. /**
  73671. * Interface for gravitational field event data
  73672. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73673. */
  73674. export interface PhysicsGravitationalFieldEventData {
  73675. /**
  73676. * A sphere mesh used for the gravitational field event
  73677. */
  73678. sphere: Mesh;
  73679. }
  73680. /**
  73681. * Interface for updraft event data
  73682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73683. */
  73684. export interface PhysicsUpdraftEventData {
  73685. /**
  73686. * A cylinder used for the updraft event
  73687. */
  73688. cylinder: Mesh;
  73689. }
  73690. /**
  73691. * Interface for vortex event data
  73692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73693. */
  73694. export interface PhysicsVortexEventData {
  73695. /**
  73696. * A cylinder used for the vortex event
  73697. */
  73698. cylinder: Mesh;
  73699. }
  73700. /**
  73701. * Interface for an affected physics impostor
  73702. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  73703. */
  73704. export interface PhysicsAffectedImpostorWithData {
  73705. /**
  73706. * The impostor affected by the effect
  73707. */
  73708. impostor: PhysicsImpostor;
  73709. /**
  73710. * The data about the hit/horce from the explosion
  73711. */
  73712. hitData: PhysicsHitData;
  73713. }
  73714. }
  73715. declare module "babylonjs/Physics/Plugins/index" {
  73716. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  73717. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  73718. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  73719. }
  73720. declare module "babylonjs/Physics/index" {
  73721. export * from "babylonjs/Physics/IPhysicsEngine";
  73722. export * from "babylonjs/Physics/physicsEngine";
  73723. export * from "babylonjs/Physics/physicsEngineComponent";
  73724. export * from "babylonjs/Physics/physicsHelper";
  73725. export * from "babylonjs/Physics/physicsImpostor";
  73726. export * from "babylonjs/Physics/physicsJoint";
  73727. export * from "babylonjs/Physics/Plugins/index";
  73728. }
  73729. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  73730. /** @hidden */
  73731. export var blackAndWhitePixelShader: {
  73732. name: string;
  73733. shader: string;
  73734. };
  73735. }
  73736. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  73737. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73738. import { Camera } from "babylonjs/Cameras/camera";
  73739. import { Engine } from "babylonjs/Engines/engine";
  73740. import "babylonjs/Shaders/blackAndWhite.fragment";
  73741. import { Nullable } from "babylonjs/types";
  73742. import { Scene } from "babylonjs/scene";
  73743. /**
  73744. * Post process used to render in black and white
  73745. */
  73746. export class BlackAndWhitePostProcess extends PostProcess {
  73747. /**
  73748. * Linear about to convert he result to black and white (default: 1)
  73749. */
  73750. degree: number;
  73751. /**
  73752. * Gets a string identifying the name of the class
  73753. * @returns "BlackAndWhitePostProcess" string
  73754. */
  73755. getClassName(): string;
  73756. /**
  73757. * Creates a black and white post process
  73758. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  73759. * @param name The name of the effect.
  73760. * @param options The required width/height ratio to downsize to before computing the render pass.
  73761. * @param camera The camera to apply the render pass to.
  73762. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73763. * @param engine The engine which the post process will be applied. (default: current engine)
  73764. * @param reusable If the post process can be reused on the same frame. (default: false)
  73765. */
  73766. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73767. /** @hidden */
  73768. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  73769. }
  73770. }
  73771. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  73772. import { Nullable } from "babylonjs/types";
  73773. import { Camera } from "babylonjs/Cameras/camera";
  73774. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73775. import { Engine } from "babylonjs/Engines/engine";
  73776. /**
  73777. * This represents a set of one or more post processes in Babylon.
  73778. * A post process can be used to apply a shader to a texture after it is rendered.
  73779. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  73780. */
  73781. export class PostProcessRenderEffect {
  73782. private _postProcesses;
  73783. private _getPostProcesses;
  73784. private _singleInstance;
  73785. private _cameras;
  73786. private _indicesForCamera;
  73787. /**
  73788. * Name of the effect
  73789. * @hidden
  73790. */
  73791. _name: string;
  73792. /**
  73793. * Instantiates a post process render effect.
  73794. * A post process can be used to apply a shader to a texture after it is rendered.
  73795. * @param engine The engine the effect is tied to
  73796. * @param name The name of the effect
  73797. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  73798. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  73799. */
  73800. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  73801. /**
  73802. * Checks if all the post processes in the effect are supported.
  73803. */
  73804. get isSupported(): boolean;
  73805. /**
  73806. * Updates the current state of the effect
  73807. * @hidden
  73808. */
  73809. _update(): void;
  73810. /**
  73811. * Attaches the effect on cameras
  73812. * @param cameras The camera to attach to.
  73813. * @hidden
  73814. */
  73815. _attachCameras(cameras: Camera): void;
  73816. /**
  73817. * Attaches the effect on cameras
  73818. * @param cameras The camera to attach to.
  73819. * @hidden
  73820. */
  73821. _attachCameras(cameras: Camera[]): void;
  73822. /**
  73823. * Detaches the effect on cameras
  73824. * @param cameras The camera to detatch from.
  73825. * @hidden
  73826. */
  73827. _detachCameras(cameras: Camera): void;
  73828. /**
  73829. * Detatches the effect on cameras
  73830. * @param cameras The camera to detatch from.
  73831. * @hidden
  73832. */
  73833. _detachCameras(cameras: Camera[]): void;
  73834. /**
  73835. * Enables the effect on given cameras
  73836. * @param cameras The camera to enable.
  73837. * @hidden
  73838. */
  73839. _enable(cameras: Camera): void;
  73840. /**
  73841. * Enables the effect on given cameras
  73842. * @param cameras The camera to enable.
  73843. * @hidden
  73844. */
  73845. _enable(cameras: Nullable<Camera[]>): void;
  73846. /**
  73847. * Disables the effect on the given cameras
  73848. * @param cameras The camera to disable.
  73849. * @hidden
  73850. */
  73851. _disable(cameras: Camera): void;
  73852. /**
  73853. * Disables the effect on the given cameras
  73854. * @param cameras The camera to disable.
  73855. * @hidden
  73856. */
  73857. _disable(cameras: Nullable<Camera[]>): void;
  73858. /**
  73859. * Gets a list of the post processes contained in the effect.
  73860. * @param camera The camera to get the post processes on.
  73861. * @returns The list of the post processes in the effect.
  73862. */
  73863. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73864. }
  73865. }
  73866. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73867. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73868. /** @hidden */
  73869. export var extractHighlightsPixelShader: {
  73870. name: string;
  73871. shader: string;
  73872. };
  73873. }
  73874. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73875. import { Nullable } from "babylonjs/types";
  73876. import { Camera } from "babylonjs/Cameras/camera";
  73877. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73878. import { Engine } from "babylonjs/Engines/engine";
  73879. import "babylonjs/Shaders/extractHighlights.fragment";
  73880. /**
  73881. * 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.
  73882. */
  73883. export class ExtractHighlightsPostProcess extends PostProcess {
  73884. /**
  73885. * The luminance threshold, pixels below this value will be set to black.
  73886. */
  73887. threshold: number;
  73888. /** @hidden */
  73889. _exposure: number;
  73890. /**
  73891. * Post process which has the input texture to be used when performing highlight extraction
  73892. * @hidden
  73893. */
  73894. _inputPostProcess: Nullable<PostProcess>;
  73895. /**
  73896. * Gets a string identifying the name of the class
  73897. * @returns "ExtractHighlightsPostProcess" string
  73898. */
  73899. getClassName(): string;
  73900. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73901. }
  73902. }
  73903. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73904. /** @hidden */
  73905. export var bloomMergePixelShader: {
  73906. name: string;
  73907. shader: string;
  73908. };
  73909. }
  73910. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73911. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73912. import { Nullable } from "babylonjs/types";
  73913. import { Engine } from "babylonjs/Engines/engine";
  73914. import { Camera } from "babylonjs/Cameras/camera";
  73915. import "babylonjs/Shaders/bloomMerge.fragment";
  73916. /**
  73917. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73918. */
  73919. export class BloomMergePostProcess extends PostProcess {
  73920. /** Weight of the bloom to be added to the original input. */
  73921. weight: number;
  73922. /**
  73923. * Gets a string identifying the name of the class
  73924. * @returns "BloomMergePostProcess" string
  73925. */
  73926. getClassName(): string;
  73927. /**
  73928. * Creates a new instance of @see BloomMergePostProcess
  73929. * @param name The name of the effect.
  73930. * @param originalFromInput Post process which's input will be used for the merge.
  73931. * @param blurred Blurred highlights post process which's output will be used.
  73932. * @param weight Weight of the bloom to be added to the original input.
  73933. * @param options The required width/height ratio to downsize to before computing the render pass.
  73934. * @param camera The camera to apply the render pass to.
  73935. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73936. * @param engine The engine which the post process will be applied. (default: current engine)
  73937. * @param reusable If the post process can be reused on the same frame. (default: false)
  73938. * @param textureType Type of textures used when performing the post process. (default: 0)
  73939. * @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)
  73940. */
  73941. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73942. /** Weight of the bloom to be added to the original input. */
  73943. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73944. }
  73945. }
  73946. declare module "babylonjs/PostProcesses/bloomEffect" {
  73947. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73948. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73949. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73950. import { Camera } from "babylonjs/Cameras/camera";
  73951. import { Scene } from "babylonjs/scene";
  73952. /**
  73953. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73954. */
  73955. export class BloomEffect extends PostProcessRenderEffect {
  73956. private bloomScale;
  73957. /**
  73958. * @hidden Internal
  73959. */
  73960. _effects: Array<PostProcess>;
  73961. /**
  73962. * @hidden Internal
  73963. */
  73964. _downscale: ExtractHighlightsPostProcess;
  73965. private _blurX;
  73966. private _blurY;
  73967. private _merge;
  73968. /**
  73969. * The luminance threshold to find bright areas of the image to bloom.
  73970. */
  73971. get threshold(): number;
  73972. set threshold(value: number);
  73973. /**
  73974. * The strength of the bloom.
  73975. */
  73976. get weight(): number;
  73977. set weight(value: number);
  73978. /**
  73979. * Specifies the size of the bloom blur kernel, relative to the final output size
  73980. */
  73981. get kernel(): number;
  73982. set kernel(value: number);
  73983. /**
  73984. * Creates a new instance of @see BloomEffect
  73985. * @param scene The scene the effect belongs to.
  73986. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73987. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73988. * @param bloomWeight The the strength of bloom.
  73989. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73990. * @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)
  73991. */
  73992. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73993. /**
  73994. * Disposes each of the internal effects for a given camera.
  73995. * @param camera The camera to dispose the effect on.
  73996. */
  73997. disposeEffects(camera: Camera): void;
  73998. /**
  73999. * @hidden Internal
  74000. */
  74001. _updateEffects(): void;
  74002. /**
  74003. * Internal
  74004. * @returns if all the contained post processes are ready.
  74005. * @hidden
  74006. */
  74007. _isReady(): boolean;
  74008. }
  74009. }
  74010. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  74011. /** @hidden */
  74012. export var chromaticAberrationPixelShader: {
  74013. name: string;
  74014. shader: string;
  74015. };
  74016. }
  74017. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  74018. import { Vector2 } from "babylonjs/Maths/math.vector";
  74019. import { Nullable } from "babylonjs/types";
  74020. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74021. import { Camera } from "babylonjs/Cameras/camera";
  74022. import { Engine } from "babylonjs/Engines/engine";
  74023. import "babylonjs/Shaders/chromaticAberration.fragment";
  74024. import { Scene } from "babylonjs/scene";
  74025. /**
  74026. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  74027. */
  74028. export class ChromaticAberrationPostProcess extends PostProcess {
  74029. /**
  74030. * The amount of seperation of rgb channels (default: 30)
  74031. */
  74032. aberrationAmount: number;
  74033. /**
  74034. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  74035. */
  74036. radialIntensity: number;
  74037. /**
  74038. * 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))
  74039. */
  74040. direction: Vector2;
  74041. /**
  74042. * 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))
  74043. */
  74044. centerPosition: Vector2;
  74045. /** The width of the screen to apply the effect on */
  74046. screenWidth: number;
  74047. /** The height of the screen to apply the effect on */
  74048. screenHeight: number;
  74049. /**
  74050. * Gets a string identifying the name of the class
  74051. * @returns "ChromaticAberrationPostProcess" string
  74052. */
  74053. getClassName(): string;
  74054. /**
  74055. * Creates a new instance ChromaticAberrationPostProcess
  74056. * @param name The name of the effect.
  74057. * @param screenWidth The width of the screen to apply the effect on.
  74058. * @param screenHeight The height of the screen to apply the effect on.
  74059. * @param options The required width/height ratio to downsize to before computing the render pass.
  74060. * @param camera The camera to apply the render pass to.
  74061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74062. * @param engine The engine which the post process will be applied. (default: current engine)
  74063. * @param reusable If the post process can be reused on the same frame. (default: false)
  74064. * @param textureType Type of textures used when performing the post process. (default: 0)
  74065. * @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)
  74066. */
  74067. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74068. /** @hidden */
  74069. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  74070. }
  74071. }
  74072. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  74073. /** @hidden */
  74074. export var circleOfConfusionPixelShader: {
  74075. name: string;
  74076. shader: string;
  74077. };
  74078. }
  74079. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  74080. import { Nullable } from "babylonjs/types";
  74081. import { Engine } from "babylonjs/Engines/engine";
  74082. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74083. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74084. import { Camera } from "babylonjs/Cameras/camera";
  74085. import "babylonjs/Shaders/circleOfConfusion.fragment";
  74086. /**
  74087. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  74088. */
  74089. export class CircleOfConfusionPostProcess extends PostProcess {
  74090. /**
  74091. * 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.
  74092. */
  74093. lensSize: number;
  74094. /**
  74095. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74096. */
  74097. fStop: number;
  74098. /**
  74099. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74100. */
  74101. focusDistance: number;
  74102. /**
  74103. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  74104. */
  74105. focalLength: number;
  74106. /**
  74107. * Gets a string identifying the name of the class
  74108. * @returns "CircleOfConfusionPostProcess" string
  74109. */
  74110. getClassName(): string;
  74111. private _depthTexture;
  74112. /**
  74113. * Creates a new instance CircleOfConfusionPostProcess
  74114. * @param name The name of the effect.
  74115. * @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.
  74116. * @param options The required width/height ratio to downsize to before computing the render pass.
  74117. * @param camera The camera to apply the render pass to.
  74118. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74119. * @param engine The engine which the post process will be applied. (default: current engine)
  74120. * @param reusable If the post process can be reused on the same frame. (default: false)
  74121. * @param textureType Type of textures used when performing the post process. (default: 0)
  74122. * @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)
  74123. */
  74124. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74125. /**
  74126. * 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.
  74127. */
  74128. set depthTexture(value: RenderTargetTexture);
  74129. }
  74130. }
  74131. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  74132. /** @hidden */
  74133. export var colorCorrectionPixelShader: {
  74134. name: string;
  74135. shader: string;
  74136. };
  74137. }
  74138. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  74139. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74140. import { Engine } from "babylonjs/Engines/engine";
  74141. import { Camera } from "babylonjs/Cameras/camera";
  74142. import "babylonjs/Shaders/colorCorrection.fragment";
  74143. import { Nullable } from "babylonjs/types";
  74144. import { Scene } from "babylonjs/scene";
  74145. /**
  74146. *
  74147. * This post-process allows the modification of rendered colors by using
  74148. * a 'look-up table' (LUT). This effect is also called Color Grading.
  74149. *
  74150. * The object needs to be provided an url to a texture containing the color
  74151. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  74152. * Use an image editing software to tweak the LUT to match your needs.
  74153. *
  74154. * For an example of a color LUT, see here:
  74155. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  74156. * For explanations on color grading, see here:
  74157. * @see http://udn.epicgames.com/Three/ColorGrading.html
  74158. *
  74159. */
  74160. export class ColorCorrectionPostProcess extends PostProcess {
  74161. private _colorTableTexture;
  74162. /**
  74163. * Gets the color table url used to create the LUT texture
  74164. */
  74165. colorTableUrl: string;
  74166. /**
  74167. * Gets a string identifying the name of the class
  74168. * @returns "ColorCorrectionPostProcess" string
  74169. */
  74170. getClassName(): string;
  74171. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74172. /** @hidden */
  74173. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  74174. }
  74175. }
  74176. declare module "babylonjs/Shaders/convolution.fragment" {
  74177. /** @hidden */
  74178. export var convolutionPixelShader: {
  74179. name: string;
  74180. shader: string;
  74181. };
  74182. }
  74183. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  74184. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74185. import { Nullable } from "babylonjs/types";
  74186. import { Camera } from "babylonjs/Cameras/camera";
  74187. import { Engine } from "babylonjs/Engines/engine";
  74188. import "babylonjs/Shaders/convolution.fragment";
  74189. import { Scene } from "babylonjs/scene";
  74190. /**
  74191. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  74192. * input texture to perform effects such as edge detection or sharpening
  74193. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74194. */
  74195. export class ConvolutionPostProcess extends PostProcess {
  74196. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  74197. kernel: number[];
  74198. /**
  74199. * Gets a string identifying the name of the class
  74200. * @returns "ConvolutionPostProcess" string
  74201. */
  74202. getClassName(): string;
  74203. /**
  74204. * Creates a new instance ConvolutionPostProcess
  74205. * @param name The name of the effect.
  74206. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  74207. * @param options The required width/height ratio to downsize to before computing the render pass.
  74208. * @param camera The camera to apply the render pass to.
  74209. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74210. * @param engine The engine which the post process will be applied. (default: current engine)
  74211. * @param reusable If the post process can be reused on the same frame. (default: false)
  74212. * @param textureType Type of textures used when performing the post process. (default: 0)
  74213. */
  74214. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74215. /** @hidden */
  74216. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  74217. /**
  74218. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74219. */
  74220. static EdgeDetect0Kernel: number[];
  74221. /**
  74222. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74223. */
  74224. static EdgeDetect1Kernel: number[];
  74225. /**
  74226. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74227. */
  74228. static EdgeDetect2Kernel: number[];
  74229. /**
  74230. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74231. */
  74232. static SharpenKernel: number[];
  74233. /**
  74234. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74235. */
  74236. static EmbossKernel: number[];
  74237. /**
  74238. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  74239. */
  74240. static GaussianKernel: number[];
  74241. }
  74242. }
  74243. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  74244. import { Nullable } from "babylonjs/types";
  74245. import { Vector2 } from "babylonjs/Maths/math.vector";
  74246. import { Camera } from "babylonjs/Cameras/camera";
  74247. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74248. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74249. import { Engine } from "babylonjs/Engines/engine";
  74250. import { Scene } from "babylonjs/scene";
  74251. /**
  74252. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  74253. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  74254. * based on samples that have a large difference in distance than the center pixel.
  74255. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  74256. */
  74257. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  74258. /**
  74259. * The direction the blur should be applied
  74260. */
  74261. direction: Vector2;
  74262. /**
  74263. * Gets a string identifying the name of the class
  74264. * @returns "DepthOfFieldBlurPostProcess" string
  74265. */
  74266. getClassName(): string;
  74267. /**
  74268. * Creates a new instance CircleOfConfusionPostProcess
  74269. * @param name The name of the effect.
  74270. * @param scene The scene the effect belongs to.
  74271. * @param direction The direction the blur should be applied.
  74272. * @param kernel The size of the kernel used to blur.
  74273. * @param options The required width/height ratio to downsize to before computing the render pass.
  74274. * @param camera The camera to apply the render pass to.
  74275. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  74276. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  74277. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74278. * @param engine The engine which the post process will be applied. (default: current engine)
  74279. * @param reusable If the post process can be reused on the same frame. (default: false)
  74280. * @param textureType Type of textures used when performing the post process. (default: 0)
  74281. * @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)
  74282. */
  74283. 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);
  74284. }
  74285. }
  74286. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  74287. /** @hidden */
  74288. export var depthOfFieldMergePixelShader: {
  74289. name: string;
  74290. shader: string;
  74291. };
  74292. }
  74293. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  74294. import { Nullable } from "babylonjs/types";
  74295. import { Camera } from "babylonjs/Cameras/camera";
  74296. import { Effect } from "babylonjs/Materials/effect";
  74297. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74298. import { Engine } from "babylonjs/Engines/engine";
  74299. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  74300. /**
  74301. * Options to be set when merging outputs from the default pipeline.
  74302. */
  74303. export class DepthOfFieldMergePostProcessOptions {
  74304. /**
  74305. * The original image to merge on top of
  74306. */
  74307. originalFromInput: PostProcess;
  74308. /**
  74309. * Parameters to perform the merge of the depth of field effect
  74310. */
  74311. depthOfField?: {
  74312. circleOfConfusion: PostProcess;
  74313. blurSteps: Array<PostProcess>;
  74314. };
  74315. /**
  74316. * Parameters to perform the merge of bloom effect
  74317. */
  74318. bloom?: {
  74319. blurred: PostProcess;
  74320. weight: number;
  74321. };
  74322. }
  74323. /**
  74324. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  74325. */
  74326. export class DepthOfFieldMergePostProcess extends PostProcess {
  74327. private blurSteps;
  74328. /**
  74329. * Gets a string identifying the name of the class
  74330. * @returns "DepthOfFieldMergePostProcess" string
  74331. */
  74332. getClassName(): string;
  74333. /**
  74334. * Creates a new instance of DepthOfFieldMergePostProcess
  74335. * @param name The name of the effect.
  74336. * @param originalFromInput Post process which's input will be used for the merge.
  74337. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  74338. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  74339. * @param options The required width/height ratio to downsize to before computing the render pass.
  74340. * @param camera The camera to apply the render pass to.
  74341. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74342. * @param engine The engine which the post process will be applied. (default: current engine)
  74343. * @param reusable If the post process can be reused on the same frame. (default: false)
  74344. * @param textureType Type of textures used when performing the post process. (default: 0)
  74345. * @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)
  74346. */
  74347. 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);
  74348. /**
  74349. * Updates the effect with the current post process compile time values and recompiles the shader.
  74350. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  74351. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  74352. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  74353. * @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
  74354. * @param onCompiled Called when the shader has been compiled.
  74355. * @param onError Called if there is an error when compiling a shader.
  74356. */
  74357. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  74358. }
  74359. }
  74360. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  74361. import { Nullable } from "babylonjs/types";
  74362. import { Camera } from "babylonjs/Cameras/camera";
  74363. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74364. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74365. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74366. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74367. import { Scene } from "babylonjs/scene";
  74368. /**
  74369. * Specifies the level of max blur that should be applied when using the depth of field effect
  74370. */
  74371. export enum DepthOfFieldEffectBlurLevel {
  74372. /**
  74373. * Subtle blur
  74374. */
  74375. Low = 0,
  74376. /**
  74377. * Medium blur
  74378. */
  74379. Medium = 1,
  74380. /**
  74381. * Large blur
  74382. */
  74383. High = 2
  74384. }
  74385. /**
  74386. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  74387. */
  74388. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  74389. private _circleOfConfusion;
  74390. /**
  74391. * @hidden Internal, blurs from high to low
  74392. */
  74393. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  74394. private _depthOfFieldBlurY;
  74395. private _dofMerge;
  74396. /**
  74397. * @hidden Internal post processes in depth of field effect
  74398. */
  74399. _effects: Array<PostProcess>;
  74400. /**
  74401. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  74402. */
  74403. set focalLength(value: number);
  74404. get focalLength(): number;
  74405. /**
  74406. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  74407. */
  74408. set fStop(value: number);
  74409. get fStop(): number;
  74410. /**
  74411. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  74412. */
  74413. set focusDistance(value: number);
  74414. get focusDistance(): number;
  74415. /**
  74416. * 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.
  74417. */
  74418. set lensSize(value: number);
  74419. get lensSize(): number;
  74420. /**
  74421. * Creates a new instance DepthOfFieldEffect
  74422. * @param scene The scene the effect belongs to.
  74423. * @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.
  74424. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  74425. * @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)
  74426. */
  74427. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  74428. /**
  74429. * Get the current class name of the current effet
  74430. * @returns "DepthOfFieldEffect"
  74431. */
  74432. getClassName(): string;
  74433. /**
  74434. * 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.
  74435. */
  74436. set depthTexture(value: RenderTargetTexture);
  74437. /**
  74438. * Disposes each of the internal effects for a given camera.
  74439. * @param camera The camera to dispose the effect on.
  74440. */
  74441. disposeEffects(camera: Camera): void;
  74442. /**
  74443. * @hidden Internal
  74444. */
  74445. _updateEffects(): void;
  74446. /**
  74447. * Internal
  74448. * @returns if all the contained post processes are ready.
  74449. * @hidden
  74450. */
  74451. _isReady(): boolean;
  74452. }
  74453. }
  74454. declare module "babylonjs/Shaders/displayPass.fragment" {
  74455. /** @hidden */
  74456. export var displayPassPixelShader: {
  74457. name: string;
  74458. shader: string;
  74459. };
  74460. }
  74461. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  74462. import { Nullable } from "babylonjs/types";
  74463. import { Camera } from "babylonjs/Cameras/camera";
  74464. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74465. import { Engine } from "babylonjs/Engines/engine";
  74466. import "babylonjs/Shaders/displayPass.fragment";
  74467. import { Scene } from "babylonjs/scene";
  74468. /**
  74469. * DisplayPassPostProcess which produces an output the same as it's input
  74470. */
  74471. export class DisplayPassPostProcess extends PostProcess {
  74472. /**
  74473. * Gets a string identifying the name of the class
  74474. * @returns "DisplayPassPostProcess" string
  74475. */
  74476. getClassName(): string;
  74477. /**
  74478. * Creates the DisplayPassPostProcess
  74479. * @param name The name of the effect.
  74480. * @param options The required width/height ratio to downsize to before computing the render pass.
  74481. * @param camera The camera to apply the render pass to.
  74482. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74483. * @param engine The engine which the post process will be applied. (default: current engine)
  74484. * @param reusable If the post process can be reused on the same frame. (default: false)
  74485. */
  74486. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74487. /** @hidden */
  74488. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  74489. }
  74490. }
  74491. declare module "babylonjs/Shaders/filter.fragment" {
  74492. /** @hidden */
  74493. export var filterPixelShader: {
  74494. name: string;
  74495. shader: string;
  74496. };
  74497. }
  74498. declare module "babylonjs/PostProcesses/filterPostProcess" {
  74499. import { Nullable } from "babylonjs/types";
  74500. import { Matrix } from "babylonjs/Maths/math.vector";
  74501. import { Camera } from "babylonjs/Cameras/camera";
  74502. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74503. import { Engine } from "babylonjs/Engines/engine";
  74504. import "babylonjs/Shaders/filter.fragment";
  74505. import { Scene } from "babylonjs/scene";
  74506. /**
  74507. * Applies a kernel filter to the image
  74508. */
  74509. export class FilterPostProcess extends PostProcess {
  74510. /** The matrix to be applied to the image */
  74511. kernelMatrix: Matrix;
  74512. /**
  74513. * Gets a string identifying the name of the class
  74514. * @returns "FilterPostProcess" string
  74515. */
  74516. getClassName(): string;
  74517. /**
  74518. *
  74519. * @param name The name of the effect.
  74520. * @param kernelMatrix The matrix to be applied to the image
  74521. * @param options The required width/height ratio to downsize to before computing the render pass.
  74522. * @param camera The camera to apply the render pass to.
  74523. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74524. * @param engine The engine which the post process will be applied. (default: current engine)
  74525. * @param reusable If the post process can be reused on the same frame. (default: false)
  74526. */
  74527. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74528. /** @hidden */
  74529. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  74530. }
  74531. }
  74532. declare module "babylonjs/Shaders/fxaa.fragment" {
  74533. /** @hidden */
  74534. export var fxaaPixelShader: {
  74535. name: string;
  74536. shader: string;
  74537. };
  74538. }
  74539. declare module "babylonjs/Shaders/fxaa.vertex" {
  74540. /** @hidden */
  74541. export var fxaaVertexShader: {
  74542. name: string;
  74543. shader: string;
  74544. };
  74545. }
  74546. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  74547. import { Nullable } from "babylonjs/types";
  74548. import { Camera } from "babylonjs/Cameras/camera";
  74549. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74550. import { Engine } from "babylonjs/Engines/engine";
  74551. import "babylonjs/Shaders/fxaa.fragment";
  74552. import "babylonjs/Shaders/fxaa.vertex";
  74553. import { Scene } from "babylonjs/scene";
  74554. /**
  74555. * Fxaa post process
  74556. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  74557. */
  74558. export class FxaaPostProcess extends PostProcess {
  74559. /**
  74560. * Gets a string identifying the name of the class
  74561. * @returns "FxaaPostProcess" string
  74562. */
  74563. getClassName(): string;
  74564. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74565. private _getDefines;
  74566. /** @hidden */
  74567. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  74568. }
  74569. }
  74570. declare module "babylonjs/Shaders/grain.fragment" {
  74571. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  74572. /** @hidden */
  74573. export var grainPixelShader: {
  74574. name: string;
  74575. shader: string;
  74576. };
  74577. }
  74578. declare module "babylonjs/PostProcesses/grainPostProcess" {
  74579. import { Nullable } from "babylonjs/types";
  74580. import { Camera } from "babylonjs/Cameras/camera";
  74581. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74582. import { Engine } from "babylonjs/Engines/engine";
  74583. import "babylonjs/Shaders/grain.fragment";
  74584. import { Scene } from "babylonjs/scene";
  74585. /**
  74586. * The GrainPostProcess adds noise to the image at mid luminance levels
  74587. */
  74588. export class GrainPostProcess extends PostProcess {
  74589. /**
  74590. * The intensity of the grain added (default: 30)
  74591. */
  74592. intensity: number;
  74593. /**
  74594. * If the grain should be randomized on every frame
  74595. */
  74596. animated: boolean;
  74597. /**
  74598. * Gets a string identifying the name of the class
  74599. * @returns "GrainPostProcess" string
  74600. */
  74601. getClassName(): string;
  74602. /**
  74603. * Creates a new instance of @see GrainPostProcess
  74604. * @param name The name of the effect.
  74605. * @param options The required width/height ratio to downsize to before computing the render pass.
  74606. * @param camera The camera to apply the render pass to.
  74607. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74608. * @param engine The engine which the post process will be applied. (default: current engine)
  74609. * @param reusable If the post process can be reused on the same frame. (default: false)
  74610. * @param textureType Type of textures used when performing the post process. (default: 0)
  74611. * @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)
  74612. */
  74613. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74614. /** @hidden */
  74615. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  74616. }
  74617. }
  74618. declare module "babylonjs/Shaders/highlights.fragment" {
  74619. /** @hidden */
  74620. export var highlightsPixelShader: {
  74621. name: string;
  74622. shader: string;
  74623. };
  74624. }
  74625. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  74626. import { Nullable } from "babylonjs/types";
  74627. import { Camera } from "babylonjs/Cameras/camera";
  74628. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74629. import { Engine } from "babylonjs/Engines/engine";
  74630. import "babylonjs/Shaders/highlights.fragment";
  74631. /**
  74632. * Extracts highlights from the image
  74633. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74634. */
  74635. export class HighlightsPostProcess extends PostProcess {
  74636. /**
  74637. * Gets a string identifying the name of the class
  74638. * @returns "HighlightsPostProcess" string
  74639. */
  74640. getClassName(): string;
  74641. /**
  74642. * Extracts highlights from the image
  74643. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  74644. * @param name The name of the effect.
  74645. * @param options The required width/height ratio to downsize to before computing the render pass.
  74646. * @param camera The camera to apply the render pass to.
  74647. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74648. * @param engine The engine which the post process will be applied. (default: current engine)
  74649. * @param reusable If the post process can be reused on the same frame. (default: false)
  74650. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  74651. */
  74652. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  74653. }
  74654. }
  74655. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74656. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74657. /**
  74658. * Contains all parameters needed for the prepass to perform
  74659. * motion blur
  74660. */
  74661. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74662. /**
  74663. * Is motion blur enabled
  74664. */
  74665. enabled: boolean;
  74666. /**
  74667. * Name of the configuration
  74668. */
  74669. name: string;
  74670. /**
  74671. * Textures that should be present in the MRT for this effect to work
  74672. */
  74673. readonly texturesRequired: number[];
  74674. }
  74675. }
  74676. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74677. import { Nullable } from "babylonjs/types";
  74678. import { Scene } from "babylonjs/scene";
  74679. import { ISceneComponent } from "babylonjs/sceneComponent";
  74680. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74681. module "babylonjs/scene" {
  74682. interface Scene {
  74683. /** @hidden (Backing field) */
  74684. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74685. /**
  74686. * Gets or Sets the current geometry buffer associated to the scene.
  74687. */
  74688. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74689. /**
  74690. * Enables a GeometryBufferRender and associates it with the scene
  74691. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74692. * @returns the GeometryBufferRenderer
  74693. */
  74694. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74695. /**
  74696. * Disables the GeometryBufferRender associated with the scene
  74697. */
  74698. disableGeometryBufferRenderer(): void;
  74699. }
  74700. }
  74701. /**
  74702. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74703. * in several rendering techniques.
  74704. */
  74705. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74706. /**
  74707. * The component name helpful to identify the component in the list of scene components.
  74708. */
  74709. readonly name: string;
  74710. /**
  74711. * The scene the component belongs to.
  74712. */
  74713. scene: Scene;
  74714. /**
  74715. * Creates a new instance of the component for the given scene
  74716. * @param scene Defines the scene to register the component in
  74717. */
  74718. constructor(scene: Scene);
  74719. /**
  74720. * Registers the component in a given scene
  74721. */
  74722. register(): void;
  74723. /**
  74724. * Rebuilds the elements related to this component in case of
  74725. * context lost for instance.
  74726. */
  74727. rebuild(): void;
  74728. /**
  74729. * Disposes the component and the associated ressources
  74730. */
  74731. dispose(): void;
  74732. private _gatherRenderTargets;
  74733. }
  74734. }
  74735. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74736. /** @hidden */
  74737. export var motionBlurPixelShader: {
  74738. name: string;
  74739. shader: string;
  74740. };
  74741. }
  74742. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74743. import { Nullable } from "babylonjs/types";
  74744. import { Camera } from "babylonjs/Cameras/camera";
  74745. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74747. import "babylonjs/Animations/animatable";
  74748. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74749. import "babylonjs/Shaders/motionBlur.fragment";
  74750. import { Engine } from "babylonjs/Engines/engine";
  74751. import { Scene } from "babylonjs/scene";
  74752. /**
  74753. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74754. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74755. * As an example, all you have to do is to create the post-process:
  74756. * var mb = new BABYLON.MotionBlurPostProcess(
  74757. * 'mb', // The name of the effect.
  74758. * scene, // The scene containing the objects to blur according to their velocity.
  74759. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74760. * camera // The camera to apply the render pass to.
  74761. * );
  74762. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74763. */
  74764. export class MotionBlurPostProcess extends PostProcess {
  74765. /**
  74766. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74767. */
  74768. motionStrength: number;
  74769. /**
  74770. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74771. */
  74772. get motionBlurSamples(): number;
  74773. /**
  74774. * Sets the number of iterations to be used for motion blur quality
  74775. */
  74776. set motionBlurSamples(samples: number);
  74777. private _motionBlurSamples;
  74778. private _forceGeometryBuffer;
  74779. private _geometryBufferRenderer;
  74780. private _prePassRenderer;
  74781. /**
  74782. * Gets a string identifying the name of the class
  74783. * @returns "MotionBlurPostProcess" string
  74784. */
  74785. getClassName(): string;
  74786. /**
  74787. * Creates a new instance MotionBlurPostProcess
  74788. * @param name The name of the effect.
  74789. * @param scene The scene containing the objects to blur according to their velocity.
  74790. * @param options The required width/height ratio to downsize to before computing the render pass.
  74791. * @param camera The camera to apply the render pass to.
  74792. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74793. * @param engine The engine which the post process will be applied. (default: current engine)
  74794. * @param reusable If the post process can be reused on the same frame. (default: false)
  74795. * @param textureType Type of textures used when performing the post process. (default: 0)
  74796. * @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)
  74797. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74798. */
  74799. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74800. /**
  74801. * Excludes the given skinned mesh from computing bones velocities.
  74802. * 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.
  74803. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74804. */
  74805. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74806. /**
  74807. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74808. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74809. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74810. */
  74811. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74812. /**
  74813. * Disposes the post process.
  74814. * @param camera The camera to dispose the post process on.
  74815. */
  74816. dispose(camera?: Camera): void;
  74817. /** @hidden */
  74818. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74819. }
  74820. }
  74821. declare module "babylonjs/Shaders/refraction.fragment" {
  74822. /** @hidden */
  74823. export var refractionPixelShader: {
  74824. name: string;
  74825. shader: string;
  74826. };
  74827. }
  74828. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74829. import { Color3 } from "babylonjs/Maths/math.color";
  74830. import { Camera } from "babylonjs/Cameras/camera";
  74831. import { Texture } from "babylonjs/Materials/Textures/texture";
  74832. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74833. import { Engine } from "babylonjs/Engines/engine";
  74834. import "babylonjs/Shaders/refraction.fragment";
  74835. import { Scene } from "babylonjs/scene";
  74836. /**
  74837. * Post process which applies a refractin texture
  74838. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74839. */
  74840. export class RefractionPostProcess extends PostProcess {
  74841. private _refTexture;
  74842. private _ownRefractionTexture;
  74843. /** the base color of the refraction (used to taint the rendering) */
  74844. color: Color3;
  74845. /** simulated refraction depth */
  74846. depth: number;
  74847. /** the coefficient of the base color (0 to remove base color tainting) */
  74848. colorLevel: number;
  74849. /** Gets the url used to load the refraction texture */
  74850. refractionTextureUrl: string;
  74851. /**
  74852. * Gets or sets the refraction texture
  74853. * Please note that you are responsible for disposing the texture if you set it manually
  74854. */
  74855. get refractionTexture(): Texture;
  74856. set refractionTexture(value: Texture);
  74857. /**
  74858. * Gets a string identifying the name of the class
  74859. * @returns "RefractionPostProcess" string
  74860. */
  74861. getClassName(): string;
  74862. /**
  74863. * Initializes the RefractionPostProcess
  74864. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74865. * @param name The name of the effect.
  74866. * @param refractionTextureUrl Url of the refraction texture to use
  74867. * @param color the base color of the refraction (used to taint the rendering)
  74868. * @param depth simulated refraction depth
  74869. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74870. * @param camera The camera to apply the render pass to.
  74871. * @param options The required width/height ratio to downsize to before computing the render pass.
  74872. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74873. * @param engine The engine which the post process will be applied. (default: current engine)
  74874. * @param reusable If the post process can be reused on the same frame. (default: false)
  74875. */
  74876. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74877. /**
  74878. * Disposes of the post process
  74879. * @param camera Camera to dispose post process on
  74880. */
  74881. dispose(camera: Camera): void;
  74882. /** @hidden */
  74883. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74884. }
  74885. }
  74886. declare module "babylonjs/Shaders/sharpen.fragment" {
  74887. /** @hidden */
  74888. export var sharpenPixelShader: {
  74889. name: string;
  74890. shader: string;
  74891. };
  74892. }
  74893. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74894. import { Nullable } from "babylonjs/types";
  74895. import { Camera } from "babylonjs/Cameras/camera";
  74896. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74897. import "babylonjs/Shaders/sharpen.fragment";
  74898. import { Engine } from "babylonjs/Engines/engine";
  74899. import { Scene } from "babylonjs/scene";
  74900. /**
  74901. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74902. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74903. */
  74904. export class SharpenPostProcess extends PostProcess {
  74905. /**
  74906. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74907. */
  74908. colorAmount: number;
  74909. /**
  74910. * How much sharpness should be applied (default: 0.3)
  74911. */
  74912. edgeAmount: number;
  74913. /**
  74914. * Gets a string identifying the name of the class
  74915. * @returns "SharpenPostProcess" string
  74916. */
  74917. getClassName(): string;
  74918. /**
  74919. * Creates a new instance ConvolutionPostProcess
  74920. * @param name The name of the effect.
  74921. * @param options The required width/height ratio to downsize to before computing the render pass.
  74922. * @param camera The camera to apply the render pass to.
  74923. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74924. * @param engine The engine which the post process will be applied. (default: current engine)
  74925. * @param reusable If the post process can be reused on the same frame. (default: false)
  74926. * @param textureType Type of textures used when performing the post process. (default: 0)
  74927. * @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)
  74928. */
  74929. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74930. /** @hidden */
  74931. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74932. }
  74933. }
  74934. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74935. import { Nullable } from "babylonjs/types";
  74936. import { Camera } from "babylonjs/Cameras/camera";
  74937. import { Engine } from "babylonjs/Engines/engine";
  74938. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74939. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74940. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74941. /**
  74942. * PostProcessRenderPipeline
  74943. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74944. */
  74945. export class PostProcessRenderPipeline {
  74946. private engine;
  74947. private _renderEffects;
  74948. private _renderEffectsForIsolatedPass;
  74949. /**
  74950. * List of inspectable custom properties (used by the Inspector)
  74951. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74952. */
  74953. inspectableCustomProperties: IInspectable[];
  74954. /**
  74955. * @hidden
  74956. */
  74957. protected _cameras: Camera[];
  74958. /** @hidden */
  74959. _name: string;
  74960. /**
  74961. * Gets pipeline name
  74962. */
  74963. get name(): string;
  74964. /** Gets the list of attached cameras */
  74965. get cameras(): Camera[];
  74966. /**
  74967. * Initializes a PostProcessRenderPipeline
  74968. * @param engine engine to add the pipeline to
  74969. * @param name name of the pipeline
  74970. */
  74971. constructor(engine: Engine, name: string);
  74972. /**
  74973. * Gets the class name
  74974. * @returns "PostProcessRenderPipeline"
  74975. */
  74976. getClassName(): string;
  74977. /**
  74978. * If all the render effects in the pipeline are supported
  74979. */
  74980. get isSupported(): boolean;
  74981. /**
  74982. * Adds an effect to the pipeline
  74983. * @param renderEffect the effect to add
  74984. */
  74985. addEffect(renderEffect: PostProcessRenderEffect): void;
  74986. /** @hidden */
  74987. _rebuild(): void;
  74988. /** @hidden */
  74989. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74990. /** @hidden */
  74991. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74992. /** @hidden */
  74993. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74994. /** @hidden */
  74995. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74996. /** @hidden */
  74997. _attachCameras(cameras: Camera, unique: boolean): void;
  74998. /** @hidden */
  74999. _attachCameras(cameras: Camera[], unique: boolean): void;
  75000. /** @hidden */
  75001. _detachCameras(cameras: Camera): void;
  75002. /** @hidden */
  75003. _detachCameras(cameras: Nullable<Camera[]>): void;
  75004. /** @hidden */
  75005. _update(): void;
  75006. /** @hidden */
  75007. _reset(): void;
  75008. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  75009. /**
  75010. * Sets the required values to the prepass renderer.
  75011. * @param prePassRenderer defines the prepass renderer to setup.
  75012. * @returns true if the pre pass is needed.
  75013. */
  75014. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  75015. /**
  75016. * Disposes of the pipeline
  75017. */
  75018. dispose(): void;
  75019. }
  75020. }
  75021. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  75022. import { Camera } from "babylonjs/Cameras/camera";
  75023. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75024. /**
  75025. * PostProcessRenderPipelineManager class
  75026. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75027. */
  75028. export class PostProcessRenderPipelineManager {
  75029. private _renderPipelines;
  75030. /**
  75031. * Initializes a PostProcessRenderPipelineManager
  75032. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75033. */
  75034. constructor();
  75035. /**
  75036. * Gets the list of supported render pipelines
  75037. */
  75038. get supportedPipelines(): PostProcessRenderPipeline[];
  75039. /**
  75040. * Adds a pipeline to the manager
  75041. * @param renderPipeline The pipeline to add
  75042. */
  75043. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  75044. /**
  75045. * Attaches a camera to the pipeline
  75046. * @param renderPipelineName The name of the pipeline to attach to
  75047. * @param cameras the camera to attach
  75048. * @param unique if the camera can be attached multiple times to the pipeline
  75049. */
  75050. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  75051. /**
  75052. * Detaches a camera from the pipeline
  75053. * @param renderPipelineName The name of the pipeline to detach from
  75054. * @param cameras the camera to detach
  75055. */
  75056. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  75057. /**
  75058. * Enables an effect by name on a pipeline
  75059. * @param renderPipelineName the name of the pipeline to enable the effect in
  75060. * @param renderEffectName the name of the effect to enable
  75061. * @param cameras the cameras that the effect should be enabled on
  75062. */
  75063. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75064. /**
  75065. * Disables an effect by name on a pipeline
  75066. * @param renderPipelineName the name of the pipeline to disable the effect in
  75067. * @param renderEffectName the name of the effect to disable
  75068. * @param cameras the cameras that the effect should be disabled on
  75069. */
  75070. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  75071. /**
  75072. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  75073. */
  75074. update(): void;
  75075. /** @hidden */
  75076. _rebuild(): void;
  75077. /**
  75078. * Disposes of the manager and pipelines
  75079. */
  75080. dispose(): void;
  75081. }
  75082. }
  75083. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  75084. import { ISceneComponent } from "babylonjs/sceneComponent";
  75085. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75086. import { Scene } from "babylonjs/scene";
  75087. module "babylonjs/scene" {
  75088. interface Scene {
  75089. /** @hidden (Backing field) */
  75090. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75091. /**
  75092. * Gets the postprocess render pipeline manager
  75093. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  75094. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75095. */
  75096. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  75097. }
  75098. }
  75099. /**
  75100. * Defines the Render Pipeline scene component responsible to rendering pipelines
  75101. */
  75102. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  75103. /**
  75104. * The component name helpfull to identify the component in the list of scene components.
  75105. */
  75106. readonly name: string;
  75107. /**
  75108. * The scene the component belongs to.
  75109. */
  75110. scene: Scene;
  75111. /**
  75112. * Creates a new instance of the component for the given scene
  75113. * @param scene Defines the scene to register the component in
  75114. */
  75115. constructor(scene: Scene);
  75116. /**
  75117. * Registers the component in a given scene
  75118. */
  75119. register(): void;
  75120. /**
  75121. * Rebuilds the elements related to this component in case of
  75122. * context lost for instance.
  75123. */
  75124. rebuild(): void;
  75125. /**
  75126. * Disposes the component and the associated ressources
  75127. */
  75128. dispose(): void;
  75129. private _gatherRenderTargets;
  75130. }
  75131. }
  75132. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  75133. import { Nullable } from "babylonjs/types";
  75134. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75135. import { Camera } from "babylonjs/Cameras/camera";
  75136. import { IDisposable } from "babylonjs/scene";
  75137. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  75138. import { Scene } from "babylonjs/scene";
  75139. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  75140. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75141. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75142. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  75143. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75144. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75145. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  75146. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75147. import { Animation } from "babylonjs/Animations/animation";
  75148. /**
  75149. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  75150. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  75151. */
  75152. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75153. private _scene;
  75154. private _camerasToBeAttached;
  75155. /**
  75156. * ID of the sharpen post process,
  75157. */
  75158. private readonly SharpenPostProcessId;
  75159. /**
  75160. * @ignore
  75161. * ID of the image processing post process;
  75162. */
  75163. readonly ImageProcessingPostProcessId: string;
  75164. /**
  75165. * @ignore
  75166. * ID of the Fast Approximate Anti-Aliasing post process;
  75167. */
  75168. readonly FxaaPostProcessId: string;
  75169. /**
  75170. * ID of the chromatic aberration post process,
  75171. */
  75172. private readonly ChromaticAberrationPostProcessId;
  75173. /**
  75174. * ID of the grain post process
  75175. */
  75176. private readonly GrainPostProcessId;
  75177. /**
  75178. * Sharpen post process which will apply a sharpen convolution to enhance edges
  75179. */
  75180. sharpen: SharpenPostProcess;
  75181. private _sharpenEffect;
  75182. private bloom;
  75183. /**
  75184. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  75185. */
  75186. depthOfField: DepthOfFieldEffect;
  75187. /**
  75188. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75189. */
  75190. fxaa: FxaaPostProcess;
  75191. /**
  75192. * Image post processing pass used to perform operations such as tone mapping or color grading.
  75193. */
  75194. imageProcessing: ImageProcessingPostProcess;
  75195. /**
  75196. * Chromatic aberration post process which will shift rgb colors in the image
  75197. */
  75198. chromaticAberration: ChromaticAberrationPostProcess;
  75199. private _chromaticAberrationEffect;
  75200. /**
  75201. * Grain post process which add noise to the image
  75202. */
  75203. grain: GrainPostProcess;
  75204. private _grainEffect;
  75205. /**
  75206. * Glow post process which adds a glow to emissive areas of the image
  75207. */
  75208. private _glowLayer;
  75209. /**
  75210. * Animations which can be used to tweak settings over a period of time
  75211. */
  75212. animations: Animation[];
  75213. private _imageProcessingConfigurationObserver;
  75214. private _sharpenEnabled;
  75215. private _bloomEnabled;
  75216. private _depthOfFieldEnabled;
  75217. private _depthOfFieldBlurLevel;
  75218. private _fxaaEnabled;
  75219. private _imageProcessingEnabled;
  75220. private _defaultPipelineTextureType;
  75221. private _bloomScale;
  75222. private _chromaticAberrationEnabled;
  75223. private _grainEnabled;
  75224. private _buildAllowed;
  75225. /**
  75226. * Gets active scene
  75227. */
  75228. get scene(): Scene;
  75229. /**
  75230. * Enable or disable the sharpen process from the pipeline
  75231. */
  75232. set sharpenEnabled(enabled: boolean);
  75233. get sharpenEnabled(): boolean;
  75234. private _resizeObserver;
  75235. private _hardwareScaleLevel;
  75236. private _bloomKernel;
  75237. /**
  75238. * Specifies the size of the bloom blur kernel, relative to the final output size
  75239. */
  75240. get bloomKernel(): number;
  75241. set bloomKernel(value: number);
  75242. /**
  75243. * Specifies the weight of the bloom in the final rendering
  75244. */
  75245. private _bloomWeight;
  75246. /**
  75247. * Specifies the luma threshold for the area that will be blurred by the bloom
  75248. */
  75249. private _bloomThreshold;
  75250. private _hdr;
  75251. /**
  75252. * The strength of the bloom.
  75253. */
  75254. set bloomWeight(value: number);
  75255. get bloomWeight(): number;
  75256. /**
  75257. * The strength of the bloom.
  75258. */
  75259. set bloomThreshold(value: number);
  75260. get bloomThreshold(): number;
  75261. /**
  75262. * The scale of the bloom, lower value will provide better performance.
  75263. */
  75264. set bloomScale(value: number);
  75265. get bloomScale(): number;
  75266. /**
  75267. * Enable or disable the bloom from the pipeline
  75268. */
  75269. set bloomEnabled(enabled: boolean);
  75270. get bloomEnabled(): boolean;
  75271. private _rebuildBloom;
  75272. /**
  75273. * If the depth of field is enabled.
  75274. */
  75275. get depthOfFieldEnabled(): boolean;
  75276. set depthOfFieldEnabled(enabled: boolean);
  75277. /**
  75278. * Blur level of the depth of field effect. (Higher blur will effect performance)
  75279. */
  75280. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  75281. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  75282. /**
  75283. * If the anti aliasing is enabled.
  75284. */
  75285. set fxaaEnabled(enabled: boolean);
  75286. get fxaaEnabled(): boolean;
  75287. private _samples;
  75288. /**
  75289. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75290. */
  75291. set samples(sampleCount: number);
  75292. get samples(): number;
  75293. /**
  75294. * If image processing is enabled.
  75295. */
  75296. set imageProcessingEnabled(enabled: boolean);
  75297. get imageProcessingEnabled(): boolean;
  75298. /**
  75299. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  75300. */
  75301. set glowLayerEnabled(enabled: boolean);
  75302. get glowLayerEnabled(): boolean;
  75303. /**
  75304. * Gets the glow layer (or null if not defined)
  75305. */
  75306. get glowLayer(): Nullable<GlowLayer>;
  75307. /**
  75308. * Enable or disable the chromaticAberration process from the pipeline
  75309. */
  75310. set chromaticAberrationEnabled(enabled: boolean);
  75311. get chromaticAberrationEnabled(): boolean;
  75312. /**
  75313. * Enable or disable the grain process from the pipeline
  75314. */
  75315. set grainEnabled(enabled: boolean);
  75316. get grainEnabled(): boolean;
  75317. /**
  75318. * @constructor
  75319. * @param name - The rendering pipeline name (default: "")
  75320. * @param hdr - If high dynamic range textures should be used (default: true)
  75321. * @param scene - The scene linked to this pipeline (default: the last created scene)
  75322. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  75323. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  75324. */
  75325. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  75326. /**
  75327. * Get the class name
  75328. * @returns "DefaultRenderingPipeline"
  75329. */
  75330. getClassName(): string;
  75331. /**
  75332. * Force the compilation of the entire pipeline.
  75333. */
  75334. prepare(): void;
  75335. private _hasCleared;
  75336. private _prevPostProcess;
  75337. private _prevPrevPostProcess;
  75338. private _setAutoClearAndTextureSharing;
  75339. private _depthOfFieldSceneObserver;
  75340. private _buildPipeline;
  75341. private _disposePostProcesses;
  75342. /**
  75343. * Adds a camera to the pipeline
  75344. * @param camera the camera to be added
  75345. */
  75346. addCamera(camera: Camera): void;
  75347. /**
  75348. * Removes a camera from the pipeline
  75349. * @param camera the camera to remove
  75350. */
  75351. removeCamera(camera: Camera): void;
  75352. /**
  75353. * Dispose of the pipeline and stop all post processes
  75354. */
  75355. dispose(): void;
  75356. /**
  75357. * Serialize the rendering pipeline (Used when exporting)
  75358. * @returns the serialized object
  75359. */
  75360. serialize(): any;
  75361. /**
  75362. * Parse the serialized pipeline
  75363. * @param source Source pipeline.
  75364. * @param scene The scene to load the pipeline to.
  75365. * @param rootUrl The URL of the serialized pipeline.
  75366. * @returns An instantiated pipeline from the serialized object.
  75367. */
  75368. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  75369. }
  75370. }
  75371. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  75372. /** @hidden */
  75373. export var lensHighlightsPixelShader: {
  75374. name: string;
  75375. shader: string;
  75376. };
  75377. }
  75378. declare module "babylonjs/Shaders/depthOfField.fragment" {
  75379. /** @hidden */
  75380. export var depthOfFieldPixelShader: {
  75381. name: string;
  75382. shader: string;
  75383. };
  75384. }
  75385. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  75386. import { Camera } from "babylonjs/Cameras/camera";
  75387. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75388. import { Scene } from "babylonjs/scene";
  75389. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75390. import "babylonjs/Shaders/chromaticAberration.fragment";
  75391. import "babylonjs/Shaders/lensHighlights.fragment";
  75392. import "babylonjs/Shaders/depthOfField.fragment";
  75393. /**
  75394. * BABYLON.JS Chromatic Aberration GLSL Shader
  75395. * Author: Olivier Guyot
  75396. * Separates very slightly R, G and B colors on the edges of the screen
  75397. * Inspired by Francois Tarlier & Martins Upitis
  75398. */
  75399. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  75400. /**
  75401. * @ignore
  75402. * The chromatic aberration PostProcess id in the pipeline
  75403. */
  75404. LensChromaticAberrationEffect: string;
  75405. /**
  75406. * @ignore
  75407. * The highlights enhancing PostProcess id in the pipeline
  75408. */
  75409. HighlightsEnhancingEffect: string;
  75410. /**
  75411. * @ignore
  75412. * The depth-of-field PostProcess id in the pipeline
  75413. */
  75414. LensDepthOfFieldEffect: string;
  75415. private _scene;
  75416. private _depthTexture;
  75417. private _grainTexture;
  75418. private _chromaticAberrationPostProcess;
  75419. private _highlightsPostProcess;
  75420. private _depthOfFieldPostProcess;
  75421. private _edgeBlur;
  75422. private _grainAmount;
  75423. private _chromaticAberration;
  75424. private _distortion;
  75425. private _highlightsGain;
  75426. private _highlightsThreshold;
  75427. private _dofDistance;
  75428. private _dofAperture;
  75429. private _dofDarken;
  75430. private _dofPentagon;
  75431. private _blurNoise;
  75432. /**
  75433. * @constructor
  75434. *
  75435. * Effect parameters are as follow:
  75436. * {
  75437. * chromatic_aberration: number; // from 0 to x (1 for realism)
  75438. * edge_blur: number; // from 0 to x (1 for realism)
  75439. * distortion: number; // from 0 to x (1 for realism)
  75440. * grain_amount: number; // from 0 to 1
  75441. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  75442. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  75443. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  75444. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  75445. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  75446. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  75447. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  75448. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  75449. * }
  75450. * Note: if an effect parameter is unset, effect is disabled
  75451. *
  75452. * @param name The rendering pipeline name
  75453. * @param parameters - An object containing all parameters (see above)
  75454. * @param scene The scene linked to this pipeline
  75455. * @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)
  75456. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75457. */
  75458. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  75459. /**
  75460. * Get the class name
  75461. * @returns "LensRenderingPipeline"
  75462. */
  75463. getClassName(): string;
  75464. /**
  75465. * Gets associated scene
  75466. */
  75467. get scene(): Scene;
  75468. /**
  75469. * Gets or sets the edge blur
  75470. */
  75471. get edgeBlur(): number;
  75472. set edgeBlur(value: number);
  75473. /**
  75474. * Gets or sets the grain amount
  75475. */
  75476. get grainAmount(): number;
  75477. set grainAmount(value: number);
  75478. /**
  75479. * Gets or sets the chromatic aberration amount
  75480. */
  75481. get chromaticAberration(): number;
  75482. set chromaticAberration(value: number);
  75483. /**
  75484. * Gets or sets the depth of field aperture
  75485. */
  75486. get dofAperture(): number;
  75487. set dofAperture(value: number);
  75488. /**
  75489. * Gets or sets the edge distortion
  75490. */
  75491. get edgeDistortion(): number;
  75492. set edgeDistortion(value: number);
  75493. /**
  75494. * Gets or sets the depth of field distortion
  75495. */
  75496. get dofDistortion(): number;
  75497. set dofDistortion(value: number);
  75498. /**
  75499. * Gets or sets the darken out of focus amount
  75500. */
  75501. get darkenOutOfFocus(): number;
  75502. set darkenOutOfFocus(value: number);
  75503. /**
  75504. * Gets or sets a boolean indicating if blur noise is enabled
  75505. */
  75506. get blurNoise(): boolean;
  75507. set blurNoise(value: boolean);
  75508. /**
  75509. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  75510. */
  75511. get pentagonBokeh(): boolean;
  75512. set pentagonBokeh(value: boolean);
  75513. /**
  75514. * Gets or sets the highlight grain amount
  75515. */
  75516. get highlightsGain(): number;
  75517. set highlightsGain(value: number);
  75518. /**
  75519. * Gets or sets the highlight threshold
  75520. */
  75521. get highlightsThreshold(): number;
  75522. set highlightsThreshold(value: number);
  75523. /**
  75524. * Sets the amount of blur at the edges
  75525. * @param amount blur amount
  75526. */
  75527. setEdgeBlur(amount: number): void;
  75528. /**
  75529. * Sets edge blur to 0
  75530. */
  75531. disableEdgeBlur(): void;
  75532. /**
  75533. * Sets the amout of grain
  75534. * @param amount Amount of grain
  75535. */
  75536. setGrainAmount(amount: number): void;
  75537. /**
  75538. * Set grain amount to 0
  75539. */
  75540. disableGrain(): void;
  75541. /**
  75542. * Sets the chromatic aberration amount
  75543. * @param amount amount of chromatic aberration
  75544. */
  75545. setChromaticAberration(amount: number): void;
  75546. /**
  75547. * Sets chromatic aberration amount to 0
  75548. */
  75549. disableChromaticAberration(): void;
  75550. /**
  75551. * Sets the EdgeDistortion amount
  75552. * @param amount amount of EdgeDistortion
  75553. */
  75554. setEdgeDistortion(amount: number): void;
  75555. /**
  75556. * Sets edge distortion to 0
  75557. */
  75558. disableEdgeDistortion(): void;
  75559. /**
  75560. * Sets the FocusDistance amount
  75561. * @param amount amount of FocusDistance
  75562. */
  75563. setFocusDistance(amount: number): void;
  75564. /**
  75565. * Disables depth of field
  75566. */
  75567. disableDepthOfField(): void;
  75568. /**
  75569. * Sets the Aperture amount
  75570. * @param amount amount of Aperture
  75571. */
  75572. setAperture(amount: number): void;
  75573. /**
  75574. * Sets the DarkenOutOfFocus amount
  75575. * @param amount amount of DarkenOutOfFocus
  75576. */
  75577. setDarkenOutOfFocus(amount: number): void;
  75578. private _pentagonBokehIsEnabled;
  75579. /**
  75580. * Creates a pentagon bokeh effect
  75581. */
  75582. enablePentagonBokeh(): void;
  75583. /**
  75584. * Disables the pentagon bokeh effect
  75585. */
  75586. disablePentagonBokeh(): void;
  75587. /**
  75588. * Enables noise blur
  75589. */
  75590. enableNoiseBlur(): void;
  75591. /**
  75592. * Disables noise blur
  75593. */
  75594. disableNoiseBlur(): void;
  75595. /**
  75596. * Sets the HighlightsGain amount
  75597. * @param amount amount of HighlightsGain
  75598. */
  75599. setHighlightsGain(amount: number): void;
  75600. /**
  75601. * Sets the HighlightsThreshold amount
  75602. * @param amount amount of HighlightsThreshold
  75603. */
  75604. setHighlightsThreshold(amount: number): void;
  75605. /**
  75606. * Disables highlights
  75607. */
  75608. disableHighlights(): void;
  75609. /**
  75610. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  75611. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  75612. */
  75613. dispose(disableDepthRender?: boolean): void;
  75614. private _createChromaticAberrationPostProcess;
  75615. private _createHighlightsPostProcess;
  75616. private _createDepthOfFieldPostProcess;
  75617. private _createGrainTexture;
  75618. }
  75619. }
  75620. declare module "babylonjs/Rendering/ssao2Configuration" {
  75621. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75622. /**
  75623. * Contains all parameters needed for the prepass to perform
  75624. * screen space subsurface scattering
  75625. */
  75626. export class SSAO2Configuration implements PrePassEffectConfiguration {
  75627. /**
  75628. * Is subsurface enabled
  75629. */
  75630. enabled: boolean;
  75631. /**
  75632. * Name of the configuration
  75633. */
  75634. name: string;
  75635. /**
  75636. * Textures that should be present in the MRT for this effect to work
  75637. */
  75638. readonly texturesRequired: number[];
  75639. }
  75640. }
  75641. declare module "babylonjs/Shaders/ssao2.fragment" {
  75642. /** @hidden */
  75643. export var ssao2PixelShader: {
  75644. name: string;
  75645. shader: string;
  75646. };
  75647. }
  75648. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75649. /** @hidden */
  75650. export var ssaoCombinePixelShader: {
  75651. name: string;
  75652. shader: string;
  75653. };
  75654. }
  75655. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75656. import { Camera } from "babylonjs/Cameras/camera";
  75657. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75658. import { Scene } from "babylonjs/scene";
  75659. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75660. import "babylonjs/Shaders/ssao2.fragment";
  75661. import "babylonjs/Shaders/ssaoCombine.fragment";
  75662. /**
  75663. * Render pipeline to produce ssao effect
  75664. */
  75665. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75666. /**
  75667. * @ignore
  75668. * The PassPostProcess id in the pipeline that contains the original scene color
  75669. */
  75670. SSAOOriginalSceneColorEffect: string;
  75671. /**
  75672. * @ignore
  75673. * The SSAO PostProcess id in the pipeline
  75674. */
  75675. SSAORenderEffect: string;
  75676. /**
  75677. * @ignore
  75678. * The horizontal blur PostProcess id in the pipeline
  75679. */
  75680. SSAOBlurHRenderEffect: string;
  75681. /**
  75682. * @ignore
  75683. * The vertical blur PostProcess id in the pipeline
  75684. */
  75685. SSAOBlurVRenderEffect: string;
  75686. /**
  75687. * @ignore
  75688. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75689. */
  75690. SSAOCombineRenderEffect: string;
  75691. /**
  75692. * The output strength of the SSAO post-process. Default value is 1.0.
  75693. */
  75694. totalStrength: number;
  75695. /**
  75696. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75697. */
  75698. maxZ: number;
  75699. /**
  75700. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75701. */
  75702. minZAspect: number;
  75703. private _samples;
  75704. /**
  75705. * Number of samples used for the SSAO calculations. Default value is 8
  75706. */
  75707. set samples(n: number);
  75708. get samples(): number;
  75709. private _textureSamples;
  75710. /**
  75711. * Number of samples to use for antialiasing
  75712. */
  75713. set textureSamples(n: number);
  75714. get textureSamples(): number;
  75715. /**
  75716. * Force rendering the geometry through geometry buffer
  75717. */
  75718. private _forceGeometryBuffer;
  75719. /**
  75720. * Ratio object used for SSAO ratio and blur ratio
  75721. */
  75722. private _ratio;
  75723. /**
  75724. * Dynamically generated sphere sampler.
  75725. */
  75726. private _sampleSphere;
  75727. /**
  75728. * Blur filter offsets
  75729. */
  75730. private _samplerOffsets;
  75731. private _expensiveBlur;
  75732. /**
  75733. * If bilateral blur should be used
  75734. */
  75735. set expensiveBlur(b: boolean);
  75736. get expensiveBlur(): boolean;
  75737. /**
  75738. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75739. */
  75740. radius: number;
  75741. /**
  75742. * The base color of the SSAO post-process
  75743. * The final result is "base + ssao" between [0, 1]
  75744. */
  75745. base: number;
  75746. /**
  75747. * Support test.
  75748. */
  75749. static get IsSupported(): boolean;
  75750. private _scene;
  75751. private _randomTexture;
  75752. private _originalColorPostProcess;
  75753. private _ssaoPostProcess;
  75754. private _blurHPostProcess;
  75755. private _blurVPostProcess;
  75756. private _ssaoCombinePostProcess;
  75757. private _prePassRenderer;
  75758. /**
  75759. * Gets active scene
  75760. */
  75761. get scene(): Scene;
  75762. /**
  75763. * @constructor
  75764. * @param name The rendering pipeline name
  75765. * @param scene The scene linked to this pipeline
  75766. * @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 }
  75767. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75768. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75769. */
  75770. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75771. /**
  75772. * Get the class name
  75773. * @returns "SSAO2RenderingPipeline"
  75774. */
  75775. getClassName(): string;
  75776. /**
  75777. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75778. */
  75779. dispose(disableGeometryBufferRenderer?: boolean): void;
  75780. private _createBlurPostProcess;
  75781. /** @hidden */
  75782. _rebuild(): void;
  75783. private _bits;
  75784. private _radicalInverse_VdC;
  75785. private _hammersley;
  75786. private _hemisphereSample_uniform;
  75787. private _generateHemisphere;
  75788. private _getDefinesForSSAO;
  75789. private _createSSAOPostProcess;
  75790. private _createSSAOCombinePostProcess;
  75791. private _createRandomTexture;
  75792. /**
  75793. * Serialize the rendering pipeline (Used when exporting)
  75794. * @returns the serialized object
  75795. */
  75796. serialize(): any;
  75797. /**
  75798. * Parse the serialized pipeline
  75799. * @param source Source pipeline.
  75800. * @param scene The scene to load the pipeline to.
  75801. * @param rootUrl The URL of the serialized pipeline.
  75802. * @returns An instantiated pipeline from the serialized object.
  75803. */
  75804. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75805. }
  75806. }
  75807. declare module "babylonjs/Shaders/ssao.fragment" {
  75808. /** @hidden */
  75809. export var ssaoPixelShader: {
  75810. name: string;
  75811. shader: string;
  75812. };
  75813. }
  75814. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75815. import { Camera } from "babylonjs/Cameras/camera";
  75816. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75817. import { Scene } from "babylonjs/scene";
  75818. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75819. import "babylonjs/Shaders/ssao.fragment";
  75820. import "babylonjs/Shaders/ssaoCombine.fragment";
  75821. /**
  75822. * Render pipeline to produce ssao effect
  75823. */
  75824. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75825. /**
  75826. * @ignore
  75827. * The PassPostProcess id in the pipeline that contains the original scene color
  75828. */
  75829. SSAOOriginalSceneColorEffect: string;
  75830. /**
  75831. * @ignore
  75832. * The SSAO PostProcess id in the pipeline
  75833. */
  75834. SSAORenderEffect: string;
  75835. /**
  75836. * @ignore
  75837. * The horizontal blur PostProcess id in the pipeline
  75838. */
  75839. SSAOBlurHRenderEffect: string;
  75840. /**
  75841. * @ignore
  75842. * The vertical blur PostProcess id in the pipeline
  75843. */
  75844. SSAOBlurVRenderEffect: string;
  75845. /**
  75846. * @ignore
  75847. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75848. */
  75849. SSAOCombineRenderEffect: string;
  75850. /**
  75851. * The output strength of the SSAO post-process. Default value is 1.0.
  75852. */
  75853. totalStrength: number;
  75854. /**
  75855. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75856. */
  75857. radius: number;
  75858. /**
  75859. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75860. * Must not be equal to fallOff and superior to fallOff.
  75861. * Default value is 0.0075
  75862. */
  75863. area: number;
  75864. /**
  75865. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75866. * Must not be equal to area and inferior to area.
  75867. * Default value is 0.000001
  75868. */
  75869. fallOff: number;
  75870. /**
  75871. * The base color of the SSAO post-process
  75872. * The final result is "base + ssao" between [0, 1]
  75873. */
  75874. base: number;
  75875. private _scene;
  75876. private _depthTexture;
  75877. private _randomTexture;
  75878. private _originalColorPostProcess;
  75879. private _ssaoPostProcess;
  75880. private _blurHPostProcess;
  75881. private _blurVPostProcess;
  75882. private _ssaoCombinePostProcess;
  75883. private _firstUpdate;
  75884. /**
  75885. * Gets active scene
  75886. */
  75887. get scene(): Scene;
  75888. /**
  75889. * @constructor
  75890. * @param name - The rendering pipeline name
  75891. * @param scene - The scene linked to this pipeline
  75892. * @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 }
  75893. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75894. */
  75895. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75896. /**
  75897. * Get the class name
  75898. * @returns "SSAORenderingPipeline"
  75899. */
  75900. getClassName(): string;
  75901. /**
  75902. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75903. */
  75904. dispose(disableDepthRender?: boolean): void;
  75905. private _createBlurPostProcess;
  75906. /** @hidden */
  75907. _rebuild(): void;
  75908. private _createSSAOPostProcess;
  75909. private _createSSAOCombinePostProcess;
  75910. private _createRandomTexture;
  75911. }
  75912. }
  75913. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75914. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75915. /**
  75916. * Contains all parameters needed for the prepass to perform
  75917. * screen space reflections
  75918. */
  75919. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75920. /**
  75921. * Is ssr enabled
  75922. */
  75923. enabled: boolean;
  75924. /**
  75925. * Name of the configuration
  75926. */
  75927. name: string;
  75928. /**
  75929. * Textures that should be present in the MRT for this effect to work
  75930. */
  75931. readonly texturesRequired: number[];
  75932. }
  75933. }
  75934. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75935. /** @hidden */
  75936. export var screenSpaceReflectionPixelShader: {
  75937. name: string;
  75938. shader: string;
  75939. };
  75940. }
  75941. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75942. import { Nullable } from "babylonjs/types";
  75943. import { Camera } from "babylonjs/Cameras/camera";
  75944. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75945. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75946. import { Engine } from "babylonjs/Engines/engine";
  75947. import { Scene } from "babylonjs/scene";
  75948. /**
  75949. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75950. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75951. */
  75952. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75953. /**
  75954. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75955. */
  75956. threshold: number;
  75957. /**
  75958. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75959. */
  75960. strength: number;
  75961. /**
  75962. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75963. */
  75964. reflectionSpecularFalloffExponent: number;
  75965. /**
  75966. * 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]
  75967. */
  75968. step: number;
  75969. /**
  75970. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75971. */
  75972. roughnessFactor: number;
  75973. private _forceGeometryBuffer;
  75974. private _geometryBufferRenderer;
  75975. private _prePassRenderer;
  75976. private _enableSmoothReflections;
  75977. private _reflectionSamples;
  75978. private _smoothSteps;
  75979. /**
  75980. * Gets a string identifying the name of the class
  75981. * @returns "ScreenSpaceReflectionPostProcess" string
  75982. */
  75983. getClassName(): string;
  75984. /**
  75985. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75986. * @param name The name of the effect.
  75987. * @param scene The scene containing the objects to calculate reflections.
  75988. * @param options The required width/height ratio to downsize to before computing the render pass.
  75989. * @param camera The camera to apply the render pass to.
  75990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75991. * @param engine The engine which the post process will be applied. (default: current engine)
  75992. * @param reusable If the post process can be reused on the same frame. (default: false)
  75993. * @param textureType Type of textures used when performing the post process. (default: 0)
  75994. * @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)
  75995. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75996. */
  75997. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75998. /**
  75999. * Gets wether or not smoothing reflections is enabled.
  76000. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76001. */
  76002. get enableSmoothReflections(): boolean;
  76003. /**
  76004. * Sets wether or not smoothing reflections is enabled.
  76005. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  76006. */
  76007. set enableSmoothReflections(enabled: boolean);
  76008. /**
  76009. * Gets the number of samples taken while computing reflections. More samples count is high,
  76010. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76011. */
  76012. get reflectionSamples(): number;
  76013. /**
  76014. * Sets the number of samples taken while computing reflections. More samples count is high,
  76015. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  76016. */
  76017. set reflectionSamples(samples: number);
  76018. /**
  76019. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  76020. * more the post-process will require GPU power and can generate a drop in FPS.
  76021. * Default value (5.0) work pretty well in all cases but can be adjusted.
  76022. */
  76023. get smoothSteps(): number;
  76024. set smoothSteps(steps: number);
  76025. private _updateEffectDefines;
  76026. /** @hidden */
  76027. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  76028. }
  76029. }
  76030. declare module "babylonjs/Shaders/standard.fragment" {
  76031. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  76032. /** @hidden */
  76033. export var standardPixelShader: {
  76034. name: string;
  76035. shader: string;
  76036. };
  76037. }
  76038. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  76039. import { Nullable } from "babylonjs/types";
  76040. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  76041. import { Camera } from "babylonjs/Cameras/camera";
  76042. import { Texture } from "babylonjs/Materials/Textures/texture";
  76043. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76044. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76045. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  76046. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  76047. import { IDisposable } from "babylonjs/scene";
  76048. import { SpotLight } from "babylonjs/Lights/spotLight";
  76049. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  76050. import { Scene } from "babylonjs/scene";
  76051. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76052. import { Animation } from "babylonjs/Animations/animation";
  76053. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76054. import "babylonjs/Shaders/standard.fragment";
  76055. /**
  76056. * Standard rendering pipeline
  76057. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76058. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  76059. */
  76060. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  76061. /**
  76062. * Public members
  76063. */
  76064. /**
  76065. * Post-process which contains the original scene color before the pipeline applies all the effects
  76066. */
  76067. originalPostProcess: Nullable<PostProcess>;
  76068. /**
  76069. * Post-process used to down scale an image x4
  76070. */
  76071. downSampleX4PostProcess: Nullable<PostProcess>;
  76072. /**
  76073. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  76074. */
  76075. brightPassPostProcess: Nullable<PostProcess>;
  76076. /**
  76077. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  76078. */
  76079. blurHPostProcesses: PostProcess[];
  76080. /**
  76081. * Post-process array storing all the vertical blur post-processes used by the pipeline
  76082. */
  76083. blurVPostProcesses: PostProcess[];
  76084. /**
  76085. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  76086. */
  76087. textureAdderPostProcess: Nullable<PostProcess>;
  76088. /**
  76089. * Post-process used to create volumetric lighting effect
  76090. */
  76091. volumetricLightPostProcess: Nullable<PostProcess>;
  76092. /**
  76093. * Post-process used to smooth the previous volumetric light post-process on the X axis
  76094. */
  76095. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  76096. /**
  76097. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  76098. */
  76099. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  76100. /**
  76101. * Post-process used to merge the volumetric light effect and the real scene color
  76102. */
  76103. volumetricLightMergePostProces: Nullable<PostProcess>;
  76104. /**
  76105. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  76106. */
  76107. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  76108. /**
  76109. * Base post-process used to calculate the average luminance of the final image for HDR
  76110. */
  76111. luminancePostProcess: Nullable<PostProcess>;
  76112. /**
  76113. * Post-processes used to create down sample post-processes in order to get
  76114. * the average luminance of the final image for HDR
  76115. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  76116. */
  76117. luminanceDownSamplePostProcesses: PostProcess[];
  76118. /**
  76119. * Post-process used to create a HDR effect (light adaptation)
  76120. */
  76121. hdrPostProcess: Nullable<PostProcess>;
  76122. /**
  76123. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  76124. */
  76125. textureAdderFinalPostProcess: Nullable<PostProcess>;
  76126. /**
  76127. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  76128. */
  76129. lensFlareFinalPostProcess: Nullable<PostProcess>;
  76130. /**
  76131. * Post-process used to merge the final HDR post-process and the real scene color
  76132. */
  76133. hdrFinalPostProcess: Nullable<PostProcess>;
  76134. /**
  76135. * Post-process used to create a lens flare effect
  76136. */
  76137. lensFlarePostProcess: Nullable<PostProcess>;
  76138. /**
  76139. * Post-process that merges the result of the lens flare post-process and the real scene color
  76140. */
  76141. lensFlareComposePostProcess: Nullable<PostProcess>;
  76142. /**
  76143. * Post-process used to create a motion blur effect
  76144. */
  76145. motionBlurPostProcess: Nullable<PostProcess>;
  76146. /**
  76147. * Post-process used to create a depth of field effect
  76148. */
  76149. depthOfFieldPostProcess: Nullable<PostProcess>;
  76150. /**
  76151. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  76152. */
  76153. fxaaPostProcess: Nullable<FxaaPostProcess>;
  76154. /**
  76155. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  76156. */
  76157. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  76158. /**
  76159. * Represents the brightness threshold in order to configure the illuminated surfaces
  76160. */
  76161. brightThreshold: number;
  76162. /**
  76163. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  76164. */
  76165. blurWidth: number;
  76166. /**
  76167. * Sets if the blur for highlighted surfaces must be only horizontal
  76168. */
  76169. horizontalBlur: boolean;
  76170. /**
  76171. * Gets the overall exposure used by the pipeline
  76172. */
  76173. get exposure(): number;
  76174. /**
  76175. * Sets the overall exposure used by the pipeline
  76176. */
  76177. set exposure(value: number);
  76178. /**
  76179. * Texture used typically to simulate "dirty" on camera lens
  76180. */
  76181. lensTexture: Nullable<Texture>;
  76182. /**
  76183. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  76184. */
  76185. volumetricLightCoefficient: number;
  76186. /**
  76187. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  76188. */
  76189. volumetricLightPower: number;
  76190. /**
  76191. * Used the set the blur intensity to smooth the volumetric lights
  76192. */
  76193. volumetricLightBlurScale: number;
  76194. /**
  76195. * Light (spot or directional) used to generate the volumetric lights rays
  76196. * The source light must have a shadow generate so the pipeline can get its
  76197. * depth map
  76198. */
  76199. sourceLight: Nullable<SpotLight | DirectionalLight>;
  76200. /**
  76201. * For eye adaptation, represents the minimum luminance the eye can see
  76202. */
  76203. hdrMinimumLuminance: number;
  76204. /**
  76205. * For eye adaptation, represents the decrease luminance speed
  76206. */
  76207. hdrDecreaseRate: number;
  76208. /**
  76209. * For eye adaptation, represents the increase luminance speed
  76210. */
  76211. hdrIncreaseRate: number;
  76212. /**
  76213. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76214. */
  76215. get hdrAutoExposure(): boolean;
  76216. /**
  76217. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  76218. */
  76219. set hdrAutoExposure(value: boolean);
  76220. /**
  76221. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  76222. */
  76223. lensColorTexture: Nullable<Texture>;
  76224. /**
  76225. * The overall strengh for the lens flare effect
  76226. */
  76227. lensFlareStrength: number;
  76228. /**
  76229. * Dispersion coefficient for lens flare ghosts
  76230. */
  76231. lensFlareGhostDispersal: number;
  76232. /**
  76233. * Main lens flare halo width
  76234. */
  76235. lensFlareHaloWidth: number;
  76236. /**
  76237. * Based on the lens distortion effect, defines how much the lens flare result
  76238. * is distorted
  76239. */
  76240. lensFlareDistortionStrength: number;
  76241. /**
  76242. * Configures the blur intensity used for for lens flare (halo)
  76243. */
  76244. lensFlareBlurWidth: number;
  76245. /**
  76246. * Lens star texture must be used to simulate rays on the flares and is available
  76247. * in the documentation
  76248. */
  76249. lensStarTexture: Nullable<Texture>;
  76250. /**
  76251. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  76252. * flare effect by taking account of the dirt texture
  76253. */
  76254. lensFlareDirtTexture: Nullable<Texture>;
  76255. /**
  76256. * Represents the focal length for the depth of field effect
  76257. */
  76258. depthOfFieldDistance: number;
  76259. /**
  76260. * Represents the blur intensity for the blurred part of the depth of field effect
  76261. */
  76262. depthOfFieldBlurWidth: number;
  76263. /**
  76264. * Gets how much the image is blurred by the movement while using the motion blur post-process
  76265. */
  76266. get motionStrength(): number;
  76267. /**
  76268. * Sets how much the image is blurred by the movement while using the motion blur post-process
  76269. */
  76270. set motionStrength(strength: number);
  76271. /**
  76272. * Gets wether or not the motion blur post-process is object based or screen based.
  76273. */
  76274. get objectBasedMotionBlur(): boolean;
  76275. /**
  76276. * Sets wether or not the motion blur post-process should be object based or screen based
  76277. */
  76278. set objectBasedMotionBlur(value: boolean);
  76279. /**
  76280. * List of animations for the pipeline (IAnimatable implementation)
  76281. */
  76282. animations: Animation[];
  76283. /**
  76284. * Private members
  76285. */
  76286. private _scene;
  76287. private _currentDepthOfFieldSource;
  76288. private _basePostProcess;
  76289. private _fixedExposure;
  76290. private _currentExposure;
  76291. private _hdrAutoExposure;
  76292. private _hdrCurrentLuminance;
  76293. private _motionStrength;
  76294. private _isObjectBasedMotionBlur;
  76295. private _floatTextureType;
  76296. private _camerasToBeAttached;
  76297. private _ratio;
  76298. private _bloomEnabled;
  76299. private _depthOfFieldEnabled;
  76300. private _vlsEnabled;
  76301. private _lensFlareEnabled;
  76302. private _hdrEnabled;
  76303. private _motionBlurEnabled;
  76304. private _fxaaEnabled;
  76305. private _screenSpaceReflectionsEnabled;
  76306. private _motionBlurSamples;
  76307. private _volumetricLightStepsCount;
  76308. private _samples;
  76309. /**
  76310. * @ignore
  76311. * Specifies if the bloom pipeline is enabled
  76312. */
  76313. get BloomEnabled(): boolean;
  76314. set BloomEnabled(enabled: boolean);
  76315. /**
  76316. * @ignore
  76317. * Specifies if the depth of field pipeline is enabed
  76318. */
  76319. get DepthOfFieldEnabled(): boolean;
  76320. set DepthOfFieldEnabled(enabled: boolean);
  76321. /**
  76322. * @ignore
  76323. * Specifies if the lens flare pipeline is enabed
  76324. */
  76325. get LensFlareEnabled(): boolean;
  76326. set LensFlareEnabled(enabled: boolean);
  76327. /**
  76328. * @ignore
  76329. * Specifies if the HDR pipeline is enabled
  76330. */
  76331. get HDREnabled(): boolean;
  76332. set HDREnabled(enabled: boolean);
  76333. /**
  76334. * @ignore
  76335. * Specifies if the volumetric lights scattering effect is enabled
  76336. */
  76337. get VLSEnabled(): boolean;
  76338. set VLSEnabled(enabled: boolean);
  76339. /**
  76340. * @ignore
  76341. * Specifies if the motion blur effect is enabled
  76342. */
  76343. get MotionBlurEnabled(): boolean;
  76344. set MotionBlurEnabled(enabled: boolean);
  76345. /**
  76346. * Specifies if anti-aliasing is enabled
  76347. */
  76348. get fxaaEnabled(): boolean;
  76349. set fxaaEnabled(enabled: boolean);
  76350. /**
  76351. * Specifies if screen space reflections are enabled.
  76352. */
  76353. get screenSpaceReflectionsEnabled(): boolean;
  76354. set screenSpaceReflectionsEnabled(enabled: boolean);
  76355. /**
  76356. * Specifies the number of steps used to calculate the volumetric lights
  76357. * Typically in interval [50, 200]
  76358. */
  76359. get volumetricLightStepsCount(): number;
  76360. set volumetricLightStepsCount(count: number);
  76361. /**
  76362. * Specifies the number of samples used for the motion blur effect
  76363. * Typically in interval [16, 64]
  76364. */
  76365. get motionBlurSamples(): number;
  76366. set motionBlurSamples(samples: number);
  76367. /**
  76368. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  76369. */
  76370. get samples(): number;
  76371. set samples(sampleCount: number);
  76372. /**
  76373. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  76374. * @constructor
  76375. * @param name The rendering pipeline name
  76376. * @param scene The scene linked to this pipeline
  76377. * @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)
  76378. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  76379. * @param cameras The array of cameras that the rendering pipeline will be attached to
  76380. */
  76381. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  76382. private _buildPipeline;
  76383. private _createDownSampleX4PostProcess;
  76384. private _createBrightPassPostProcess;
  76385. private _createBlurPostProcesses;
  76386. private _createTextureAdderPostProcess;
  76387. private _createVolumetricLightPostProcess;
  76388. private _createLuminancePostProcesses;
  76389. private _createHdrPostProcess;
  76390. private _createLensFlarePostProcess;
  76391. private _createDepthOfFieldPostProcess;
  76392. private _createMotionBlurPostProcess;
  76393. private _getDepthTexture;
  76394. private _disposePostProcesses;
  76395. /**
  76396. * Dispose of the pipeline and stop all post processes
  76397. */
  76398. dispose(): void;
  76399. /**
  76400. * Serialize the rendering pipeline (Used when exporting)
  76401. * @returns the serialized object
  76402. */
  76403. serialize(): any;
  76404. /**
  76405. * Parse the serialized pipeline
  76406. * @param source Source pipeline.
  76407. * @param scene The scene to load the pipeline to.
  76408. * @param rootUrl The URL of the serialized pipeline.
  76409. * @returns An instantiated pipeline from the serialized object.
  76410. */
  76411. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  76412. /**
  76413. * Luminance steps
  76414. */
  76415. static LuminanceSteps: number;
  76416. }
  76417. }
  76418. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  76419. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  76420. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  76421. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  76422. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  76423. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  76424. }
  76425. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  76426. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  76427. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  76428. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  76429. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  76430. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  76431. }
  76432. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  76433. /** @hidden */
  76434. export var stereoscopicInterlacePixelShader: {
  76435. name: string;
  76436. shader: string;
  76437. };
  76438. }
  76439. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  76440. import { Camera } from "babylonjs/Cameras/camera";
  76441. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76442. import { Engine } from "babylonjs/Engines/engine";
  76443. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  76444. /**
  76445. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  76446. */
  76447. export class StereoscopicInterlacePostProcessI extends PostProcess {
  76448. private _stepSize;
  76449. private _passedProcess;
  76450. /**
  76451. * Gets a string identifying the name of the class
  76452. * @returns "StereoscopicInterlacePostProcessI" string
  76453. */
  76454. getClassName(): string;
  76455. /**
  76456. * Initializes a StereoscopicInterlacePostProcessI
  76457. * @param name The name of the effect.
  76458. * @param rigCameras The rig cameras to be appled to the post process
  76459. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  76460. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  76461. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76462. * @param engine The engine which the post process will be applied. (default: current engine)
  76463. * @param reusable If the post process can be reused on the same frame. (default: false)
  76464. */
  76465. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76466. }
  76467. /**
  76468. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  76469. */
  76470. export class StereoscopicInterlacePostProcess extends PostProcess {
  76471. private _stepSize;
  76472. private _passedProcess;
  76473. /**
  76474. * Gets a string identifying the name of the class
  76475. * @returns "StereoscopicInterlacePostProcess" string
  76476. */
  76477. getClassName(): string;
  76478. /**
  76479. * Initializes a StereoscopicInterlacePostProcess
  76480. * @param name The name of the effect.
  76481. * @param rigCameras The rig cameras to be appled to the post process
  76482. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  76483. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76484. * @param engine The engine which the post process will be applied. (default: current engine)
  76485. * @param reusable If the post process can be reused on the same frame. (default: false)
  76486. */
  76487. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  76488. }
  76489. }
  76490. declare module "babylonjs/Shaders/tonemap.fragment" {
  76491. /** @hidden */
  76492. export var tonemapPixelShader: {
  76493. name: string;
  76494. shader: string;
  76495. };
  76496. }
  76497. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  76498. import { Camera } from "babylonjs/Cameras/camera";
  76499. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76500. import "babylonjs/Shaders/tonemap.fragment";
  76501. import { Engine } from "babylonjs/Engines/engine";
  76502. /** Defines operator used for tonemapping */
  76503. export enum TonemappingOperator {
  76504. /** Hable */
  76505. Hable = 0,
  76506. /** Reinhard */
  76507. Reinhard = 1,
  76508. /** HejiDawson */
  76509. HejiDawson = 2,
  76510. /** Photographic */
  76511. Photographic = 3
  76512. }
  76513. /**
  76514. * Defines a post process to apply tone mapping
  76515. */
  76516. export class TonemapPostProcess extends PostProcess {
  76517. private _operator;
  76518. /** Defines the required exposure adjustement */
  76519. exposureAdjustment: number;
  76520. /**
  76521. * Gets a string identifying the name of the class
  76522. * @returns "TonemapPostProcess" string
  76523. */
  76524. getClassName(): string;
  76525. /**
  76526. * Creates a new TonemapPostProcess
  76527. * @param name defines the name of the postprocess
  76528. * @param _operator defines the operator to use
  76529. * @param exposureAdjustment defines the required exposure adjustement
  76530. * @param camera defines the camera to use (can be null)
  76531. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  76532. * @param engine defines the hosting engine (can be ignore if camera is set)
  76533. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  76534. */
  76535. constructor(name: string, _operator: TonemappingOperator,
  76536. /** Defines the required exposure adjustement */
  76537. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  76538. }
  76539. }
  76540. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  76541. /** @hidden */
  76542. export var volumetricLightScatteringPixelShader: {
  76543. name: string;
  76544. shader: string;
  76545. };
  76546. }
  76547. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  76548. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76549. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76550. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76551. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76552. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76553. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76554. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76555. /** @hidden */
  76556. export var volumetricLightScatteringPassVertexShader: {
  76557. name: string;
  76558. shader: string;
  76559. };
  76560. }
  76561. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  76562. /** @hidden */
  76563. export var volumetricLightScatteringPassPixelShader: {
  76564. name: string;
  76565. shader: string;
  76566. };
  76567. }
  76568. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  76569. import { Vector3 } from "babylonjs/Maths/math.vector";
  76570. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76571. import { Mesh } from "babylonjs/Meshes/mesh";
  76572. import { Camera } from "babylonjs/Cameras/camera";
  76573. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  76574. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  76575. import { Scene } from "babylonjs/scene";
  76576. import "babylonjs/Meshes/Builders/planeBuilder";
  76577. import "babylonjs/Shaders/depth.vertex";
  76578. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  76579. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  76580. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  76581. import { Engine } from "babylonjs/Engines/engine";
  76582. /**
  76583. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  76584. */
  76585. export class VolumetricLightScatteringPostProcess extends PostProcess {
  76586. private _volumetricLightScatteringPass;
  76587. private _volumetricLightScatteringRTT;
  76588. private _viewPort;
  76589. private _screenCoordinates;
  76590. private _cachedDefines;
  76591. /**
  76592. * If not undefined, the mesh position is computed from the attached node position
  76593. */
  76594. attachedNode: {
  76595. position: Vector3;
  76596. };
  76597. /**
  76598. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  76599. */
  76600. customMeshPosition: Vector3;
  76601. /**
  76602. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  76603. */
  76604. useCustomMeshPosition: boolean;
  76605. /**
  76606. * If the post-process should inverse the light scattering direction
  76607. */
  76608. invert: boolean;
  76609. /**
  76610. * The internal mesh used by the post-process
  76611. */
  76612. mesh: Mesh;
  76613. /**
  76614. * @hidden
  76615. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  76616. */
  76617. get useDiffuseColor(): boolean;
  76618. set useDiffuseColor(useDiffuseColor: boolean);
  76619. /**
  76620. * Array containing the excluded meshes not rendered in the internal pass
  76621. */
  76622. excludedMeshes: AbstractMesh[];
  76623. /**
  76624. * Controls the overall intensity of the post-process
  76625. */
  76626. exposure: number;
  76627. /**
  76628. * Dissipates each sample's contribution in range [0, 1]
  76629. */
  76630. decay: number;
  76631. /**
  76632. * Controls the overall intensity of each sample
  76633. */
  76634. weight: number;
  76635. /**
  76636. * Controls the density of each sample
  76637. */
  76638. density: number;
  76639. /**
  76640. * @constructor
  76641. * @param name The post-process name
  76642. * @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)
  76643. * @param camera The camera that the post-process will be attached to
  76644. * @param mesh The mesh used to create the light scattering
  76645. * @param samples The post-process quality, default 100
  76646. * @param samplingModeThe post-process filtering mode
  76647. * @param engine The babylon engine
  76648. * @param reusable If the post-process is reusable
  76649. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76650. */
  76651. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76652. /**
  76653. * Returns the string "VolumetricLightScatteringPostProcess"
  76654. * @returns "VolumetricLightScatteringPostProcess"
  76655. */
  76656. getClassName(): string;
  76657. private _isReady;
  76658. /**
  76659. * Sets the new light position for light scattering effect
  76660. * @param position The new custom light position
  76661. */
  76662. setCustomMeshPosition(position: Vector3): void;
  76663. /**
  76664. * Returns the light position for light scattering effect
  76665. * @return Vector3 The custom light position
  76666. */
  76667. getCustomMeshPosition(): Vector3;
  76668. /**
  76669. * Disposes the internal assets and detaches the post-process from the camera
  76670. */
  76671. dispose(camera: Camera): void;
  76672. /**
  76673. * Returns the render target texture used by the post-process
  76674. * @return the render target texture used by the post-process
  76675. */
  76676. getPass(): RenderTargetTexture;
  76677. private _meshExcluded;
  76678. private _createPass;
  76679. private _updateMeshScreenCoordinates;
  76680. /**
  76681. * Creates a default mesh for the Volumeric Light Scattering post-process
  76682. * @param name The mesh name
  76683. * @param scene The scene where to create the mesh
  76684. * @return the default mesh
  76685. */
  76686. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76687. }
  76688. }
  76689. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76690. /** @hidden */
  76691. export var screenSpaceCurvaturePixelShader: {
  76692. name: string;
  76693. shader: string;
  76694. };
  76695. }
  76696. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76697. import { Nullable } from "babylonjs/types";
  76698. import { Camera } from "babylonjs/Cameras/camera";
  76699. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76700. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76701. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76702. import { Engine } from "babylonjs/Engines/engine";
  76703. import { Scene } from "babylonjs/scene";
  76704. /**
  76705. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76706. */
  76707. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76708. /**
  76709. * Defines how much ridge the curvature effect displays.
  76710. */
  76711. ridge: number;
  76712. /**
  76713. * Defines how much valley the curvature effect displays.
  76714. */
  76715. valley: number;
  76716. private _geometryBufferRenderer;
  76717. /**
  76718. * Gets a string identifying the name of the class
  76719. * @returns "ScreenSpaceCurvaturePostProcess" string
  76720. */
  76721. getClassName(): string;
  76722. /**
  76723. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76724. * @param name The name of the effect.
  76725. * @param scene The scene containing the objects to blur according to their velocity.
  76726. * @param options The required width/height ratio to downsize to before computing the render pass.
  76727. * @param camera The camera to apply the render pass to.
  76728. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76729. * @param engine The engine which the post process will be applied. (default: current engine)
  76730. * @param reusable If the post process can be reused on the same frame. (default: false)
  76731. * @param textureType Type of textures used when performing the post process. (default: 0)
  76732. * @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)
  76733. */
  76734. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76735. /**
  76736. * Support test.
  76737. */
  76738. static get IsSupported(): boolean;
  76739. /** @hidden */
  76740. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76741. }
  76742. }
  76743. declare module "babylonjs/PostProcesses/index" {
  76744. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76745. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76746. export * from "babylonjs/PostProcesses/bloomEffect";
  76747. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76748. export * from "babylonjs/PostProcesses/blurPostProcess";
  76749. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76750. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76751. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76752. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76753. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76754. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76755. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76756. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76757. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76758. export * from "babylonjs/PostProcesses/filterPostProcess";
  76759. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76760. export * from "babylonjs/PostProcesses/grainPostProcess";
  76761. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76762. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76763. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76764. export * from "babylonjs/PostProcesses/passPostProcess";
  76765. export * from "babylonjs/PostProcesses/postProcess";
  76766. export * from "babylonjs/PostProcesses/postProcessManager";
  76767. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76768. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76769. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76770. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76771. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76772. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76773. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76774. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76775. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76776. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76777. }
  76778. declare module "babylonjs/Probes/index" {
  76779. export * from "babylonjs/Probes/reflectionProbe";
  76780. }
  76781. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76782. import { Scene } from "babylonjs/scene";
  76783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76784. import { SmartArray } from "babylonjs/Misc/smartArray";
  76785. import { ISceneComponent } from "babylonjs/sceneComponent";
  76786. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76787. import "babylonjs/Meshes/Builders/boxBuilder";
  76788. import "babylonjs/Shaders/color.fragment";
  76789. import "babylonjs/Shaders/color.vertex";
  76790. import { Color3 } from "babylonjs/Maths/math.color";
  76791. import { Observable } from "babylonjs/Misc/observable";
  76792. module "babylonjs/scene" {
  76793. interface Scene {
  76794. /** @hidden (Backing field) */
  76795. _boundingBoxRenderer: BoundingBoxRenderer;
  76796. /** @hidden (Backing field) */
  76797. _forceShowBoundingBoxes: boolean;
  76798. /**
  76799. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76800. */
  76801. forceShowBoundingBoxes: boolean;
  76802. /**
  76803. * Gets the bounding box renderer associated with the scene
  76804. * @returns a BoundingBoxRenderer
  76805. */
  76806. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76807. }
  76808. }
  76809. module "babylonjs/Meshes/abstractMesh" {
  76810. interface AbstractMesh {
  76811. /** @hidden (Backing field) */
  76812. _showBoundingBox: boolean;
  76813. /**
  76814. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76815. */
  76816. showBoundingBox: boolean;
  76817. }
  76818. }
  76819. /**
  76820. * Component responsible of rendering the bounding box of the meshes in a scene.
  76821. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76822. */
  76823. export class BoundingBoxRenderer implements ISceneComponent {
  76824. /**
  76825. * The component name helpfull to identify the component in the list of scene components.
  76826. */
  76827. readonly name: string;
  76828. /**
  76829. * The scene the component belongs to.
  76830. */
  76831. scene: Scene;
  76832. /**
  76833. * Color of the bounding box lines placed in front of an object
  76834. */
  76835. frontColor: Color3;
  76836. /**
  76837. * Color of the bounding box lines placed behind an object
  76838. */
  76839. backColor: Color3;
  76840. /**
  76841. * Defines if the renderer should show the back lines or not
  76842. */
  76843. showBackLines: boolean;
  76844. /**
  76845. * Observable raised before rendering a bounding box
  76846. */
  76847. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76848. /**
  76849. * Observable raised after rendering a bounding box
  76850. */
  76851. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76852. /**
  76853. * When false, no bounding boxes will be rendered
  76854. */
  76855. enabled: boolean;
  76856. /**
  76857. * @hidden
  76858. */
  76859. renderList: SmartArray<BoundingBox>;
  76860. private _colorShader;
  76861. private _vertexBuffers;
  76862. private _indexBuffer;
  76863. private _fillIndexBuffer;
  76864. private _fillIndexData;
  76865. /**
  76866. * Instantiates a new bounding box renderer in a scene.
  76867. * @param scene the scene the renderer renders in
  76868. */
  76869. constructor(scene: Scene);
  76870. /**
  76871. * Registers the component in a given scene
  76872. */
  76873. register(): void;
  76874. private _evaluateSubMesh;
  76875. private _preActiveMesh;
  76876. private _prepareRessources;
  76877. private _createIndexBuffer;
  76878. /**
  76879. * Rebuilds the elements related to this component in case of
  76880. * context lost for instance.
  76881. */
  76882. rebuild(): void;
  76883. /**
  76884. * @hidden
  76885. */
  76886. reset(): void;
  76887. /**
  76888. * Render the bounding boxes of a specific rendering group
  76889. * @param renderingGroupId defines the rendering group to render
  76890. */
  76891. render(renderingGroupId: number): void;
  76892. /**
  76893. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76894. * @param mesh Define the mesh to render the occlusion bounding box for
  76895. */
  76896. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76897. /**
  76898. * Dispose and release the resources attached to this renderer.
  76899. */
  76900. dispose(): void;
  76901. }
  76902. }
  76903. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76904. import { Nullable } from "babylonjs/types";
  76905. import { Scene } from "babylonjs/scene";
  76906. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76907. import { Camera } from "babylonjs/Cameras/camera";
  76908. import { ISceneComponent } from "babylonjs/sceneComponent";
  76909. module "babylonjs/scene" {
  76910. interface Scene {
  76911. /** @hidden (Backing field) */
  76912. _depthRenderer: {
  76913. [id: string]: DepthRenderer;
  76914. };
  76915. /**
  76916. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76917. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76918. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76919. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76920. * @returns the created depth renderer
  76921. */
  76922. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76923. /**
  76924. * Disables a depth renderer for a given camera
  76925. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76926. */
  76927. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76928. }
  76929. }
  76930. /**
  76931. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76932. * in several rendering techniques.
  76933. */
  76934. export class DepthRendererSceneComponent implements ISceneComponent {
  76935. /**
  76936. * The component name helpfull to identify the component in the list of scene components.
  76937. */
  76938. readonly name: string;
  76939. /**
  76940. * The scene the component belongs to.
  76941. */
  76942. scene: Scene;
  76943. /**
  76944. * Creates a new instance of the component for the given scene
  76945. * @param scene Defines the scene to register the component in
  76946. */
  76947. constructor(scene: Scene);
  76948. /**
  76949. * Registers the component in a given scene
  76950. */
  76951. register(): void;
  76952. /**
  76953. * Rebuilds the elements related to this component in case of
  76954. * context lost for instance.
  76955. */
  76956. rebuild(): void;
  76957. /**
  76958. * Disposes the component and the associated ressources
  76959. */
  76960. dispose(): void;
  76961. private _gatherRenderTargets;
  76962. private _gatherActiveCameraRenderTargets;
  76963. }
  76964. }
  76965. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76966. import { Nullable } from "babylonjs/types";
  76967. import { Scene } from "babylonjs/scene";
  76968. import { ISceneComponent } from "babylonjs/sceneComponent";
  76969. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76970. module "babylonjs/abstractScene" {
  76971. interface AbstractScene {
  76972. /** @hidden (Backing field) */
  76973. _prePassRenderer: Nullable<PrePassRenderer>;
  76974. /**
  76975. * Gets or Sets the current prepass renderer associated to the scene.
  76976. */
  76977. prePassRenderer: Nullable<PrePassRenderer>;
  76978. /**
  76979. * Enables the prepass and associates it with the scene
  76980. * @returns the PrePassRenderer
  76981. */
  76982. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76983. /**
  76984. * Disables the prepass associated with the scene
  76985. */
  76986. disablePrePassRenderer(): void;
  76987. }
  76988. }
  76989. /**
  76990. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76991. * in several rendering techniques.
  76992. */
  76993. export class PrePassRendererSceneComponent implements ISceneComponent {
  76994. /**
  76995. * The component name helpful to identify the component in the list of scene components.
  76996. */
  76997. readonly name: string;
  76998. /**
  76999. * The scene the component belongs to.
  77000. */
  77001. scene: Scene;
  77002. /**
  77003. * Creates a new instance of the component for the given scene
  77004. * @param scene Defines the scene to register the component in
  77005. */
  77006. constructor(scene: Scene);
  77007. /**
  77008. * Registers the component in a given scene
  77009. */
  77010. register(): void;
  77011. private _beforeCameraDraw;
  77012. private _afterCameraDraw;
  77013. private _beforeClearStage;
  77014. /**
  77015. * Rebuilds the elements related to this component in case of
  77016. * context lost for instance.
  77017. */
  77018. rebuild(): void;
  77019. /**
  77020. * Disposes the component and the associated ressources
  77021. */
  77022. dispose(): void;
  77023. }
  77024. }
  77025. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  77026. /** @hidden */
  77027. export var fibonacci: {
  77028. name: string;
  77029. shader: string;
  77030. };
  77031. }
  77032. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  77033. /** @hidden */
  77034. export var diffusionProfile: {
  77035. name: string;
  77036. shader: string;
  77037. };
  77038. }
  77039. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  77040. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  77041. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  77042. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  77043. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  77044. /** @hidden */
  77045. export var subSurfaceScatteringPixelShader: {
  77046. name: string;
  77047. shader: string;
  77048. };
  77049. }
  77050. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  77051. import { Nullable } from "babylonjs/types";
  77052. import { Camera } from "babylonjs/Cameras/camera";
  77053. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  77054. import { Engine } from "babylonjs/Engines/engine";
  77055. import { Scene } from "babylonjs/scene";
  77056. import "babylonjs/Shaders/imageProcessing.fragment";
  77057. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  77058. import "babylonjs/Shaders/postprocess.vertex";
  77059. /**
  77060. * Sub surface scattering post process
  77061. */
  77062. export class SubSurfaceScatteringPostProcess extends PostProcess {
  77063. /**
  77064. * Gets a string identifying the name of the class
  77065. * @returns "SubSurfaceScatteringPostProcess" string
  77066. */
  77067. getClassName(): string;
  77068. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  77069. }
  77070. }
  77071. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  77072. import { Scene } from "babylonjs/scene";
  77073. import { Color3 } from "babylonjs/Maths/math.color";
  77074. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  77075. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  77076. /**
  77077. * Contains all parameters needed for the prepass to perform
  77078. * screen space subsurface scattering
  77079. */
  77080. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  77081. /** @hidden */
  77082. static _SceneComponentInitialization: (scene: Scene) => void;
  77083. private _ssDiffusionS;
  77084. private _ssFilterRadii;
  77085. private _ssDiffusionD;
  77086. /**
  77087. * Post process to attach for screen space subsurface scattering
  77088. */
  77089. postProcess: SubSurfaceScatteringPostProcess;
  77090. /**
  77091. * Diffusion profile color for subsurface scattering
  77092. */
  77093. get ssDiffusionS(): number[];
  77094. /**
  77095. * Diffusion profile max color channel value for subsurface scattering
  77096. */
  77097. get ssDiffusionD(): number[];
  77098. /**
  77099. * Diffusion profile filter radius for subsurface scattering
  77100. */
  77101. get ssFilterRadii(): number[];
  77102. /**
  77103. * Is subsurface enabled
  77104. */
  77105. enabled: boolean;
  77106. /**
  77107. * Name of the configuration
  77108. */
  77109. name: string;
  77110. /**
  77111. * Diffusion profile colors for subsurface scattering
  77112. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  77113. * See ...
  77114. * Note that you can only store up to 5 of them
  77115. */
  77116. ssDiffusionProfileColors: Color3[];
  77117. /**
  77118. * Defines the ratio real world => scene units.
  77119. * Used for subsurface scattering
  77120. */
  77121. metersPerUnit: number;
  77122. /**
  77123. * Textures that should be present in the MRT for this effect to work
  77124. */
  77125. readonly texturesRequired: number[];
  77126. private _scene;
  77127. /**
  77128. * Builds a subsurface configuration object
  77129. * @param scene The scene
  77130. */
  77131. constructor(scene: Scene);
  77132. /**
  77133. * Adds a new diffusion profile.
  77134. * Useful for more realistic subsurface scattering on diverse materials.
  77135. * @param color The color of the diffusion profile. Should be the average color of the material.
  77136. * @return The index of the diffusion profile for the material subsurface configuration
  77137. */
  77138. addDiffusionProfile(color: Color3): number;
  77139. /**
  77140. * Creates the sss post process
  77141. * @return The created post process
  77142. */
  77143. createPostProcess(): SubSurfaceScatteringPostProcess;
  77144. /**
  77145. * Deletes all diffusion profiles.
  77146. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  77147. */
  77148. clearAllDiffusionProfiles(): void;
  77149. /**
  77150. * Disposes this object
  77151. */
  77152. dispose(): void;
  77153. /**
  77154. * @hidden
  77155. * https://zero-radiance.github.io/post/sampling-diffusion/
  77156. *
  77157. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  77158. * ------------------------------------------------------------------------------------
  77159. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  77160. * PDF[r, phi, s] = r * R[r, phi, s]
  77161. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  77162. * ------------------------------------------------------------------------------------
  77163. * We importance sample the color channel with the widest scattering distance.
  77164. */
  77165. getDiffusionProfileParameters(color: Color3): number;
  77166. /**
  77167. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  77168. * 'u' is the random number (the value of the CDF): [0, 1).
  77169. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  77170. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  77171. */
  77172. private _sampleBurleyDiffusionProfile;
  77173. }
  77174. }
  77175. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  77176. import { Nullable } from "babylonjs/types";
  77177. import { Scene } from "babylonjs/scene";
  77178. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  77179. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  77180. import { AbstractScene } from "babylonjs/abstractScene";
  77181. module "babylonjs/abstractScene" {
  77182. interface AbstractScene {
  77183. /** @hidden (Backing field) */
  77184. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77185. /**
  77186. * Gets or Sets the current prepass renderer associated to the scene.
  77187. */
  77188. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  77189. /**
  77190. * Enables the subsurface effect for prepass
  77191. * @returns the SubSurfaceConfiguration
  77192. */
  77193. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  77194. /**
  77195. * Disables the subsurface effect for prepass
  77196. */
  77197. disableSubSurfaceForPrePass(): void;
  77198. }
  77199. }
  77200. /**
  77201. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  77202. * in several rendering techniques.
  77203. */
  77204. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  77205. /**
  77206. * The component name helpful to identify the component in the list of scene components.
  77207. */
  77208. readonly name: string;
  77209. /**
  77210. * The scene the component belongs to.
  77211. */
  77212. scene: Scene;
  77213. /**
  77214. * Creates a new instance of the component for the given scene
  77215. * @param scene Defines the scene to register the component in
  77216. */
  77217. constructor(scene: Scene);
  77218. /**
  77219. * Registers the component in a given scene
  77220. */
  77221. register(): void;
  77222. /**
  77223. * Serializes the component data to the specified json object
  77224. * @param serializationObject The object to serialize to
  77225. */
  77226. serialize(serializationObject: any): void;
  77227. /**
  77228. * Adds all the elements from the container to the scene
  77229. * @param container the container holding the elements
  77230. */
  77231. addFromContainer(container: AbstractScene): void;
  77232. /**
  77233. * Removes all the elements in the container from the scene
  77234. * @param container contains the elements to remove
  77235. * @param dispose if the removed element should be disposed (default: false)
  77236. */
  77237. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77238. /**
  77239. * Rebuilds the elements related to this component in case of
  77240. * context lost for instance.
  77241. */
  77242. rebuild(): void;
  77243. /**
  77244. * Disposes the component and the associated ressources
  77245. */
  77246. dispose(): void;
  77247. }
  77248. }
  77249. declare module "babylonjs/Shaders/outline.fragment" {
  77250. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77251. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  77252. /** @hidden */
  77253. export var outlinePixelShader: {
  77254. name: string;
  77255. shader: string;
  77256. };
  77257. }
  77258. declare module "babylonjs/Shaders/outline.vertex" {
  77259. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  77260. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  77261. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  77262. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  77263. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  77264. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  77265. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  77266. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  77267. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  77268. /** @hidden */
  77269. export var outlineVertexShader: {
  77270. name: string;
  77271. shader: string;
  77272. };
  77273. }
  77274. declare module "babylonjs/Rendering/outlineRenderer" {
  77275. import { SubMesh } from "babylonjs/Meshes/subMesh";
  77276. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  77277. import { Scene } from "babylonjs/scene";
  77278. import { ISceneComponent } from "babylonjs/sceneComponent";
  77279. import "babylonjs/Shaders/outline.fragment";
  77280. import "babylonjs/Shaders/outline.vertex";
  77281. module "babylonjs/scene" {
  77282. interface Scene {
  77283. /** @hidden */
  77284. _outlineRenderer: OutlineRenderer;
  77285. /**
  77286. * Gets the outline renderer associated with the scene
  77287. * @returns a OutlineRenderer
  77288. */
  77289. getOutlineRenderer(): OutlineRenderer;
  77290. }
  77291. }
  77292. module "babylonjs/Meshes/abstractMesh" {
  77293. interface AbstractMesh {
  77294. /** @hidden (Backing field) */
  77295. _renderOutline: boolean;
  77296. /**
  77297. * Gets or sets a boolean indicating if the outline must be rendered as well
  77298. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  77299. */
  77300. renderOutline: boolean;
  77301. /** @hidden (Backing field) */
  77302. _renderOverlay: boolean;
  77303. /**
  77304. * Gets or sets a boolean indicating if the overlay must be rendered as well
  77305. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  77306. */
  77307. renderOverlay: boolean;
  77308. }
  77309. }
  77310. /**
  77311. * This class is responsible to draw bothe outline/overlay of meshes.
  77312. * It should not be used directly but through the available method on mesh.
  77313. */
  77314. export class OutlineRenderer implements ISceneComponent {
  77315. /**
  77316. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  77317. */
  77318. private static _StencilReference;
  77319. /**
  77320. * The name of the component. Each component must have a unique name.
  77321. */
  77322. name: string;
  77323. /**
  77324. * The scene the component belongs to.
  77325. */
  77326. scene: Scene;
  77327. /**
  77328. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  77329. */
  77330. zOffset: number;
  77331. private _engine;
  77332. private _effect;
  77333. private _cachedDefines;
  77334. private _savedDepthWrite;
  77335. /**
  77336. * Instantiates a new outline renderer. (There could be only one per scene).
  77337. * @param scene Defines the scene it belongs to
  77338. */
  77339. constructor(scene: Scene);
  77340. /**
  77341. * Register the component to one instance of a scene.
  77342. */
  77343. register(): void;
  77344. /**
  77345. * Rebuilds the elements related to this component in case of
  77346. * context lost for instance.
  77347. */
  77348. rebuild(): void;
  77349. /**
  77350. * Disposes the component and the associated ressources.
  77351. */
  77352. dispose(): void;
  77353. /**
  77354. * Renders the outline in the canvas.
  77355. * @param subMesh Defines the sumesh to render
  77356. * @param batch Defines the batch of meshes in case of instances
  77357. * @param useOverlay Defines if the rendering is for the overlay or the outline
  77358. */
  77359. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  77360. /**
  77361. * Returns whether or not the outline renderer is ready for a given submesh.
  77362. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  77363. * @param subMesh Defines the submesh to check readyness for
  77364. * @param useInstances Defines wheter wee are trying to render instances or not
  77365. * @returns true if ready otherwise false
  77366. */
  77367. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  77368. private _beforeRenderingMesh;
  77369. private _afterRenderingMesh;
  77370. }
  77371. }
  77372. declare module "babylonjs/Rendering/index" {
  77373. export * from "babylonjs/Rendering/boundingBoxRenderer";
  77374. export * from "babylonjs/Rendering/depthRenderer";
  77375. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  77376. export * from "babylonjs/Rendering/edgesRenderer";
  77377. export * from "babylonjs/Rendering/geometryBufferRenderer";
  77378. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  77379. export * from "babylonjs/Rendering/prePassRenderer";
  77380. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  77381. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  77382. export * from "babylonjs/Rendering/outlineRenderer";
  77383. export * from "babylonjs/Rendering/renderingGroup";
  77384. export * from "babylonjs/Rendering/renderingManager";
  77385. export * from "babylonjs/Rendering/utilityLayerRenderer";
  77386. }
  77387. declare module "babylonjs/Sprites/ISprites" {
  77388. /**
  77389. * Defines the basic options interface of a Sprite Frame Source Size.
  77390. */
  77391. export interface ISpriteJSONSpriteSourceSize {
  77392. /**
  77393. * number of the original width of the Frame
  77394. */
  77395. w: number;
  77396. /**
  77397. * number of the original height of the Frame
  77398. */
  77399. h: number;
  77400. }
  77401. /**
  77402. * Defines the basic options interface of a Sprite Frame Data.
  77403. */
  77404. export interface ISpriteJSONSpriteFrameData {
  77405. /**
  77406. * number of the x offset of the Frame
  77407. */
  77408. x: number;
  77409. /**
  77410. * number of the y offset of the Frame
  77411. */
  77412. y: number;
  77413. /**
  77414. * number of the width of the Frame
  77415. */
  77416. w: number;
  77417. /**
  77418. * number of the height of the Frame
  77419. */
  77420. h: number;
  77421. }
  77422. /**
  77423. * Defines the basic options interface of a JSON Sprite.
  77424. */
  77425. export interface ISpriteJSONSprite {
  77426. /**
  77427. * string name of the Frame
  77428. */
  77429. filename: string;
  77430. /**
  77431. * ISpriteJSONSpriteFrame basic object of the frame data
  77432. */
  77433. frame: ISpriteJSONSpriteFrameData;
  77434. /**
  77435. * boolean to flag is the frame was rotated.
  77436. */
  77437. rotated: boolean;
  77438. /**
  77439. * boolean to flag is the frame was trimmed.
  77440. */
  77441. trimmed: boolean;
  77442. /**
  77443. * ISpriteJSONSpriteFrame basic object of the source data
  77444. */
  77445. spriteSourceSize: ISpriteJSONSpriteFrameData;
  77446. /**
  77447. * ISpriteJSONSpriteFrame basic object of the source data
  77448. */
  77449. sourceSize: ISpriteJSONSpriteSourceSize;
  77450. }
  77451. /**
  77452. * Defines the basic options interface of a JSON atlas.
  77453. */
  77454. export interface ISpriteJSONAtlas {
  77455. /**
  77456. * Array of objects that contain the frame data.
  77457. */
  77458. frames: Array<ISpriteJSONSprite>;
  77459. /**
  77460. * object basic object containing the sprite meta data.
  77461. */
  77462. meta?: object;
  77463. }
  77464. }
  77465. declare module "babylonjs/Shaders/spriteMap.fragment" {
  77466. /** @hidden */
  77467. export var spriteMapPixelShader: {
  77468. name: string;
  77469. shader: string;
  77470. };
  77471. }
  77472. declare module "babylonjs/Shaders/spriteMap.vertex" {
  77473. /** @hidden */
  77474. export var spriteMapVertexShader: {
  77475. name: string;
  77476. shader: string;
  77477. };
  77478. }
  77479. declare module "babylonjs/Sprites/spriteMap" {
  77480. import { IDisposable, Scene } from "babylonjs/scene";
  77481. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  77482. import { Texture } from "babylonjs/Materials/Textures/texture";
  77483. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  77484. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  77485. import "babylonjs/Meshes/Builders/planeBuilder";
  77486. import "babylonjs/Shaders/spriteMap.fragment";
  77487. import "babylonjs/Shaders/spriteMap.vertex";
  77488. /**
  77489. * Defines the basic options interface of a SpriteMap
  77490. */
  77491. export interface ISpriteMapOptions {
  77492. /**
  77493. * Vector2 of the number of cells in the grid.
  77494. */
  77495. stageSize?: Vector2;
  77496. /**
  77497. * Vector2 of the size of the output plane in World Units.
  77498. */
  77499. outputSize?: Vector2;
  77500. /**
  77501. * Vector3 of the position of the output plane in World Units.
  77502. */
  77503. outputPosition?: Vector3;
  77504. /**
  77505. * Vector3 of the rotation of the output plane.
  77506. */
  77507. outputRotation?: Vector3;
  77508. /**
  77509. * number of layers that the system will reserve in resources.
  77510. */
  77511. layerCount?: number;
  77512. /**
  77513. * number of max animation frames a single cell will reserve in resources.
  77514. */
  77515. maxAnimationFrames?: number;
  77516. /**
  77517. * number cell index of the base tile when the system compiles.
  77518. */
  77519. baseTile?: number;
  77520. /**
  77521. * boolean flip the sprite after its been repositioned by the framing data.
  77522. */
  77523. flipU?: boolean;
  77524. /**
  77525. * Vector3 scalar of the global RGB values of the SpriteMap.
  77526. */
  77527. colorMultiply?: Vector3;
  77528. }
  77529. /**
  77530. * Defines the IDisposable interface in order to be cleanable from resources.
  77531. */
  77532. export interface ISpriteMap extends IDisposable {
  77533. /**
  77534. * String name of the SpriteMap.
  77535. */
  77536. name: string;
  77537. /**
  77538. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  77539. */
  77540. atlasJSON: ISpriteJSONAtlas;
  77541. /**
  77542. * Texture of the SpriteMap.
  77543. */
  77544. spriteSheet: Texture;
  77545. /**
  77546. * The parameters to initialize the SpriteMap with.
  77547. */
  77548. options: ISpriteMapOptions;
  77549. }
  77550. /**
  77551. * Class used to manage a grid restricted sprite deployment on an Output plane.
  77552. */
  77553. export class SpriteMap implements ISpriteMap {
  77554. /** The Name of the spriteMap */
  77555. name: string;
  77556. /** The JSON file with the frame and meta data */
  77557. atlasJSON: ISpriteJSONAtlas;
  77558. /** The systems Sprite Sheet Texture */
  77559. spriteSheet: Texture;
  77560. /** Arguments passed with the Constructor */
  77561. options: ISpriteMapOptions;
  77562. /** Public Sprite Storage array, parsed from atlasJSON */
  77563. sprites: Array<ISpriteJSONSprite>;
  77564. /** Returns the Number of Sprites in the System */
  77565. get spriteCount(): number;
  77566. /** Returns the Position of Output Plane*/
  77567. get position(): Vector3;
  77568. /** Returns the Position of Output Plane*/
  77569. set position(v: Vector3);
  77570. /** Returns the Rotation of Output Plane*/
  77571. get rotation(): Vector3;
  77572. /** Returns the Rotation of Output Plane*/
  77573. set rotation(v: Vector3);
  77574. /** Sets the AnimationMap*/
  77575. get animationMap(): RawTexture;
  77576. /** Sets the AnimationMap*/
  77577. set animationMap(v: RawTexture);
  77578. /** Scene that the SpriteMap was created in */
  77579. private _scene;
  77580. /** Texture Buffer of Float32 that holds tile frame data*/
  77581. private _frameMap;
  77582. /** Texture Buffers of Float32 that holds tileMap data*/
  77583. private _tileMaps;
  77584. /** Texture Buffer of Float32 that holds Animation Data*/
  77585. private _animationMap;
  77586. /** Custom ShaderMaterial Central to the System*/
  77587. private _material;
  77588. /** Custom ShaderMaterial Central to the System*/
  77589. private _output;
  77590. /** Systems Time Ticker*/
  77591. private _time;
  77592. /**
  77593. * Creates a new SpriteMap
  77594. * @param name defines the SpriteMaps Name
  77595. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  77596. * @param spriteSheet is the Texture that the Sprites are on.
  77597. * @param options a basic deployment configuration
  77598. * @param scene The Scene that the map is deployed on
  77599. */
  77600. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  77601. /**
  77602. * Returns tileID location
  77603. * @returns Vector2 the cell position ID
  77604. */
  77605. getTileID(): Vector2;
  77606. /**
  77607. * Gets the UV location of the mouse over the SpriteMap.
  77608. * @returns Vector2 the UV position of the mouse interaction
  77609. */
  77610. getMousePosition(): Vector2;
  77611. /**
  77612. * Creates the "frame" texture Buffer
  77613. * -------------------------------------
  77614. * Structure of frames
  77615. * "filename": "Falling-Water-2.png",
  77616. * "frame": {"x":69,"y":103,"w":24,"h":32},
  77617. * "rotated": true,
  77618. * "trimmed": true,
  77619. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  77620. * "sourceSize": {"w":32,"h":32}
  77621. * @returns RawTexture of the frameMap
  77622. */
  77623. private _createFrameBuffer;
  77624. /**
  77625. * Creates the tileMap texture Buffer
  77626. * @param buffer normally and array of numbers, or a false to generate from scratch
  77627. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  77628. * @returns RawTexture of the tileMap
  77629. */
  77630. private _createTileBuffer;
  77631. /**
  77632. * Modifies the data of the tileMaps
  77633. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  77634. * @param pos is the iVector2 Coordinates of the Tile
  77635. * @param tile The SpriteIndex of the new Tile
  77636. */
  77637. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  77638. /**
  77639. * Creates the animationMap texture Buffer
  77640. * @param buffer normally and array of numbers, or a false to generate from scratch
  77641. * @returns RawTexture of the animationMap
  77642. */
  77643. private _createTileAnimationBuffer;
  77644. /**
  77645. * Modifies the data of the animationMap
  77646. * @param cellID is the Index of the Sprite
  77647. * @param _frame is the target Animation frame
  77648. * @param toCell is the Target Index of the next frame of the animation
  77649. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  77650. * @param speed is a global scalar of the time variable on the map.
  77651. */
  77652. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77653. /**
  77654. * Exports the .tilemaps file
  77655. */
  77656. saveTileMaps(): void;
  77657. /**
  77658. * Imports the .tilemaps file
  77659. * @param url of the .tilemaps file
  77660. */
  77661. loadTileMaps(url: string): void;
  77662. /**
  77663. * Release associated resources
  77664. */
  77665. dispose(): void;
  77666. }
  77667. }
  77668. declare module "babylonjs/Sprites/spritePackedManager" {
  77669. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77670. import { Scene } from "babylonjs/scene";
  77671. /**
  77672. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77673. * @see https://doc.babylonjs.com/babylon101/sprites
  77674. */
  77675. export class SpritePackedManager extends SpriteManager {
  77676. /** defines the packed manager's name */
  77677. name: string;
  77678. /**
  77679. * Creates a new sprite manager from a packed sprite sheet
  77680. * @param name defines the manager's name
  77681. * @param imgUrl defines the sprite sheet url
  77682. * @param capacity defines the maximum allowed number of sprites
  77683. * @param scene defines the hosting scene
  77684. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77685. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77686. * @param samplingMode defines the smapling mode to use with spritesheet
  77687. * @param fromPacked set to true; do not alter
  77688. */
  77689. constructor(
  77690. /** defines the packed manager's name */
  77691. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77692. }
  77693. }
  77694. declare module "babylonjs/Sprites/index" {
  77695. export * from "babylonjs/Sprites/sprite";
  77696. export * from "babylonjs/Sprites/ISprites";
  77697. export * from "babylonjs/Sprites/spriteManager";
  77698. export * from "babylonjs/Sprites/spriteMap";
  77699. export * from "babylonjs/Sprites/spritePackedManager";
  77700. export * from "babylonjs/Sprites/spriteSceneComponent";
  77701. }
  77702. declare module "babylonjs/States/index" {
  77703. export * from "babylonjs/States/alphaCullingState";
  77704. export * from "babylonjs/States/depthCullingState";
  77705. export * from "babylonjs/States/stencilState";
  77706. }
  77707. declare module "babylonjs/Misc/assetsManager" {
  77708. import { Scene } from "babylonjs/scene";
  77709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77710. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77711. import { Skeleton } from "babylonjs/Bones/skeleton";
  77712. import { Observable } from "babylonjs/Misc/observable";
  77713. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77714. import { Texture } from "babylonjs/Materials/Textures/texture";
  77715. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77716. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77717. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77718. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77719. import { AssetContainer } from "babylonjs/assetContainer";
  77720. /**
  77721. * Defines the list of states available for a task inside a AssetsManager
  77722. */
  77723. export enum AssetTaskState {
  77724. /**
  77725. * Initialization
  77726. */
  77727. INIT = 0,
  77728. /**
  77729. * Running
  77730. */
  77731. RUNNING = 1,
  77732. /**
  77733. * Done
  77734. */
  77735. DONE = 2,
  77736. /**
  77737. * Error
  77738. */
  77739. ERROR = 3
  77740. }
  77741. /**
  77742. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77743. */
  77744. export abstract class AbstractAssetTask {
  77745. /**
  77746. * Task name
  77747. */ name: string;
  77748. /**
  77749. * Callback called when the task is successful
  77750. */
  77751. onSuccess: (task: any) => void;
  77752. /**
  77753. * Callback called when the task is not successful
  77754. */
  77755. onError: (task: any, message?: string, exception?: any) => void;
  77756. /**
  77757. * Creates a new AssetsManager
  77758. * @param name defines the name of the task
  77759. */
  77760. constructor(
  77761. /**
  77762. * Task name
  77763. */ name: string);
  77764. private _isCompleted;
  77765. private _taskState;
  77766. private _errorObject;
  77767. /**
  77768. * Get if the task is completed
  77769. */
  77770. get isCompleted(): boolean;
  77771. /**
  77772. * Gets the current state of the task
  77773. */
  77774. get taskState(): AssetTaskState;
  77775. /**
  77776. * Gets the current error object (if task is in error)
  77777. */
  77778. get errorObject(): {
  77779. message?: string;
  77780. exception?: any;
  77781. };
  77782. /**
  77783. * Internal only
  77784. * @hidden
  77785. */
  77786. _setErrorObject(message?: string, exception?: any): void;
  77787. /**
  77788. * Execute the current task
  77789. * @param scene defines the scene where you want your assets to be loaded
  77790. * @param onSuccess is a callback called when the task is successfully executed
  77791. * @param onError is a callback called if an error occurs
  77792. */
  77793. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77794. /**
  77795. * Execute the current task
  77796. * @param scene defines the scene where you want your assets to be loaded
  77797. * @param onSuccess is a callback called when the task is successfully executed
  77798. * @param onError is a callback called if an error occurs
  77799. */
  77800. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77801. /**
  77802. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77803. * This can be used with failed tasks that have the reason for failure fixed.
  77804. */
  77805. reset(): void;
  77806. private onErrorCallback;
  77807. private onDoneCallback;
  77808. }
  77809. /**
  77810. * Define the interface used by progress events raised during assets loading
  77811. */
  77812. export interface IAssetsProgressEvent {
  77813. /**
  77814. * Defines the number of remaining tasks to process
  77815. */
  77816. remainingCount: number;
  77817. /**
  77818. * Defines the total number of tasks
  77819. */
  77820. totalCount: number;
  77821. /**
  77822. * Defines the task that was just processed
  77823. */
  77824. task: AbstractAssetTask;
  77825. }
  77826. /**
  77827. * Class used to share progress information about assets loading
  77828. */
  77829. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77830. /**
  77831. * Defines the number of remaining tasks to process
  77832. */
  77833. remainingCount: number;
  77834. /**
  77835. * Defines the total number of tasks
  77836. */
  77837. totalCount: number;
  77838. /**
  77839. * Defines the task that was just processed
  77840. */
  77841. task: AbstractAssetTask;
  77842. /**
  77843. * Creates a AssetsProgressEvent
  77844. * @param remainingCount defines the number of remaining tasks to process
  77845. * @param totalCount defines the total number of tasks
  77846. * @param task defines the task that was just processed
  77847. */
  77848. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77849. }
  77850. /**
  77851. * Define a task used by AssetsManager to load assets into a container
  77852. */
  77853. export class ContainerAssetTask extends AbstractAssetTask {
  77854. /**
  77855. * Defines the name of the task
  77856. */
  77857. name: string;
  77858. /**
  77859. * Defines the list of mesh's names you want to load
  77860. */
  77861. meshesNames: any;
  77862. /**
  77863. * Defines the root url to use as a base to load your meshes and associated resources
  77864. */
  77865. rootUrl: string;
  77866. /**
  77867. * Defines the filename or File of the scene to load from
  77868. */
  77869. sceneFilename: string | File;
  77870. /**
  77871. * Get the loaded asset container
  77872. */
  77873. loadedContainer: AssetContainer;
  77874. /**
  77875. * Gets the list of loaded meshes
  77876. */
  77877. loadedMeshes: Array<AbstractMesh>;
  77878. /**
  77879. * Gets the list of loaded particle systems
  77880. */
  77881. loadedParticleSystems: Array<IParticleSystem>;
  77882. /**
  77883. * Gets the list of loaded skeletons
  77884. */
  77885. loadedSkeletons: Array<Skeleton>;
  77886. /**
  77887. * Gets the list of loaded animation groups
  77888. */
  77889. loadedAnimationGroups: Array<AnimationGroup>;
  77890. /**
  77891. * Callback called when the task is successful
  77892. */
  77893. onSuccess: (task: ContainerAssetTask) => void;
  77894. /**
  77895. * Callback called when the task is successful
  77896. */
  77897. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77898. /**
  77899. * Creates a new ContainerAssetTask
  77900. * @param name defines the name of the task
  77901. * @param meshesNames defines the list of mesh's names you want to load
  77902. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77903. * @param sceneFilename defines the filename or File of the scene to load from
  77904. */
  77905. constructor(
  77906. /**
  77907. * Defines the name of the task
  77908. */
  77909. name: string,
  77910. /**
  77911. * Defines the list of mesh's names you want to load
  77912. */
  77913. meshesNames: any,
  77914. /**
  77915. * Defines the root url to use as a base to load your meshes and associated resources
  77916. */
  77917. rootUrl: string,
  77918. /**
  77919. * Defines the filename or File of the scene to load from
  77920. */
  77921. sceneFilename: string | File);
  77922. /**
  77923. * Execute the current task
  77924. * @param scene defines the scene where you want your assets to be loaded
  77925. * @param onSuccess is a callback called when the task is successfully executed
  77926. * @param onError is a callback called if an error occurs
  77927. */
  77928. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77929. }
  77930. /**
  77931. * Define a task used by AssetsManager to load meshes
  77932. */
  77933. export class MeshAssetTask extends AbstractAssetTask {
  77934. /**
  77935. * Defines the name of the task
  77936. */
  77937. name: string;
  77938. /**
  77939. * Defines the list of mesh's names you want to load
  77940. */
  77941. meshesNames: any;
  77942. /**
  77943. * Defines the root url to use as a base to load your meshes and associated resources
  77944. */
  77945. rootUrl: string;
  77946. /**
  77947. * Defines the filename or File of the scene to load from
  77948. */
  77949. sceneFilename: string | File;
  77950. /**
  77951. * Gets the list of loaded meshes
  77952. */
  77953. loadedMeshes: Array<AbstractMesh>;
  77954. /**
  77955. * Gets the list of loaded particle systems
  77956. */
  77957. loadedParticleSystems: Array<IParticleSystem>;
  77958. /**
  77959. * Gets the list of loaded skeletons
  77960. */
  77961. loadedSkeletons: Array<Skeleton>;
  77962. /**
  77963. * Gets the list of loaded animation groups
  77964. */
  77965. loadedAnimationGroups: Array<AnimationGroup>;
  77966. /**
  77967. * Callback called when the task is successful
  77968. */
  77969. onSuccess: (task: MeshAssetTask) => void;
  77970. /**
  77971. * Callback called when the task is successful
  77972. */
  77973. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77974. /**
  77975. * Creates a new MeshAssetTask
  77976. * @param name defines the name of the task
  77977. * @param meshesNames defines the list of mesh's names you want to load
  77978. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77979. * @param sceneFilename defines the filename or File of the scene to load from
  77980. */
  77981. constructor(
  77982. /**
  77983. * Defines the name of the task
  77984. */
  77985. name: string,
  77986. /**
  77987. * Defines the list of mesh's names you want to load
  77988. */
  77989. meshesNames: any,
  77990. /**
  77991. * Defines the root url to use as a base to load your meshes and associated resources
  77992. */
  77993. rootUrl: string,
  77994. /**
  77995. * Defines the filename or File of the scene to load from
  77996. */
  77997. sceneFilename: string | File);
  77998. /**
  77999. * Execute the current task
  78000. * @param scene defines the scene where you want your assets to be loaded
  78001. * @param onSuccess is a callback called when the task is successfully executed
  78002. * @param onError is a callback called if an error occurs
  78003. */
  78004. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78005. }
  78006. /**
  78007. * Define a task used by AssetsManager to load text content
  78008. */
  78009. export class TextFileAssetTask extends AbstractAssetTask {
  78010. /**
  78011. * Defines the name of the task
  78012. */
  78013. name: string;
  78014. /**
  78015. * Defines the location of the file to load
  78016. */
  78017. url: string;
  78018. /**
  78019. * Gets the loaded text string
  78020. */
  78021. text: string;
  78022. /**
  78023. * Callback called when the task is successful
  78024. */
  78025. onSuccess: (task: TextFileAssetTask) => void;
  78026. /**
  78027. * Callback called when the task is successful
  78028. */
  78029. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  78030. /**
  78031. * Creates a new TextFileAssetTask object
  78032. * @param name defines the name of the task
  78033. * @param url defines the location of the file to load
  78034. */
  78035. constructor(
  78036. /**
  78037. * Defines the name of the task
  78038. */
  78039. name: string,
  78040. /**
  78041. * Defines the location of the file to load
  78042. */
  78043. url: string);
  78044. /**
  78045. * Execute the current task
  78046. * @param scene defines the scene where you want your assets to be loaded
  78047. * @param onSuccess is a callback called when the task is successfully executed
  78048. * @param onError is a callback called if an error occurs
  78049. */
  78050. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78051. }
  78052. /**
  78053. * Define a task used by AssetsManager to load binary data
  78054. */
  78055. export class BinaryFileAssetTask extends AbstractAssetTask {
  78056. /**
  78057. * Defines the name of the task
  78058. */
  78059. name: string;
  78060. /**
  78061. * Defines the location of the file to load
  78062. */
  78063. url: string;
  78064. /**
  78065. * Gets the lodaded data (as an array buffer)
  78066. */
  78067. data: ArrayBuffer;
  78068. /**
  78069. * Callback called when the task is successful
  78070. */
  78071. onSuccess: (task: BinaryFileAssetTask) => void;
  78072. /**
  78073. * Callback called when the task is successful
  78074. */
  78075. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  78076. /**
  78077. * Creates a new BinaryFileAssetTask object
  78078. * @param name defines the name of the new task
  78079. * @param url defines the location of the file to load
  78080. */
  78081. constructor(
  78082. /**
  78083. * Defines the name of the task
  78084. */
  78085. name: string,
  78086. /**
  78087. * Defines the location of the file to load
  78088. */
  78089. url: string);
  78090. /**
  78091. * Execute the current task
  78092. * @param scene defines the scene where you want your assets to be loaded
  78093. * @param onSuccess is a callback called when the task is successfully executed
  78094. * @param onError is a callback called if an error occurs
  78095. */
  78096. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78097. }
  78098. /**
  78099. * Define a task used by AssetsManager to load images
  78100. */
  78101. export class ImageAssetTask extends AbstractAssetTask {
  78102. /**
  78103. * Defines the name of the task
  78104. */
  78105. name: string;
  78106. /**
  78107. * Defines the location of the image to load
  78108. */
  78109. url: string;
  78110. /**
  78111. * Gets the loaded images
  78112. */
  78113. image: HTMLImageElement;
  78114. /**
  78115. * Callback called when the task is successful
  78116. */
  78117. onSuccess: (task: ImageAssetTask) => void;
  78118. /**
  78119. * Callback called when the task is successful
  78120. */
  78121. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  78122. /**
  78123. * Creates a new ImageAssetTask
  78124. * @param name defines the name of the task
  78125. * @param url defines the location of the image to load
  78126. */
  78127. constructor(
  78128. /**
  78129. * Defines the name of the task
  78130. */
  78131. name: string,
  78132. /**
  78133. * Defines the location of the image to load
  78134. */
  78135. url: string);
  78136. /**
  78137. * Execute the current task
  78138. * @param scene defines the scene where you want your assets to be loaded
  78139. * @param onSuccess is a callback called when the task is successfully executed
  78140. * @param onError is a callback called if an error occurs
  78141. */
  78142. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78143. }
  78144. /**
  78145. * Defines the interface used by texture loading tasks
  78146. */
  78147. export interface ITextureAssetTask<TEX extends BaseTexture> {
  78148. /**
  78149. * Gets the loaded texture
  78150. */
  78151. texture: TEX;
  78152. }
  78153. /**
  78154. * Define a task used by AssetsManager to load 2D textures
  78155. */
  78156. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  78157. /**
  78158. * Defines the name of the task
  78159. */
  78160. name: string;
  78161. /**
  78162. * Defines the location of the file to load
  78163. */
  78164. url: string;
  78165. /**
  78166. * Defines if mipmap should not be generated (default is false)
  78167. */
  78168. noMipmap?: boolean | undefined;
  78169. /**
  78170. * Defines if texture must be inverted on Y axis (default is true)
  78171. */
  78172. invertY: boolean;
  78173. /**
  78174. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78175. */
  78176. samplingMode: number;
  78177. /**
  78178. * Gets the loaded texture
  78179. */
  78180. texture: Texture;
  78181. /**
  78182. * Callback called when the task is successful
  78183. */
  78184. onSuccess: (task: TextureAssetTask) => void;
  78185. /**
  78186. * Callback called when the task is successful
  78187. */
  78188. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  78189. /**
  78190. * Creates a new TextureAssetTask object
  78191. * @param name defines the name of the task
  78192. * @param url defines the location of the file to load
  78193. * @param noMipmap defines if mipmap should not be generated (default is false)
  78194. * @param invertY defines if texture must be inverted on Y axis (default is true)
  78195. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78196. */
  78197. constructor(
  78198. /**
  78199. * Defines the name of the task
  78200. */
  78201. name: string,
  78202. /**
  78203. * Defines the location of the file to load
  78204. */
  78205. url: string,
  78206. /**
  78207. * Defines if mipmap should not be generated (default is false)
  78208. */
  78209. noMipmap?: boolean | undefined,
  78210. /**
  78211. * Defines if texture must be inverted on Y axis (default is true)
  78212. */
  78213. invertY?: boolean,
  78214. /**
  78215. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  78216. */
  78217. samplingMode?: number);
  78218. /**
  78219. * Execute the current task
  78220. * @param scene defines the scene where you want your assets to be loaded
  78221. * @param onSuccess is a callback called when the task is successfully executed
  78222. * @param onError is a callback called if an error occurs
  78223. */
  78224. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78225. }
  78226. /**
  78227. * Define a task used by AssetsManager to load cube textures
  78228. */
  78229. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  78230. /**
  78231. * Defines the name of the task
  78232. */
  78233. name: string;
  78234. /**
  78235. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78236. */
  78237. url: string;
  78238. /**
  78239. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78240. */
  78241. extensions?: string[] | undefined;
  78242. /**
  78243. * Defines if mipmaps should not be generated (default is false)
  78244. */
  78245. noMipmap?: boolean | undefined;
  78246. /**
  78247. * Defines the explicit list of files (undefined by default)
  78248. */
  78249. files?: string[] | undefined;
  78250. /**
  78251. * Gets the loaded texture
  78252. */
  78253. texture: CubeTexture;
  78254. /**
  78255. * Callback called when the task is successful
  78256. */
  78257. onSuccess: (task: CubeTextureAssetTask) => void;
  78258. /**
  78259. * Callback called when the task is successful
  78260. */
  78261. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  78262. /**
  78263. * Creates a new CubeTextureAssetTask
  78264. * @param name defines the name of the task
  78265. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78266. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78267. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78268. * @param files defines the explicit list of files (undefined by default)
  78269. */
  78270. constructor(
  78271. /**
  78272. * Defines the name of the task
  78273. */
  78274. name: string,
  78275. /**
  78276. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  78277. */
  78278. url: string,
  78279. /**
  78280. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  78281. */
  78282. extensions?: string[] | undefined,
  78283. /**
  78284. * Defines if mipmaps should not be generated (default is false)
  78285. */
  78286. noMipmap?: boolean | undefined,
  78287. /**
  78288. * Defines the explicit list of files (undefined by default)
  78289. */
  78290. files?: string[] | undefined);
  78291. /**
  78292. * Execute the current task
  78293. * @param scene defines the scene where you want your assets to be loaded
  78294. * @param onSuccess is a callback called when the task is successfully executed
  78295. * @param onError is a callback called if an error occurs
  78296. */
  78297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78298. }
  78299. /**
  78300. * Define a task used by AssetsManager to load HDR cube textures
  78301. */
  78302. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  78303. /**
  78304. * Defines the name of the task
  78305. */
  78306. name: string;
  78307. /**
  78308. * Defines the location of the file to load
  78309. */
  78310. url: string;
  78311. /**
  78312. * Defines the desired size (the more it increases the longer the generation will be)
  78313. */
  78314. size: number;
  78315. /**
  78316. * Defines if mipmaps should not be generated (default is false)
  78317. */
  78318. noMipmap: boolean;
  78319. /**
  78320. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78321. */
  78322. generateHarmonics: boolean;
  78323. /**
  78324. * 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)
  78325. */
  78326. gammaSpace: boolean;
  78327. /**
  78328. * Internal Use Only
  78329. */
  78330. reserved: boolean;
  78331. /**
  78332. * Gets the loaded texture
  78333. */
  78334. texture: HDRCubeTexture;
  78335. /**
  78336. * Callback called when the task is successful
  78337. */
  78338. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  78339. /**
  78340. * Callback called when the task is successful
  78341. */
  78342. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  78343. /**
  78344. * Creates a new HDRCubeTextureAssetTask object
  78345. * @param name defines the name of the task
  78346. * @param url defines the location of the file to load
  78347. * @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.
  78348. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78349. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78350. * @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)
  78351. * @param reserved Internal use only
  78352. */
  78353. constructor(
  78354. /**
  78355. * Defines the name of the task
  78356. */
  78357. name: string,
  78358. /**
  78359. * Defines the location of the file to load
  78360. */
  78361. url: string,
  78362. /**
  78363. * Defines the desired size (the more it increases the longer the generation will be)
  78364. */
  78365. size: number,
  78366. /**
  78367. * Defines if mipmaps should not be generated (default is false)
  78368. */
  78369. noMipmap?: boolean,
  78370. /**
  78371. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  78372. */
  78373. generateHarmonics?: boolean,
  78374. /**
  78375. * 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)
  78376. */
  78377. gammaSpace?: boolean,
  78378. /**
  78379. * Internal Use Only
  78380. */
  78381. reserved?: boolean);
  78382. /**
  78383. * Execute the current task
  78384. * @param scene defines the scene where you want your assets to be loaded
  78385. * @param onSuccess is a callback called when the task is successfully executed
  78386. * @param onError is a callback called if an error occurs
  78387. */
  78388. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78389. }
  78390. /**
  78391. * Define a task used by AssetsManager to load Equirectangular cube textures
  78392. */
  78393. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  78394. /**
  78395. * Defines the name of the task
  78396. */
  78397. name: string;
  78398. /**
  78399. * Defines the location of the file to load
  78400. */
  78401. url: string;
  78402. /**
  78403. * Defines the desired size (the more it increases the longer the generation will be)
  78404. */
  78405. size: number;
  78406. /**
  78407. * Defines if mipmaps should not be generated (default is false)
  78408. */
  78409. noMipmap: boolean;
  78410. /**
  78411. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78412. * but the standard material would require them in Gamma space) (default is true)
  78413. */
  78414. gammaSpace: boolean;
  78415. /**
  78416. * Gets the loaded texture
  78417. */
  78418. texture: EquiRectangularCubeTexture;
  78419. /**
  78420. * Callback called when the task is successful
  78421. */
  78422. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  78423. /**
  78424. * Callback called when the task is successful
  78425. */
  78426. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  78427. /**
  78428. * Creates a new EquiRectangularCubeTextureAssetTask object
  78429. * @param name defines the name of the task
  78430. * @param url defines the location of the file to load
  78431. * @param size defines the desired size (the more it increases the longer the generation will be)
  78432. * If the size is omitted this implies you are using a preprocessed cubemap.
  78433. * @param noMipmap defines if mipmaps should not be generated (default is false)
  78434. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  78435. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  78436. * (default is true)
  78437. */
  78438. constructor(
  78439. /**
  78440. * Defines the name of the task
  78441. */
  78442. name: string,
  78443. /**
  78444. * Defines the location of the file to load
  78445. */
  78446. url: string,
  78447. /**
  78448. * Defines the desired size (the more it increases the longer the generation will be)
  78449. */
  78450. size: number,
  78451. /**
  78452. * Defines if mipmaps should not be generated (default is false)
  78453. */
  78454. noMipmap?: boolean,
  78455. /**
  78456. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  78457. * but the standard material would require them in Gamma space) (default is true)
  78458. */
  78459. gammaSpace?: boolean);
  78460. /**
  78461. * Execute the current task
  78462. * @param scene defines the scene where you want your assets to be loaded
  78463. * @param onSuccess is a callback called when the task is successfully executed
  78464. * @param onError is a callback called if an error occurs
  78465. */
  78466. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  78467. }
  78468. /**
  78469. * This class can be used to easily import assets into a scene
  78470. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  78471. */
  78472. export class AssetsManager {
  78473. private _scene;
  78474. private _isLoading;
  78475. protected _tasks: AbstractAssetTask[];
  78476. protected _waitingTasksCount: number;
  78477. protected _totalTasksCount: number;
  78478. /**
  78479. * Callback called when all tasks are processed
  78480. */
  78481. onFinish: (tasks: AbstractAssetTask[]) => void;
  78482. /**
  78483. * Callback called when a task is successful
  78484. */
  78485. onTaskSuccess: (task: AbstractAssetTask) => void;
  78486. /**
  78487. * Callback called when a task had an error
  78488. */
  78489. onTaskError: (task: AbstractAssetTask) => void;
  78490. /**
  78491. * Callback called when a task is done (whatever the result is)
  78492. */
  78493. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  78494. /**
  78495. * Observable called when all tasks are processed
  78496. */
  78497. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  78498. /**
  78499. * Observable called when a task had an error
  78500. */
  78501. onTaskErrorObservable: Observable<AbstractAssetTask>;
  78502. /**
  78503. * Observable called when all tasks were executed
  78504. */
  78505. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  78506. /**
  78507. * Observable called when a task is done (whatever the result is)
  78508. */
  78509. onProgressObservable: Observable<IAssetsProgressEvent>;
  78510. /**
  78511. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  78512. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  78513. */
  78514. useDefaultLoadingScreen: boolean;
  78515. /**
  78516. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  78517. * when all assets have been downloaded.
  78518. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  78519. */
  78520. autoHideLoadingUI: boolean;
  78521. /**
  78522. * Creates a new AssetsManager
  78523. * @param scene defines the scene to work on
  78524. */
  78525. constructor(scene: Scene);
  78526. /**
  78527. * Add a ContainerAssetTask to the list of active tasks
  78528. * @param taskName defines the name of the new task
  78529. * @param meshesNames defines the name of meshes to load
  78530. * @param rootUrl defines the root url to use to locate files
  78531. * @param sceneFilename defines the filename of the scene file
  78532. * @returns a new ContainerAssetTask object
  78533. */
  78534. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  78535. /**
  78536. * Add a MeshAssetTask to the list of active tasks
  78537. * @param taskName defines the name of the new task
  78538. * @param meshesNames defines the name of meshes to load
  78539. * @param rootUrl defines the root url to use to locate files
  78540. * @param sceneFilename defines the filename of the scene file
  78541. * @returns a new MeshAssetTask object
  78542. */
  78543. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  78544. /**
  78545. * Add a TextFileAssetTask to the list of active tasks
  78546. * @param taskName defines the name of the new task
  78547. * @param url defines the url of the file to load
  78548. * @returns a new TextFileAssetTask object
  78549. */
  78550. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  78551. /**
  78552. * Add a BinaryFileAssetTask to the list of active tasks
  78553. * @param taskName defines the name of the new task
  78554. * @param url defines the url of the file to load
  78555. * @returns a new BinaryFileAssetTask object
  78556. */
  78557. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  78558. /**
  78559. * Add a ImageAssetTask to the list of active tasks
  78560. * @param taskName defines the name of the new task
  78561. * @param url defines the url of the file to load
  78562. * @returns a new ImageAssetTask object
  78563. */
  78564. addImageTask(taskName: string, url: string): ImageAssetTask;
  78565. /**
  78566. * Add a TextureAssetTask to the list of active tasks
  78567. * @param taskName defines the name of the new task
  78568. * @param url defines the url of the file to load
  78569. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78570. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  78571. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  78572. * @returns a new TextureAssetTask object
  78573. */
  78574. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  78575. /**
  78576. * Add a CubeTextureAssetTask to the list of active tasks
  78577. * @param taskName defines the name of the new task
  78578. * @param url defines the url of the file to load
  78579. * @param extensions defines the extension to use to load the cube map (can be null)
  78580. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78581. * @param files defines the list of files to load (can be null)
  78582. * @returns a new CubeTextureAssetTask object
  78583. */
  78584. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  78585. /**
  78586. *
  78587. * Add a HDRCubeTextureAssetTask to the list of active tasks
  78588. * @param taskName defines the name of the new task
  78589. * @param url defines the url of the file to load
  78590. * @param size defines the size you want for the cubemap (can be null)
  78591. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78592. * @param generateHarmonics defines if you want to automatically generate (true by default)
  78593. * @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)
  78594. * @param reserved Internal use only
  78595. * @returns a new HDRCubeTextureAssetTask object
  78596. */
  78597. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  78598. /**
  78599. *
  78600. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  78601. * @param taskName defines the name of the new task
  78602. * @param url defines the url of the file to load
  78603. * @param size defines the size you want for the cubemap (can be null)
  78604. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  78605. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  78606. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  78607. * @returns a new EquiRectangularCubeTextureAssetTask object
  78608. */
  78609. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  78610. /**
  78611. * Remove a task from the assets manager.
  78612. * @param task the task to remove
  78613. */
  78614. removeTask(task: AbstractAssetTask): void;
  78615. private _decreaseWaitingTasksCount;
  78616. private _runTask;
  78617. /**
  78618. * Reset the AssetsManager and remove all tasks
  78619. * @return the current instance of the AssetsManager
  78620. */
  78621. reset(): AssetsManager;
  78622. /**
  78623. * Start the loading process
  78624. * @return the current instance of the AssetsManager
  78625. */
  78626. load(): AssetsManager;
  78627. /**
  78628. * Start the loading process as an async operation
  78629. * @return a promise returning the list of failed tasks
  78630. */
  78631. loadAsync(): Promise<void>;
  78632. }
  78633. }
  78634. declare module "babylonjs/Misc/deferred" {
  78635. /**
  78636. * Wrapper class for promise with external resolve and reject.
  78637. */
  78638. export class Deferred<T> {
  78639. /**
  78640. * The promise associated with this deferred object.
  78641. */
  78642. readonly promise: Promise<T>;
  78643. private _resolve;
  78644. private _reject;
  78645. /**
  78646. * The resolve method of the promise associated with this deferred object.
  78647. */
  78648. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  78649. /**
  78650. * The reject method of the promise associated with this deferred object.
  78651. */
  78652. get reject(): (reason?: any) => void;
  78653. /**
  78654. * Constructor for this deferred object.
  78655. */
  78656. constructor();
  78657. }
  78658. }
  78659. declare module "babylonjs/Misc/meshExploder" {
  78660. import { Mesh } from "babylonjs/Meshes/mesh";
  78661. /**
  78662. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78663. */
  78664. export class MeshExploder {
  78665. private _centerMesh;
  78666. private _meshes;
  78667. private _meshesOrigins;
  78668. private _toCenterVectors;
  78669. private _scaledDirection;
  78670. private _newPosition;
  78671. private _centerPosition;
  78672. /**
  78673. * Explodes meshes from a center mesh.
  78674. * @param meshes The meshes to explode.
  78675. * @param centerMesh The mesh to be center of explosion.
  78676. */
  78677. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78678. private _setCenterMesh;
  78679. /**
  78680. * Get class name
  78681. * @returns "MeshExploder"
  78682. */
  78683. getClassName(): string;
  78684. /**
  78685. * "Exploded meshes"
  78686. * @returns Array of meshes with the centerMesh at index 0.
  78687. */
  78688. getMeshes(): Array<Mesh>;
  78689. /**
  78690. * Explodes meshes giving a specific direction
  78691. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78692. */
  78693. explode(direction?: number): void;
  78694. }
  78695. }
  78696. declare module "babylonjs/Misc/filesInput" {
  78697. import { Engine } from "babylonjs/Engines/engine";
  78698. import { Scene } from "babylonjs/scene";
  78699. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78700. import { Nullable } from "babylonjs/types";
  78701. /**
  78702. * Class used to help managing file picking and drag'n'drop
  78703. */
  78704. export class FilesInput {
  78705. /**
  78706. * List of files ready to be loaded
  78707. */
  78708. static get FilesToLoad(): {
  78709. [key: string]: File;
  78710. };
  78711. /**
  78712. * Callback called when a file is processed
  78713. */
  78714. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78715. private _engine;
  78716. private _currentScene;
  78717. private _sceneLoadedCallback;
  78718. private _progressCallback;
  78719. private _additionalRenderLoopLogicCallback;
  78720. private _textureLoadingCallback;
  78721. private _startingProcessingFilesCallback;
  78722. private _onReloadCallback;
  78723. private _errorCallback;
  78724. private _elementToMonitor;
  78725. private _sceneFileToLoad;
  78726. private _filesToLoad;
  78727. /**
  78728. * Creates a new FilesInput
  78729. * @param engine defines the rendering engine
  78730. * @param scene defines the hosting scene
  78731. * @param sceneLoadedCallback callback called when scene is loaded
  78732. * @param progressCallback callback called to track progress
  78733. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78734. * @param textureLoadingCallback callback called when a texture is loading
  78735. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78736. * @param onReloadCallback callback called when a reload is requested
  78737. * @param errorCallback callback call if an error occurs
  78738. */
  78739. 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>);
  78740. private _dragEnterHandler;
  78741. private _dragOverHandler;
  78742. private _dropHandler;
  78743. /**
  78744. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78745. * @param elementToMonitor defines the DOM element to track
  78746. */
  78747. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78748. /** Gets the current list of files to load */
  78749. get filesToLoad(): File[];
  78750. /**
  78751. * Release all associated resources
  78752. */
  78753. dispose(): void;
  78754. private renderFunction;
  78755. private drag;
  78756. private drop;
  78757. private _traverseFolder;
  78758. private _processFiles;
  78759. /**
  78760. * Load files from a drop event
  78761. * @param event defines the drop event to use as source
  78762. */
  78763. loadFiles(event: any): void;
  78764. private _processReload;
  78765. /**
  78766. * Reload the current scene from the loaded files
  78767. */
  78768. reload(): void;
  78769. }
  78770. }
  78771. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78772. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78773. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78774. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78775. }
  78776. declare module "babylonjs/Misc/sceneOptimizer" {
  78777. import { Scene, IDisposable } from "babylonjs/scene";
  78778. import { Observable } from "babylonjs/Misc/observable";
  78779. /**
  78780. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78781. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78782. */
  78783. export class SceneOptimization {
  78784. /**
  78785. * Defines the priority of this optimization (0 by default which means first in the list)
  78786. */
  78787. priority: number;
  78788. /**
  78789. * Gets a string describing the action executed by the current optimization
  78790. * @returns description string
  78791. */
  78792. getDescription(): string;
  78793. /**
  78794. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78795. * @param scene defines the current scene where to apply this optimization
  78796. * @param optimizer defines the current optimizer
  78797. * @returns true if everything that can be done was applied
  78798. */
  78799. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78800. /**
  78801. * Creates the SceneOptimization object
  78802. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78803. * @param desc defines the description associated with the optimization
  78804. */
  78805. constructor(
  78806. /**
  78807. * Defines the priority of this optimization (0 by default which means first in the list)
  78808. */
  78809. priority?: number);
  78810. }
  78811. /**
  78812. * Defines an optimization used to reduce the size of render target textures
  78813. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78814. */
  78815. export class TextureOptimization extends SceneOptimization {
  78816. /**
  78817. * Defines the priority of this optimization (0 by default which means first in the list)
  78818. */
  78819. priority: number;
  78820. /**
  78821. * 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
  78822. */
  78823. maximumSize: number;
  78824. /**
  78825. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78826. */
  78827. step: number;
  78828. /**
  78829. * Gets a string describing the action executed by the current optimization
  78830. * @returns description string
  78831. */
  78832. getDescription(): string;
  78833. /**
  78834. * Creates the TextureOptimization object
  78835. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78836. * @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
  78837. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78838. */
  78839. constructor(
  78840. /**
  78841. * Defines the priority of this optimization (0 by default which means first in the list)
  78842. */
  78843. priority?: number,
  78844. /**
  78845. * 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
  78846. */
  78847. maximumSize?: number,
  78848. /**
  78849. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78850. */
  78851. step?: number);
  78852. /**
  78853. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78854. * @param scene defines the current scene where to apply this optimization
  78855. * @param optimizer defines the current optimizer
  78856. * @returns true if everything that can be done was applied
  78857. */
  78858. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78859. }
  78860. /**
  78861. * Defines an optimization used to increase or decrease the rendering resolution
  78862. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78863. */
  78864. export class HardwareScalingOptimization extends SceneOptimization {
  78865. /**
  78866. * Defines the priority of this optimization (0 by default which means first in the list)
  78867. */
  78868. priority: number;
  78869. /**
  78870. * Defines the maximum scale to use (2 by default)
  78871. */
  78872. maximumScale: number;
  78873. /**
  78874. * Defines the step to use between two passes (0.5 by default)
  78875. */
  78876. step: number;
  78877. private _currentScale;
  78878. private _directionOffset;
  78879. /**
  78880. * Gets a string describing the action executed by the current optimization
  78881. * @return description string
  78882. */
  78883. getDescription(): string;
  78884. /**
  78885. * Creates the HardwareScalingOptimization object
  78886. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78887. * @param maximumScale defines the maximum scale to use (2 by default)
  78888. * @param step defines the step to use between two passes (0.5 by default)
  78889. */
  78890. constructor(
  78891. /**
  78892. * Defines the priority of this optimization (0 by default which means first in the list)
  78893. */
  78894. priority?: number,
  78895. /**
  78896. * Defines the maximum scale to use (2 by default)
  78897. */
  78898. maximumScale?: number,
  78899. /**
  78900. * Defines the step to use between two passes (0.5 by default)
  78901. */
  78902. step?: number);
  78903. /**
  78904. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78905. * @param scene defines the current scene where to apply this optimization
  78906. * @param optimizer defines the current optimizer
  78907. * @returns true if everything that can be done was applied
  78908. */
  78909. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78910. }
  78911. /**
  78912. * Defines an optimization used to remove shadows
  78913. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78914. */
  78915. export class ShadowsOptimization extends SceneOptimization {
  78916. /**
  78917. * Gets a string describing the action executed by the current optimization
  78918. * @return description string
  78919. */
  78920. getDescription(): string;
  78921. /**
  78922. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78923. * @param scene defines the current scene where to apply this optimization
  78924. * @param optimizer defines the current optimizer
  78925. * @returns true if everything that can be done was applied
  78926. */
  78927. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78928. }
  78929. /**
  78930. * Defines an optimization used to turn post-processes off
  78931. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78932. */
  78933. export class PostProcessesOptimization extends SceneOptimization {
  78934. /**
  78935. * Gets a string describing the action executed by the current optimization
  78936. * @return description string
  78937. */
  78938. getDescription(): string;
  78939. /**
  78940. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78941. * @param scene defines the current scene where to apply this optimization
  78942. * @param optimizer defines the current optimizer
  78943. * @returns true if everything that can be done was applied
  78944. */
  78945. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78946. }
  78947. /**
  78948. * Defines an optimization used to turn lens flares off
  78949. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78950. */
  78951. export class LensFlaresOptimization extends SceneOptimization {
  78952. /**
  78953. * Gets a string describing the action executed by the current optimization
  78954. * @return description string
  78955. */
  78956. getDescription(): string;
  78957. /**
  78958. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78959. * @param scene defines the current scene where to apply this optimization
  78960. * @param optimizer defines the current optimizer
  78961. * @returns true if everything that can be done was applied
  78962. */
  78963. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78964. }
  78965. /**
  78966. * Defines an optimization based on user defined callback.
  78967. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78968. */
  78969. export class CustomOptimization extends SceneOptimization {
  78970. /**
  78971. * Callback called to apply the custom optimization.
  78972. */
  78973. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78974. /**
  78975. * Callback called to get custom description
  78976. */
  78977. onGetDescription: () => string;
  78978. /**
  78979. * Gets a string describing the action executed by the current optimization
  78980. * @returns description string
  78981. */
  78982. getDescription(): string;
  78983. /**
  78984. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78985. * @param scene defines the current scene where to apply this optimization
  78986. * @param optimizer defines the current optimizer
  78987. * @returns true if everything that can be done was applied
  78988. */
  78989. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78990. }
  78991. /**
  78992. * Defines an optimization used to turn particles off
  78993. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78994. */
  78995. export class ParticlesOptimization extends SceneOptimization {
  78996. /**
  78997. * Gets a string describing the action executed by the current optimization
  78998. * @return description string
  78999. */
  79000. getDescription(): string;
  79001. /**
  79002. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79003. * @param scene defines the current scene where to apply this optimization
  79004. * @param optimizer defines the current optimizer
  79005. * @returns true if everything that can be done was applied
  79006. */
  79007. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79008. }
  79009. /**
  79010. * Defines an optimization used to turn render targets off
  79011. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79012. */
  79013. export class RenderTargetsOptimization extends SceneOptimization {
  79014. /**
  79015. * Gets a string describing the action executed by the current optimization
  79016. * @return description string
  79017. */
  79018. getDescription(): string;
  79019. /**
  79020. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79021. * @param scene defines the current scene where to apply this optimization
  79022. * @param optimizer defines the current optimizer
  79023. * @returns true if everything that can be done was applied
  79024. */
  79025. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  79026. }
  79027. /**
  79028. * Defines an optimization used to merge meshes with compatible materials
  79029. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79030. */
  79031. export class MergeMeshesOptimization extends SceneOptimization {
  79032. private static _UpdateSelectionTree;
  79033. /**
  79034. * Gets or sets a boolean which defines if optimization octree has to be updated
  79035. */
  79036. static get UpdateSelectionTree(): boolean;
  79037. /**
  79038. * Gets or sets a boolean which defines if optimization octree has to be updated
  79039. */
  79040. static set UpdateSelectionTree(value: boolean);
  79041. /**
  79042. * Gets a string describing the action executed by the current optimization
  79043. * @return description string
  79044. */
  79045. getDescription(): string;
  79046. private _canBeMerged;
  79047. /**
  79048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  79049. * @param scene defines the current scene where to apply this optimization
  79050. * @param optimizer defines the current optimizer
  79051. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  79052. * @returns true if everything that can be done was applied
  79053. */
  79054. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  79055. }
  79056. /**
  79057. * Defines a list of options used by SceneOptimizer
  79058. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79059. */
  79060. export class SceneOptimizerOptions {
  79061. /**
  79062. * Defines the target frame rate to reach (60 by default)
  79063. */
  79064. targetFrameRate: number;
  79065. /**
  79066. * Defines the interval between two checkes (2000ms by default)
  79067. */
  79068. trackerDuration: number;
  79069. /**
  79070. * Gets the list of optimizations to apply
  79071. */
  79072. optimizations: SceneOptimization[];
  79073. /**
  79074. * Creates a new list of options used by SceneOptimizer
  79075. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  79076. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  79077. */
  79078. constructor(
  79079. /**
  79080. * Defines the target frame rate to reach (60 by default)
  79081. */
  79082. targetFrameRate?: number,
  79083. /**
  79084. * Defines the interval between two checkes (2000ms by default)
  79085. */
  79086. trackerDuration?: number);
  79087. /**
  79088. * Add a new optimization
  79089. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  79090. * @returns the current SceneOptimizerOptions
  79091. */
  79092. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  79093. /**
  79094. * Add a new custom optimization
  79095. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  79096. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  79097. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  79098. * @returns the current SceneOptimizerOptions
  79099. */
  79100. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  79101. /**
  79102. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  79103. * @param targetFrameRate defines the target frame rate (60 by default)
  79104. * @returns a SceneOptimizerOptions object
  79105. */
  79106. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79107. /**
  79108. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  79109. * @param targetFrameRate defines the target frame rate (60 by default)
  79110. * @returns a SceneOptimizerOptions object
  79111. */
  79112. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79113. /**
  79114. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  79115. * @param targetFrameRate defines the target frame rate (60 by default)
  79116. * @returns a SceneOptimizerOptions object
  79117. */
  79118. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  79119. }
  79120. /**
  79121. * Class used to run optimizations in order to reach a target frame rate
  79122. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  79123. */
  79124. export class SceneOptimizer implements IDisposable {
  79125. private _isRunning;
  79126. private _options;
  79127. private _scene;
  79128. private _currentPriorityLevel;
  79129. private _targetFrameRate;
  79130. private _trackerDuration;
  79131. private _currentFrameRate;
  79132. private _sceneDisposeObserver;
  79133. private _improvementMode;
  79134. /**
  79135. * Defines an observable called when the optimizer reaches the target frame rate
  79136. */
  79137. onSuccessObservable: Observable<SceneOptimizer>;
  79138. /**
  79139. * Defines an observable called when the optimizer enables an optimization
  79140. */
  79141. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  79142. /**
  79143. * Defines an observable called when the optimizer is not able to reach the target frame rate
  79144. */
  79145. onFailureObservable: Observable<SceneOptimizer>;
  79146. /**
  79147. * Gets a boolean indicating if the optimizer is in improvement mode
  79148. */
  79149. get isInImprovementMode(): boolean;
  79150. /**
  79151. * Gets the current priority level (0 at start)
  79152. */
  79153. get currentPriorityLevel(): number;
  79154. /**
  79155. * Gets the current frame rate checked by the SceneOptimizer
  79156. */
  79157. get currentFrameRate(): number;
  79158. /**
  79159. * Gets or sets the current target frame rate (60 by default)
  79160. */
  79161. get targetFrameRate(): number;
  79162. /**
  79163. * Gets or sets the current target frame rate (60 by default)
  79164. */
  79165. set targetFrameRate(value: number);
  79166. /**
  79167. * Gets or sets the current interval between two checks (every 2000ms by default)
  79168. */
  79169. get trackerDuration(): number;
  79170. /**
  79171. * Gets or sets the current interval between two checks (every 2000ms by default)
  79172. */
  79173. set trackerDuration(value: number);
  79174. /**
  79175. * Gets the list of active optimizations
  79176. */
  79177. get optimizations(): SceneOptimization[];
  79178. /**
  79179. * Creates a new SceneOptimizer
  79180. * @param scene defines the scene to work on
  79181. * @param options defines the options to use with the SceneOptimizer
  79182. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  79183. * @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)
  79184. */
  79185. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  79186. /**
  79187. * Stops the current optimizer
  79188. */
  79189. stop(): void;
  79190. /**
  79191. * Reset the optimizer to initial step (current priority level = 0)
  79192. */
  79193. reset(): void;
  79194. /**
  79195. * Start the optimizer. By default it will try to reach a specific framerate
  79196. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  79197. */
  79198. start(): void;
  79199. private _checkCurrentState;
  79200. /**
  79201. * Release all resources
  79202. */
  79203. dispose(): void;
  79204. /**
  79205. * Helper function to create a SceneOptimizer with one single line of code
  79206. * @param scene defines the scene to work on
  79207. * @param options defines the options to use with the SceneOptimizer
  79208. * @param onSuccess defines a callback to call on success
  79209. * @param onFailure defines a callback to call on failure
  79210. * @returns the new SceneOptimizer object
  79211. */
  79212. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  79213. }
  79214. }
  79215. declare module "babylonjs/Misc/sceneSerializer" {
  79216. import { Scene } from "babylonjs/scene";
  79217. /**
  79218. * Class used to serialize a scene into a string
  79219. */
  79220. export class SceneSerializer {
  79221. /**
  79222. * Clear cache used by a previous serialization
  79223. */
  79224. static ClearCache(): void;
  79225. /**
  79226. * Serialize a scene into a JSON compatible object
  79227. * @param scene defines the scene to serialize
  79228. * @returns a JSON compatible object
  79229. */
  79230. static Serialize(scene: Scene): any;
  79231. /**
  79232. * Serialize a mesh into a JSON compatible object
  79233. * @param toSerialize defines the mesh to serialize
  79234. * @param withParents defines if parents must be serialized as well
  79235. * @param withChildren defines if children must be serialized as well
  79236. * @returns a JSON compatible object
  79237. */
  79238. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  79239. }
  79240. }
  79241. declare module "babylonjs/Misc/textureTools" {
  79242. import { Texture } from "babylonjs/Materials/Textures/texture";
  79243. /**
  79244. * Class used to host texture specific utilities
  79245. */
  79246. export class TextureTools {
  79247. /**
  79248. * Uses the GPU to create a copy texture rescaled at a given size
  79249. * @param texture Texture to copy from
  79250. * @param width defines the desired width
  79251. * @param height defines the desired height
  79252. * @param useBilinearMode defines if bilinear mode has to be used
  79253. * @return the generated texture
  79254. */
  79255. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  79256. }
  79257. }
  79258. declare module "babylonjs/Misc/videoRecorder" {
  79259. import { Nullable } from "babylonjs/types";
  79260. import { Engine } from "babylonjs/Engines/engine";
  79261. /**
  79262. * This represents the different options available for the video capture.
  79263. */
  79264. export interface VideoRecorderOptions {
  79265. /** Defines the mime type of the video. */
  79266. mimeType: string;
  79267. /** Defines the FPS the video should be recorded at. */
  79268. fps: number;
  79269. /** Defines the chunk size for the recording data. */
  79270. recordChunckSize: number;
  79271. /** The audio tracks to attach to the recording. */
  79272. audioTracks?: MediaStreamTrack[];
  79273. }
  79274. /**
  79275. * This can help with recording videos from BabylonJS.
  79276. * This is based on the available WebRTC functionalities of the browser.
  79277. *
  79278. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  79279. */
  79280. export class VideoRecorder {
  79281. private static readonly _defaultOptions;
  79282. /**
  79283. * Returns whether or not the VideoRecorder is available in your browser.
  79284. * @param engine Defines the Babylon Engine.
  79285. * @returns true if supported otherwise false.
  79286. */
  79287. static IsSupported(engine: Engine): boolean;
  79288. private readonly _options;
  79289. private _canvas;
  79290. private _mediaRecorder;
  79291. private _recordedChunks;
  79292. private _fileName;
  79293. private _resolve;
  79294. private _reject;
  79295. /**
  79296. * True when a recording is already in progress.
  79297. */
  79298. get isRecording(): boolean;
  79299. /**
  79300. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  79301. * @param engine Defines the BabylonJS Engine you wish to record.
  79302. * @param options Defines options that can be used to customize the capture.
  79303. */
  79304. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  79305. /**
  79306. * Stops the current recording before the default capture timeout passed in the startRecording function.
  79307. */
  79308. stopRecording(): void;
  79309. /**
  79310. * Starts recording the canvas for a max duration specified in parameters.
  79311. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  79312. * If null no automatic download will start and you can rely on the promise to get the data back.
  79313. * @param maxDuration Defines the maximum recording time in seconds.
  79314. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  79315. * @return A promise callback at the end of the recording with the video data in Blob.
  79316. */
  79317. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  79318. /**
  79319. * Releases internal resources used during the recording.
  79320. */
  79321. dispose(): void;
  79322. private _handleDataAvailable;
  79323. private _handleError;
  79324. private _handleStop;
  79325. }
  79326. }
  79327. declare module "babylonjs/Misc/screenshotTools" {
  79328. import { Camera } from "babylonjs/Cameras/camera";
  79329. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  79330. import { Engine } from "babylonjs/Engines/engine";
  79331. /**
  79332. * Class containing a set of static utilities functions for screenshots
  79333. */
  79334. export class ScreenshotTools {
  79335. /**
  79336. * Captures a screenshot of the current rendering
  79337. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79338. * @param engine defines the rendering engine
  79339. * @param camera defines the source camera
  79340. * @param size This parameter can be set to a single number or to an object with the
  79341. * following (optional) properties: precision, width, height. If a single number is passed,
  79342. * it will be used for both width and height. If an object is passed, the screenshot size
  79343. * will be derived from the parameters. The precision property is a multiplier allowing
  79344. * rendering at a higher or lower resolution
  79345. * @param successCallback defines the callback receives a single parameter which contains the
  79346. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79347. * src parameter of an <img> to display it
  79348. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79349. * Check your browser for supported MIME types
  79350. */
  79351. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  79352. /**
  79353. * Captures a screenshot of the current rendering
  79354. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79355. * @param engine defines the rendering engine
  79356. * @param camera defines the source camera
  79357. * @param size This parameter can be set to a single number or to an object with the
  79358. * following (optional) properties: precision, width, height. If a single number is passed,
  79359. * it will be used for both width and height. If an object is passed, the screenshot size
  79360. * will be derived from the parameters. The precision property is a multiplier allowing
  79361. * rendering at a higher or lower resolution
  79362. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  79363. * Check your browser for supported MIME types
  79364. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79365. * to the src parameter of an <img> to display it
  79366. */
  79367. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  79368. /**
  79369. * Generates an image screenshot from the specified camera.
  79370. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79371. * @param engine The engine to use for rendering
  79372. * @param camera The camera to use for rendering
  79373. * @param size This parameter can be set to a single number or to an object with the
  79374. * following (optional) properties: precision, width, height. If a single number is passed,
  79375. * it will be used for both width and height. If an object is passed, the screenshot size
  79376. * will be derived from the parameters. The precision property is a multiplier allowing
  79377. * rendering at a higher or lower resolution
  79378. * @param successCallback The callback receives a single parameter which contains the
  79379. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  79380. * src parameter of an <img> to display it
  79381. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79382. * Check your browser for supported MIME types
  79383. * @param samples Texture samples (default: 1)
  79384. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79385. * @param fileName A name for for the downloaded file.
  79386. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79387. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  79388. */
  79389. 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;
  79390. /**
  79391. * Generates an image screenshot from the specified camera.
  79392. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  79393. * @param engine The engine to use for rendering
  79394. * @param camera The camera to use for rendering
  79395. * @param size This parameter can be set to a single number or to an object with the
  79396. * following (optional) properties: precision, width, height. If a single number is passed,
  79397. * it will be used for both width and height. If an object is passed, the screenshot size
  79398. * will be derived from the parameters. The precision property is a multiplier allowing
  79399. * rendering at a higher or lower resolution
  79400. * @param mimeType The MIME type of the screenshot image (default: image/png).
  79401. * Check your browser for supported MIME types
  79402. * @param samples Texture samples (default: 1)
  79403. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  79404. * @param fileName A name for for the downloaded file.
  79405. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  79406. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  79407. * to the src parameter of an <img> to display it
  79408. */
  79409. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  79410. /**
  79411. * Gets height and width for screenshot size
  79412. * @private
  79413. */
  79414. private static _getScreenshotSize;
  79415. }
  79416. }
  79417. declare module "babylonjs/Misc/dataReader" {
  79418. /**
  79419. * Interface for a data buffer
  79420. */
  79421. export interface IDataBuffer {
  79422. /**
  79423. * Reads bytes from the data buffer.
  79424. * @param byteOffset The byte offset to read
  79425. * @param byteLength The byte length to read
  79426. * @returns A promise that resolves when the bytes are read
  79427. */
  79428. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  79429. /**
  79430. * The byte length of the buffer.
  79431. */
  79432. readonly byteLength: number;
  79433. }
  79434. /**
  79435. * Utility class for reading from a data buffer
  79436. */
  79437. export class DataReader {
  79438. /**
  79439. * The data buffer associated with this data reader.
  79440. */
  79441. readonly buffer: IDataBuffer;
  79442. /**
  79443. * The current byte offset from the beginning of the data buffer.
  79444. */
  79445. byteOffset: number;
  79446. private _dataView;
  79447. private _dataByteOffset;
  79448. /**
  79449. * Constructor
  79450. * @param buffer The buffer to read
  79451. */
  79452. constructor(buffer: IDataBuffer);
  79453. /**
  79454. * Loads the given byte length.
  79455. * @param byteLength The byte length to load
  79456. * @returns A promise that resolves when the load is complete
  79457. */
  79458. loadAsync(byteLength: number): Promise<void>;
  79459. /**
  79460. * Read a unsigned 32-bit integer from the currently loaded data range.
  79461. * @returns The 32-bit integer read
  79462. */
  79463. readUint32(): number;
  79464. /**
  79465. * Read a byte array from the currently loaded data range.
  79466. * @param byteLength The byte length to read
  79467. * @returns The byte array read
  79468. */
  79469. readUint8Array(byteLength: number): Uint8Array;
  79470. /**
  79471. * Read a string from the currently loaded data range.
  79472. * @param byteLength The byte length to read
  79473. * @returns The string read
  79474. */
  79475. readString(byteLength: number): string;
  79476. /**
  79477. * Skips the given byte length the currently loaded data range.
  79478. * @param byteLength The byte length to skip
  79479. */
  79480. skipBytes(byteLength: number): void;
  79481. }
  79482. }
  79483. declare module "babylonjs/Misc/dataStorage" {
  79484. /**
  79485. * Class for storing data to local storage if available or in-memory storage otherwise
  79486. */
  79487. export class DataStorage {
  79488. private static _Storage;
  79489. private static _GetStorage;
  79490. /**
  79491. * Reads a string from the data storage
  79492. * @param key The key to read
  79493. * @param defaultValue The value if the key doesn't exist
  79494. * @returns The string value
  79495. */
  79496. static ReadString(key: string, defaultValue: string): string;
  79497. /**
  79498. * Writes a string to the data storage
  79499. * @param key The key to write
  79500. * @param value The value to write
  79501. */
  79502. static WriteString(key: string, value: string): void;
  79503. /**
  79504. * Reads a boolean from the data storage
  79505. * @param key The key to read
  79506. * @param defaultValue The value if the key doesn't exist
  79507. * @returns The boolean value
  79508. */
  79509. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  79510. /**
  79511. * Writes a boolean to the data storage
  79512. * @param key The key to write
  79513. * @param value The value to write
  79514. */
  79515. static WriteBoolean(key: string, value: boolean): void;
  79516. /**
  79517. * Reads a number from the data storage
  79518. * @param key The key to read
  79519. * @param defaultValue The value if the key doesn't exist
  79520. * @returns The number value
  79521. */
  79522. static ReadNumber(key: string, defaultValue: number): number;
  79523. /**
  79524. * Writes a number to the data storage
  79525. * @param key The key to write
  79526. * @param value The value to write
  79527. */
  79528. static WriteNumber(key: string, value: number): void;
  79529. }
  79530. }
  79531. declare module "babylonjs/Misc/sceneRecorder" {
  79532. import { Scene } from "babylonjs/scene";
  79533. /**
  79534. * Class used to record delta files between 2 scene states
  79535. */
  79536. export class SceneRecorder {
  79537. private _trackedScene;
  79538. private _savedJSON;
  79539. /**
  79540. * Track a given scene. This means the current scene state will be considered the original state
  79541. * @param scene defines the scene to track
  79542. */
  79543. track(scene: Scene): void;
  79544. /**
  79545. * Get the delta between current state and original state
  79546. * @returns a string containing the delta
  79547. */
  79548. getDelta(): any;
  79549. private _compareArray;
  79550. private _compareObjects;
  79551. private _compareCollections;
  79552. private static GetShadowGeneratorById;
  79553. /**
  79554. * Apply a given delta to a given scene
  79555. * @param deltaJSON defines the JSON containing the delta
  79556. * @param scene defines the scene to apply the delta to
  79557. */
  79558. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  79559. private static _ApplyPropertiesToEntity;
  79560. private static _ApplyDeltaForEntity;
  79561. }
  79562. }
  79563. declare module "babylonjs/Misc/trajectoryClassifier" {
  79564. import { DeepImmutable, Nullable } from "babylonjs/types";
  79565. import { Vector3 } from "babylonjs/Maths/math.vector";
  79566. /**
  79567. * A 3D trajectory consisting of an order list of vectors describing a
  79568. * path of motion through 3D space.
  79569. */
  79570. export class Trajectory {
  79571. private _points;
  79572. private readonly _segmentLength;
  79573. /**
  79574. * Serialize to JSON.
  79575. * @returns serialized JSON string
  79576. */
  79577. serialize(): string;
  79578. /**
  79579. * Deserialize from JSON.
  79580. * @param json serialized JSON string
  79581. * @returns deserialized Trajectory
  79582. */
  79583. static Deserialize(json: string): Trajectory;
  79584. /**
  79585. * Create a new empty Trajectory.
  79586. * @param segmentLength radius of discretization for Trajectory points
  79587. */
  79588. constructor(segmentLength?: number);
  79589. /**
  79590. * Get the length of the Trajectory.
  79591. * @returns length of the Trajectory
  79592. */
  79593. getLength(): number;
  79594. /**
  79595. * Append a new point to the Trajectory.
  79596. * NOTE: This implementation has many allocations.
  79597. * @param point point to append to the Trajectory
  79598. */
  79599. add(point: DeepImmutable<Vector3>): void;
  79600. /**
  79601. * Create a new Trajectory with a segment length chosen to make it
  79602. * probable that the new Trajectory will have a specified number of
  79603. * segments. This operation is imprecise.
  79604. * @param targetResolution number of segments desired
  79605. * @returns new Trajectory with approximately the requested number of segments
  79606. */
  79607. resampleAtTargetResolution(targetResolution: number): Trajectory;
  79608. /**
  79609. * Convert Trajectory segments into tokenized representation. This
  79610. * representation is an array of numbers where each nth number is the
  79611. * index of the token which is most similar to the nth segment of the
  79612. * Trajectory.
  79613. * @param tokens list of vectors which serve as discrete tokens
  79614. * @returns list of indices of most similar token per segment
  79615. */
  79616. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  79617. private static _forwardDir;
  79618. private static _inverseFromVec;
  79619. private static _upDir;
  79620. private static _fromToVec;
  79621. private static _lookMatrix;
  79622. /**
  79623. * Transform the rotation (i.e., direction) of a segment to isolate
  79624. * the relative transformation represented by the segment. This operation
  79625. * may or may not succeed due to singularities in the equations that define
  79626. * motion relativity in this context.
  79627. * @param priorVec the origin of the prior segment
  79628. * @param fromVec the origin of the current segment
  79629. * @param toVec the destination of the current segment
  79630. * @param result reference to output variable
  79631. * @returns whether or not transformation was successful
  79632. */
  79633. private static _transformSegmentDirToRef;
  79634. private static _bestMatch;
  79635. private static _score;
  79636. private static _bestScore;
  79637. /**
  79638. * Determine which token vector is most similar to the
  79639. * segment vector.
  79640. * @param segment segment vector
  79641. * @param tokens token vector list
  79642. * @returns index of the most similar token to the segment
  79643. */
  79644. private static _tokenizeSegment;
  79645. }
  79646. /**
  79647. * Class representing a set of known, named trajectories to which Trajectories can be
  79648. * added and using which Trajectories can be recognized.
  79649. */
  79650. export class TrajectoryClassifier {
  79651. private _maximumAllowableMatchCost;
  79652. private _vector3Alphabet;
  79653. private _levenshteinAlphabet;
  79654. private _nameToDescribedTrajectory;
  79655. /**
  79656. * Serialize to JSON.
  79657. * @returns JSON serialization
  79658. */
  79659. serialize(): string;
  79660. /**
  79661. * Deserialize from JSON.
  79662. * @param json JSON serialization
  79663. * @returns deserialized TrajectorySet
  79664. */
  79665. static Deserialize(json: string): TrajectoryClassifier;
  79666. /**
  79667. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79668. * VERY naive, need to be generating these things from known
  79669. * sets. Better version later, probably eliminating this one.
  79670. * @returns auto-generated TrajectorySet
  79671. */
  79672. static Generate(): TrajectoryClassifier;
  79673. private constructor();
  79674. /**
  79675. * Add a new Trajectory to the set with a given name.
  79676. * @param trajectory new Trajectory to be added
  79677. * @param classification name to which to add the Trajectory
  79678. */
  79679. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79680. /**
  79681. * Remove a known named trajectory and all Trajectories associated with it.
  79682. * @param classification name to remove
  79683. * @returns whether anything was removed
  79684. */
  79685. deleteClassification(classification: string): boolean;
  79686. /**
  79687. * Attempt to recognize a Trajectory from among all the classifications
  79688. * already known to the classifier.
  79689. * @param trajectory Trajectory to be recognized
  79690. * @returns classification of Trajectory if recognized, null otherwise
  79691. */
  79692. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79693. }
  79694. }
  79695. declare module "babylonjs/Misc/index" {
  79696. export * from "babylonjs/Misc/andOrNotEvaluator";
  79697. export * from "babylonjs/Misc/assetsManager";
  79698. export * from "babylonjs/Misc/basis";
  79699. export * from "babylonjs/Misc/dds";
  79700. export * from "babylonjs/Misc/decorators";
  79701. export * from "babylonjs/Misc/deferred";
  79702. export * from "babylonjs/Misc/environmentTextureTools";
  79703. export * from "babylonjs/Misc/meshExploder";
  79704. export * from "babylonjs/Misc/filesInput";
  79705. export * from "babylonjs/Misc/HighDynamicRange/index";
  79706. export * from "babylonjs/Misc/khronosTextureContainer";
  79707. export * from "babylonjs/Misc/observable";
  79708. export * from "babylonjs/Misc/performanceMonitor";
  79709. export * from "babylonjs/Misc/promise";
  79710. export * from "babylonjs/Misc/sceneOptimizer";
  79711. export * from "babylonjs/Misc/sceneSerializer";
  79712. export * from "babylonjs/Misc/smartArray";
  79713. export * from "babylonjs/Misc/stringDictionary";
  79714. export * from "babylonjs/Misc/tags";
  79715. export * from "babylonjs/Misc/textureTools";
  79716. export * from "babylonjs/Misc/tga";
  79717. export * from "babylonjs/Misc/tools";
  79718. export * from "babylonjs/Misc/videoRecorder";
  79719. export * from "babylonjs/Misc/virtualJoystick";
  79720. export * from "babylonjs/Misc/workerPool";
  79721. export * from "babylonjs/Misc/logger";
  79722. export * from "babylonjs/Misc/typeStore";
  79723. export * from "babylonjs/Misc/filesInputStore";
  79724. export * from "babylonjs/Misc/deepCopier";
  79725. export * from "babylonjs/Misc/pivotTools";
  79726. export * from "babylonjs/Misc/precisionDate";
  79727. export * from "babylonjs/Misc/screenshotTools";
  79728. export * from "babylonjs/Misc/typeStore";
  79729. export * from "babylonjs/Misc/webRequest";
  79730. export * from "babylonjs/Misc/iInspectable";
  79731. export * from "babylonjs/Misc/brdfTextureTools";
  79732. export * from "babylonjs/Misc/rgbdTextureTools";
  79733. export * from "babylonjs/Misc/gradients";
  79734. export * from "babylonjs/Misc/perfCounter";
  79735. export * from "babylonjs/Misc/fileRequest";
  79736. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79737. export * from "babylonjs/Misc/retryStrategy";
  79738. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79739. export * from "babylonjs/Misc/canvasGenerator";
  79740. export * from "babylonjs/Misc/fileTools";
  79741. export * from "babylonjs/Misc/stringTools";
  79742. export * from "babylonjs/Misc/dataReader";
  79743. export * from "babylonjs/Misc/minMaxReducer";
  79744. export * from "babylonjs/Misc/depthReducer";
  79745. export * from "babylonjs/Misc/dataStorage";
  79746. export * from "babylonjs/Misc/sceneRecorder";
  79747. export * from "babylonjs/Misc/khronosTextureContainer2";
  79748. export * from "babylonjs/Misc/trajectoryClassifier";
  79749. export * from "babylonjs/Misc/timer";
  79750. }
  79751. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79752. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79753. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79754. import { Observable } from "babylonjs/Misc/observable";
  79755. import { Matrix } from "babylonjs/Maths/math.vector";
  79756. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79757. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79758. /**
  79759. * An interface for all Hit test features
  79760. */
  79761. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79762. /**
  79763. * Triggered when new babylon (transformed) hit test results are available
  79764. */
  79765. onHitTestResultObservable: Observable<T[]>;
  79766. }
  79767. /**
  79768. * Options used for hit testing
  79769. */
  79770. export interface IWebXRLegacyHitTestOptions {
  79771. /**
  79772. * Only test when user interacted with the scene. Default - hit test every frame
  79773. */
  79774. testOnPointerDownOnly?: boolean;
  79775. /**
  79776. * The node to use to transform the local results to world coordinates
  79777. */
  79778. worldParentNode?: TransformNode;
  79779. }
  79780. /**
  79781. * Interface defining the babylon result of raycasting/hit-test
  79782. */
  79783. export interface IWebXRLegacyHitResult {
  79784. /**
  79785. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79786. */
  79787. transformationMatrix: Matrix;
  79788. /**
  79789. * The native hit test result
  79790. */
  79791. xrHitResult: XRHitResult | XRHitTestResult;
  79792. }
  79793. /**
  79794. * The currently-working hit-test module.
  79795. * Hit test (or Ray-casting) is used to interact with the real world.
  79796. * For further information read here - https://github.com/immersive-web/hit-test
  79797. */
  79798. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79799. /**
  79800. * options to use when constructing this feature
  79801. */
  79802. readonly options: IWebXRLegacyHitTestOptions;
  79803. private _direction;
  79804. private _mat;
  79805. private _onSelectEnabled;
  79806. private _origin;
  79807. /**
  79808. * The module's name
  79809. */
  79810. static readonly Name: string;
  79811. /**
  79812. * The (Babylon) version of this module.
  79813. * This is an integer representing the implementation version.
  79814. * This number does not correspond to the WebXR specs version
  79815. */
  79816. static readonly Version: number;
  79817. /**
  79818. * Populated with the last native XR Hit Results
  79819. */
  79820. lastNativeXRHitResults: XRHitResult[];
  79821. /**
  79822. * Triggered when new babylon (transformed) hit test results are available
  79823. */
  79824. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79825. /**
  79826. * Creates a new instance of the (legacy version) hit test feature
  79827. * @param _xrSessionManager an instance of WebXRSessionManager
  79828. * @param options options to use when constructing this feature
  79829. */
  79830. constructor(_xrSessionManager: WebXRSessionManager,
  79831. /**
  79832. * options to use when constructing this feature
  79833. */
  79834. options?: IWebXRLegacyHitTestOptions);
  79835. /**
  79836. * execute a hit test with an XR Ray
  79837. *
  79838. * @param xrSession a native xrSession that will execute this hit test
  79839. * @param xrRay the ray (position and direction) to use for ray-casting
  79840. * @param referenceSpace native XR reference space to use for the hit-test
  79841. * @param filter filter function that will filter the results
  79842. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79843. */
  79844. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79845. /**
  79846. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79847. * @param event the (select) event to use to select with
  79848. * @param referenceSpace the reference space to use for this hit test
  79849. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79850. */
  79851. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79852. /**
  79853. * attach this feature
  79854. * Will usually be called by the features manager
  79855. *
  79856. * @returns true if successful.
  79857. */
  79858. attach(): boolean;
  79859. /**
  79860. * detach this feature.
  79861. * Will usually be called by the features manager
  79862. *
  79863. * @returns true if successful.
  79864. */
  79865. detach(): boolean;
  79866. /**
  79867. * Dispose this feature and all of the resources attached
  79868. */
  79869. dispose(): void;
  79870. protected _onXRFrame(frame: XRFrame): void;
  79871. private _onHitTestResults;
  79872. private _onSelect;
  79873. }
  79874. }
  79875. declare module "babylonjs/XR/features/WebXRHitTest" {
  79876. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79877. import { Observable } from "babylonjs/Misc/observable";
  79878. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79879. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79880. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79881. /**
  79882. * Options used for hit testing (version 2)
  79883. */
  79884. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79885. /**
  79886. * Do not create a permanent hit test. Will usually be used when only
  79887. * transient inputs are needed.
  79888. */
  79889. disablePermanentHitTest?: boolean;
  79890. /**
  79891. * Enable transient (for example touch-based) hit test inspections
  79892. */
  79893. enableTransientHitTest?: boolean;
  79894. /**
  79895. * Offset ray for the permanent hit test
  79896. */
  79897. offsetRay?: Vector3;
  79898. /**
  79899. * Offset ray for the transient hit test
  79900. */
  79901. transientOffsetRay?: Vector3;
  79902. /**
  79903. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79904. */
  79905. useReferenceSpace?: boolean;
  79906. /**
  79907. * Override the default entity type(s) of the hit-test result
  79908. */
  79909. entityTypes?: XRHitTestTrackableType[];
  79910. }
  79911. /**
  79912. * Interface defining the babylon result of hit-test
  79913. */
  79914. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79915. /**
  79916. * The input source that generated this hit test (if transient)
  79917. */
  79918. inputSource?: XRInputSource;
  79919. /**
  79920. * Is this a transient hit test
  79921. */
  79922. isTransient?: boolean;
  79923. /**
  79924. * Position of the hit test result
  79925. */
  79926. position: Vector3;
  79927. /**
  79928. * Rotation of the hit test result
  79929. */
  79930. rotationQuaternion: Quaternion;
  79931. /**
  79932. * The native hit test result
  79933. */
  79934. xrHitResult: XRHitTestResult;
  79935. }
  79936. /**
  79937. * The currently-working hit-test module.
  79938. * Hit test (or Ray-casting) is used to interact with the real world.
  79939. * For further information read here - https://github.com/immersive-web/hit-test
  79940. *
  79941. * Tested on chrome (mobile) 80.
  79942. */
  79943. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79944. /**
  79945. * options to use when constructing this feature
  79946. */
  79947. readonly options: IWebXRHitTestOptions;
  79948. private _tmpMat;
  79949. private _tmpPos;
  79950. private _tmpQuat;
  79951. private _transientXrHitTestSource;
  79952. private _xrHitTestSource;
  79953. private initHitTestSource;
  79954. /**
  79955. * The module's name
  79956. */
  79957. static readonly Name: string;
  79958. /**
  79959. * The (Babylon) version of this module.
  79960. * This is an integer representing the implementation version.
  79961. * This number does not correspond to the WebXR specs version
  79962. */
  79963. static readonly Version: number;
  79964. /**
  79965. * When set to true, each hit test will have its own position/rotation objects
  79966. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79967. * the developers will clone them or copy them as they see fit.
  79968. */
  79969. autoCloneTransformation: boolean;
  79970. /**
  79971. * Triggered when new babylon (transformed) hit test results are available
  79972. * Note - this will be called when results come back from the device. It can be an empty array!!
  79973. */
  79974. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79975. /**
  79976. * Use this to temporarily pause hit test checks.
  79977. */
  79978. paused: boolean;
  79979. /**
  79980. * Creates a new instance of the hit test feature
  79981. * @param _xrSessionManager an instance of WebXRSessionManager
  79982. * @param options options to use when constructing this feature
  79983. */
  79984. constructor(_xrSessionManager: WebXRSessionManager,
  79985. /**
  79986. * options to use when constructing this feature
  79987. */
  79988. options?: IWebXRHitTestOptions);
  79989. /**
  79990. * attach this feature
  79991. * Will usually be called by the features manager
  79992. *
  79993. * @returns true if successful.
  79994. */
  79995. attach(): boolean;
  79996. /**
  79997. * detach this feature.
  79998. * Will usually be called by the features manager
  79999. *
  80000. * @returns true if successful.
  80001. */
  80002. detach(): boolean;
  80003. /**
  80004. * Dispose this feature and all of the resources attached
  80005. */
  80006. dispose(): void;
  80007. protected _onXRFrame(frame: XRFrame): void;
  80008. private _processWebXRHitTestResult;
  80009. }
  80010. }
  80011. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  80012. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80013. import { Observable } from "babylonjs/Misc/observable";
  80014. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  80015. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80016. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80017. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  80018. /**
  80019. * Configuration options of the anchor system
  80020. */
  80021. export interface IWebXRAnchorSystemOptions {
  80022. /**
  80023. * a node that will be used to convert local to world coordinates
  80024. */
  80025. worldParentNode?: TransformNode;
  80026. /**
  80027. * If set to true a reference of the created anchors will be kept until the next session starts
  80028. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  80029. */
  80030. doNotRemoveAnchorsOnSessionEnded?: boolean;
  80031. }
  80032. /**
  80033. * A babylon container for an XR Anchor
  80034. */
  80035. export interface IWebXRAnchor {
  80036. /**
  80037. * A babylon-assigned ID for this anchor
  80038. */
  80039. id: number;
  80040. /**
  80041. * Transformation matrix to apply to an object attached to this anchor
  80042. */
  80043. transformationMatrix: Matrix;
  80044. /**
  80045. * The native anchor object
  80046. */
  80047. xrAnchor: XRAnchor;
  80048. /**
  80049. * if defined, this object will be constantly updated by the anchor's position and rotation
  80050. */
  80051. attachedNode?: TransformNode;
  80052. }
  80053. /**
  80054. * An implementation of the anchor system for WebXR.
  80055. * For further information see https://github.com/immersive-web/anchors/
  80056. */
  80057. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  80058. private _options;
  80059. private _lastFrameDetected;
  80060. private _trackedAnchors;
  80061. private _referenceSpaceForFrameAnchors;
  80062. private _futureAnchors;
  80063. /**
  80064. * The module's name
  80065. */
  80066. static readonly Name: string;
  80067. /**
  80068. * The (Babylon) version of this module.
  80069. * This is an integer representing the implementation version.
  80070. * This number does not correspond to the WebXR specs version
  80071. */
  80072. static readonly Version: number;
  80073. /**
  80074. * Observers registered here will be executed when a new anchor was added to the session
  80075. */
  80076. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  80077. /**
  80078. * Observers registered here will be executed when an anchor was removed from the session
  80079. */
  80080. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  80081. /**
  80082. * Observers registered here will be executed when an existing anchor updates
  80083. * This can execute N times every frame
  80084. */
  80085. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  80086. /**
  80087. * Set the reference space to use for anchor creation, when not using a hit test.
  80088. * Will default to the session's reference space if not defined
  80089. */
  80090. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  80091. /**
  80092. * constructs a new anchor system
  80093. * @param _xrSessionManager an instance of WebXRSessionManager
  80094. * @param _options configuration object for this feature
  80095. */
  80096. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  80097. private _tmpVector;
  80098. private _tmpQuaternion;
  80099. private _populateTmpTransformation;
  80100. /**
  80101. * Create a new anchor point using a hit test result at a specific point in the scene
  80102. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80103. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80104. *
  80105. * @param hitTestResult The hit test result to use for this anchor creation
  80106. * @param position an optional position offset for this anchor
  80107. * @param rotationQuaternion an optional rotation offset for this anchor
  80108. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  80109. */
  80110. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  80111. /**
  80112. * Add a new anchor at a specific position and rotation
  80113. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  80114. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  80115. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  80116. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  80117. *
  80118. * @param position the position in which to add an anchor
  80119. * @param rotationQuaternion an optional rotation for the anchor transformation
  80120. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  80121. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  80122. */
  80123. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  80124. /**
  80125. * detach this feature.
  80126. * Will usually be called by the features manager
  80127. *
  80128. * @returns true if successful.
  80129. */
  80130. detach(): boolean;
  80131. /**
  80132. * Dispose this feature and all of the resources attached
  80133. */
  80134. dispose(): void;
  80135. protected _onXRFrame(frame: XRFrame): void;
  80136. /**
  80137. * avoiding using Array.find for global support.
  80138. * @param xrAnchor the plane to find in the array
  80139. */
  80140. private _findIndexInAnchorArray;
  80141. private _updateAnchorWithXRFrame;
  80142. private _createAnchorAtTransformation;
  80143. }
  80144. }
  80145. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  80146. import { TransformNode } from "babylonjs/Meshes/transformNode";
  80147. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80148. import { Observable } from "babylonjs/Misc/observable";
  80149. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  80150. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80151. /**
  80152. * Options used in the plane detector module
  80153. */
  80154. export interface IWebXRPlaneDetectorOptions {
  80155. /**
  80156. * The node to use to transform the local results to world coordinates
  80157. */
  80158. worldParentNode?: TransformNode;
  80159. /**
  80160. * If set to true a reference of the created planes will be kept until the next session starts
  80161. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  80162. */
  80163. doNotRemovePlanesOnSessionEnded?: boolean;
  80164. }
  80165. /**
  80166. * A babylon interface for a WebXR plane.
  80167. * A Plane is actually a polygon, built from N points in space
  80168. *
  80169. * Supported in chrome 79, not supported in canary 81 ATM
  80170. */
  80171. export interface IWebXRPlane {
  80172. /**
  80173. * a babylon-assigned ID for this polygon
  80174. */
  80175. id: number;
  80176. /**
  80177. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  80178. */
  80179. polygonDefinition: Array<Vector3>;
  80180. /**
  80181. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  80182. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  80183. */
  80184. transformationMatrix: Matrix;
  80185. /**
  80186. * the native xr-plane object
  80187. */
  80188. xrPlane: XRPlane;
  80189. }
  80190. /**
  80191. * The plane detector is used to detect planes in the real world when in AR
  80192. * For more information see https://github.com/immersive-web/real-world-geometry/
  80193. */
  80194. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  80195. private _options;
  80196. private _detectedPlanes;
  80197. private _enabled;
  80198. private _lastFrameDetected;
  80199. /**
  80200. * The module's name
  80201. */
  80202. static readonly Name: string;
  80203. /**
  80204. * The (Babylon) version of this module.
  80205. * This is an integer representing the implementation version.
  80206. * This number does not correspond to the WebXR specs version
  80207. */
  80208. static readonly Version: number;
  80209. /**
  80210. * Observers registered here will be executed when a new plane was added to the session
  80211. */
  80212. onPlaneAddedObservable: Observable<IWebXRPlane>;
  80213. /**
  80214. * Observers registered here will be executed when a plane is no longer detected in the session
  80215. */
  80216. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  80217. /**
  80218. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  80219. * This can execute N times every frame
  80220. */
  80221. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  80222. /**
  80223. * construct a new Plane Detector
  80224. * @param _xrSessionManager an instance of xr Session manager
  80225. * @param _options configuration to use when constructing this feature
  80226. */
  80227. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  80228. /**
  80229. * detach this feature.
  80230. * Will usually be called by the features manager
  80231. *
  80232. * @returns true if successful.
  80233. */
  80234. detach(): boolean;
  80235. /**
  80236. * Dispose this feature and all of the resources attached
  80237. */
  80238. dispose(): void;
  80239. protected _onXRFrame(frame: XRFrame): void;
  80240. private _init;
  80241. private _updatePlaneWithXRPlane;
  80242. /**
  80243. * avoiding using Array.find for global support.
  80244. * @param xrPlane the plane to find in the array
  80245. */
  80246. private findIndexInPlaneArray;
  80247. }
  80248. }
  80249. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  80250. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80252. import { Observable } from "babylonjs/Misc/observable";
  80253. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80254. /**
  80255. * Options interface for the background remover plugin
  80256. */
  80257. export interface IWebXRBackgroundRemoverOptions {
  80258. /**
  80259. * Further background meshes to disable when entering AR
  80260. */
  80261. backgroundMeshes?: AbstractMesh[];
  80262. /**
  80263. * flags to configure the removal of the environment helper.
  80264. * If not set, the entire background will be removed. If set, flags should be set as well.
  80265. */
  80266. environmentHelperRemovalFlags?: {
  80267. /**
  80268. * Should the skybox be removed (default false)
  80269. */
  80270. skyBox?: boolean;
  80271. /**
  80272. * Should the ground be removed (default false)
  80273. */
  80274. ground?: boolean;
  80275. };
  80276. /**
  80277. * don't disable the environment helper
  80278. */
  80279. ignoreEnvironmentHelper?: boolean;
  80280. }
  80281. /**
  80282. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  80283. */
  80284. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  80285. /**
  80286. * read-only options to be used in this module
  80287. */
  80288. readonly options: IWebXRBackgroundRemoverOptions;
  80289. /**
  80290. * The module's name
  80291. */
  80292. static readonly Name: string;
  80293. /**
  80294. * The (Babylon) version of this module.
  80295. * This is an integer representing the implementation version.
  80296. * This number does not correspond to the WebXR specs version
  80297. */
  80298. static readonly Version: number;
  80299. /**
  80300. * registered observers will be triggered when the background state changes
  80301. */
  80302. onBackgroundStateChangedObservable: Observable<boolean>;
  80303. /**
  80304. * constructs a new background remover module
  80305. * @param _xrSessionManager the session manager for this module
  80306. * @param options read-only options to be used in this module
  80307. */
  80308. constructor(_xrSessionManager: WebXRSessionManager,
  80309. /**
  80310. * read-only options to be used in this module
  80311. */
  80312. options?: IWebXRBackgroundRemoverOptions);
  80313. /**
  80314. * attach this feature
  80315. * Will usually be called by the features manager
  80316. *
  80317. * @returns true if successful.
  80318. */
  80319. attach(): boolean;
  80320. /**
  80321. * detach this feature.
  80322. * Will usually be called by the features manager
  80323. *
  80324. * @returns true if successful.
  80325. */
  80326. detach(): boolean;
  80327. /**
  80328. * Dispose this feature and all of the resources attached
  80329. */
  80330. dispose(): void;
  80331. protected _onXRFrame(_xrFrame: XRFrame): void;
  80332. private _setBackgroundState;
  80333. }
  80334. }
  80335. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  80336. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80337. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80338. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  80339. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80340. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80341. import { Nullable } from "babylonjs/types";
  80342. /**
  80343. * Options for the controller physics feature
  80344. */
  80345. export class IWebXRControllerPhysicsOptions {
  80346. /**
  80347. * Should the headset get its own impostor
  80348. */
  80349. enableHeadsetImpostor?: boolean;
  80350. /**
  80351. * Optional parameters for the headset impostor
  80352. */
  80353. headsetImpostorParams?: {
  80354. /**
  80355. * The type of impostor to create. Default is sphere
  80356. */
  80357. impostorType: number;
  80358. /**
  80359. * the size of the impostor. Defaults to 10cm
  80360. */
  80361. impostorSize?: number | {
  80362. width: number;
  80363. height: number;
  80364. depth: number;
  80365. };
  80366. /**
  80367. * Friction definitions
  80368. */
  80369. friction?: number;
  80370. /**
  80371. * Restitution
  80372. */
  80373. restitution?: number;
  80374. };
  80375. /**
  80376. * The physics properties of the future impostors
  80377. */
  80378. physicsProperties?: {
  80379. /**
  80380. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  80381. * Note that this requires a physics engine that supports mesh impostors!
  80382. */
  80383. useControllerMesh?: boolean;
  80384. /**
  80385. * The type of impostor to create. Default is sphere
  80386. */
  80387. impostorType?: number;
  80388. /**
  80389. * the size of the impostor. Defaults to 10cm
  80390. */
  80391. impostorSize?: number | {
  80392. width: number;
  80393. height: number;
  80394. depth: number;
  80395. };
  80396. /**
  80397. * Friction definitions
  80398. */
  80399. friction?: number;
  80400. /**
  80401. * Restitution
  80402. */
  80403. restitution?: number;
  80404. };
  80405. /**
  80406. * the xr input to use with this pointer selection
  80407. */
  80408. xrInput: WebXRInput;
  80409. }
  80410. /**
  80411. * Add physics impostor to your webxr controllers,
  80412. * including naive calculation of their linear and angular velocity
  80413. */
  80414. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  80415. private readonly _options;
  80416. private _attachController;
  80417. private _controllers;
  80418. private _debugMode;
  80419. private _delta;
  80420. private _headsetImpostor?;
  80421. private _headsetMesh?;
  80422. private _lastTimestamp;
  80423. private _tmpQuaternion;
  80424. private _tmpVector;
  80425. /**
  80426. * The module's name
  80427. */
  80428. static readonly Name: string;
  80429. /**
  80430. * The (Babylon) version of this module.
  80431. * This is an integer representing the implementation version.
  80432. * This number does not correspond to the webxr specs version
  80433. */
  80434. static readonly Version: number;
  80435. /**
  80436. * Construct a new Controller Physics Feature
  80437. * @param _xrSessionManager the corresponding xr session manager
  80438. * @param _options options to create this feature with
  80439. */
  80440. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  80441. /**
  80442. * @hidden
  80443. * enable debugging - will show console outputs and the impostor mesh
  80444. */
  80445. _enablePhysicsDebug(): void;
  80446. /**
  80447. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  80448. * @param xrController the controller to add
  80449. */
  80450. addController(xrController: WebXRInputSource): void;
  80451. /**
  80452. * attach this feature
  80453. * Will usually be called by the features manager
  80454. *
  80455. * @returns true if successful.
  80456. */
  80457. attach(): boolean;
  80458. /**
  80459. * detach this feature.
  80460. * Will usually be called by the features manager
  80461. *
  80462. * @returns true if successful.
  80463. */
  80464. detach(): boolean;
  80465. /**
  80466. * Get the headset impostor, if enabled
  80467. * @returns the impostor
  80468. */
  80469. getHeadsetImpostor(): PhysicsImpostor | undefined;
  80470. /**
  80471. * Get the physics impostor of a specific controller.
  80472. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  80473. * @param controller the controller or the controller id of which to get the impostor
  80474. * @returns the impostor or null
  80475. */
  80476. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  80477. /**
  80478. * Update the physics properties provided in the constructor
  80479. * @param newProperties the new properties object
  80480. */
  80481. setPhysicsProperties(newProperties: {
  80482. impostorType?: number;
  80483. impostorSize?: number | {
  80484. width: number;
  80485. height: number;
  80486. depth: number;
  80487. };
  80488. friction?: number;
  80489. restitution?: number;
  80490. }): void;
  80491. protected _onXRFrame(_xrFrame: any): void;
  80492. private _detachController;
  80493. }
  80494. }
  80495. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  80496. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80497. import { Observable } from "babylonjs/Misc/observable";
  80498. import { Vector3 } from "babylonjs/Maths/math.vector";
  80499. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80500. /**
  80501. * A babylon interface for a "WebXR" feature point.
  80502. * Represents the position and confidence value of a given feature point.
  80503. */
  80504. export interface IWebXRFeaturePoint {
  80505. /**
  80506. * Represents the position of the feature point in world space.
  80507. */
  80508. position: Vector3;
  80509. /**
  80510. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  80511. */
  80512. confidenceValue: number;
  80513. }
  80514. /**
  80515. * The feature point system is used to detect feature points from real world geometry.
  80516. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  80517. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  80518. */
  80519. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  80520. private _enabled;
  80521. private _featurePointCloud;
  80522. /**
  80523. * The module's name
  80524. */
  80525. static readonly Name: string;
  80526. /**
  80527. * The (Babylon) version of this module.
  80528. * This is an integer representing the implementation version.
  80529. * This number does not correspond to the WebXR specs version
  80530. */
  80531. static readonly Version: number;
  80532. /**
  80533. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  80534. * Will notify the observers about which feature points have been added.
  80535. */
  80536. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  80537. /**
  80538. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  80539. * Will notify the observers about which feature points have been updated.
  80540. */
  80541. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  80542. /**
  80543. * The current feature point cloud maintained across frames.
  80544. */
  80545. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  80546. /**
  80547. * construct the feature point system
  80548. * @param _xrSessionManager an instance of xr Session manager
  80549. */
  80550. constructor(_xrSessionManager: WebXRSessionManager);
  80551. /**
  80552. * Detach this feature.
  80553. * Will usually be called by the features manager
  80554. *
  80555. * @returns true if successful.
  80556. */
  80557. detach(): boolean;
  80558. /**
  80559. * Dispose this feature and all of the resources attached
  80560. */
  80561. dispose(): void;
  80562. /**
  80563. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  80564. */
  80565. protected _onXRFrame(frame: XRFrame): void;
  80566. /**
  80567. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  80568. */
  80569. private _init;
  80570. }
  80571. }
  80572. declare module "babylonjs/XR/features/WebXRHandTracking" {
  80573. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  80574. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  80575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80576. import { Mesh } from "babylonjs/Meshes/mesh";
  80577. import { WebXRInput } from "babylonjs/XR/webXRInput";
  80578. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  80579. import { Nullable } from "babylonjs/types";
  80580. import { IDisposable } from "babylonjs/scene";
  80581. import { Observable } from "babylonjs/Misc/observable";
  80582. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  80583. /**
  80584. * Configuration interface for the hand tracking feature
  80585. */
  80586. export interface IWebXRHandTrackingOptions {
  80587. /**
  80588. * The xrInput that will be used as source for new hands
  80589. */
  80590. xrInput: WebXRInput;
  80591. /**
  80592. * Configuration object for the joint meshes
  80593. */
  80594. jointMeshes?: {
  80595. /**
  80596. * Should the meshes created be invisible (defaults to false)
  80597. */
  80598. invisible?: boolean;
  80599. /**
  80600. * A source mesh to be used to create instances. Defaults to a sphere.
  80601. * This mesh will be the source for all other (25) meshes.
  80602. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  80603. */
  80604. sourceMesh?: Mesh;
  80605. /**
  80606. * This function will be called after a mesh was created for a specific joint.
  80607. * Using this function you can either manipulate the instance or return a new mesh.
  80608. * When returning a new mesh the instance created before will be disposed
  80609. */
  80610. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  80611. /**
  80612. * Should the source mesh stay visible. Defaults to false
  80613. */
  80614. keepOriginalVisible?: boolean;
  80615. /**
  80616. * Scale factor for all instances (defaults to 2)
  80617. */
  80618. scaleFactor?: number;
  80619. /**
  80620. * Should each instance have its own physics impostor
  80621. */
  80622. enablePhysics?: boolean;
  80623. /**
  80624. * If enabled, override default physics properties
  80625. */
  80626. physicsProps?: {
  80627. friction?: number;
  80628. restitution?: number;
  80629. impostorType?: number;
  80630. };
  80631. /**
  80632. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  80633. */
  80634. handMesh?: AbstractMesh;
  80635. };
  80636. }
  80637. /**
  80638. * Parts of the hands divided to writs and finger names
  80639. */
  80640. export const enum HandPart {
  80641. /**
  80642. * HandPart - Wrist
  80643. */
  80644. WRIST = "wrist",
  80645. /**
  80646. * HandPart - The THumb
  80647. */
  80648. THUMB = "thumb",
  80649. /**
  80650. * HandPart - Index finger
  80651. */
  80652. INDEX = "index",
  80653. /**
  80654. * HandPart - Middle finger
  80655. */
  80656. MIDDLE = "middle",
  80657. /**
  80658. * HandPart - Ring finger
  80659. */
  80660. RING = "ring",
  80661. /**
  80662. * HandPart - Little finger
  80663. */
  80664. LITTLE = "little"
  80665. }
  80666. /**
  80667. * Representing a single hand (with its corresponding native XRHand object)
  80668. */
  80669. export class WebXRHand implements IDisposable {
  80670. /** the controller to which the hand correlates */
  80671. readonly xrController: WebXRInputSource;
  80672. /** the meshes to be used to track the hand joints */
  80673. readonly trackedMeshes: AbstractMesh[];
  80674. /**
  80675. * Hand-parts definition (key is HandPart)
  80676. */
  80677. handPartsDefinition: {
  80678. [key: string]: number[];
  80679. };
  80680. /**
  80681. * Populate the HandPartsDefinition object.
  80682. * This is called as a side effect since certain browsers don't have XRHand defined.
  80683. */
  80684. private generateHandPartsDefinition;
  80685. /**
  80686. * Construct a new hand object
  80687. * @param xrController the controller to which the hand correlates
  80688. * @param trackedMeshes the meshes to be used to track the hand joints
  80689. */
  80690. constructor(
  80691. /** the controller to which the hand correlates */
  80692. xrController: WebXRInputSource,
  80693. /** the meshes to be used to track the hand joints */
  80694. trackedMeshes: AbstractMesh[]);
  80695. /**
  80696. * Update this hand from the latest xr frame
  80697. * @param xrFrame xrFrame to update from
  80698. * @param referenceSpace The current viewer reference space
  80699. * @param scaleFactor optional scale factor for the meshes
  80700. */
  80701. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80702. /**
  80703. * Get meshes of part of the hand
  80704. * @param part the part of hand to get
  80705. * @returns An array of meshes that correlate to the hand part requested
  80706. */
  80707. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80708. /**
  80709. * Dispose this Hand object
  80710. */
  80711. dispose(): void;
  80712. }
  80713. /**
  80714. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80715. */
  80716. export class WebXRHandTracking extends WebXRAbstractFeature {
  80717. /**
  80718. * options to use when constructing this feature
  80719. */
  80720. readonly options: IWebXRHandTrackingOptions;
  80721. private static _idCounter;
  80722. /**
  80723. * The module's name
  80724. */
  80725. static readonly Name: string;
  80726. /**
  80727. * The (Babylon) version of this module.
  80728. * This is an integer representing the implementation version.
  80729. * This number does not correspond to the WebXR specs version
  80730. */
  80731. static readonly Version: number;
  80732. /**
  80733. * This observable will notify registered observers when a new hand object was added and initialized
  80734. */
  80735. onHandAddedObservable: Observable<WebXRHand>;
  80736. /**
  80737. * This observable will notify its observers right before the hand object is disposed
  80738. */
  80739. onHandRemovedObservable: Observable<WebXRHand>;
  80740. private _hands;
  80741. /**
  80742. * Creates a new instance of the hit test feature
  80743. * @param _xrSessionManager an instance of WebXRSessionManager
  80744. * @param options options to use when constructing this feature
  80745. */
  80746. constructor(_xrSessionManager: WebXRSessionManager,
  80747. /**
  80748. * options to use when constructing this feature
  80749. */
  80750. options: IWebXRHandTrackingOptions);
  80751. /**
  80752. * Check if the needed objects are defined.
  80753. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80754. */
  80755. isCompatible(): boolean;
  80756. /**
  80757. * attach this feature
  80758. * Will usually be called by the features manager
  80759. *
  80760. * @returns true if successful.
  80761. */
  80762. attach(): boolean;
  80763. /**
  80764. * detach this feature.
  80765. * Will usually be called by the features manager
  80766. *
  80767. * @returns true if successful.
  80768. */
  80769. detach(): boolean;
  80770. /**
  80771. * Dispose this feature and all of the resources attached
  80772. */
  80773. dispose(): void;
  80774. /**
  80775. * Get the hand object according to the controller id
  80776. * @param controllerId the controller id to which we want to get the hand
  80777. * @returns null if not found or the WebXRHand object if found
  80778. */
  80779. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80780. /**
  80781. * Get a hand object according to the requested handedness
  80782. * @param handedness the handedness to request
  80783. * @returns null if not found or the WebXRHand object if found
  80784. */
  80785. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80786. protected _onXRFrame(_xrFrame: XRFrame): void;
  80787. private _attachHand;
  80788. private _detachHand;
  80789. }
  80790. }
  80791. declare module "babylonjs/XR/features/index" {
  80792. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80793. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80794. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80795. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80796. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80797. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80798. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80799. export * from "babylonjs/XR/features/WebXRHitTest";
  80800. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80801. export * from "babylonjs/XR/features/WebXRHandTracking";
  80802. }
  80803. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80804. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80805. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80806. import { Scene } from "babylonjs/scene";
  80807. /**
  80808. * The motion controller class for all microsoft mixed reality controllers
  80809. */
  80810. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80811. protected readonly _mapping: {
  80812. defaultButton: {
  80813. valueNodeName: string;
  80814. unpressedNodeName: string;
  80815. pressedNodeName: string;
  80816. };
  80817. defaultAxis: {
  80818. valueNodeName: string;
  80819. minNodeName: string;
  80820. maxNodeName: string;
  80821. };
  80822. buttons: {
  80823. "xr-standard-trigger": {
  80824. rootNodeName: string;
  80825. componentProperty: string;
  80826. states: string[];
  80827. };
  80828. "xr-standard-squeeze": {
  80829. rootNodeName: string;
  80830. componentProperty: string;
  80831. states: string[];
  80832. };
  80833. "xr-standard-touchpad": {
  80834. rootNodeName: string;
  80835. labelAnchorNodeName: string;
  80836. touchPointNodeName: string;
  80837. };
  80838. "xr-standard-thumbstick": {
  80839. rootNodeName: string;
  80840. componentProperty: string;
  80841. states: string[];
  80842. };
  80843. };
  80844. axes: {
  80845. "xr-standard-touchpad": {
  80846. "x-axis": {
  80847. rootNodeName: string;
  80848. };
  80849. "y-axis": {
  80850. rootNodeName: string;
  80851. };
  80852. };
  80853. "xr-standard-thumbstick": {
  80854. "x-axis": {
  80855. rootNodeName: string;
  80856. };
  80857. "y-axis": {
  80858. rootNodeName: string;
  80859. };
  80860. };
  80861. };
  80862. };
  80863. /**
  80864. * The base url used to load the left and right controller models
  80865. */
  80866. static MODEL_BASE_URL: string;
  80867. /**
  80868. * The name of the left controller model file
  80869. */
  80870. static MODEL_LEFT_FILENAME: string;
  80871. /**
  80872. * The name of the right controller model file
  80873. */
  80874. static MODEL_RIGHT_FILENAME: string;
  80875. profileId: string;
  80876. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80877. protected _getFilenameAndPath(): {
  80878. filename: string;
  80879. path: string;
  80880. };
  80881. protected _getModelLoadingConstraints(): boolean;
  80882. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80883. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80884. protected _updateModel(): void;
  80885. }
  80886. }
  80887. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80888. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80890. import { Scene } from "babylonjs/scene";
  80891. /**
  80892. * The motion controller class for oculus touch (quest, rift).
  80893. * This class supports legacy mapping as well the standard xr mapping
  80894. */
  80895. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80896. private _forceLegacyControllers;
  80897. private _modelRootNode;
  80898. /**
  80899. * The base url used to load the left and right controller models
  80900. */
  80901. static MODEL_BASE_URL: string;
  80902. /**
  80903. * The name of the left controller model file
  80904. */
  80905. static MODEL_LEFT_FILENAME: string;
  80906. /**
  80907. * The name of the right controller model file
  80908. */
  80909. static MODEL_RIGHT_FILENAME: string;
  80910. /**
  80911. * Base Url for the Quest controller model.
  80912. */
  80913. static QUEST_MODEL_BASE_URL: string;
  80914. profileId: string;
  80915. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80916. protected _getFilenameAndPath(): {
  80917. filename: string;
  80918. path: string;
  80919. };
  80920. protected _getModelLoadingConstraints(): boolean;
  80921. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80922. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80923. protected _updateModel(): void;
  80924. /**
  80925. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80926. * between the touch and touch 2.
  80927. */
  80928. private _isQuest;
  80929. }
  80930. }
  80931. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80932. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80933. import { Scene } from "babylonjs/scene";
  80934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80935. /**
  80936. * The motion controller class for the standard HTC-Vive controllers
  80937. */
  80938. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80939. private _modelRootNode;
  80940. /**
  80941. * The base url used to load the left and right controller models
  80942. */
  80943. static MODEL_BASE_URL: string;
  80944. /**
  80945. * File name for the controller model.
  80946. */
  80947. static MODEL_FILENAME: string;
  80948. profileId: string;
  80949. /**
  80950. * Create a new Vive motion controller object
  80951. * @param scene the scene to use to create this controller
  80952. * @param gamepadObject the corresponding gamepad object
  80953. * @param handedness the handedness of the controller
  80954. */
  80955. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80956. protected _getFilenameAndPath(): {
  80957. filename: string;
  80958. path: string;
  80959. };
  80960. protected _getModelLoadingConstraints(): boolean;
  80961. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80962. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80963. protected _updateModel(): void;
  80964. }
  80965. }
  80966. declare module "babylonjs/XR/motionController/index" {
  80967. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80968. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80969. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80970. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80971. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80972. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80973. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80974. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80975. }
  80976. declare module "babylonjs/XR/index" {
  80977. export * from "babylonjs/XR/webXRCamera";
  80978. export * from "babylonjs/XR/webXREnterExitUI";
  80979. export * from "babylonjs/XR/webXRExperienceHelper";
  80980. export * from "babylonjs/XR/webXRInput";
  80981. export * from "babylonjs/XR/webXRInputSource";
  80982. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80983. export * from "babylonjs/XR/webXRTypes";
  80984. export * from "babylonjs/XR/webXRSessionManager";
  80985. export * from "babylonjs/XR/webXRDefaultExperience";
  80986. export * from "babylonjs/XR/webXRFeaturesManager";
  80987. export * from "babylonjs/XR/features/index";
  80988. export * from "babylonjs/XR/motionController/index";
  80989. }
  80990. declare module "babylonjs/index" {
  80991. export * from "babylonjs/abstractScene";
  80992. export * from "babylonjs/Actions/index";
  80993. export * from "babylonjs/Animations/index";
  80994. export * from "babylonjs/assetContainer";
  80995. export * from "babylonjs/Audio/index";
  80996. export * from "babylonjs/Behaviors/index";
  80997. export * from "babylonjs/Bones/index";
  80998. export * from "babylonjs/Cameras/index";
  80999. export * from "babylonjs/Collisions/index";
  81000. export * from "babylonjs/Culling/index";
  81001. export * from "babylonjs/Debug/index";
  81002. export * from "babylonjs/DeviceInput/index";
  81003. export * from "babylonjs/Engines/index";
  81004. export * from "babylonjs/Events/index";
  81005. export * from "babylonjs/Gamepads/index";
  81006. export * from "babylonjs/Gizmos/index";
  81007. export * from "babylonjs/Helpers/index";
  81008. export * from "babylonjs/Instrumentation/index";
  81009. export * from "babylonjs/Layers/index";
  81010. export * from "babylonjs/LensFlares/index";
  81011. export * from "babylonjs/Lights/index";
  81012. export * from "babylonjs/Loading/index";
  81013. export * from "babylonjs/Materials/index";
  81014. export * from "babylonjs/Maths/index";
  81015. export * from "babylonjs/Meshes/index";
  81016. export * from "babylonjs/Morph/index";
  81017. export * from "babylonjs/Navigation/index";
  81018. export * from "babylonjs/node";
  81019. export * from "babylonjs/Offline/index";
  81020. export * from "babylonjs/Particles/index";
  81021. export * from "babylonjs/Physics/index";
  81022. export * from "babylonjs/PostProcesses/index";
  81023. export * from "babylonjs/Probes/index";
  81024. export * from "babylonjs/Rendering/index";
  81025. export * from "babylonjs/scene";
  81026. export * from "babylonjs/sceneComponent";
  81027. export * from "babylonjs/Sprites/index";
  81028. export * from "babylonjs/States/index";
  81029. export * from "babylonjs/Misc/index";
  81030. export * from "babylonjs/XR/index";
  81031. export * from "babylonjs/types";
  81032. }
  81033. declare module "babylonjs/Animations/pathCursor" {
  81034. import { Vector3 } from "babylonjs/Maths/math.vector";
  81035. import { Path2 } from "babylonjs/Maths/math.path";
  81036. /**
  81037. * A cursor which tracks a point on a path
  81038. */
  81039. export class PathCursor {
  81040. private path;
  81041. /**
  81042. * Stores path cursor callbacks for when an onchange event is triggered
  81043. */
  81044. private _onchange;
  81045. /**
  81046. * The value of the path cursor
  81047. */
  81048. value: number;
  81049. /**
  81050. * The animation array of the path cursor
  81051. */
  81052. animations: Animation[];
  81053. /**
  81054. * Initializes the path cursor
  81055. * @param path The path to track
  81056. */
  81057. constructor(path: Path2);
  81058. /**
  81059. * Gets the cursor point on the path
  81060. * @returns A point on the path cursor at the cursor location
  81061. */
  81062. getPoint(): Vector3;
  81063. /**
  81064. * Moves the cursor ahead by the step amount
  81065. * @param step The amount to move the cursor forward
  81066. * @returns This path cursor
  81067. */
  81068. moveAhead(step?: number): PathCursor;
  81069. /**
  81070. * Moves the cursor behind by the step amount
  81071. * @param step The amount to move the cursor back
  81072. * @returns This path cursor
  81073. */
  81074. moveBack(step?: number): PathCursor;
  81075. /**
  81076. * Moves the cursor by the step amount
  81077. * If the step amount is greater than one, an exception is thrown
  81078. * @param step The amount to move the cursor
  81079. * @returns This path cursor
  81080. */
  81081. move(step: number): PathCursor;
  81082. /**
  81083. * Ensures that the value is limited between zero and one
  81084. * @returns This path cursor
  81085. */
  81086. private ensureLimits;
  81087. /**
  81088. * Runs onchange callbacks on change (used by the animation engine)
  81089. * @returns This path cursor
  81090. */
  81091. private raiseOnChange;
  81092. /**
  81093. * Executes a function on change
  81094. * @param f A path cursor onchange callback
  81095. * @returns This path cursor
  81096. */
  81097. onchange(f: (cursor: PathCursor) => void): PathCursor;
  81098. }
  81099. }
  81100. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  81101. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  81102. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  81103. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  81104. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  81105. }
  81106. declare module "babylonjs/Engines/Processors/Expressions/index" {
  81107. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  81108. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  81109. }
  81110. declare module "babylonjs/Engines/Processors/index" {
  81111. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  81112. export * from "babylonjs/Engines/Processors/Expressions/index";
  81113. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  81114. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  81115. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  81116. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  81117. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  81118. export * from "babylonjs/Engines/Processors/shaderProcessor";
  81119. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  81120. }
  81121. declare module "babylonjs/Legacy/legacy" {
  81122. import * as Babylon from "babylonjs/index";
  81123. export * from "babylonjs/index";
  81124. }
  81125. declare module "babylonjs/Shaders/blur.fragment" {
  81126. /** @hidden */
  81127. export var blurPixelShader: {
  81128. name: string;
  81129. shader: string;
  81130. };
  81131. }
  81132. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  81133. /** @hidden */
  81134. export var pointCloudVertexDeclaration: {
  81135. name: string;
  81136. shader: string;
  81137. };
  81138. }
  81139. declare module "babylonjs" {
  81140. export * from "babylonjs/Legacy/legacy";
  81141. }
  81142. declare module BABYLON {
  81143. /** Alias type for value that can be null */
  81144. export type Nullable<T> = T | null;
  81145. /**
  81146. * Alias type for number that are floats
  81147. * @ignorenaming
  81148. */
  81149. export type float = number;
  81150. /**
  81151. * Alias type for number that are doubles.
  81152. * @ignorenaming
  81153. */
  81154. export type double = number;
  81155. /**
  81156. * Alias type for number that are integer
  81157. * @ignorenaming
  81158. */
  81159. export type int = number;
  81160. /** Alias type for number array or Float32Array */
  81161. export type FloatArray = number[] | Float32Array;
  81162. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  81163. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  81164. /**
  81165. * Alias for types that can be used by a Buffer or VertexBuffer.
  81166. */
  81167. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  81168. /**
  81169. * Alias type for primitive types
  81170. * @ignorenaming
  81171. */
  81172. type Primitive = undefined | null | boolean | string | number | Function;
  81173. /**
  81174. * Type modifier to make all the properties of an object Readonly
  81175. */
  81176. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  81177. /**
  81178. * Type modifier to make all the properties of an object Readonly recursively
  81179. */
  81180. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  81181. /**
  81182. * Type modifier to make object properties readonly.
  81183. */
  81184. export type DeepImmutableObject<T> = {
  81185. readonly [K in keyof T]: DeepImmutable<T[K]>;
  81186. };
  81187. /** @hidden */
  81188. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  81189. }
  81190. }
  81191. declare module BABYLON {
  81192. /**
  81193. * A class serves as a medium between the observable and its observers
  81194. */
  81195. export class EventState {
  81196. /**
  81197. * Create a new EventState
  81198. * @param mask defines the mask associated with this state
  81199. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81200. * @param target defines the original target of the state
  81201. * @param currentTarget defines the current target of the state
  81202. */
  81203. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  81204. /**
  81205. * Initialize the current event state
  81206. * @param mask defines the mask associated with this state
  81207. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  81208. * @param target defines the original target of the state
  81209. * @param currentTarget defines the current target of the state
  81210. * @returns the current event state
  81211. */
  81212. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  81213. /**
  81214. * An Observer can set this property to true to prevent subsequent observers of being notified
  81215. */
  81216. skipNextObservers: boolean;
  81217. /**
  81218. * Get the mask value that were used to trigger the event corresponding to this EventState object
  81219. */
  81220. mask: number;
  81221. /**
  81222. * The object that originally notified the event
  81223. */
  81224. target?: any;
  81225. /**
  81226. * The current object in the bubbling phase
  81227. */
  81228. currentTarget?: any;
  81229. /**
  81230. * This will be populated with the return value of the last function that was executed.
  81231. * If it is the first function in the callback chain it will be the event data.
  81232. */
  81233. lastReturnValue?: any;
  81234. /**
  81235. * User defined information that will be sent to observers
  81236. */
  81237. userInfo?: any;
  81238. }
  81239. /**
  81240. * Represent an Observer registered to a given Observable object.
  81241. */
  81242. export class Observer<T> {
  81243. /**
  81244. * Defines the callback to call when the observer is notified
  81245. */
  81246. callback: (eventData: T, eventState: EventState) => void;
  81247. /**
  81248. * Defines the mask of the observer (used to filter notifications)
  81249. */
  81250. mask: number;
  81251. /**
  81252. * Defines the current scope used to restore the JS context
  81253. */
  81254. scope: any;
  81255. /** @hidden */
  81256. _willBeUnregistered: boolean;
  81257. /**
  81258. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  81259. */
  81260. unregisterOnNextCall: boolean;
  81261. /**
  81262. * Creates a new observer
  81263. * @param callback defines the callback to call when the observer is notified
  81264. * @param mask defines the mask of the observer (used to filter notifications)
  81265. * @param scope defines the current scope used to restore the JS context
  81266. */
  81267. constructor(
  81268. /**
  81269. * Defines the callback to call when the observer is notified
  81270. */
  81271. callback: (eventData: T, eventState: EventState) => void,
  81272. /**
  81273. * Defines the mask of the observer (used to filter notifications)
  81274. */
  81275. mask: number,
  81276. /**
  81277. * Defines the current scope used to restore the JS context
  81278. */
  81279. scope?: any);
  81280. }
  81281. /**
  81282. * Represent a list of observers registered to multiple Observables object.
  81283. */
  81284. export class MultiObserver<T> {
  81285. private _observers;
  81286. private _observables;
  81287. /**
  81288. * Release associated resources
  81289. */
  81290. dispose(): void;
  81291. /**
  81292. * Raise a callback when one of the observable will notify
  81293. * @param observables defines a list of observables to watch
  81294. * @param callback defines the callback to call on notification
  81295. * @param mask defines the mask used to filter notifications
  81296. * @param scope defines the current scope used to restore the JS context
  81297. * @returns the new MultiObserver
  81298. */
  81299. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  81300. }
  81301. /**
  81302. * The Observable class is a simple implementation of the Observable pattern.
  81303. *
  81304. * 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.
  81305. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  81306. * 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).
  81307. * 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.
  81308. */
  81309. export class Observable<T> {
  81310. private _observers;
  81311. private _eventState;
  81312. private _onObserverAdded;
  81313. /**
  81314. * Gets the list of observers
  81315. */
  81316. get observers(): Array<Observer<T>>;
  81317. /**
  81318. * Creates a new observable
  81319. * @param onObserverAdded defines a callback to call when a new observer is added
  81320. */
  81321. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  81322. /**
  81323. * Create a new Observer with the specified callback
  81324. * @param callback the callback that will be executed for that Observer
  81325. * @param mask the mask used to filter observers
  81326. * @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.
  81327. * @param scope optional scope for the callback to be called from
  81328. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  81329. * @returns the new observer created for the callback
  81330. */
  81331. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  81332. /**
  81333. * Create a new Observer with the specified callback and unregisters after the next notification
  81334. * @param callback the callback that will be executed for that Observer
  81335. * @returns the new observer created for the callback
  81336. */
  81337. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  81338. /**
  81339. * Remove an Observer from the Observable object
  81340. * @param observer the instance of the Observer to remove
  81341. * @returns false if it doesn't belong to this Observable
  81342. */
  81343. remove(observer: Nullable<Observer<T>>): boolean;
  81344. /**
  81345. * Remove a callback from the Observable object
  81346. * @param callback the callback to remove
  81347. * @param scope optional scope. If used only the callbacks with this scope will be removed
  81348. * @returns false if it doesn't belong to this Observable
  81349. */
  81350. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  81351. private _deferUnregister;
  81352. private _remove;
  81353. /**
  81354. * Moves the observable to the top of the observer list making it get called first when notified
  81355. * @param observer the observer to move
  81356. */
  81357. makeObserverTopPriority(observer: Observer<T>): void;
  81358. /**
  81359. * Moves the observable to the bottom of the observer list making it get called last when notified
  81360. * @param observer the observer to move
  81361. */
  81362. makeObserverBottomPriority(observer: Observer<T>): void;
  81363. /**
  81364. * Notify all Observers by calling their respective callback with the given data
  81365. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  81366. * @param eventData defines the data to send to all observers
  81367. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  81368. * @param target defines the original target of the state
  81369. * @param currentTarget defines the current target of the state
  81370. * @param userInfo defines any user info to send to observers
  81371. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  81372. */
  81373. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  81374. /**
  81375. * Calling this will execute each callback, expecting it to be a promise or return a value.
  81376. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  81377. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  81378. * and it is crucial that all callbacks will be executed.
  81379. * The order of the callbacks is kept, callbacks are not executed parallel.
  81380. *
  81381. * @param eventData The data to be sent to each callback
  81382. * @param mask is used to filter observers defaults to -1
  81383. * @param target defines the callback target (see EventState)
  81384. * @param currentTarget defines he current object in the bubbling phase
  81385. * @param userInfo defines any user info to send to observers
  81386. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  81387. */
  81388. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  81389. /**
  81390. * Notify a specific observer
  81391. * @param observer defines the observer to notify
  81392. * @param eventData defines the data to be sent to each callback
  81393. * @param mask is used to filter observers defaults to -1
  81394. */
  81395. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  81396. /**
  81397. * Gets a boolean indicating if the observable has at least one observer
  81398. * @returns true is the Observable has at least one Observer registered
  81399. */
  81400. hasObservers(): boolean;
  81401. /**
  81402. * Clear the list of observers
  81403. */
  81404. clear(): void;
  81405. /**
  81406. * Clone the current observable
  81407. * @returns a new observable
  81408. */
  81409. clone(): Observable<T>;
  81410. /**
  81411. * Does this observable handles observer registered with a given mask
  81412. * @param mask defines the mask to be tested
  81413. * @return whether or not one observer registered with the given mask is handeled
  81414. **/
  81415. hasSpecificMask(mask?: number): boolean;
  81416. }
  81417. }
  81418. declare module BABYLON {
  81419. /**
  81420. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  81421. * Babylon.js
  81422. */
  81423. export class DomManagement {
  81424. /**
  81425. * Checks if the window object exists
  81426. * @returns true if the window object exists
  81427. */
  81428. static IsWindowObjectExist(): boolean;
  81429. /**
  81430. * Checks if the navigator object exists
  81431. * @returns true if the navigator object exists
  81432. */
  81433. static IsNavigatorAvailable(): boolean;
  81434. /**
  81435. * Check if the document object exists
  81436. * @returns true if the document object exists
  81437. */
  81438. static IsDocumentAvailable(): boolean;
  81439. /**
  81440. * Extracts text content from a DOM element hierarchy
  81441. * @param element defines the root element
  81442. * @returns a string
  81443. */
  81444. static GetDOMTextContent(element: HTMLElement): string;
  81445. }
  81446. }
  81447. declare module BABYLON {
  81448. /**
  81449. * Logger used througouht the application to allow configuration of
  81450. * the log level required for the messages.
  81451. */
  81452. export class Logger {
  81453. /**
  81454. * No log
  81455. */
  81456. static readonly NoneLogLevel: number;
  81457. /**
  81458. * Only message logs
  81459. */
  81460. static readonly MessageLogLevel: number;
  81461. /**
  81462. * Only warning logs
  81463. */
  81464. static readonly WarningLogLevel: number;
  81465. /**
  81466. * Only error logs
  81467. */
  81468. static readonly ErrorLogLevel: number;
  81469. /**
  81470. * All logs
  81471. */
  81472. static readonly AllLogLevel: number;
  81473. private static _LogCache;
  81474. /**
  81475. * Gets a value indicating the number of loading errors
  81476. * @ignorenaming
  81477. */
  81478. static errorsCount: number;
  81479. /**
  81480. * Callback called when a new log is added
  81481. */
  81482. static OnNewCacheEntry: (entry: string) => void;
  81483. private static _AddLogEntry;
  81484. private static _FormatMessage;
  81485. private static _LogDisabled;
  81486. private static _LogEnabled;
  81487. private static _WarnDisabled;
  81488. private static _WarnEnabled;
  81489. private static _ErrorDisabled;
  81490. private static _ErrorEnabled;
  81491. /**
  81492. * Log a message to the console
  81493. */
  81494. static Log: (message: string) => void;
  81495. /**
  81496. * Write a warning message to the console
  81497. */
  81498. static Warn: (message: string) => void;
  81499. /**
  81500. * Write an error message to the console
  81501. */
  81502. static Error: (message: string) => void;
  81503. /**
  81504. * Gets current log cache (list of logs)
  81505. */
  81506. static get LogCache(): string;
  81507. /**
  81508. * Clears the log cache
  81509. */
  81510. static ClearLogCache(): void;
  81511. /**
  81512. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  81513. */
  81514. static set LogLevels(level: number);
  81515. }
  81516. }
  81517. declare module BABYLON {
  81518. /** @hidden */
  81519. export class _TypeStore {
  81520. /** @hidden */
  81521. static RegisteredTypes: {
  81522. [key: string]: Object;
  81523. };
  81524. /** @hidden */
  81525. static GetClass(fqdn: string): any;
  81526. }
  81527. }
  81528. declare module BABYLON {
  81529. /**
  81530. * Helper to manipulate strings
  81531. */
  81532. export class StringTools {
  81533. /**
  81534. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  81535. * @param str Source string
  81536. * @param suffix Suffix to search for in the source string
  81537. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81538. */
  81539. static EndsWith(str: string, suffix: string): boolean;
  81540. /**
  81541. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  81542. * @param str Source string
  81543. * @param suffix Suffix to search for in the source string
  81544. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  81545. */
  81546. static StartsWith(str: string, suffix: string): boolean;
  81547. /**
  81548. * Decodes a buffer into a string
  81549. * @param buffer The buffer to decode
  81550. * @returns The decoded string
  81551. */
  81552. static Decode(buffer: Uint8Array | Uint16Array): string;
  81553. /**
  81554. * Encode a buffer to a base64 string
  81555. * @param buffer defines the buffer to encode
  81556. * @returns the encoded string
  81557. */
  81558. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  81559. /**
  81560. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  81561. * @param num the number to convert and pad
  81562. * @param length the expected length of the string
  81563. * @returns the padded string
  81564. */
  81565. static PadNumber(num: number, length: number): string;
  81566. }
  81567. }
  81568. declare module BABYLON {
  81569. /**
  81570. * Class containing a set of static utilities functions for deep copy.
  81571. */
  81572. export class DeepCopier {
  81573. /**
  81574. * Tries to copy an object by duplicating every property
  81575. * @param source defines the source object
  81576. * @param destination defines the target object
  81577. * @param doNotCopyList defines a list of properties to avoid
  81578. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  81579. */
  81580. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  81581. }
  81582. }
  81583. declare module BABYLON {
  81584. /**
  81585. * Class containing a set of static utilities functions for precision date
  81586. */
  81587. export class PrecisionDate {
  81588. /**
  81589. * Gets either window.performance.now() if supported or Date.now() else
  81590. */
  81591. static get Now(): number;
  81592. }
  81593. }
  81594. declare module BABYLON {
  81595. /** @hidden */
  81596. export class _DevTools {
  81597. static WarnImport(name: string): string;
  81598. }
  81599. }
  81600. declare module BABYLON {
  81601. /**
  81602. * Interface used to define the mechanism to get data from the network
  81603. */
  81604. export interface IWebRequest {
  81605. /**
  81606. * Returns client's response url
  81607. */
  81608. responseURL: string;
  81609. /**
  81610. * Returns client's status
  81611. */
  81612. status: number;
  81613. /**
  81614. * Returns client's status as a text
  81615. */
  81616. statusText: string;
  81617. }
  81618. }
  81619. declare module BABYLON {
  81620. /**
  81621. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  81622. */
  81623. export class WebRequest implements IWebRequest {
  81624. private _xhr;
  81625. /**
  81626. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  81627. * i.e. when loading files, where the server/service expects an Authorization header
  81628. */
  81629. static CustomRequestHeaders: {
  81630. [key: string]: string;
  81631. };
  81632. /**
  81633. * Add callback functions in this array to update all the requests before they get sent to the network
  81634. */
  81635. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  81636. private _injectCustomRequestHeaders;
  81637. /**
  81638. * Gets or sets a function to be called when loading progress changes
  81639. */
  81640. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  81641. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  81642. /**
  81643. * Returns client's state
  81644. */
  81645. get readyState(): number;
  81646. /**
  81647. * Returns client's status
  81648. */
  81649. get status(): number;
  81650. /**
  81651. * Returns client's status as a text
  81652. */
  81653. get statusText(): string;
  81654. /**
  81655. * Returns client's response
  81656. */
  81657. get response(): any;
  81658. /**
  81659. * Returns client's response url
  81660. */
  81661. get responseURL(): string;
  81662. /**
  81663. * Returns client's response as text
  81664. */
  81665. get responseText(): string;
  81666. /**
  81667. * Gets or sets the expected response type
  81668. */
  81669. get responseType(): XMLHttpRequestResponseType;
  81670. set responseType(value: XMLHttpRequestResponseType);
  81671. /** @hidden */
  81672. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81673. /** @hidden */
  81674. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81675. /**
  81676. * Cancels any network activity
  81677. */
  81678. abort(): void;
  81679. /**
  81680. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81681. * @param body defines an optional request body
  81682. */
  81683. send(body?: Document | BodyInit | null): void;
  81684. /**
  81685. * Sets the request method, request URL
  81686. * @param method defines the method to use (GET, POST, etc..)
  81687. * @param url defines the url to connect with
  81688. */
  81689. open(method: string, url: string): void;
  81690. /**
  81691. * Sets the value of a request header.
  81692. * @param name The name of the header whose value is to be set
  81693. * @param value The value to set as the body of the header
  81694. */
  81695. setRequestHeader(name: string, value: string): void;
  81696. /**
  81697. * Get the string containing the text of a particular header's value.
  81698. * @param name The name of the header
  81699. * @returns The string containing the text of the given header name
  81700. */
  81701. getResponseHeader(name: string): Nullable<string>;
  81702. }
  81703. }
  81704. declare module BABYLON {
  81705. /**
  81706. * File request interface
  81707. */
  81708. export interface IFileRequest {
  81709. /**
  81710. * Raised when the request is complete (success or error).
  81711. */
  81712. onCompleteObservable: Observable<IFileRequest>;
  81713. /**
  81714. * Aborts the request for a file.
  81715. */
  81716. abort: () => void;
  81717. }
  81718. }
  81719. declare module BABYLON {
  81720. /**
  81721. * Define options used to create a render target texture
  81722. */
  81723. export class RenderTargetCreationOptions {
  81724. /**
  81725. * Specifies is mipmaps must be generated
  81726. */
  81727. generateMipMaps?: boolean;
  81728. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81729. generateDepthBuffer?: boolean;
  81730. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81731. generateStencilBuffer?: boolean;
  81732. /** Defines texture type (int by default) */
  81733. type?: number;
  81734. /** Defines sampling mode (trilinear by default) */
  81735. samplingMode?: number;
  81736. /** Defines format (RGBA by default) */
  81737. format?: number;
  81738. }
  81739. }
  81740. declare module BABYLON {
  81741. /** Defines the cross module used constants to avoid circular dependncies */
  81742. export class Constants {
  81743. /** Defines that alpha blending is disabled */
  81744. static readonly ALPHA_DISABLE: number;
  81745. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81746. static readonly ALPHA_ADD: number;
  81747. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81748. static readonly ALPHA_COMBINE: number;
  81749. /** Defines that alpha blending is DEST - SRC * DEST */
  81750. static readonly ALPHA_SUBTRACT: number;
  81751. /** Defines that alpha blending is SRC * DEST */
  81752. static readonly ALPHA_MULTIPLY: number;
  81753. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81754. static readonly ALPHA_MAXIMIZED: number;
  81755. /** Defines that alpha blending is SRC + DEST */
  81756. static readonly ALPHA_ONEONE: number;
  81757. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81758. static readonly ALPHA_PREMULTIPLIED: number;
  81759. /**
  81760. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81761. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81762. */
  81763. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81764. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81765. static readonly ALPHA_INTERPOLATE: number;
  81766. /**
  81767. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81768. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81769. */
  81770. static readonly ALPHA_SCREENMODE: number;
  81771. /**
  81772. * Defines that alpha blending is SRC + DST
  81773. * Alpha will be set to SRC ALPHA + DST ALPHA
  81774. */
  81775. static readonly ALPHA_ONEONE_ONEONE: number;
  81776. /**
  81777. * Defines that alpha blending is SRC * DST ALPHA + DST
  81778. * Alpha will be set to 0
  81779. */
  81780. static readonly ALPHA_ALPHATOCOLOR: number;
  81781. /**
  81782. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81783. */
  81784. static readonly ALPHA_REVERSEONEMINUS: number;
  81785. /**
  81786. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81787. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81788. */
  81789. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81790. /**
  81791. * Defines that alpha blending is SRC + DST
  81792. * Alpha will be set to SRC ALPHA
  81793. */
  81794. static readonly ALPHA_ONEONE_ONEZERO: number;
  81795. /**
  81796. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81797. * Alpha will be set to DST ALPHA
  81798. */
  81799. static readonly ALPHA_EXCLUSION: number;
  81800. /** Defines that alpha blending equation a SUM */
  81801. static readonly ALPHA_EQUATION_ADD: number;
  81802. /** Defines that alpha blending equation a SUBSTRACTION */
  81803. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81804. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81805. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81806. /** Defines that alpha blending equation a MAX operation */
  81807. static readonly ALPHA_EQUATION_MAX: number;
  81808. /** Defines that alpha blending equation a MIN operation */
  81809. static readonly ALPHA_EQUATION_MIN: number;
  81810. /**
  81811. * Defines that alpha blending equation a DARKEN operation:
  81812. * It takes the min of the src and sums the alpha channels.
  81813. */
  81814. static readonly ALPHA_EQUATION_DARKEN: number;
  81815. /** Defines that the ressource is not delayed*/
  81816. static readonly DELAYLOADSTATE_NONE: number;
  81817. /** Defines that the ressource was successfully delay loaded */
  81818. static readonly DELAYLOADSTATE_LOADED: number;
  81819. /** Defines that the ressource is currently delay loading */
  81820. static readonly DELAYLOADSTATE_LOADING: number;
  81821. /** Defines that the ressource is delayed and has not started loading */
  81822. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81823. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81824. static readonly NEVER: number;
  81825. /** 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 */
  81826. static readonly ALWAYS: number;
  81827. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81828. static readonly LESS: number;
  81829. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81830. static readonly EQUAL: number;
  81831. /** 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 */
  81832. static readonly LEQUAL: number;
  81833. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81834. static readonly GREATER: number;
  81835. /** 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 */
  81836. static readonly GEQUAL: number;
  81837. /** 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 */
  81838. static readonly NOTEQUAL: number;
  81839. /** Passed to stencilOperation to specify that stencil value must be kept */
  81840. static readonly KEEP: number;
  81841. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81842. static readonly REPLACE: number;
  81843. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81844. static readonly INCR: number;
  81845. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81846. static readonly DECR: number;
  81847. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81848. static readonly INVERT: number;
  81849. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81850. static readonly INCR_WRAP: number;
  81851. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81852. static readonly DECR_WRAP: number;
  81853. /** Texture is not repeating outside of 0..1 UVs */
  81854. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81855. /** Texture is repeating outside of 0..1 UVs */
  81856. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81857. /** Texture is repeating and mirrored */
  81858. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81859. /** ALPHA */
  81860. static readonly TEXTUREFORMAT_ALPHA: number;
  81861. /** LUMINANCE */
  81862. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81863. /** LUMINANCE_ALPHA */
  81864. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81865. /** RGB */
  81866. static readonly TEXTUREFORMAT_RGB: number;
  81867. /** RGBA */
  81868. static readonly TEXTUREFORMAT_RGBA: number;
  81869. /** RED */
  81870. static readonly TEXTUREFORMAT_RED: number;
  81871. /** RED (2nd reference) */
  81872. static readonly TEXTUREFORMAT_R: number;
  81873. /** RG */
  81874. static readonly TEXTUREFORMAT_RG: number;
  81875. /** RED_INTEGER */
  81876. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81877. /** RED_INTEGER (2nd reference) */
  81878. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81879. /** RG_INTEGER */
  81880. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81881. /** RGB_INTEGER */
  81882. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81883. /** RGBA_INTEGER */
  81884. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81885. /** UNSIGNED_BYTE */
  81886. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81887. /** UNSIGNED_BYTE (2nd reference) */
  81888. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81889. /** FLOAT */
  81890. static readonly TEXTURETYPE_FLOAT: number;
  81891. /** HALF_FLOAT */
  81892. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81893. /** BYTE */
  81894. static readonly TEXTURETYPE_BYTE: number;
  81895. /** SHORT */
  81896. static readonly TEXTURETYPE_SHORT: number;
  81897. /** UNSIGNED_SHORT */
  81898. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81899. /** INT */
  81900. static readonly TEXTURETYPE_INT: number;
  81901. /** UNSIGNED_INT */
  81902. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81903. /** UNSIGNED_SHORT_4_4_4_4 */
  81904. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81905. /** UNSIGNED_SHORT_5_5_5_1 */
  81906. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81907. /** UNSIGNED_SHORT_5_6_5 */
  81908. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81909. /** UNSIGNED_INT_2_10_10_10_REV */
  81910. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81911. /** UNSIGNED_INT_24_8 */
  81912. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81913. /** UNSIGNED_INT_10F_11F_11F_REV */
  81914. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81915. /** UNSIGNED_INT_5_9_9_9_REV */
  81916. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81917. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81918. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81919. /** nearest is mag = nearest and min = nearest and no mip */
  81920. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81921. /** mag = nearest and min = nearest and mip = none */
  81922. static readonly TEXTURE_NEAREST_NEAREST: number;
  81923. /** Bilinear is mag = linear and min = linear and no mip */
  81924. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81925. /** mag = linear and min = linear and mip = none */
  81926. static readonly TEXTURE_LINEAR_LINEAR: number;
  81927. /** Trilinear is mag = linear and min = linear and mip = linear */
  81928. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81929. /** Trilinear is mag = linear and min = linear and mip = linear */
  81930. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81931. /** mag = nearest and min = nearest and mip = nearest */
  81932. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81933. /** mag = nearest and min = linear and mip = nearest */
  81934. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81935. /** mag = nearest and min = linear and mip = linear */
  81936. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81937. /** mag = nearest and min = linear and mip = none */
  81938. static readonly TEXTURE_NEAREST_LINEAR: number;
  81939. /** nearest is mag = nearest and min = nearest and mip = linear */
  81940. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81941. /** mag = linear and min = nearest and mip = nearest */
  81942. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81943. /** mag = linear and min = nearest and mip = linear */
  81944. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81945. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81946. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81947. /** mag = linear and min = nearest and mip = none */
  81948. static readonly TEXTURE_LINEAR_NEAREST: number;
  81949. /** Explicit coordinates mode */
  81950. static readonly TEXTURE_EXPLICIT_MODE: number;
  81951. /** Spherical coordinates mode */
  81952. static readonly TEXTURE_SPHERICAL_MODE: number;
  81953. /** Planar coordinates mode */
  81954. static readonly TEXTURE_PLANAR_MODE: number;
  81955. /** Cubic coordinates mode */
  81956. static readonly TEXTURE_CUBIC_MODE: number;
  81957. /** Projection coordinates mode */
  81958. static readonly TEXTURE_PROJECTION_MODE: number;
  81959. /** Skybox coordinates mode */
  81960. static readonly TEXTURE_SKYBOX_MODE: number;
  81961. /** Inverse Cubic coordinates mode */
  81962. static readonly TEXTURE_INVCUBIC_MODE: number;
  81963. /** Equirectangular coordinates mode */
  81964. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81965. /** Equirectangular Fixed coordinates mode */
  81966. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81967. /** Equirectangular Fixed Mirrored coordinates mode */
  81968. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81969. /** Offline (baking) quality for texture filtering */
  81970. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81971. /** High quality for texture filtering */
  81972. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81973. /** Medium quality for texture filtering */
  81974. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81975. /** Low quality for texture filtering */
  81976. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81977. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81978. static readonly SCALEMODE_FLOOR: number;
  81979. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81980. static readonly SCALEMODE_NEAREST: number;
  81981. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81982. static readonly SCALEMODE_CEILING: number;
  81983. /**
  81984. * The dirty texture flag value
  81985. */
  81986. static readonly MATERIAL_TextureDirtyFlag: number;
  81987. /**
  81988. * The dirty light flag value
  81989. */
  81990. static readonly MATERIAL_LightDirtyFlag: number;
  81991. /**
  81992. * The dirty fresnel flag value
  81993. */
  81994. static readonly MATERIAL_FresnelDirtyFlag: number;
  81995. /**
  81996. * The dirty attribute flag value
  81997. */
  81998. static readonly MATERIAL_AttributesDirtyFlag: number;
  81999. /**
  82000. * The dirty misc flag value
  82001. */
  82002. static readonly MATERIAL_MiscDirtyFlag: number;
  82003. /**
  82004. * The dirty prepass flag value
  82005. */
  82006. static readonly MATERIAL_PrePassDirtyFlag: number;
  82007. /**
  82008. * The all dirty flag value
  82009. */
  82010. static readonly MATERIAL_AllDirtyFlag: number;
  82011. /**
  82012. * Returns the triangle fill mode
  82013. */
  82014. static readonly MATERIAL_TriangleFillMode: number;
  82015. /**
  82016. * Returns the wireframe mode
  82017. */
  82018. static readonly MATERIAL_WireFrameFillMode: number;
  82019. /**
  82020. * Returns the point fill mode
  82021. */
  82022. static readonly MATERIAL_PointFillMode: number;
  82023. /**
  82024. * Returns the point list draw mode
  82025. */
  82026. static readonly MATERIAL_PointListDrawMode: number;
  82027. /**
  82028. * Returns the line list draw mode
  82029. */
  82030. static readonly MATERIAL_LineListDrawMode: number;
  82031. /**
  82032. * Returns the line loop draw mode
  82033. */
  82034. static readonly MATERIAL_LineLoopDrawMode: number;
  82035. /**
  82036. * Returns the line strip draw mode
  82037. */
  82038. static readonly MATERIAL_LineStripDrawMode: number;
  82039. /**
  82040. * Returns the triangle strip draw mode
  82041. */
  82042. static readonly MATERIAL_TriangleStripDrawMode: number;
  82043. /**
  82044. * Returns the triangle fan draw mode
  82045. */
  82046. static readonly MATERIAL_TriangleFanDrawMode: number;
  82047. /**
  82048. * Stores the clock-wise side orientation
  82049. */
  82050. static readonly MATERIAL_ClockWiseSideOrientation: number;
  82051. /**
  82052. * Stores the counter clock-wise side orientation
  82053. */
  82054. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  82055. /**
  82056. * Nothing
  82057. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82058. */
  82059. static readonly ACTION_NothingTrigger: number;
  82060. /**
  82061. * On pick
  82062. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82063. */
  82064. static readonly ACTION_OnPickTrigger: number;
  82065. /**
  82066. * On left pick
  82067. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82068. */
  82069. static readonly ACTION_OnLeftPickTrigger: number;
  82070. /**
  82071. * On right pick
  82072. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82073. */
  82074. static readonly ACTION_OnRightPickTrigger: number;
  82075. /**
  82076. * On center pick
  82077. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82078. */
  82079. static readonly ACTION_OnCenterPickTrigger: number;
  82080. /**
  82081. * On pick down
  82082. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82083. */
  82084. static readonly ACTION_OnPickDownTrigger: number;
  82085. /**
  82086. * On double pick
  82087. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82088. */
  82089. static readonly ACTION_OnDoublePickTrigger: number;
  82090. /**
  82091. * On pick up
  82092. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82093. */
  82094. static readonly ACTION_OnPickUpTrigger: number;
  82095. /**
  82096. * On pick out.
  82097. * This trigger will only be raised if you also declared a OnPickDown
  82098. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82099. */
  82100. static readonly ACTION_OnPickOutTrigger: number;
  82101. /**
  82102. * On long press
  82103. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82104. */
  82105. static readonly ACTION_OnLongPressTrigger: number;
  82106. /**
  82107. * On pointer over
  82108. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82109. */
  82110. static readonly ACTION_OnPointerOverTrigger: number;
  82111. /**
  82112. * On pointer out
  82113. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82114. */
  82115. static readonly ACTION_OnPointerOutTrigger: number;
  82116. /**
  82117. * On every frame
  82118. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82119. */
  82120. static readonly ACTION_OnEveryFrameTrigger: number;
  82121. /**
  82122. * On intersection enter
  82123. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82124. */
  82125. static readonly ACTION_OnIntersectionEnterTrigger: number;
  82126. /**
  82127. * On intersection exit
  82128. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82129. */
  82130. static readonly ACTION_OnIntersectionExitTrigger: number;
  82131. /**
  82132. * On key down
  82133. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82134. */
  82135. static readonly ACTION_OnKeyDownTrigger: number;
  82136. /**
  82137. * On key up
  82138. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  82139. */
  82140. static readonly ACTION_OnKeyUpTrigger: number;
  82141. /**
  82142. * Billboard mode will only apply to Y axis
  82143. */
  82144. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  82145. /**
  82146. * Billboard mode will apply to all axes
  82147. */
  82148. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  82149. /**
  82150. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  82151. */
  82152. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  82153. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  82154. * Test order :
  82155. * Is the bounding sphere outside the frustum ?
  82156. * If not, are the bounding box vertices outside the frustum ?
  82157. * It not, then the cullable object is in the frustum.
  82158. */
  82159. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  82160. /** Culling strategy : Bounding Sphere Only.
  82161. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  82162. * It's also less accurate than the standard because some not visible objects can still be selected.
  82163. * Test : is the bounding sphere outside the frustum ?
  82164. * If not, then the cullable object is in the frustum.
  82165. */
  82166. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  82167. /** Culling strategy : Optimistic Inclusion.
  82168. * This in an inclusion test first, then the standard exclusion test.
  82169. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  82170. * 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.
  82171. * Anyway, it's as accurate as the standard strategy.
  82172. * Test :
  82173. * Is the cullable object bounding sphere center in the frustum ?
  82174. * If not, apply the default culling strategy.
  82175. */
  82176. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  82177. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  82178. * This in an inclusion test first, then the bounding sphere only exclusion test.
  82179. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  82180. * 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.
  82181. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  82182. * Test :
  82183. * Is the cullable object bounding sphere center in the frustum ?
  82184. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  82185. */
  82186. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  82187. /**
  82188. * No logging while loading
  82189. */
  82190. static readonly SCENELOADER_NO_LOGGING: number;
  82191. /**
  82192. * Minimal logging while loading
  82193. */
  82194. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  82195. /**
  82196. * Summary logging while loading
  82197. */
  82198. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  82199. /**
  82200. * Detailled logging while loading
  82201. */
  82202. static readonly SCENELOADER_DETAILED_LOGGING: number;
  82203. /**
  82204. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  82205. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  82206. */
  82207. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  82208. /**
  82209. * Constant used to retrieve the position texture index in the textures array in the prepass
  82210. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  82211. */
  82212. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  82213. /**
  82214. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  82215. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  82216. */
  82217. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  82218. /**
  82219. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  82220. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  82221. */
  82222. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  82223. /**
  82224. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  82225. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  82226. */
  82227. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  82228. /**
  82229. * Constant used to retrieve depth + normal index in the textures array in the prepass
  82230. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  82231. */
  82232. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  82233. /**
  82234. * Constant used to retrieve albedo index in the textures array in the prepass
  82235. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  82236. */
  82237. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  82238. }
  82239. }
  82240. declare module BABYLON {
  82241. /**
  82242. * This represents the required contract to create a new type of texture loader.
  82243. */
  82244. export interface IInternalTextureLoader {
  82245. /**
  82246. * Defines wether the loader supports cascade loading the different faces.
  82247. */
  82248. supportCascades: boolean;
  82249. /**
  82250. * This returns if the loader support the current file information.
  82251. * @param extension defines the file extension of the file being loaded
  82252. * @param mimeType defines the optional mime type of the file being loaded
  82253. * @returns true if the loader can load the specified file
  82254. */
  82255. canLoad(extension: string, mimeType?: string): boolean;
  82256. /**
  82257. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  82258. * @param data contains the texture data
  82259. * @param texture defines the BabylonJS internal texture
  82260. * @param createPolynomials will be true if polynomials have been requested
  82261. * @param onLoad defines the callback to trigger once the texture is ready
  82262. * @param onError defines the callback to trigger in case of error
  82263. * @param options options to be passed to the loader
  82264. */
  82265. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, options?: any): void;
  82266. /**
  82267. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  82268. * @param data contains the texture data
  82269. * @param texture defines the BabylonJS internal texture
  82270. * @param callback defines the method to call once ready to upload
  82271. * @param options options to be passed to the loader
  82272. */
  82273. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void, options?: any): void;
  82274. }
  82275. }
  82276. declare module BABYLON {
  82277. /**
  82278. * Class used to store and describe the pipeline context associated with an effect
  82279. */
  82280. export interface IPipelineContext {
  82281. /**
  82282. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  82283. */
  82284. isAsync: boolean;
  82285. /**
  82286. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  82287. */
  82288. isReady: boolean;
  82289. /** @hidden */
  82290. _getVertexShaderCode(): string | null;
  82291. /** @hidden */
  82292. _getFragmentShaderCode(): string | null;
  82293. /** @hidden */
  82294. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  82295. }
  82296. }
  82297. declare module BABYLON {
  82298. /**
  82299. * Class used to store gfx data (like WebGLBuffer)
  82300. */
  82301. export class DataBuffer {
  82302. /**
  82303. * Gets or sets the number of objects referencing this buffer
  82304. */
  82305. references: number;
  82306. /** Gets or sets the size of the underlying buffer */
  82307. capacity: number;
  82308. /**
  82309. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  82310. */
  82311. is32Bits: boolean;
  82312. /**
  82313. * Gets the underlying buffer
  82314. */
  82315. get underlyingResource(): any;
  82316. }
  82317. }
  82318. declare module BABYLON {
  82319. /** @hidden */
  82320. export interface IShaderProcessor {
  82321. attributeProcessor?: (attribute: string) => string;
  82322. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  82323. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  82324. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  82325. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  82326. lineProcessor?: (line: string, isFragment: boolean) => string;
  82327. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  82328. postProcessor?: (code: string, defines: string[], isFragment: boolean, engine: ThinEngine) => string;
  82329. }
  82330. }
  82331. declare module BABYLON {
  82332. /** @hidden */
  82333. export interface ProcessingOptions {
  82334. defines: string[];
  82335. indexParameters: any;
  82336. isFragment: boolean;
  82337. shouldUseHighPrecisionShader: boolean;
  82338. supportsUniformBuffers: boolean;
  82339. shadersRepository: string;
  82340. includesShadersStore: {
  82341. [key: string]: string;
  82342. };
  82343. processor?: IShaderProcessor;
  82344. version: string;
  82345. platformName: string;
  82346. lookForClosingBracketForUniformBuffer?: boolean;
  82347. }
  82348. }
  82349. declare module BABYLON {
  82350. /** @hidden */
  82351. export class ShaderCodeNode {
  82352. line: string;
  82353. children: ShaderCodeNode[];
  82354. additionalDefineKey?: string;
  82355. additionalDefineValue?: string;
  82356. isValid(preprocessors: {
  82357. [key: string]: string;
  82358. }): boolean;
  82359. process(preprocessors: {
  82360. [key: string]: string;
  82361. }, options: ProcessingOptions): string;
  82362. }
  82363. }
  82364. declare module BABYLON {
  82365. /** @hidden */
  82366. export class ShaderCodeCursor {
  82367. private _lines;
  82368. lineIndex: number;
  82369. get currentLine(): string;
  82370. get canRead(): boolean;
  82371. set lines(value: string[]);
  82372. }
  82373. }
  82374. declare module BABYLON {
  82375. /** @hidden */
  82376. export class ShaderCodeConditionNode extends ShaderCodeNode {
  82377. process(preprocessors: {
  82378. [key: string]: string;
  82379. }, options: ProcessingOptions): string;
  82380. }
  82381. }
  82382. declare module BABYLON {
  82383. /** @hidden */
  82384. export class ShaderDefineExpression {
  82385. isTrue(preprocessors: {
  82386. [key: string]: string;
  82387. }): boolean;
  82388. private static _OperatorPriority;
  82389. private static _Stack;
  82390. static postfixToInfix(postfix: string[]): string;
  82391. static infixToPostfix(infix: string): string[];
  82392. }
  82393. }
  82394. declare module BABYLON {
  82395. /** @hidden */
  82396. export class ShaderCodeTestNode extends ShaderCodeNode {
  82397. testExpression: ShaderDefineExpression;
  82398. isValid(preprocessors: {
  82399. [key: string]: string;
  82400. }): boolean;
  82401. }
  82402. }
  82403. declare module BABYLON {
  82404. /** @hidden */
  82405. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  82406. define: string;
  82407. not: boolean;
  82408. constructor(define: string, not?: boolean);
  82409. isTrue(preprocessors: {
  82410. [key: string]: string;
  82411. }): boolean;
  82412. }
  82413. }
  82414. declare module BABYLON {
  82415. /** @hidden */
  82416. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  82417. leftOperand: ShaderDefineExpression;
  82418. rightOperand: ShaderDefineExpression;
  82419. isTrue(preprocessors: {
  82420. [key: string]: string;
  82421. }): boolean;
  82422. }
  82423. }
  82424. declare module BABYLON {
  82425. /** @hidden */
  82426. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  82427. leftOperand: ShaderDefineExpression;
  82428. rightOperand: ShaderDefineExpression;
  82429. isTrue(preprocessors: {
  82430. [key: string]: string;
  82431. }): boolean;
  82432. }
  82433. }
  82434. declare module BABYLON {
  82435. /** @hidden */
  82436. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  82437. define: string;
  82438. operand: string;
  82439. testValue: string;
  82440. constructor(define: string, operand: string, testValue: string);
  82441. isTrue(preprocessors: {
  82442. [key: string]: string;
  82443. }): boolean;
  82444. }
  82445. }
  82446. declare module BABYLON {
  82447. /**
  82448. * Class used to enable access to offline support
  82449. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  82450. */
  82451. export interface IOfflineProvider {
  82452. /**
  82453. * Gets a boolean indicating if scene must be saved in the database
  82454. */
  82455. enableSceneOffline: boolean;
  82456. /**
  82457. * Gets a boolean indicating if textures must be saved in the database
  82458. */
  82459. enableTexturesOffline: boolean;
  82460. /**
  82461. * Open the offline support and make it available
  82462. * @param successCallback defines the callback to call on success
  82463. * @param errorCallback defines the callback to call on error
  82464. */
  82465. open(successCallback: () => void, errorCallback: () => void): void;
  82466. /**
  82467. * Loads an image from the offline support
  82468. * @param url defines the url to load from
  82469. * @param image defines the target DOM image
  82470. */
  82471. loadImage(url: string, image: HTMLImageElement): void;
  82472. /**
  82473. * Loads a file from offline support
  82474. * @param url defines the URL to load from
  82475. * @param sceneLoaded defines a callback to call on success
  82476. * @param progressCallBack defines a callback to call when progress changed
  82477. * @param errorCallback defines a callback to call on error
  82478. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  82479. */
  82480. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  82481. }
  82482. }
  82483. declare module BABYLON {
  82484. /**
  82485. * Class used to help managing file picking and drag'n'drop
  82486. * File Storage
  82487. */
  82488. export class FilesInputStore {
  82489. /**
  82490. * List of files ready to be loaded
  82491. */
  82492. static FilesToLoad: {
  82493. [key: string]: File;
  82494. };
  82495. }
  82496. }
  82497. declare module BABYLON {
  82498. /**
  82499. * Class used to define a retry strategy when error happens while loading assets
  82500. */
  82501. export class RetryStrategy {
  82502. /**
  82503. * Function used to defines an exponential back off strategy
  82504. * @param maxRetries defines the maximum number of retries (3 by default)
  82505. * @param baseInterval defines the interval between retries
  82506. * @returns the strategy function to use
  82507. */
  82508. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  82509. }
  82510. }
  82511. declare module BABYLON {
  82512. /**
  82513. * @ignore
  82514. * Application error to support additional information when loading a file
  82515. */
  82516. export abstract class BaseError extends Error {
  82517. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  82518. }
  82519. }
  82520. declare module BABYLON {
  82521. /** @ignore */
  82522. export class LoadFileError extends BaseError {
  82523. request?: WebRequest;
  82524. file?: File;
  82525. /**
  82526. * Creates a new LoadFileError
  82527. * @param message defines the message of the error
  82528. * @param request defines the optional web request
  82529. * @param file defines the optional file
  82530. */
  82531. constructor(message: string, object?: WebRequest | File);
  82532. }
  82533. /** @ignore */
  82534. export class RequestFileError extends BaseError {
  82535. request: WebRequest;
  82536. /**
  82537. * Creates a new LoadFileError
  82538. * @param message defines the message of the error
  82539. * @param request defines the optional web request
  82540. */
  82541. constructor(message: string, request: WebRequest);
  82542. }
  82543. /** @ignore */
  82544. export class ReadFileError extends BaseError {
  82545. file: File;
  82546. /**
  82547. * Creates a new ReadFileError
  82548. * @param message defines the message of the error
  82549. * @param file defines the optional file
  82550. */
  82551. constructor(message: string, file: File);
  82552. }
  82553. /**
  82554. * @hidden
  82555. */
  82556. export class FileTools {
  82557. /**
  82558. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  82559. */
  82560. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  82561. /**
  82562. * Gets or sets the base URL to use to load assets
  82563. */
  82564. static BaseUrl: string;
  82565. /**
  82566. * Default behaviour for cors in the application.
  82567. * It can be a string if the expected behavior is identical in the entire app.
  82568. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  82569. */
  82570. static CorsBehavior: string | ((url: string | string[]) => string);
  82571. /**
  82572. * Gets or sets a function used to pre-process url before using them to load assets
  82573. */
  82574. static PreprocessUrl: (url: string) => string;
  82575. /**
  82576. * Removes unwanted characters from an url
  82577. * @param url defines the url to clean
  82578. * @returns the cleaned url
  82579. */
  82580. private static _CleanUrl;
  82581. /**
  82582. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  82583. * @param url define the url we are trying
  82584. * @param element define the dom element where to configure the cors policy
  82585. */
  82586. static SetCorsBehavior(url: string | string[], element: {
  82587. crossOrigin: string | null;
  82588. }): void;
  82589. /**
  82590. * Loads an image as an HTMLImageElement.
  82591. * @param input url string, ArrayBuffer, or Blob to load
  82592. * @param onLoad callback called when the image successfully loads
  82593. * @param onError callback called when the image fails to load
  82594. * @param offlineProvider offline provider for caching
  82595. * @param mimeType optional mime type
  82596. * @returns the HTMLImageElement of the loaded image
  82597. */
  82598. 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>;
  82599. /**
  82600. * Reads a file from a File object
  82601. * @param file defines the file to load
  82602. * @param onSuccess defines the callback to call when data is loaded
  82603. * @param onProgress defines the callback to call during loading process
  82604. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  82605. * @param onError defines the callback to call when an error occurs
  82606. * @returns a file request object
  82607. */
  82608. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  82609. /**
  82610. * Loads a file from a url
  82611. * @param url url to load
  82612. * @param onSuccess callback called when the file successfully loads
  82613. * @param onProgress callback called while file is loading (if the server supports this mode)
  82614. * @param offlineProvider defines the offline provider for caching
  82615. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82616. * @param onError callback called when the file fails to load
  82617. * @returns a file request object
  82618. */
  82619. 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;
  82620. /**
  82621. * Loads a file
  82622. * @param url url to load
  82623. * @param onSuccess callback called when the file successfully loads
  82624. * @param onProgress callback called while file is loading (if the server supports this mode)
  82625. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82626. * @param onError callback called when the file fails to load
  82627. * @param onOpened callback called when the web request is opened
  82628. * @returns a file request object
  82629. */
  82630. 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;
  82631. /**
  82632. * Checks if the loaded document was accessed via `file:`-Protocol.
  82633. * @returns boolean
  82634. */
  82635. static IsFileURL(): boolean;
  82636. }
  82637. }
  82638. declare module BABYLON {
  82639. /** @hidden */
  82640. export class ShaderProcessor {
  82641. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void, engine: ThinEngine): void;
  82642. private static _ProcessPrecision;
  82643. private static _ExtractOperation;
  82644. private static _BuildSubExpression;
  82645. private static _BuildExpression;
  82646. private static _MoveCursorWithinIf;
  82647. private static _MoveCursor;
  82648. private static _EvaluatePreProcessors;
  82649. private static _PreparePreProcessors;
  82650. private static _ProcessShaderConversion;
  82651. private static _ProcessIncludes;
  82652. /**
  82653. * Loads a file from a url
  82654. * @param url url to load
  82655. * @param onSuccess callback called when the file successfully loads
  82656. * @param onProgress callback called while file is loading (if the server supports this mode)
  82657. * @param offlineProvider defines the offline provider for caching
  82658. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  82659. * @param onError callback called when the file fails to load
  82660. * @returns a file request object
  82661. * @hidden
  82662. */
  82663. 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;
  82664. }
  82665. }
  82666. declare module BABYLON {
  82667. /**
  82668. * @hidden
  82669. */
  82670. export interface IColor4Like {
  82671. r: float;
  82672. g: float;
  82673. b: float;
  82674. a: float;
  82675. }
  82676. /**
  82677. * @hidden
  82678. */
  82679. export interface IColor3Like {
  82680. r: float;
  82681. g: float;
  82682. b: float;
  82683. }
  82684. /**
  82685. * @hidden
  82686. */
  82687. export interface IVector4Like {
  82688. x: float;
  82689. y: float;
  82690. z: float;
  82691. w: float;
  82692. }
  82693. /**
  82694. * @hidden
  82695. */
  82696. export interface IVector3Like {
  82697. x: float;
  82698. y: float;
  82699. z: float;
  82700. }
  82701. /**
  82702. * @hidden
  82703. */
  82704. export interface IVector2Like {
  82705. x: float;
  82706. y: float;
  82707. }
  82708. /**
  82709. * @hidden
  82710. */
  82711. export interface IMatrixLike {
  82712. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82713. updateFlag: int;
  82714. }
  82715. /**
  82716. * @hidden
  82717. */
  82718. export interface IViewportLike {
  82719. x: float;
  82720. y: float;
  82721. width: float;
  82722. height: float;
  82723. }
  82724. /**
  82725. * @hidden
  82726. */
  82727. export interface IPlaneLike {
  82728. normal: IVector3Like;
  82729. d: float;
  82730. normalize(): void;
  82731. }
  82732. }
  82733. declare module BABYLON {
  82734. /**
  82735. * Interface used to define common properties for effect fallbacks
  82736. */
  82737. export interface IEffectFallbacks {
  82738. /**
  82739. * Removes the defines that should be removed when falling back.
  82740. * @param currentDefines defines the current define statements for the shader.
  82741. * @param effect defines the current effect we try to compile
  82742. * @returns The resulting defines with defines of the current rank removed.
  82743. */
  82744. reduce(currentDefines: string, effect: Effect): string;
  82745. /**
  82746. * Removes the fallback from the bound mesh.
  82747. */
  82748. unBindMesh(): void;
  82749. /**
  82750. * Checks to see if more fallbacks are still availible.
  82751. */
  82752. hasMoreFallbacks: boolean;
  82753. }
  82754. }
  82755. declare module BABYLON {
  82756. /**
  82757. * Class used to evalaute queries containing `and` and `or` operators
  82758. */
  82759. export class AndOrNotEvaluator {
  82760. /**
  82761. * Evaluate a query
  82762. * @param query defines the query to evaluate
  82763. * @param evaluateCallback defines the callback used to filter result
  82764. * @returns true if the query matches
  82765. */
  82766. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82767. private static _HandleParenthesisContent;
  82768. private static _SimplifyNegation;
  82769. }
  82770. }
  82771. declare module BABYLON {
  82772. /**
  82773. * Class used to store custom tags
  82774. */
  82775. export class Tags {
  82776. /**
  82777. * Adds support for tags on the given object
  82778. * @param obj defines the object to use
  82779. */
  82780. static EnableFor(obj: any): void;
  82781. /**
  82782. * Removes tags support
  82783. * @param obj defines the object to use
  82784. */
  82785. static DisableFor(obj: any): void;
  82786. /**
  82787. * Gets a boolean indicating if the given object has tags
  82788. * @param obj defines the object to use
  82789. * @returns a boolean
  82790. */
  82791. static HasTags(obj: any): boolean;
  82792. /**
  82793. * Gets the tags available on a given object
  82794. * @param obj defines the object to use
  82795. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82796. * @returns the tags
  82797. */
  82798. static GetTags(obj: any, asString?: boolean): any;
  82799. /**
  82800. * Adds tags to an object
  82801. * @param obj defines the object to use
  82802. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82803. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82804. */
  82805. static AddTagsTo(obj: any, tagsString: string): void;
  82806. /**
  82807. * @hidden
  82808. */
  82809. static _AddTagTo(obj: any, tag: string): void;
  82810. /**
  82811. * Removes specific tags from a specific object
  82812. * @param obj defines the object to use
  82813. * @param tagsString defines the tags to remove
  82814. */
  82815. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82816. /**
  82817. * @hidden
  82818. */
  82819. static _RemoveTagFrom(obj: any, tag: string): void;
  82820. /**
  82821. * Defines if tags hosted on an object match a given query
  82822. * @param obj defines the object to use
  82823. * @param tagsQuery defines the tag query
  82824. * @returns a boolean
  82825. */
  82826. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82827. }
  82828. }
  82829. declare module BABYLON {
  82830. /**
  82831. * Scalar computation library
  82832. */
  82833. export class Scalar {
  82834. /**
  82835. * Two pi constants convenient for computation.
  82836. */
  82837. static TwoPi: number;
  82838. /**
  82839. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82840. * @param a number
  82841. * @param b number
  82842. * @param epsilon (default = 1.401298E-45)
  82843. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82844. */
  82845. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82846. /**
  82847. * Returns a string : the upper case translation of the number i to hexadecimal.
  82848. * @param i number
  82849. * @returns the upper case translation of the number i to hexadecimal.
  82850. */
  82851. static ToHex(i: number): string;
  82852. /**
  82853. * Returns -1 if value is negative and +1 is value is positive.
  82854. * @param value the value
  82855. * @returns the value itself if it's equal to zero.
  82856. */
  82857. static Sign(value: number): number;
  82858. /**
  82859. * Returns the value itself if it's between min and max.
  82860. * Returns min if the value is lower than min.
  82861. * Returns max if the value is greater than max.
  82862. * @param value the value to clmap
  82863. * @param min the min value to clamp to (default: 0)
  82864. * @param max the max value to clamp to (default: 1)
  82865. * @returns the clamped value
  82866. */
  82867. static Clamp(value: number, min?: number, max?: number): number;
  82868. /**
  82869. * the log2 of value.
  82870. * @param value the value to compute log2 of
  82871. * @returns the log2 of value.
  82872. */
  82873. static Log2(value: number): number;
  82874. /**
  82875. * Loops the value, so that it is never larger than length and never smaller than 0.
  82876. *
  82877. * This is similar to the modulo operator but it works with floating point numbers.
  82878. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82879. * With t = 5 and length = 2.5, the result would be 0.0.
  82880. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82881. * @param value the value
  82882. * @param length the length
  82883. * @returns the looped value
  82884. */
  82885. static Repeat(value: number, length: number): number;
  82886. /**
  82887. * Normalize the value between 0.0 and 1.0 using min and max values
  82888. * @param value value to normalize
  82889. * @param min max to normalize between
  82890. * @param max min to normalize between
  82891. * @returns the normalized value
  82892. */
  82893. static Normalize(value: number, min: number, max: number): number;
  82894. /**
  82895. * Denormalize the value from 0.0 and 1.0 using min and max values
  82896. * @param normalized value to denormalize
  82897. * @param min max to denormalize between
  82898. * @param max min to denormalize between
  82899. * @returns the denormalized value
  82900. */
  82901. static Denormalize(normalized: number, min: number, max: number): number;
  82902. /**
  82903. * Calculates the shortest difference between two given angles given in degrees.
  82904. * @param current current angle in degrees
  82905. * @param target target angle in degrees
  82906. * @returns the delta
  82907. */
  82908. static DeltaAngle(current: number, target: number): number;
  82909. /**
  82910. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82911. * @param tx value
  82912. * @param length length
  82913. * @returns The returned value will move back and forth between 0 and length
  82914. */
  82915. static PingPong(tx: number, length: number): number;
  82916. /**
  82917. * Interpolates between min and max with smoothing at the limits.
  82918. *
  82919. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82920. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82921. * @param from from
  82922. * @param to to
  82923. * @param tx value
  82924. * @returns the smooth stepped value
  82925. */
  82926. static SmoothStep(from: number, to: number, tx: number): number;
  82927. /**
  82928. * Moves a value current towards target.
  82929. *
  82930. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82931. * Negative values of maxDelta pushes the value away from target.
  82932. * @param current current value
  82933. * @param target target value
  82934. * @param maxDelta max distance to move
  82935. * @returns resulting value
  82936. */
  82937. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82938. /**
  82939. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82940. *
  82941. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82942. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82943. * @param current current value
  82944. * @param target target value
  82945. * @param maxDelta max distance to move
  82946. * @returns resulting angle
  82947. */
  82948. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82949. /**
  82950. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82951. * @param start start value
  82952. * @param end target value
  82953. * @param amount amount to lerp between
  82954. * @returns the lerped value
  82955. */
  82956. static Lerp(start: number, end: number, amount: number): number;
  82957. /**
  82958. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82959. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82960. * @param start start value
  82961. * @param end target value
  82962. * @param amount amount to lerp between
  82963. * @returns the lerped value
  82964. */
  82965. static LerpAngle(start: number, end: number, amount: number): number;
  82966. /**
  82967. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82968. * @param a start value
  82969. * @param b target value
  82970. * @param value value between a and b
  82971. * @returns the inverseLerp value
  82972. */
  82973. static InverseLerp(a: number, b: number, value: number): number;
  82974. /**
  82975. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82976. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82977. * @param value1 spline value
  82978. * @param tangent1 spline value
  82979. * @param value2 spline value
  82980. * @param tangent2 spline value
  82981. * @param amount input value
  82982. * @returns hermite result
  82983. */
  82984. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82985. /**
  82986. * Returns a random float number between and min and max values
  82987. * @param min min value of random
  82988. * @param max max value of random
  82989. * @returns random value
  82990. */
  82991. static RandomRange(min: number, max: number): number;
  82992. /**
  82993. * This function returns percentage of a number in a given range.
  82994. *
  82995. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82996. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82997. * @param number to convert to percentage
  82998. * @param min min range
  82999. * @param max max range
  83000. * @returns the percentage
  83001. */
  83002. static RangeToPercent(number: number, min: number, max: number): number;
  83003. /**
  83004. * This function returns number that corresponds to the percentage in a given range.
  83005. *
  83006. * PercentToRange(0.34,0,100) will return 34.
  83007. * @param percent to convert to number
  83008. * @param min min range
  83009. * @param max max range
  83010. * @returns the number
  83011. */
  83012. static PercentToRange(percent: number, min: number, max: number): number;
  83013. /**
  83014. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  83015. * @param angle The angle to normalize in radian.
  83016. * @return The converted angle.
  83017. */
  83018. static NormalizeRadians(angle: number): number;
  83019. }
  83020. }
  83021. declare module BABYLON {
  83022. /**
  83023. * Constant used to convert a value to gamma space
  83024. * @ignorenaming
  83025. */
  83026. export const ToGammaSpace: number;
  83027. /**
  83028. * Constant used to convert a value to linear space
  83029. * @ignorenaming
  83030. */
  83031. export const ToLinearSpace = 2.2;
  83032. /**
  83033. * Constant used to define the minimal number value in Babylon.js
  83034. * @ignorenaming
  83035. */
  83036. let Epsilon: number;
  83037. }
  83038. declare module BABYLON {
  83039. /**
  83040. * Class used to represent a viewport on screen
  83041. */
  83042. export class Viewport {
  83043. /** viewport left coordinate */
  83044. x: number;
  83045. /** viewport top coordinate */
  83046. y: number;
  83047. /**viewport width */
  83048. width: number;
  83049. /** viewport height */
  83050. height: number;
  83051. /**
  83052. * Creates a Viewport object located at (x, y) and sized (width, height)
  83053. * @param x defines viewport left coordinate
  83054. * @param y defines viewport top coordinate
  83055. * @param width defines the viewport width
  83056. * @param height defines the viewport height
  83057. */
  83058. constructor(
  83059. /** viewport left coordinate */
  83060. x: number,
  83061. /** viewport top coordinate */
  83062. y: number,
  83063. /**viewport width */
  83064. width: number,
  83065. /** viewport height */
  83066. height: number);
  83067. /**
  83068. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  83069. * @param renderWidth defines the rendering width
  83070. * @param renderHeight defines the rendering height
  83071. * @returns a new Viewport
  83072. */
  83073. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  83074. /**
  83075. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  83076. * @param renderWidth defines the rendering width
  83077. * @param renderHeight defines the rendering height
  83078. * @param ref defines the target viewport
  83079. * @returns the current viewport
  83080. */
  83081. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  83082. /**
  83083. * Returns a new Viewport copied from the current one
  83084. * @returns a new Viewport
  83085. */
  83086. clone(): Viewport;
  83087. }
  83088. }
  83089. declare module BABYLON {
  83090. /**
  83091. * Class containing a set of static utilities functions for arrays.
  83092. */
  83093. export class ArrayTools {
  83094. /**
  83095. * Returns an array of the given size filled with element built from the given constructor and the paramters
  83096. * @param size the number of element to construct and put in the array
  83097. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  83098. * @returns a new array filled with new objects
  83099. */
  83100. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  83101. }
  83102. }
  83103. declare module BABYLON {
  83104. /**
  83105. * Represents a plane by the equation ax + by + cz + d = 0
  83106. */
  83107. export class Plane {
  83108. private static _TmpMatrix;
  83109. /**
  83110. * Normal of the plane (a,b,c)
  83111. */
  83112. normal: Vector3;
  83113. /**
  83114. * d component of the plane
  83115. */
  83116. d: number;
  83117. /**
  83118. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  83119. * @param a a component of the plane
  83120. * @param b b component of the plane
  83121. * @param c c component of the plane
  83122. * @param d d component of the plane
  83123. */
  83124. constructor(a: number, b: number, c: number, d: number);
  83125. /**
  83126. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  83127. */
  83128. asArray(): number[];
  83129. /**
  83130. * @returns a new plane copied from the current Plane.
  83131. */
  83132. clone(): Plane;
  83133. /**
  83134. * @returns the string "Plane".
  83135. */
  83136. getClassName(): string;
  83137. /**
  83138. * @returns the Plane hash code.
  83139. */
  83140. getHashCode(): number;
  83141. /**
  83142. * Normalize the current Plane in place.
  83143. * @returns the updated Plane.
  83144. */
  83145. normalize(): Plane;
  83146. /**
  83147. * Applies a transformation the plane and returns the result
  83148. * @param transformation the transformation matrix to be applied to the plane
  83149. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  83150. */
  83151. transform(transformation: DeepImmutable<Matrix>): Plane;
  83152. /**
  83153. * Compute the dot product between the point and the plane normal
  83154. * @param point point to calculate the dot product with
  83155. * @returns the dot product (float) of the point coordinates and the plane normal.
  83156. */
  83157. dotCoordinate(point: DeepImmutable<Vector3>): number;
  83158. /**
  83159. * Updates the current Plane from the plane defined by the three given points.
  83160. * @param point1 one of the points used to contruct the plane
  83161. * @param point2 one of the points used to contruct the plane
  83162. * @param point3 one of the points used to contruct the plane
  83163. * @returns the updated Plane.
  83164. */
  83165. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  83166. /**
  83167. * Checks if the plane is facing a given direction
  83168. * @param direction the direction to check if the plane is facing
  83169. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  83170. * @returns True is the vector "direction" is the same side than the plane normal.
  83171. */
  83172. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  83173. /**
  83174. * Calculates the distance to a point
  83175. * @param point point to calculate distance to
  83176. * @returns the signed distance (float) from the given point to the Plane.
  83177. */
  83178. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  83179. /**
  83180. * Creates a plane from an array
  83181. * @param array the array to create a plane from
  83182. * @returns a new Plane from the given array.
  83183. */
  83184. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  83185. /**
  83186. * Creates a plane from three points
  83187. * @param point1 point used to create the plane
  83188. * @param point2 point used to create the plane
  83189. * @param point3 point used to create the plane
  83190. * @returns a new Plane defined by the three given points.
  83191. */
  83192. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  83193. /**
  83194. * Creates a plane from an origin point and a normal
  83195. * @param origin origin of the plane to be constructed
  83196. * @param normal normal of the plane to be constructed
  83197. * @returns a new Plane the normal vector to this plane at the given origin point.
  83198. * Note : the vector "normal" is updated because normalized.
  83199. */
  83200. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  83201. /**
  83202. * Calculates the distance from a plane and a point
  83203. * @param origin origin of the plane to be constructed
  83204. * @param normal normal of the plane to be constructed
  83205. * @param point point to calculate distance to
  83206. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  83207. */
  83208. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  83209. }
  83210. }
  83211. declare module BABYLON {
  83212. /** @hidden */
  83213. export class PerformanceConfigurator {
  83214. /** @hidden */
  83215. static MatrixUse64Bits: boolean;
  83216. /** @hidden */
  83217. static MatrixTrackPrecisionChange: boolean;
  83218. /** @hidden */
  83219. static MatrixCurrentType: any;
  83220. /** @hidden */
  83221. static MatrixTrackedMatrices: Array<any> | null;
  83222. /** @hidden */
  83223. static SetMatrixPrecision(use64bits: boolean): void;
  83224. }
  83225. }
  83226. declare module BABYLON {
  83227. /**
  83228. * Class representing a vector containing 2 coordinates
  83229. */
  83230. export class Vector2 {
  83231. /** defines the first coordinate */
  83232. x: number;
  83233. /** defines the second coordinate */
  83234. y: number;
  83235. /**
  83236. * Creates a new Vector2 from the given x and y coordinates
  83237. * @param x defines the first coordinate
  83238. * @param y defines the second coordinate
  83239. */
  83240. constructor(
  83241. /** defines the first coordinate */
  83242. x?: number,
  83243. /** defines the second coordinate */
  83244. y?: number);
  83245. /**
  83246. * Gets a string with the Vector2 coordinates
  83247. * @returns a string with the Vector2 coordinates
  83248. */
  83249. toString(): string;
  83250. /**
  83251. * Gets class name
  83252. * @returns the string "Vector2"
  83253. */
  83254. getClassName(): string;
  83255. /**
  83256. * Gets current vector hash code
  83257. * @returns the Vector2 hash code as a number
  83258. */
  83259. getHashCode(): number;
  83260. /**
  83261. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  83262. * @param array defines the source array
  83263. * @param index defines the offset in source array
  83264. * @returns the current Vector2
  83265. */
  83266. toArray(array: FloatArray, index?: number): Vector2;
  83267. /**
  83268. * Update the current vector from an array
  83269. * @param array defines the destination array
  83270. * @param index defines the offset in the destination array
  83271. * @returns the current Vector3
  83272. */
  83273. fromArray(array: FloatArray, index?: number): Vector2;
  83274. /**
  83275. * Copy the current vector to an array
  83276. * @returns a new array with 2 elements: the Vector2 coordinates.
  83277. */
  83278. asArray(): number[];
  83279. /**
  83280. * Sets the Vector2 coordinates with the given Vector2 coordinates
  83281. * @param source defines the source Vector2
  83282. * @returns the current updated Vector2
  83283. */
  83284. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  83285. /**
  83286. * Sets the Vector2 coordinates with the given floats
  83287. * @param x defines the first coordinate
  83288. * @param y defines the second coordinate
  83289. * @returns the current updated Vector2
  83290. */
  83291. copyFromFloats(x: number, y: number): Vector2;
  83292. /**
  83293. * Sets the Vector2 coordinates with the given floats
  83294. * @param x defines the first coordinate
  83295. * @param y defines the second coordinate
  83296. * @returns the current updated Vector2
  83297. */
  83298. set(x: number, y: number): Vector2;
  83299. /**
  83300. * Add another vector with the current one
  83301. * @param otherVector defines the other vector
  83302. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  83303. */
  83304. add(otherVector: DeepImmutable<Vector2>): Vector2;
  83305. /**
  83306. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  83307. * @param otherVector defines the other vector
  83308. * @param result defines the target vector
  83309. * @returns the unmodified current Vector2
  83310. */
  83311. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83312. /**
  83313. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  83314. * @param otherVector defines the other vector
  83315. * @returns the current updated Vector2
  83316. */
  83317. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83318. /**
  83319. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  83320. * @param otherVector defines the other vector
  83321. * @returns a new Vector2
  83322. */
  83323. addVector3(otherVector: Vector3): Vector2;
  83324. /**
  83325. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  83326. * @param otherVector defines the other vector
  83327. * @returns a new Vector2
  83328. */
  83329. subtract(otherVector: Vector2): Vector2;
  83330. /**
  83331. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  83332. * @param otherVector defines the other vector
  83333. * @param result defines the target vector
  83334. * @returns the unmodified current Vector2
  83335. */
  83336. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83337. /**
  83338. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  83339. * @param otherVector defines the other vector
  83340. * @returns the current updated Vector2
  83341. */
  83342. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83343. /**
  83344. * Multiplies in place the current Vector2 coordinates by the given ones
  83345. * @param otherVector defines the other vector
  83346. * @returns the current updated Vector2
  83347. */
  83348. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83349. /**
  83350. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  83351. * @param otherVector defines the other vector
  83352. * @returns a new Vector2
  83353. */
  83354. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  83355. /**
  83356. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  83357. * @param otherVector defines the other vector
  83358. * @param result defines the target vector
  83359. * @returns the unmodified current Vector2
  83360. */
  83361. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83362. /**
  83363. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  83364. * @param x defines the first coordinate
  83365. * @param y defines the second coordinate
  83366. * @returns a new Vector2
  83367. */
  83368. multiplyByFloats(x: number, y: number): Vector2;
  83369. /**
  83370. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  83371. * @param otherVector defines the other vector
  83372. * @returns a new Vector2
  83373. */
  83374. divide(otherVector: Vector2): Vector2;
  83375. /**
  83376. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  83377. * @param otherVector defines the other vector
  83378. * @param result defines the target vector
  83379. * @returns the unmodified current Vector2
  83380. */
  83381. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  83382. /**
  83383. * Divides the current Vector2 coordinates by the given ones
  83384. * @param otherVector defines the other vector
  83385. * @returns the current updated Vector2
  83386. */
  83387. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  83388. /**
  83389. * Gets a new Vector2 with current Vector2 negated coordinates
  83390. * @returns a new Vector2
  83391. */
  83392. negate(): Vector2;
  83393. /**
  83394. * Negate this vector in place
  83395. * @returns this
  83396. */
  83397. negateInPlace(): Vector2;
  83398. /**
  83399. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  83400. * @param result defines the Vector3 object where to store the result
  83401. * @returns the current Vector2
  83402. */
  83403. negateToRef(result: Vector2): Vector2;
  83404. /**
  83405. * Multiply the Vector2 coordinates by scale
  83406. * @param scale defines the scaling factor
  83407. * @returns the current updated Vector2
  83408. */
  83409. scaleInPlace(scale: number): Vector2;
  83410. /**
  83411. * Returns a new Vector2 scaled by "scale" from the current Vector2
  83412. * @param scale defines the scaling factor
  83413. * @returns a new Vector2
  83414. */
  83415. scale(scale: number): Vector2;
  83416. /**
  83417. * Scale the current Vector2 values by a factor to a given Vector2
  83418. * @param scale defines the scale factor
  83419. * @param result defines the Vector2 object where to store the result
  83420. * @returns the unmodified current Vector2
  83421. */
  83422. scaleToRef(scale: number, result: Vector2): Vector2;
  83423. /**
  83424. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  83425. * @param scale defines the scale factor
  83426. * @param result defines the Vector2 object where to store the result
  83427. * @returns the unmodified current Vector2
  83428. */
  83429. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  83430. /**
  83431. * Gets a boolean if two vectors are equals
  83432. * @param otherVector defines the other vector
  83433. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  83434. */
  83435. equals(otherVector: DeepImmutable<Vector2>): boolean;
  83436. /**
  83437. * Gets a boolean if two vectors are equals (using an epsilon value)
  83438. * @param otherVector defines the other vector
  83439. * @param epsilon defines the minimal distance to consider equality
  83440. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  83441. */
  83442. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  83443. /**
  83444. * Gets a new Vector2 from current Vector2 floored values
  83445. * @returns a new Vector2
  83446. */
  83447. floor(): Vector2;
  83448. /**
  83449. * Gets a new Vector2 from current Vector2 floored values
  83450. * @returns a new Vector2
  83451. */
  83452. fract(): Vector2;
  83453. /**
  83454. * Gets the length of the vector
  83455. * @returns the vector length (float)
  83456. */
  83457. length(): number;
  83458. /**
  83459. * Gets the vector squared length
  83460. * @returns the vector squared length (float)
  83461. */
  83462. lengthSquared(): number;
  83463. /**
  83464. * Normalize the vector
  83465. * @returns the current updated Vector2
  83466. */
  83467. normalize(): Vector2;
  83468. /**
  83469. * Gets a new Vector2 copied from the Vector2
  83470. * @returns a new Vector2
  83471. */
  83472. clone(): Vector2;
  83473. /**
  83474. * Gets a new Vector2(0, 0)
  83475. * @returns a new Vector2
  83476. */
  83477. static Zero(): Vector2;
  83478. /**
  83479. * Gets a new Vector2(1, 1)
  83480. * @returns a new Vector2
  83481. */
  83482. static One(): Vector2;
  83483. /**
  83484. * Gets a new Vector2 set from the given index element of the given array
  83485. * @param array defines the data source
  83486. * @param offset defines the offset in the data source
  83487. * @returns a new Vector2
  83488. */
  83489. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  83490. /**
  83491. * Sets "result" from the given index element of the given array
  83492. * @param array defines the data source
  83493. * @param offset defines the offset in the data source
  83494. * @param result defines the target vector
  83495. */
  83496. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  83497. /**
  83498. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  83499. * @param value1 defines 1st point of control
  83500. * @param value2 defines 2nd point of control
  83501. * @param value3 defines 3rd point of control
  83502. * @param value4 defines 4th point of control
  83503. * @param amount defines the interpolation factor
  83504. * @returns a new Vector2
  83505. */
  83506. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  83507. /**
  83508. * 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".
  83509. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  83510. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  83511. * @param value defines the value to clamp
  83512. * @param min defines the lower limit
  83513. * @param max defines the upper limit
  83514. * @returns a new Vector2
  83515. */
  83516. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  83517. /**
  83518. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  83519. * @param value1 defines the 1st control point
  83520. * @param tangent1 defines the outgoing tangent
  83521. * @param value2 defines the 2nd control point
  83522. * @param tangent2 defines the incoming tangent
  83523. * @param amount defines the interpolation factor
  83524. * @returns a new Vector2
  83525. */
  83526. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  83527. /**
  83528. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  83529. * @param start defines the start vector
  83530. * @param end defines the end vector
  83531. * @param amount defines the interpolation factor
  83532. * @returns a new Vector2
  83533. */
  83534. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  83535. /**
  83536. * Gets the dot product of the vector "left" and the vector "right"
  83537. * @param left defines first vector
  83538. * @param right defines second vector
  83539. * @returns the dot product (float)
  83540. */
  83541. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  83542. /**
  83543. * Returns a new Vector2 equal to the normalized given vector
  83544. * @param vector defines the vector to normalize
  83545. * @returns a new Vector2
  83546. */
  83547. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  83548. /**
  83549. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  83550. * @param left defines 1st vector
  83551. * @param right defines 2nd vector
  83552. * @returns a new Vector2
  83553. */
  83554. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83555. /**
  83556. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  83557. * @param left defines 1st vector
  83558. * @param right defines 2nd vector
  83559. * @returns a new Vector2
  83560. */
  83561. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  83562. /**
  83563. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  83564. * @param vector defines the vector to transform
  83565. * @param transformation defines the matrix to apply
  83566. * @returns a new Vector2
  83567. */
  83568. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  83569. /**
  83570. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  83571. * @param vector defines the vector to transform
  83572. * @param transformation defines the matrix to apply
  83573. * @param result defines the target vector
  83574. */
  83575. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  83576. /**
  83577. * Determines if a given vector is included in a triangle
  83578. * @param p defines the vector to test
  83579. * @param p0 defines 1st triangle point
  83580. * @param p1 defines 2nd triangle point
  83581. * @param p2 defines 3rd triangle point
  83582. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  83583. */
  83584. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  83585. /**
  83586. * Gets the distance between the vectors "value1" and "value2"
  83587. * @param value1 defines first vector
  83588. * @param value2 defines second vector
  83589. * @returns the distance between vectors
  83590. */
  83591. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83592. /**
  83593. * Returns the squared distance between the vectors "value1" and "value2"
  83594. * @param value1 defines first vector
  83595. * @param value2 defines second vector
  83596. * @returns the squared distance between vectors
  83597. */
  83598. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  83599. /**
  83600. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  83601. * @param value1 defines first vector
  83602. * @param value2 defines second vector
  83603. * @returns a new Vector2
  83604. */
  83605. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  83606. /**
  83607. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  83608. * @param p defines the middle point
  83609. * @param segA defines one point of the segment
  83610. * @param segB defines the other point of the segment
  83611. * @returns the shortest distance
  83612. */
  83613. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  83614. }
  83615. /**
  83616. * Class used to store (x,y,z) vector representation
  83617. * A Vector3 is the main object used in 3D geometry
  83618. * It can represent etiher the coordinates of a point the space, either a direction
  83619. * Reminder: js uses a left handed forward facing system
  83620. */
  83621. export class Vector3 {
  83622. private static _UpReadOnly;
  83623. private static _ZeroReadOnly;
  83624. /** @hidden */
  83625. _x: number;
  83626. /** @hidden */
  83627. _y: number;
  83628. /** @hidden */
  83629. _z: number;
  83630. /** @hidden */
  83631. _isDirty: boolean;
  83632. /** Gets or sets the x coordinate */
  83633. get x(): number;
  83634. set x(value: number);
  83635. /** Gets or sets the y coordinate */
  83636. get y(): number;
  83637. set y(value: number);
  83638. /** Gets or sets the z coordinate */
  83639. get z(): number;
  83640. set z(value: number);
  83641. /**
  83642. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  83643. * @param x defines the first coordinates (on X axis)
  83644. * @param y defines the second coordinates (on Y axis)
  83645. * @param z defines the third coordinates (on Z axis)
  83646. */
  83647. constructor(x?: number, y?: number, z?: number);
  83648. /**
  83649. * Creates a string representation of the Vector3
  83650. * @returns a string with the Vector3 coordinates.
  83651. */
  83652. toString(): string;
  83653. /**
  83654. * Gets the class name
  83655. * @returns the string "Vector3"
  83656. */
  83657. getClassName(): string;
  83658. /**
  83659. * Creates the Vector3 hash code
  83660. * @returns a number which tends to be unique between Vector3 instances
  83661. */
  83662. getHashCode(): number;
  83663. /**
  83664. * Creates an array containing three elements : the coordinates of the Vector3
  83665. * @returns a new array of numbers
  83666. */
  83667. asArray(): number[];
  83668. /**
  83669. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83670. * @param array defines the destination array
  83671. * @param index defines the offset in the destination array
  83672. * @returns the current Vector3
  83673. */
  83674. toArray(array: FloatArray, index?: number): Vector3;
  83675. /**
  83676. * Update the current vector from an array
  83677. * @param array defines the destination array
  83678. * @param index defines the offset in the destination array
  83679. * @returns the current Vector3
  83680. */
  83681. fromArray(array: FloatArray, index?: number): Vector3;
  83682. /**
  83683. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83684. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83685. */
  83686. toQuaternion(): Quaternion;
  83687. /**
  83688. * Adds the given vector to the current Vector3
  83689. * @param otherVector defines the second operand
  83690. * @returns the current updated Vector3
  83691. */
  83692. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83693. /**
  83694. * Adds the given coordinates to the current Vector3
  83695. * @param x defines the x coordinate of the operand
  83696. * @param y defines the y coordinate of the operand
  83697. * @param z defines the z coordinate of the operand
  83698. * @returns the current updated Vector3
  83699. */
  83700. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83701. /**
  83702. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83703. * @param otherVector defines the second operand
  83704. * @returns the resulting Vector3
  83705. */
  83706. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83707. /**
  83708. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83709. * @param otherVector defines the second operand
  83710. * @param result defines the Vector3 object where to store the result
  83711. * @returns the current Vector3
  83712. */
  83713. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83714. /**
  83715. * Subtract the given vector from the current Vector3
  83716. * @param otherVector defines the second operand
  83717. * @returns the current updated Vector3
  83718. */
  83719. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83720. /**
  83721. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83722. * @param otherVector defines the second operand
  83723. * @returns the resulting Vector3
  83724. */
  83725. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83726. /**
  83727. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83728. * @param otherVector defines the second operand
  83729. * @param result defines the Vector3 object where to store the result
  83730. * @returns the current Vector3
  83731. */
  83732. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83733. /**
  83734. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83735. * @param x defines the x coordinate of the operand
  83736. * @param y defines the y coordinate of the operand
  83737. * @param z defines the z coordinate of the operand
  83738. * @returns the resulting Vector3
  83739. */
  83740. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83741. /**
  83742. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83743. * @param x defines the x coordinate of the operand
  83744. * @param y defines the y coordinate of the operand
  83745. * @param z defines the z coordinate of the operand
  83746. * @param result defines the Vector3 object where to store the result
  83747. * @returns the current Vector3
  83748. */
  83749. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83750. /**
  83751. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83752. * @returns a new Vector3
  83753. */
  83754. negate(): Vector3;
  83755. /**
  83756. * Negate this vector in place
  83757. * @returns this
  83758. */
  83759. negateInPlace(): Vector3;
  83760. /**
  83761. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83762. * @param result defines the Vector3 object where to store the result
  83763. * @returns the current Vector3
  83764. */
  83765. negateToRef(result: Vector3): Vector3;
  83766. /**
  83767. * Multiplies the Vector3 coordinates by the float "scale"
  83768. * @param scale defines the multiplier factor
  83769. * @returns the current updated Vector3
  83770. */
  83771. scaleInPlace(scale: number): Vector3;
  83772. /**
  83773. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83774. * @param scale defines the multiplier factor
  83775. * @returns a new Vector3
  83776. */
  83777. scale(scale: number): Vector3;
  83778. /**
  83779. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83780. * @param scale defines the multiplier factor
  83781. * @param result defines the Vector3 object where to store the result
  83782. * @returns the current Vector3
  83783. */
  83784. scaleToRef(scale: number, result: Vector3): Vector3;
  83785. /**
  83786. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83787. * @param scale defines the scale factor
  83788. * @param result defines the Vector3 object where to store the result
  83789. * @returns the unmodified current Vector3
  83790. */
  83791. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83792. /**
  83793. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83794. * @param origin defines the origin of the projection ray
  83795. * @param plane defines the plane to project to
  83796. * @returns the projected vector3
  83797. */
  83798. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83799. /**
  83800. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83801. * @param origin defines the origin of the projection ray
  83802. * @param plane defines the plane to project to
  83803. * @param result defines the Vector3 where to store the result
  83804. */
  83805. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83806. /**
  83807. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83808. * @param otherVector defines the second operand
  83809. * @returns true if both vectors are equals
  83810. */
  83811. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83812. /**
  83813. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83814. * @param otherVector defines the second operand
  83815. * @param epsilon defines the minimal distance to define values as equals
  83816. * @returns true if both vectors are distant less than epsilon
  83817. */
  83818. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83819. /**
  83820. * Returns true if the current Vector3 coordinates equals the given floats
  83821. * @param x defines the x coordinate of the operand
  83822. * @param y defines the y coordinate of the operand
  83823. * @param z defines the z coordinate of the operand
  83824. * @returns true if both vectors are equals
  83825. */
  83826. equalsToFloats(x: number, y: number, z: number): boolean;
  83827. /**
  83828. * Multiplies the current Vector3 coordinates by the given ones
  83829. * @param otherVector defines the second operand
  83830. * @returns the current updated Vector3
  83831. */
  83832. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83833. /**
  83834. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83835. * @param otherVector defines the second operand
  83836. * @returns the new Vector3
  83837. */
  83838. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83839. /**
  83840. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83841. * @param otherVector defines the second operand
  83842. * @param result defines the Vector3 object where to store the result
  83843. * @returns the current Vector3
  83844. */
  83845. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83846. /**
  83847. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83848. * @param x defines the x coordinate of the operand
  83849. * @param y defines the y coordinate of the operand
  83850. * @param z defines the z coordinate of the operand
  83851. * @returns the new Vector3
  83852. */
  83853. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83854. /**
  83855. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83856. * @param otherVector defines the second operand
  83857. * @returns the new Vector3
  83858. */
  83859. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83860. /**
  83861. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83862. * @param otherVector defines the second operand
  83863. * @param result defines the Vector3 object where to store the result
  83864. * @returns the current Vector3
  83865. */
  83866. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83867. /**
  83868. * Divides the current Vector3 coordinates by the given ones.
  83869. * @param otherVector defines the second operand
  83870. * @returns the current updated Vector3
  83871. */
  83872. divideInPlace(otherVector: Vector3): Vector3;
  83873. /**
  83874. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83875. * @param other defines the second operand
  83876. * @returns the current updated Vector3
  83877. */
  83878. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83879. /**
  83880. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83881. * @param other defines the second operand
  83882. * @returns the current updated Vector3
  83883. */
  83884. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83885. /**
  83886. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83887. * @param x defines the x coordinate of the operand
  83888. * @param y defines the y coordinate of the operand
  83889. * @param z defines the z coordinate of the operand
  83890. * @returns the current updated Vector3
  83891. */
  83892. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83893. /**
  83894. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83895. * @param x defines the x coordinate of the operand
  83896. * @param y defines the y coordinate of the operand
  83897. * @param z defines the z coordinate of the operand
  83898. * @returns the current updated Vector3
  83899. */
  83900. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83901. /**
  83902. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83903. * Check if is non uniform within a certain amount of decimal places to account for this
  83904. * @param epsilon the amount the values can differ
  83905. * @returns if the the vector is non uniform to a certain number of decimal places
  83906. */
  83907. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83908. /**
  83909. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83910. */
  83911. get isNonUniform(): boolean;
  83912. /**
  83913. * Gets a new Vector3 from current Vector3 floored values
  83914. * @returns a new Vector3
  83915. */
  83916. floor(): Vector3;
  83917. /**
  83918. * Gets a new Vector3 from current Vector3 floored values
  83919. * @returns a new Vector3
  83920. */
  83921. fract(): Vector3;
  83922. /**
  83923. * Gets the length of the Vector3
  83924. * @returns the length of the Vector3
  83925. */
  83926. length(): number;
  83927. /**
  83928. * Gets the squared length of the Vector3
  83929. * @returns squared length of the Vector3
  83930. */
  83931. lengthSquared(): number;
  83932. /**
  83933. * Normalize the current Vector3.
  83934. * Please note that this is an in place operation.
  83935. * @returns the current updated Vector3
  83936. */
  83937. normalize(): Vector3;
  83938. /**
  83939. * Reorders the x y z properties of the vector in place
  83940. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83941. * @returns the current updated vector
  83942. */
  83943. reorderInPlace(order: string): this;
  83944. /**
  83945. * Rotates the vector around 0,0,0 by a quaternion
  83946. * @param quaternion the rotation quaternion
  83947. * @param result vector to store the result
  83948. * @returns the resulting vector
  83949. */
  83950. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83951. /**
  83952. * Rotates a vector around a given point
  83953. * @param quaternion the rotation quaternion
  83954. * @param point the point to rotate around
  83955. * @param result vector to store the result
  83956. * @returns the resulting vector
  83957. */
  83958. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83959. /**
  83960. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83961. * The cross product is then orthogonal to both current and "other"
  83962. * @param other defines the right operand
  83963. * @returns the cross product
  83964. */
  83965. cross(other: Vector3): Vector3;
  83966. /**
  83967. * Normalize the current Vector3 with the given input length.
  83968. * Please note that this is an in place operation.
  83969. * @param len the length of the vector
  83970. * @returns the current updated Vector3
  83971. */
  83972. normalizeFromLength(len: number): Vector3;
  83973. /**
  83974. * Normalize the current Vector3 to a new vector
  83975. * @returns the new Vector3
  83976. */
  83977. normalizeToNew(): Vector3;
  83978. /**
  83979. * Normalize the current Vector3 to the reference
  83980. * @param reference define the Vector3 to update
  83981. * @returns the updated Vector3
  83982. */
  83983. normalizeToRef(reference: Vector3): Vector3;
  83984. /**
  83985. * Creates a new Vector3 copied from the current Vector3
  83986. * @returns the new Vector3
  83987. */
  83988. clone(): Vector3;
  83989. /**
  83990. * Copies the given vector coordinates to the current Vector3 ones
  83991. * @param source defines the source Vector3
  83992. * @returns the current updated Vector3
  83993. */
  83994. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83995. /**
  83996. * Copies the given floats to the current Vector3 coordinates
  83997. * @param x defines the x coordinate of the operand
  83998. * @param y defines the y coordinate of the operand
  83999. * @param z defines the z coordinate of the operand
  84000. * @returns the current updated Vector3
  84001. */
  84002. copyFromFloats(x: number, y: number, z: number): Vector3;
  84003. /**
  84004. * Copies the given floats to the current Vector3 coordinates
  84005. * @param x defines the x coordinate of the operand
  84006. * @param y defines the y coordinate of the operand
  84007. * @param z defines the z coordinate of the operand
  84008. * @returns the current updated Vector3
  84009. */
  84010. set(x: number, y: number, z: number): Vector3;
  84011. /**
  84012. * Copies the given float to the current Vector3 coordinates
  84013. * @param v defines the x, y and z coordinates of the operand
  84014. * @returns the current updated Vector3
  84015. */
  84016. setAll(v: number): Vector3;
  84017. /**
  84018. * Get the clip factor between two vectors
  84019. * @param vector0 defines the first operand
  84020. * @param vector1 defines the second operand
  84021. * @param axis defines the axis to use
  84022. * @param size defines the size along the axis
  84023. * @returns the clip factor
  84024. */
  84025. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  84026. /**
  84027. * Get angle between two vectors
  84028. * @param vector0 angle between vector0 and vector1
  84029. * @param vector1 angle between vector0 and vector1
  84030. * @param normal direction of the normal
  84031. * @return the angle between vector0 and vector1
  84032. */
  84033. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  84034. /**
  84035. * Returns a new Vector3 set from the index "offset" of the given array
  84036. * @param array defines the source array
  84037. * @param offset defines the offset in the source array
  84038. * @returns the new Vector3
  84039. */
  84040. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  84041. /**
  84042. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  84043. * @param array defines the source array
  84044. * @param offset defines the offset in the source array
  84045. * @returns the new Vector3
  84046. * @deprecated Please use FromArray instead.
  84047. */
  84048. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  84049. /**
  84050. * Sets the given vector "result" with the element values from the index "offset" of the given array
  84051. * @param array defines the source array
  84052. * @param offset defines the offset in the source array
  84053. * @param result defines the Vector3 where to store the result
  84054. */
  84055. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  84056. /**
  84057. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  84058. * @param array defines the source array
  84059. * @param offset defines the offset in the source array
  84060. * @param result defines the Vector3 where to store the result
  84061. * @deprecated Please use FromArrayToRef instead.
  84062. */
  84063. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  84064. /**
  84065. * Sets the given vector "result" with the given floats.
  84066. * @param x defines the x coordinate of the source
  84067. * @param y defines the y coordinate of the source
  84068. * @param z defines the z coordinate of the source
  84069. * @param result defines the Vector3 where to store the result
  84070. */
  84071. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  84072. /**
  84073. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  84074. * @returns a new empty Vector3
  84075. */
  84076. static Zero(): Vector3;
  84077. /**
  84078. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  84079. * @returns a new unit Vector3
  84080. */
  84081. static One(): Vector3;
  84082. /**
  84083. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  84084. * @returns a new up Vector3
  84085. */
  84086. static Up(): Vector3;
  84087. /**
  84088. * Gets a up Vector3 that must not be updated
  84089. */
  84090. static get UpReadOnly(): DeepImmutable<Vector3>;
  84091. /**
  84092. * Gets a zero Vector3 that must not be updated
  84093. */
  84094. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  84095. /**
  84096. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  84097. * @returns a new down Vector3
  84098. */
  84099. static Down(): Vector3;
  84100. /**
  84101. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  84102. * @param rightHandedSystem is the scene right-handed (negative z)
  84103. * @returns a new forward Vector3
  84104. */
  84105. static Forward(rightHandedSystem?: boolean): Vector3;
  84106. /**
  84107. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  84108. * @param rightHandedSystem is the scene right-handed (negative-z)
  84109. * @returns a new forward Vector3
  84110. */
  84111. static Backward(rightHandedSystem?: boolean): Vector3;
  84112. /**
  84113. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  84114. * @returns a new right Vector3
  84115. */
  84116. static Right(): Vector3;
  84117. /**
  84118. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  84119. * @returns a new left Vector3
  84120. */
  84121. static Left(): Vector3;
  84122. /**
  84123. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  84124. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84125. * @param vector defines the Vector3 to transform
  84126. * @param transformation defines the transformation matrix
  84127. * @returns the transformed Vector3
  84128. */
  84129. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84130. /**
  84131. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  84132. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  84133. * @param vector defines the Vector3 to transform
  84134. * @param transformation defines the transformation matrix
  84135. * @param result defines the Vector3 where to store the result
  84136. */
  84137. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84138. /**
  84139. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  84140. * This method computes tranformed coordinates only, not transformed direction vectors
  84141. * @param x define the x coordinate of the source vector
  84142. * @param y define the y coordinate of the source vector
  84143. * @param z define the z coordinate of the source vector
  84144. * @param transformation defines the transformation matrix
  84145. * @param result defines the Vector3 where to store the result
  84146. */
  84147. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84148. /**
  84149. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  84150. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84151. * @param vector defines the Vector3 to transform
  84152. * @param transformation defines the transformation matrix
  84153. * @returns the new Vector3
  84154. */
  84155. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  84156. /**
  84157. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  84158. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84159. * @param vector defines the Vector3 to transform
  84160. * @param transformation defines the transformation matrix
  84161. * @param result defines the Vector3 where to store the result
  84162. */
  84163. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84164. /**
  84165. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  84166. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  84167. * @param x define the x coordinate of the source vector
  84168. * @param y define the y coordinate of the source vector
  84169. * @param z define the z coordinate of the source vector
  84170. * @param transformation defines the transformation matrix
  84171. * @param result defines the Vector3 where to store the result
  84172. */
  84173. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  84174. /**
  84175. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  84176. * @param value1 defines the first control point
  84177. * @param value2 defines the second control point
  84178. * @param value3 defines the third control point
  84179. * @param value4 defines the fourth control point
  84180. * @param amount defines the amount on the spline to use
  84181. * @returns the new Vector3
  84182. */
  84183. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  84184. /**
  84185. * 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"
  84186. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84187. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84188. * @param value defines the current value
  84189. * @param min defines the lower range value
  84190. * @param max defines the upper range value
  84191. * @returns the new Vector3
  84192. */
  84193. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  84194. /**
  84195. * 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"
  84196. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  84197. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  84198. * @param value defines the current value
  84199. * @param min defines the lower range value
  84200. * @param max defines the upper range value
  84201. * @param result defines the Vector3 where to store the result
  84202. */
  84203. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  84204. /**
  84205. * Checks if a given vector is inside a specific range
  84206. * @param v defines the vector to test
  84207. * @param min defines the minimum range
  84208. * @param max defines the maximum range
  84209. */
  84210. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  84211. /**
  84212. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  84213. * @param value1 defines the first control point
  84214. * @param tangent1 defines the first tangent vector
  84215. * @param value2 defines the second control point
  84216. * @param tangent2 defines the second tangent vector
  84217. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  84218. * @returns the new Vector3
  84219. */
  84220. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  84221. /**
  84222. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  84223. * @param start defines the start value
  84224. * @param end defines the end value
  84225. * @param amount max defines amount between both (between 0 and 1)
  84226. * @returns the new Vector3
  84227. */
  84228. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  84229. /**
  84230. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  84231. * @param start defines the start value
  84232. * @param end defines the end value
  84233. * @param amount max defines amount between both (between 0 and 1)
  84234. * @param result defines the Vector3 where to store the result
  84235. */
  84236. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  84237. /**
  84238. * Returns the dot product (float) between the vectors "left" and "right"
  84239. * @param left defines the left operand
  84240. * @param right defines the right operand
  84241. * @returns the dot product
  84242. */
  84243. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  84244. /**
  84245. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  84246. * The cross product is then orthogonal to both "left" and "right"
  84247. * @param left defines the left operand
  84248. * @param right defines the right operand
  84249. * @returns the cross product
  84250. */
  84251. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84252. /**
  84253. * Sets the given vector "result" with the cross product of "left" and "right"
  84254. * The cross product is then orthogonal to both "left" and "right"
  84255. * @param left defines the left operand
  84256. * @param right defines the right operand
  84257. * @param result defines the Vector3 where to store the result
  84258. */
  84259. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  84260. /**
  84261. * Returns a new Vector3 as the normalization of the given vector
  84262. * @param vector defines the Vector3 to normalize
  84263. * @returns the new Vector3
  84264. */
  84265. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  84266. /**
  84267. * Sets the given vector "result" with the normalization of the given first vector
  84268. * @param vector defines the Vector3 to normalize
  84269. * @param result defines the Vector3 where to store the result
  84270. */
  84271. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  84272. /**
  84273. * Project a Vector3 onto screen space
  84274. * @param vector defines the Vector3 to project
  84275. * @param world defines the world matrix to use
  84276. * @param transform defines the transform (view x projection) matrix to use
  84277. * @param viewport defines the screen viewport to use
  84278. * @returns the new Vector3
  84279. */
  84280. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  84281. /**
  84282. * Project a Vector3 onto screen space to reference
  84283. * @param vector defines the Vector3 to project
  84284. * @param world defines the world matrix to use
  84285. * @param transform defines the transform (view x projection) matrix to use
  84286. * @param viewport defines the screen viewport to use
  84287. * @param result the vector in which the screen space will be stored
  84288. * @returns the new Vector3
  84289. */
  84290. static ProjectToRef(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>, result: DeepImmutable<Vector3>): Vector3;
  84291. /** @hidden */
  84292. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  84293. /**
  84294. * Unproject from screen space to object space
  84295. * @param source defines the screen space Vector3 to use
  84296. * @param viewportWidth defines the current width of the viewport
  84297. * @param viewportHeight defines the current height of the viewport
  84298. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84299. * @param transform defines the transform (view x projection) matrix to use
  84300. * @returns the new Vector3
  84301. */
  84302. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  84303. /**
  84304. * Unproject from screen space to object space
  84305. * @param source defines the screen space Vector3 to use
  84306. * @param viewportWidth defines the current width of the viewport
  84307. * @param viewportHeight defines the current height of the viewport
  84308. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84309. * @param view defines the view matrix to use
  84310. * @param projection defines the projection matrix to use
  84311. * @returns the new Vector3
  84312. */
  84313. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  84314. /**
  84315. * Unproject from screen space to object space
  84316. * @param source defines the screen space Vector3 to use
  84317. * @param viewportWidth defines the current width of the viewport
  84318. * @param viewportHeight defines the current height of the viewport
  84319. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84320. * @param view defines the view matrix to use
  84321. * @param projection defines the projection matrix to use
  84322. * @param result defines the Vector3 where to store the result
  84323. */
  84324. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  84325. /**
  84326. * Unproject from screen space to object space
  84327. * @param sourceX defines the screen space x coordinate to use
  84328. * @param sourceY defines the screen space y coordinate to use
  84329. * @param sourceZ defines the screen space z coordinate to use
  84330. * @param viewportWidth defines the current width of the viewport
  84331. * @param viewportHeight defines the current height of the viewport
  84332. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  84333. * @param view defines the view matrix to use
  84334. * @param projection defines the projection matrix to use
  84335. * @param result defines the Vector3 where to store the result
  84336. */
  84337. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  84338. /**
  84339. * Gets the minimal coordinate values between two Vector3
  84340. * @param left defines the first operand
  84341. * @param right defines the second operand
  84342. * @returns the new Vector3
  84343. */
  84344. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84345. /**
  84346. * Gets the maximal coordinate values between two Vector3
  84347. * @param left defines the first operand
  84348. * @param right defines the second operand
  84349. * @returns the new Vector3
  84350. */
  84351. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  84352. /**
  84353. * Returns the distance between the vectors "value1" and "value2"
  84354. * @param value1 defines the first operand
  84355. * @param value2 defines the second operand
  84356. * @returns the distance
  84357. */
  84358. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  84359. /**
  84360. * Returns the squared distance between the vectors "value1" and "value2"
  84361. * @param value1 defines the first operand
  84362. * @param value2 defines the second operand
  84363. * @returns the squared distance
  84364. */
  84365. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  84366. /**
  84367. * Returns a new Vector3 located at the center between "value1" and "value2"
  84368. * @param value1 defines the first operand
  84369. * @param value2 defines the second operand
  84370. * @returns the new Vector3
  84371. */
  84372. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  84373. /**
  84374. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  84375. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  84376. * to something in order to rotate it from its local system to the given target system
  84377. * Note: axis1, axis2 and axis3 are normalized during this operation
  84378. * @param axis1 defines the first axis
  84379. * @param axis2 defines the second axis
  84380. * @param axis3 defines the third axis
  84381. * @returns a new Vector3
  84382. */
  84383. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  84384. /**
  84385. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  84386. * @param axis1 defines the first axis
  84387. * @param axis2 defines the second axis
  84388. * @param axis3 defines the third axis
  84389. * @param ref defines the Vector3 where to store the result
  84390. */
  84391. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  84392. }
  84393. /**
  84394. * Vector4 class created for EulerAngle class conversion to Quaternion
  84395. */
  84396. export class Vector4 {
  84397. /** x value of the vector */
  84398. x: number;
  84399. /** y value of the vector */
  84400. y: number;
  84401. /** z value of the vector */
  84402. z: number;
  84403. /** w value of the vector */
  84404. w: number;
  84405. /**
  84406. * Creates a Vector4 object from the given floats.
  84407. * @param x x value of the vector
  84408. * @param y y value of the vector
  84409. * @param z z value of the vector
  84410. * @param w w value of the vector
  84411. */
  84412. constructor(
  84413. /** x value of the vector */
  84414. x: number,
  84415. /** y value of the vector */
  84416. y: number,
  84417. /** z value of the vector */
  84418. z: number,
  84419. /** w value of the vector */
  84420. w: number);
  84421. /**
  84422. * Returns the string with the Vector4 coordinates.
  84423. * @returns a string containing all the vector values
  84424. */
  84425. toString(): string;
  84426. /**
  84427. * Returns the string "Vector4".
  84428. * @returns "Vector4"
  84429. */
  84430. getClassName(): string;
  84431. /**
  84432. * Returns the Vector4 hash code.
  84433. * @returns a unique hash code
  84434. */
  84435. getHashCode(): number;
  84436. /**
  84437. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  84438. * @returns the resulting array
  84439. */
  84440. asArray(): number[];
  84441. /**
  84442. * Populates the given array from the given index with the Vector4 coordinates.
  84443. * @param array array to populate
  84444. * @param index index of the array to start at (default: 0)
  84445. * @returns the Vector4.
  84446. */
  84447. toArray(array: FloatArray, index?: number): Vector4;
  84448. /**
  84449. * Update the current vector from an array
  84450. * @param array defines the destination array
  84451. * @param index defines the offset in the destination array
  84452. * @returns the current Vector3
  84453. */
  84454. fromArray(array: FloatArray, index?: number): Vector4;
  84455. /**
  84456. * Adds the given vector to the current Vector4.
  84457. * @param otherVector the vector to add
  84458. * @returns the updated Vector4.
  84459. */
  84460. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84461. /**
  84462. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  84463. * @param otherVector the vector to add
  84464. * @returns the resulting vector
  84465. */
  84466. add(otherVector: DeepImmutable<Vector4>): Vector4;
  84467. /**
  84468. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  84469. * @param otherVector the vector to add
  84470. * @param result the vector to store the result
  84471. * @returns the current Vector4.
  84472. */
  84473. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84474. /**
  84475. * Subtract in place the given vector from the current Vector4.
  84476. * @param otherVector the vector to subtract
  84477. * @returns the updated Vector4.
  84478. */
  84479. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84480. /**
  84481. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  84482. * @param otherVector the vector to add
  84483. * @returns the new vector with the result
  84484. */
  84485. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  84486. /**
  84487. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  84488. * @param otherVector the vector to subtract
  84489. * @param result the vector to store the result
  84490. * @returns the current Vector4.
  84491. */
  84492. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84493. /**
  84494. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84495. */
  84496. /**
  84497. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84498. * @param x value to subtract
  84499. * @param y value to subtract
  84500. * @param z value to subtract
  84501. * @param w value to subtract
  84502. * @returns new vector containing the result
  84503. */
  84504. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84505. /**
  84506. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  84507. * @param x value to subtract
  84508. * @param y value to subtract
  84509. * @param z value to subtract
  84510. * @param w value to subtract
  84511. * @param result the vector to store the result in
  84512. * @returns the current Vector4.
  84513. */
  84514. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  84515. /**
  84516. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  84517. * @returns a new vector with the negated values
  84518. */
  84519. negate(): Vector4;
  84520. /**
  84521. * Negate this vector in place
  84522. * @returns this
  84523. */
  84524. negateInPlace(): Vector4;
  84525. /**
  84526. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  84527. * @param result defines the Vector3 object where to store the result
  84528. * @returns the current Vector4
  84529. */
  84530. negateToRef(result: Vector4): Vector4;
  84531. /**
  84532. * Multiplies the current Vector4 coordinates by scale (float).
  84533. * @param scale the number to scale with
  84534. * @returns the updated Vector4.
  84535. */
  84536. scaleInPlace(scale: number): Vector4;
  84537. /**
  84538. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  84539. * @param scale the number to scale with
  84540. * @returns a new vector with the result
  84541. */
  84542. scale(scale: number): Vector4;
  84543. /**
  84544. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  84545. * @param scale the number to scale with
  84546. * @param result a vector to store the result in
  84547. * @returns the current Vector4.
  84548. */
  84549. scaleToRef(scale: number, result: Vector4): Vector4;
  84550. /**
  84551. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  84552. * @param scale defines the scale factor
  84553. * @param result defines the Vector4 object where to store the result
  84554. * @returns the unmodified current Vector4
  84555. */
  84556. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  84557. /**
  84558. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  84559. * @param otherVector the vector to compare against
  84560. * @returns true if they are equal
  84561. */
  84562. equals(otherVector: DeepImmutable<Vector4>): boolean;
  84563. /**
  84564. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  84565. * @param otherVector vector to compare against
  84566. * @param epsilon (Default: very small number)
  84567. * @returns true if they are equal
  84568. */
  84569. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  84570. /**
  84571. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  84572. * @param x x value to compare against
  84573. * @param y y value to compare against
  84574. * @param z z value to compare against
  84575. * @param w w value to compare against
  84576. * @returns true if equal
  84577. */
  84578. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  84579. /**
  84580. * Multiplies in place the current Vector4 by the given one.
  84581. * @param otherVector vector to multiple with
  84582. * @returns the updated Vector4.
  84583. */
  84584. multiplyInPlace(otherVector: Vector4): Vector4;
  84585. /**
  84586. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  84587. * @param otherVector vector to multiple with
  84588. * @returns resulting new vector
  84589. */
  84590. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  84591. /**
  84592. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  84593. * @param otherVector vector to multiple with
  84594. * @param result vector to store the result
  84595. * @returns the current Vector4.
  84596. */
  84597. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84598. /**
  84599. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  84600. * @param x x value multiply with
  84601. * @param y y value multiply with
  84602. * @param z z value multiply with
  84603. * @param w w value multiply with
  84604. * @returns resulting new vector
  84605. */
  84606. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  84607. /**
  84608. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  84609. * @param otherVector vector to devide with
  84610. * @returns resulting new vector
  84611. */
  84612. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  84613. /**
  84614. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  84615. * @param otherVector vector to devide with
  84616. * @param result vector to store the result
  84617. * @returns the current Vector4.
  84618. */
  84619. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  84620. /**
  84621. * Divides the current Vector3 coordinates by the given ones.
  84622. * @param otherVector vector to devide with
  84623. * @returns the updated Vector3.
  84624. */
  84625. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  84626. /**
  84627. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  84628. * @param other defines the second operand
  84629. * @returns the current updated Vector4
  84630. */
  84631. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84632. /**
  84633. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  84634. * @param other defines the second operand
  84635. * @returns the current updated Vector4
  84636. */
  84637. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  84638. /**
  84639. * Gets a new Vector4 from current Vector4 floored values
  84640. * @returns a new Vector4
  84641. */
  84642. floor(): Vector4;
  84643. /**
  84644. * Gets a new Vector4 from current Vector3 floored values
  84645. * @returns a new Vector4
  84646. */
  84647. fract(): Vector4;
  84648. /**
  84649. * Returns the Vector4 length (float).
  84650. * @returns the length
  84651. */
  84652. length(): number;
  84653. /**
  84654. * Returns the Vector4 squared length (float).
  84655. * @returns the length squared
  84656. */
  84657. lengthSquared(): number;
  84658. /**
  84659. * Normalizes in place the Vector4.
  84660. * @returns the updated Vector4.
  84661. */
  84662. normalize(): Vector4;
  84663. /**
  84664. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  84665. * @returns this converted to a new vector3
  84666. */
  84667. toVector3(): Vector3;
  84668. /**
  84669. * Returns a new Vector4 copied from the current one.
  84670. * @returns the new cloned vector
  84671. */
  84672. clone(): Vector4;
  84673. /**
  84674. * Updates the current Vector4 with the given one coordinates.
  84675. * @param source the source vector to copy from
  84676. * @returns the updated Vector4.
  84677. */
  84678. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84679. /**
  84680. * Updates the current Vector4 coordinates with the given floats.
  84681. * @param x float to copy from
  84682. * @param y float to copy from
  84683. * @param z float to copy from
  84684. * @param w float to copy from
  84685. * @returns the updated Vector4.
  84686. */
  84687. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84688. /**
  84689. * Updates the current Vector4 coordinates with the given floats.
  84690. * @param x float to set from
  84691. * @param y float to set from
  84692. * @param z float to set from
  84693. * @param w float to set from
  84694. * @returns the updated Vector4.
  84695. */
  84696. set(x: number, y: number, z: number, w: number): Vector4;
  84697. /**
  84698. * Copies the given float to the current Vector3 coordinates
  84699. * @param v defines the x, y, z and w coordinates of the operand
  84700. * @returns the current updated Vector3
  84701. */
  84702. setAll(v: number): Vector4;
  84703. /**
  84704. * Returns a new Vector4 set from the starting index of the given array.
  84705. * @param array the array to pull values from
  84706. * @param offset the offset into the array to start at
  84707. * @returns the new vector
  84708. */
  84709. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84710. /**
  84711. * Updates the given vector "result" from the starting index of the given array.
  84712. * @param array the array to pull values from
  84713. * @param offset the offset into the array to start at
  84714. * @param result the vector to store the result in
  84715. */
  84716. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84717. /**
  84718. * Updates the given vector "result" from the starting index of the given Float32Array.
  84719. * @param array the array to pull values from
  84720. * @param offset the offset into the array to start at
  84721. * @param result the vector to store the result in
  84722. */
  84723. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84724. /**
  84725. * Updates the given vector "result" coordinates from the given floats.
  84726. * @param x float to set from
  84727. * @param y float to set from
  84728. * @param z float to set from
  84729. * @param w float to set from
  84730. * @param result the vector to the floats in
  84731. */
  84732. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84733. /**
  84734. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84735. * @returns the new vector
  84736. */
  84737. static Zero(): Vector4;
  84738. /**
  84739. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84740. * @returns the new vector
  84741. */
  84742. static One(): Vector4;
  84743. /**
  84744. * Returns a new normalized Vector4 from the given one.
  84745. * @param vector the vector to normalize
  84746. * @returns the vector
  84747. */
  84748. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84749. /**
  84750. * Updates the given vector "result" from the normalization of the given one.
  84751. * @param vector the vector to normalize
  84752. * @param result the vector to store the result in
  84753. */
  84754. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84755. /**
  84756. * Returns a vector with the minimum values from the left and right vectors
  84757. * @param left left vector to minimize
  84758. * @param right right vector to minimize
  84759. * @returns a new vector with the minimum of the left and right vector values
  84760. */
  84761. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84762. /**
  84763. * Returns a vector with the maximum values from the left and right vectors
  84764. * @param left left vector to maximize
  84765. * @param right right vector to maximize
  84766. * @returns a new vector with the maximum of the left and right vector values
  84767. */
  84768. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84769. /**
  84770. * Returns the distance (float) between the vectors "value1" and "value2".
  84771. * @param value1 value to calulate the distance between
  84772. * @param value2 value to calulate the distance between
  84773. * @return the distance between the two vectors
  84774. */
  84775. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84776. /**
  84777. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84778. * @param value1 value to calulate the distance between
  84779. * @param value2 value to calulate the distance between
  84780. * @return the distance between the two vectors squared
  84781. */
  84782. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84783. /**
  84784. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84785. * @param value1 value to calulate the center between
  84786. * @param value2 value to calulate the center between
  84787. * @return the center between the two vectors
  84788. */
  84789. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84790. /**
  84791. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84792. * This methods computes transformed normalized direction vectors only.
  84793. * @param vector the vector to transform
  84794. * @param transformation the transformation matrix to apply
  84795. * @returns the new vector
  84796. */
  84797. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84798. /**
  84799. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84800. * This methods computes transformed normalized direction vectors only.
  84801. * @param vector the vector to transform
  84802. * @param transformation the transformation matrix to apply
  84803. * @param result the vector to store the result in
  84804. */
  84805. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84806. /**
  84807. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84808. * This methods computes transformed normalized direction vectors only.
  84809. * @param x value to transform
  84810. * @param y value to transform
  84811. * @param z value to transform
  84812. * @param w value to transform
  84813. * @param transformation the transformation matrix to apply
  84814. * @param result the vector to store the results in
  84815. */
  84816. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84817. /**
  84818. * Creates a new Vector4 from a Vector3
  84819. * @param source defines the source data
  84820. * @param w defines the 4th component (default is 0)
  84821. * @returns a new Vector4
  84822. */
  84823. static FromVector3(source: Vector3, w?: number): Vector4;
  84824. }
  84825. /**
  84826. * Class used to store quaternion data
  84827. * @see https://en.wikipedia.org/wiki/Quaternion
  84828. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84829. */
  84830. export class Quaternion {
  84831. /** @hidden */
  84832. _x: number;
  84833. /** @hidden */
  84834. _y: number;
  84835. /** @hidden */
  84836. _z: number;
  84837. /** @hidden */
  84838. _w: number;
  84839. /** @hidden */
  84840. _isDirty: boolean;
  84841. /** Gets or sets the x coordinate */
  84842. get x(): number;
  84843. set x(value: number);
  84844. /** Gets or sets the y coordinate */
  84845. get y(): number;
  84846. set y(value: number);
  84847. /** Gets or sets the z coordinate */
  84848. get z(): number;
  84849. set z(value: number);
  84850. /** Gets or sets the w coordinate */
  84851. get w(): number;
  84852. set w(value: number);
  84853. /**
  84854. * Creates a new Quaternion from the given floats
  84855. * @param x defines the first component (0 by default)
  84856. * @param y defines the second component (0 by default)
  84857. * @param z defines the third component (0 by default)
  84858. * @param w defines the fourth component (1.0 by default)
  84859. */
  84860. constructor(x?: number, y?: number, z?: number, w?: number);
  84861. /**
  84862. * Gets a string representation for the current quaternion
  84863. * @returns a string with the Quaternion coordinates
  84864. */
  84865. toString(): string;
  84866. /**
  84867. * Gets the class name of the quaternion
  84868. * @returns the string "Quaternion"
  84869. */
  84870. getClassName(): string;
  84871. /**
  84872. * Gets a hash code for this quaternion
  84873. * @returns the quaternion hash code
  84874. */
  84875. getHashCode(): number;
  84876. /**
  84877. * Copy the quaternion to an array
  84878. * @returns a new array populated with 4 elements from the quaternion coordinates
  84879. */
  84880. asArray(): number[];
  84881. /**
  84882. * Check if two quaternions are equals
  84883. * @param otherQuaternion defines the second operand
  84884. * @return true if the current quaternion and the given one coordinates are strictly equals
  84885. */
  84886. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84887. /**
  84888. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84889. * @param otherQuaternion defines the other quaternion
  84890. * @param epsilon defines the minimal distance to consider equality
  84891. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84892. */
  84893. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84894. /**
  84895. * Clone the current quaternion
  84896. * @returns a new quaternion copied from the current one
  84897. */
  84898. clone(): Quaternion;
  84899. /**
  84900. * Copy a quaternion to the current one
  84901. * @param other defines the other quaternion
  84902. * @returns the updated current quaternion
  84903. */
  84904. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84905. /**
  84906. * Updates the current quaternion with the given float coordinates
  84907. * @param x defines the x coordinate
  84908. * @param y defines the y coordinate
  84909. * @param z defines the z coordinate
  84910. * @param w defines the w coordinate
  84911. * @returns the updated current quaternion
  84912. */
  84913. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84914. /**
  84915. * Updates the current quaternion from the given float coordinates
  84916. * @param x defines the x coordinate
  84917. * @param y defines the y coordinate
  84918. * @param z defines the z coordinate
  84919. * @param w defines the w coordinate
  84920. * @returns the updated current quaternion
  84921. */
  84922. set(x: number, y: number, z: number, w: number): Quaternion;
  84923. /**
  84924. * Adds two quaternions
  84925. * @param other defines the second operand
  84926. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84927. */
  84928. add(other: DeepImmutable<Quaternion>): Quaternion;
  84929. /**
  84930. * Add a quaternion to the current one
  84931. * @param other defines the quaternion to add
  84932. * @returns the current quaternion
  84933. */
  84934. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84935. /**
  84936. * Subtract two quaternions
  84937. * @param other defines the second operand
  84938. * @returns a new quaternion as the subtraction result of the given one from the current one
  84939. */
  84940. subtract(other: Quaternion): Quaternion;
  84941. /**
  84942. * Multiplies the current quaternion by a scale factor
  84943. * @param value defines the scale factor
  84944. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84945. */
  84946. scale(value: number): Quaternion;
  84947. /**
  84948. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84949. * @param scale defines the scale factor
  84950. * @param result defines the Quaternion object where to store the result
  84951. * @returns the unmodified current quaternion
  84952. */
  84953. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84954. /**
  84955. * Multiplies in place the current quaternion by a scale factor
  84956. * @param value defines the scale factor
  84957. * @returns the current modified quaternion
  84958. */
  84959. scaleInPlace(value: number): Quaternion;
  84960. /**
  84961. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84962. * @param scale defines the scale factor
  84963. * @param result defines the Quaternion object where to store the result
  84964. * @returns the unmodified current quaternion
  84965. */
  84966. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84967. /**
  84968. * Multiplies two quaternions
  84969. * @param q1 defines the second operand
  84970. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84971. */
  84972. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84973. /**
  84974. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84975. * @param q1 defines the second operand
  84976. * @param result defines the target quaternion
  84977. * @returns the current quaternion
  84978. */
  84979. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84980. /**
  84981. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84982. * @param q1 defines the second operand
  84983. * @returns the currentupdated quaternion
  84984. */
  84985. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84986. /**
  84987. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84988. * @param ref defines the target quaternion
  84989. * @returns the current quaternion
  84990. */
  84991. conjugateToRef(ref: Quaternion): Quaternion;
  84992. /**
  84993. * Conjugates in place (1-q) the current quaternion
  84994. * @returns the current updated quaternion
  84995. */
  84996. conjugateInPlace(): Quaternion;
  84997. /**
  84998. * Conjugates in place (1-q) the current quaternion
  84999. * @returns a new quaternion
  85000. */
  85001. conjugate(): Quaternion;
  85002. /**
  85003. * Gets length of current quaternion
  85004. * @returns the quaternion length (float)
  85005. */
  85006. length(): number;
  85007. /**
  85008. * Normalize in place the current quaternion
  85009. * @returns the current updated quaternion
  85010. */
  85011. normalize(): Quaternion;
  85012. /**
  85013. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  85014. * @param order is a reserved parameter and is ignored for now
  85015. * @returns a new Vector3 containing the Euler angles
  85016. */
  85017. toEulerAngles(order?: string): Vector3;
  85018. /**
  85019. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  85020. * @param result defines the vector which will be filled with the Euler angles
  85021. * @returns the current unchanged quaternion
  85022. */
  85023. toEulerAnglesToRef(result: Vector3): Quaternion;
  85024. /**
  85025. * Updates the given rotation matrix with the current quaternion values
  85026. * @param result defines the target matrix
  85027. * @returns the current unchanged quaternion
  85028. */
  85029. toRotationMatrix(result: Matrix): Quaternion;
  85030. /**
  85031. * Updates the current quaternion from the given rotation matrix values
  85032. * @param matrix defines the source matrix
  85033. * @returns the current updated quaternion
  85034. */
  85035. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85036. /**
  85037. * Creates a new quaternion from a rotation matrix
  85038. * @param matrix defines the source matrix
  85039. * @returns a new quaternion created from the given rotation matrix values
  85040. */
  85041. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  85042. /**
  85043. * Updates the given quaternion with the given rotation matrix values
  85044. * @param matrix defines the source matrix
  85045. * @param result defines the target quaternion
  85046. */
  85047. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  85048. /**
  85049. * Returns the dot product (float) between the quaternions "left" and "right"
  85050. * @param left defines the left operand
  85051. * @param right defines the right operand
  85052. * @returns the dot product
  85053. */
  85054. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  85055. /**
  85056. * Checks if the two quaternions are close to each other
  85057. * @param quat0 defines the first quaternion to check
  85058. * @param quat1 defines the second quaternion to check
  85059. * @returns true if the two quaternions are close to each other
  85060. */
  85061. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  85062. /**
  85063. * Creates an empty quaternion
  85064. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  85065. */
  85066. static Zero(): Quaternion;
  85067. /**
  85068. * Inverse a given quaternion
  85069. * @param q defines the source quaternion
  85070. * @returns a new quaternion as the inverted current quaternion
  85071. */
  85072. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  85073. /**
  85074. * Inverse a given quaternion
  85075. * @param q defines the source quaternion
  85076. * @param result the quaternion the result will be stored in
  85077. * @returns the result quaternion
  85078. */
  85079. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  85080. /**
  85081. * Creates an identity quaternion
  85082. * @returns the identity quaternion
  85083. */
  85084. static Identity(): Quaternion;
  85085. /**
  85086. * Gets a boolean indicating if the given quaternion is identity
  85087. * @param quaternion defines the quaternion to check
  85088. * @returns true if the quaternion is identity
  85089. */
  85090. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  85091. /**
  85092. * Creates a quaternion from a rotation around an axis
  85093. * @param axis defines the axis to use
  85094. * @param angle defines the angle to use
  85095. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  85096. */
  85097. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  85098. /**
  85099. * Creates a rotation around an axis and stores it into the given quaternion
  85100. * @param axis defines the axis to use
  85101. * @param angle defines the angle to use
  85102. * @param result defines the target quaternion
  85103. * @returns the target quaternion
  85104. */
  85105. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  85106. /**
  85107. * Creates a new quaternion from data stored into an array
  85108. * @param array defines the data source
  85109. * @param offset defines the offset in the source array where the data starts
  85110. * @returns a new quaternion
  85111. */
  85112. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  85113. /**
  85114. * Updates the given quaternion "result" from the starting index of the given array.
  85115. * @param array the array to pull values from
  85116. * @param offset the offset into the array to start at
  85117. * @param result the quaternion to store the result in
  85118. */
  85119. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  85120. /**
  85121. * Create a quaternion from Euler rotation angles
  85122. * @param x Pitch
  85123. * @param y Yaw
  85124. * @param z Roll
  85125. * @returns the new Quaternion
  85126. */
  85127. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  85128. /**
  85129. * Updates a quaternion from Euler rotation angles
  85130. * @param x Pitch
  85131. * @param y Yaw
  85132. * @param z Roll
  85133. * @param result the quaternion to store the result
  85134. * @returns the updated quaternion
  85135. */
  85136. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  85137. /**
  85138. * Create a quaternion from Euler rotation vector
  85139. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85140. * @returns the new Quaternion
  85141. */
  85142. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  85143. /**
  85144. * Updates a quaternion from Euler rotation vector
  85145. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  85146. * @param result the quaternion to store the result
  85147. * @returns the updated quaternion
  85148. */
  85149. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  85150. /**
  85151. * Creates a new quaternion from the given Euler float angles (y, x, z)
  85152. * @param yaw defines the rotation around Y axis
  85153. * @param pitch defines the rotation around X axis
  85154. * @param roll defines the rotation around Z axis
  85155. * @returns the new quaternion
  85156. */
  85157. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  85158. /**
  85159. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  85160. * @param yaw defines the rotation around Y axis
  85161. * @param pitch defines the rotation around X axis
  85162. * @param roll defines the rotation around Z axis
  85163. * @param result defines the target quaternion
  85164. */
  85165. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  85166. /**
  85167. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  85168. * @param alpha defines the rotation around first axis
  85169. * @param beta defines the rotation around second axis
  85170. * @param gamma defines the rotation around third axis
  85171. * @returns the new quaternion
  85172. */
  85173. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  85174. /**
  85175. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  85176. * @param alpha defines the rotation around first axis
  85177. * @param beta defines the rotation around second axis
  85178. * @param gamma defines the rotation around third axis
  85179. * @param result defines the target quaternion
  85180. */
  85181. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  85182. /**
  85183. * 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)
  85184. * @param axis1 defines the first axis
  85185. * @param axis2 defines the second axis
  85186. * @param axis3 defines the third axis
  85187. * @returns the new quaternion
  85188. */
  85189. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  85190. /**
  85191. * 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
  85192. * @param axis1 defines the first axis
  85193. * @param axis2 defines the second axis
  85194. * @param axis3 defines the third axis
  85195. * @param ref defines the target quaternion
  85196. */
  85197. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  85198. /**
  85199. * Interpolates between two quaternions
  85200. * @param left defines first quaternion
  85201. * @param right defines second quaternion
  85202. * @param amount defines the gradient to use
  85203. * @returns the new interpolated quaternion
  85204. */
  85205. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  85206. /**
  85207. * Interpolates between two quaternions and stores it into a target quaternion
  85208. * @param left defines first quaternion
  85209. * @param right defines second quaternion
  85210. * @param amount defines the gradient to use
  85211. * @param result defines the target quaternion
  85212. */
  85213. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  85214. /**
  85215. * Interpolate between two quaternions using Hermite interpolation
  85216. * @param value1 defines first quaternion
  85217. * @param tangent1 defines the incoming tangent
  85218. * @param value2 defines second quaternion
  85219. * @param tangent2 defines the outgoing tangent
  85220. * @param amount defines the target quaternion
  85221. * @returns the new interpolated quaternion
  85222. */
  85223. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  85224. }
  85225. /**
  85226. * Class used to store matrix data (4x4)
  85227. */
  85228. export class Matrix {
  85229. /**
  85230. * Gets the precision of matrix computations
  85231. */
  85232. static get Use64Bits(): boolean;
  85233. private static _updateFlagSeed;
  85234. private static _identityReadOnly;
  85235. private _isIdentity;
  85236. private _isIdentityDirty;
  85237. private _isIdentity3x2;
  85238. private _isIdentity3x2Dirty;
  85239. /**
  85240. * Gets the update flag of the matrix which is an unique number for the matrix.
  85241. * It will be incremented every time the matrix data change.
  85242. * You can use it to speed the comparison between two versions of the same matrix.
  85243. */
  85244. updateFlag: number;
  85245. private readonly _m;
  85246. /**
  85247. * Gets the internal data of the matrix
  85248. */
  85249. get m(): DeepImmutable<Float32Array | Array<number>>;
  85250. /** @hidden */
  85251. _markAsUpdated(): void;
  85252. /** @hidden */
  85253. private _updateIdentityStatus;
  85254. /**
  85255. * Creates an empty matrix (filled with zeros)
  85256. */
  85257. constructor();
  85258. /**
  85259. * Check if the current matrix is identity
  85260. * @returns true is the matrix is the identity matrix
  85261. */
  85262. isIdentity(): boolean;
  85263. /**
  85264. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  85265. * @returns true is the matrix is the identity matrix
  85266. */
  85267. isIdentityAs3x2(): boolean;
  85268. /**
  85269. * Gets the determinant of the matrix
  85270. * @returns the matrix determinant
  85271. */
  85272. determinant(): number;
  85273. /**
  85274. * Returns the matrix as a Float32Array or Array<number>
  85275. * @returns the matrix underlying array
  85276. */
  85277. toArray(): DeepImmutable<Float32Array | Array<number>>;
  85278. /**
  85279. * Returns the matrix as a Float32Array or Array<number>
  85280. * @returns the matrix underlying array.
  85281. */
  85282. asArray(): DeepImmutable<Float32Array | Array<number>>;
  85283. /**
  85284. * Inverts the current matrix in place
  85285. * @returns the current inverted matrix
  85286. */
  85287. invert(): Matrix;
  85288. /**
  85289. * Sets all the matrix elements to zero
  85290. * @returns the current matrix
  85291. */
  85292. reset(): Matrix;
  85293. /**
  85294. * Adds the current matrix with a second one
  85295. * @param other defines the matrix to add
  85296. * @returns a new matrix as the addition of the current matrix and the given one
  85297. */
  85298. add(other: DeepImmutable<Matrix>): Matrix;
  85299. /**
  85300. * Sets the given matrix "result" to the addition of the current matrix and the given one
  85301. * @param other defines the matrix to add
  85302. * @param result defines the target matrix
  85303. * @returns the current matrix
  85304. */
  85305. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  85306. /**
  85307. * Adds in place the given matrix to the current matrix
  85308. * @param other defines the second operand
  85309. * @returns the current updated matrix
  85310. */
  85311. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  85312. /**
  85313. * Sets the given matrix to the current inverted Matrix
  85314. * @param other defines the target matrix
  85315. * @returns the unmodified current matrix
  85316. */
  85317. invertToRef(other: Matrix): Matrix;
  85318. /**
  85319. * add a value at the specified position in the current Matrix
  85320. * @param index the index of the value within the matrix. between 0 and 15.
  85321. * @param value the value to be added
  85322. * @returns the current updated matrix
  85323. */
  85324. addAtIndex(index: number, value: number): Matrix;
  85325. /**
  85326. * mutiply the specified position in the current Matrix by a value
  85327. * @param index the index of the value within the matrix. between 0 and 15.
  85328. * @param value the value to be added
  85329. * @returns the current updated matrix
  85330. */
  85331. multiplyAtIndex(index: number, value: number): Matrix;
  85332. /**
  85333. * Inserts the translation vector (using 3 floats) in the current matrix
  85334. * @param x defines the 1st component of the translation
  85335. * @param y defines the 2nd component of the translation
  85336. * @param z defines the 3rd component of the translation
  85337. * @returns the current updated matrix
  85338. */
  85339. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  85340. /**
  85341. * Adds the translation vector (using 3 floats) in the current matrix
  85342. * @param x defines the 1st component of the translation
  85343. * @param y defines the 2nd component of the translation
  85344. * @param z defines the 3rd component of the translation
  85345. * @returns the current updated matrix
  85346. */
  85347. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  85348. /**
  85349. * Inserts the translation vector in the current matrix
  85350. * @param vector3 defines the translation to insert
  85351. * @returns the current updated matrix
  85352. */
  85353. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  85354. /**
  85355. * Gets the translation value of the current matrix
  85356. * @returns a new Vector3 as the extracted translation from the matrix
  85357. */
  85358. getTranslation(): Vector3;
  85359. /**
  85360. * Fill a Vector3 with the extracted translation from the matrix
  85361. * @param result defines the Vector3 where to store the translation
  85362. * @returns the current matrix
  85363. */
  85364. getTranslationToRef(result: Vector3): Matrix;
  85365. /**
  85366. * Remove rotation and scaling part from the matrix
  85367. * @returns the updated matrix
  85368. */
  85369. removeRotationAndScaling(): Matrix;
  85370. /**
  85371. * Multiply two matrices
  85372. * @param other defines the second operand
  85373. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  85374. */
  85375. multiply(other: DeepImmutable<Matrix>): Matrix;
  85376. /**
  85377. * Copy the current matrix from the given one
  85378. * @param other defines the source matrix
  85379. * @returns the current updated matrix
  85380. */
  85381. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  85382. /**
  85383. * Populates the given array from the starting index with the current matrix values
  85384. * @param array defines the target array
  85385. * @param offset defines the offset in the target array where to start storing values
  85386. * @returns the current matrix
  85387. */
  85388. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  85389. /**
  85390. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  85391. * @param other defines the second operand
  85392. * @param result defines the matrix where to store the multiplication
  85393. * @returns the current matrix
  85394. */
  85395. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  85396. /**
  85397. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  85398. * @param other defines the second operand
  85399. * @param result defines the array where to store the multiplication
  85400. * @param offset defines the offset in the target array where to start storing values
  85401. * @returns the current matrix
  85402. */
  85403. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  85404. /**
  85405. * Check equality between this matrix and a second one
  85406. * @param value defines the second matrix to compare
  85407. * @returns true is the current matrix and the given one values are strictly equal
  85408. */
  85409. equals(value: DeepImmutable<Matrix>): boolean;
  85410. /**
  85411. * Clone the current matrix
  85412. * @returns a new matrix from the current matrix
  85413. */
  85414. clone(): Matrix;
  85415. /**
  85416. * Returns the name of the current matrix class
  85417. * @returns the string "Matrix"
  85418. */
  85419. getClassName(): string;
  85420. /**
  85421. * Gets the hash code of the current matrix
  85422. * @returns the hash code
  85423. */
  85424. getHashCode(): number;
  85425. /**
  85426. * Decomposes the current Matrix into a translation, rotation and scaling components
  85427. * @param scale defines the scale vector3 given as a reference to update
  85428. * @param rotation defines the rotation quaternion given as a reference to update
  85429. * @param translation defines the translation vector3 given as a reference to update
  85430. * @returns true if operation was successful
  85431. */
  85432. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  85433. /**
  85434. * Gets specific row of the matrix
  85435. * @param index defines the number of the row to get
  85436. * @returns the index-th row of the current matrix as a new Vector4
  85437. */
  85438. getRow(index: number): Nullable<Vector4>;
  85439. /**
  85440. * Sets the index-th row of the current matrix to the vector4 values
  85441. * @param index defines the number of the row to set
  85442. * @param row defines the target vector4
  85443. * @returns the updated current matrix
  85444. */
  85445. setRow(index: number, row: Vector4): Matrix;
  85446. /**
  85447. * Compute the transpose of the matrix
  85448. * @returns the new transposed matrix
  85449. */
  85450. transpose(): Matrix;
  85451. /**
  85452. * Compute the transpose of the matrix and store it in a given matrix
  85453. * @param result defines the target matrix
  85454. * @returns the current matrix
  85455. */
  85456. transposeToRef(result: Matrix): Matrix;
  85457. /**
  85458. * Sets the index-th row of the current matrix with the given 4 x float values
  85459. * @param index defines the row index
  85460. * @param x defines the x component to set
  85461. * @param y defines the y component to set
  85462. * @param z defines the z component to set
  85463. * @param w defines the w component to set
  85464. * @returns the updated current matrix
  85465. */
  85466. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  85467. /**
  85468. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  85469. * @param scale defines the scale factor
  85470. * @returns a new matrix
  85471. */
  85472. scale(scale: number): Matrix;
  85473. /**
  85474. * Scale the current matrix values by a factor to a given result matrix
  85475. * @param scale defines the scale factor
  85476. * @param result defines the matrix to store the result
  85477. * @returns the current matrix
  85478. */
  85479. scaleToRef(scale: number, result: Matrix): Matrix;
  85480. /**
  85481. * Scale the current matrix values by a factor and add the result to a given matrix
  85482. * @param scale defines the scale factor
  85483. * @param result defines the Matrix to store the result
  85484. * @returns the current matrix
  85485. */
  85486. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  85487. /**
  85488. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  85489. * @param ref matrix to store the result
  85490. */
  85491. toNormalMatrix(ref: Matrix): void;
  85492. /**
  85493. * Gets only rotation part of the current matrix
  85494. * @returns a new matrix sets to the extracted rotation matrix from the current one
  85495. */
  85496. getRotationMatrix(): Matrix;
  85497. /**
  85498. * Extracts the rotation matrix from the current one and sets it as the given "result"
  85499. * @param result defines the target matrix to store data to
  85500. * @returns the current matrix
  85501. */
  85502. getRotationMatrixToRef(result: Matrix): Matrix;
  85503. /**
  85504. * Toggles model matrix from being right handed to left handed in place and vice versa
  85505. */
  85506. toggleModelMatrixHandInPlace(): void;
  85507. /**
  85508. * Toggles projection matrix from being right handed to left handed in place and vice versa
  85509. */
  85510. toggleProjectionMatrixHandInPlace(): void;
  85511. /**
  85512. * Creates a matrix from an array
  85513. * @param array defines the source array
  85514. * @param offset defines an offset in the source array
  85515. * @returns a new Matrix set from the starting index of the given array
  85516. */
  85517. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  85518. /**
  85519. * Copy the content of an array into a given matrix
  85520. * @param array defines the source array
  85521. * @param offset defines an offset in the source array
  85522. * @param result defines the target matrix
  85523. */
  85524. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  85525. /**
  85526. * Stores an array into a matrix after having multiplied each component by a given factor
  85527. * @param array defines the source array
  85528. * @param offset defines the offset in the source array
  85529. * @param scale defines the scaling factor
  85530. * @param result defines the target matrix
  85531. */
  85532. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  85533. /**
  85534. * Gets an identity matrix that must not be updated
  85535. */
  85536. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  85537. /**
  85538. * Stores a list of values (16) inside a given matrix
  85539. * @param initialM11 defines 1st value of 1st row
  85540. * @param initialM12 defines 2nd value of 1st row
  85541. * @param initialM13 defines 3rd value of 1st row
  85542. * @param initialM14 defines 4th value of 1st row
  85543. * @param initialM21 defines 1st value of 2nd row
  85544. * @param initialM22 defines 2nd value of 2nd row
  85545. * @param initialM23 defines 3rd value of 2nd row
  85546. * @param initialM24 defines 4th value of 2nd row
  85547. * @param initialM31 defines 1st value of 3rd row
  85548. * @param initialM32 defines 2nd value of 3rd row
  85549. * @param initialM33 defines 3rd value of 3rd row
  85550. * @param initialM34 defines 4th value of 3rd row
  85551. * @param initialM41 defines 1st value of 4th row
  85552. * @param initialM42 defines 2nd value of 4th row
  85553. * @param initialM43 defines 3rd value of 4th row
  85554. * @param initialM44 defines 4th value of 4th row
  85555. * @param result defines the target matrix
  85556. */
  85557. 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;
  85558. /**
  85559. * Creates new matrix from a list of values (16)
  85560. * @param initialM11 defines 1st value of 1st row
  85561. * @param initialM12 defines 2nd value of 1st row
  85562. * @param initialM13 defines 3rd value of 1st row
  85563. * @param initialM14 defines 4th value of 1st row
  85564. * @param initialM21 defines 1st value of 2nd row
  85565. * @param initialM22 defines 2nd value of 2nd row
  85566. * @param initialM23 defines 3rd value of 2nd row
  85567. * @param initialM24 defines 4th value of 2nd row
  85568. * @param initialM31 defines 1st value of 3rd row
  85569. * @param initialM32 defines 2nd value of 3rd row
  85570. * @param initialM33 defines 3rd value of 3rd row
  85571. * @param initialM34 defines 4th value of 3rd row
  85572. * @param initialM41 defines 1st value of 4th row
  85573. * @param initialM42 defines 2nd value of 4th row
  85574. * @param initialM43 defines 3rd value of 4th row
  85575. * @param initialM44 defines 4th value of 4th row
  85576. * @returns the new matrix
  85577. */
  85578. 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;
  85579. /**
  85580. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85581. * @param scale defines the scale vector3
  85582. * @param rotation defines the rotation quaternion
  85583. * @param translation defines the translation vector3
  85584. * @returns a new matrix
  85585. */
  85586. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  85587. /**
  85588. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  85589. * @param scale defines the scale vector3
  85590. * @param rotation defines the rotation quaternion
  85591. * @param translation defines the translation vector3
  85592. * @param result defines the target matrix
  85593. */
  85594. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  85595. /**
  85596. * Creates a new identity matrix
  85597. * @returns a new identity matrix
  85598. */
  85599. static Identity(): Matrix;
  85600. /**
  85601. * Creates a new identity matrix and stores the result in a given matrix
  85602. * @param result defines the target matrix
  85603. */
  85604. static IdentityToRef(result: Matrix): void;
  85605. /**
  85606. * Creates a new zero matrix
  85607. * @returns a new zero matrix
  85608. */
  85609. static Zero(): Matrix;
  85610. /**
  85611. * Creates a new rotation matrix for "angle" radians around the X axis
  85612. * @param angle defines the angle (in radians) to use
  85613. * @return the new matrix
  85614. */
  85615. static RotationX(angle: number): Matrix;
  85616. /**
  85617. * Creates a new matrix as the invert of a given matrix
  85618. * @param source defines the source matrix
  85619. * @returns the new matrix
  85620. */
  85621. static Invert(source: DeepImmutable<Matrix>): Matrix;
  85622. /**
  85623. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  85624. * @param angle defines the angle (in radians) to use
  85625. * @param result defines the target matrix
  85626. */
  85627. static RotationXToRef(angle: number, result: Matrix): void;
  85628. /**
  85629. * Creates a new rotation matrix for "angle" radians around the Y axis
  85630. * @param angle defines the angle (in radians) to use
  85631. * @return the new matrix
  85632. */
  85633. static RotationY(angle: number): Matrix;
  85634. /**
  85635. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  85636. * @param angle defines the angle (in radians) to use
  85637. * @param result defines the target matrix
  85638. */
  85639. static RotationYToRef(angle: number, result: Matrix): void;
  85640. /**
  85641. * Creates a new rotation matrix for "angle" radians around the Z axis
  85642. * @param angle defines the angle (in radians) to use
  85643. * @return the new matrix
  85644. */
  85645. static RotationZ(angle: number): Matrix;
  85646. /**
  85647. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  85648. * @param angle defines the angle (in radians) to use
  85649. * @param result defines the target matrix
  85650. */
  85651. static RotationZToRef(angle: number, result: Matrix): void;
  85652. /**
  85653. * Creates a new rotation matrix for "angle" radians around the given axis
  85654. * @param axis defines the axis to use
  85655. * @param angle defines the angle (in radians) to use
  85656. * @return the new matrix
  85657. */
  85658. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  85659. /**
  85660. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  85661. * @param axis defines the axis to use
  85662. * @param angle defines the angle (in radians) to use
  85663. * @param result defines the target matrix
  85664. */
  85665. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  85666. /**
  85667. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  85668. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  85669. * @param from defines the vector to align
  85670. * @param to defines the vector to align to
  85671. * @param result defines the target matrix
  85672. */
  85673. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  85674. /**
  85675. * Creates a rotation matrix
  85676. * @param yaw defines the yaw angle in radians (Y axis)
  85677. * @param pitch defines the pitch angle in radians (X axis)
  85678. * @param roll defines the roll angle in radians (Z axis)
  85679. * @returns the new rotation matrix
  85680. */
  85681. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85682. /**
  85683. * Creates a rotation matrix and stores it in a given matrix
  85684. * @param yaw defines the yaw angle in radians (Y axis)
  85685. * @param pitch defines the pitch angle in radians (X axis)
  85686. * @param roll defines the roll angle in radians (Z axis)
  85687. * @param result defines the target matrix
  85688. */
  85689. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85690. /**
  85691. * Creates a scaling matrix
  85692. * @param x defines the scale factor on X axis
  85693. * @param y defines the scale factor on Y axis
  85694. * @param z defines the scale factor on Z axis
  85695. * @returns the new matrix
  85696. */
  85697. static Scaling(x: number, y: number, z: number): Matrix;
  85698. /**
  85699. * Creates a scaling matrix and stores it in a given matrix
  85700. * @param x defines the scale factor on X axis
  85701. * @param y defines the scale factor on Y axis
  85702. * @param z defines the scale factor on Z axis
  85703. * @param result defines the target matrix
  85704. */
  85705. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85706. /**
  85707. * Creates a translation matrix
  85708. * @param x defines the translation on X axis
  85709. * @param y defines the translation on Y axis
  85710. * @param z defines the translationon Z axis
  85711. * @returns the new matrix
  85712. */
  85713. static Translation(x: number, y: number, z: number): Matrix;
  85714. /**
  85715. * Creates a translation matrix and stores it in a given matrix
  85716. * @param x defines the translation on X axis
  85717. * @param y defines the translation on Y axis
  85718. * @param z defines the translationon Z axis
  85719. * @param result defines the target matrix
  85720. */
  85721. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85722. /**
  85723. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85724. * @param startValue defines the start value
  85725. * @param endValue defines the end value
  85726. * @param gradient defines the gradient factor
  85727. * @returns the new matrix
  85728. */
  85729. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85730. /**
  85731. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85732. * @param startValue defines the start value
  85733. * @param endValue defines the end value
  85734. * @param gradient defines the gradient factor
  85735. * @param result defines the Matrix object where to store data
  85736. */
  85737. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85738. /**
  85739. * Builds a new matrix whose values are computed by:
  85740. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85741. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85742. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85743. * @param startValue defines the first matrix
  85744. * @param endValue defines the second matrix
  85745. * @param gradient defines the gradient between the two matrices
  85746. * @returns the new matrix
  85747. */
  85748. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85749. /**
  85750. * Update a matrix to values which are computed by:
  85751. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85752. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85753. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85754. * @param startValue defines the first matrix
  85755. * @param endValue defines the second matrix
  85756. * @param gradient defines the gradient between the two matrices
  85757. * @param result defines the target matrix
  85758. */
  85759. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85760. /**
  85761. * 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"
  85762. * This function works in left handed mode
  85763. * @param eye defines the final position of the entity
  85764. * @param target defines where the entity should look at
  85765. * @param up defines the up vector for the entity
  85766. * @returns the new matrix
  85767. */
  85768. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85769. /**
  85770. * 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".
  85771. * This function works in left handed mode
  85772. * @param eye defines the final position of the entity
  85773. * @param target defines where the entity should look at
  85774. * @param up defines the up vector for the entity
  85775. * @param result defines the target matrix
  85776. */
  85777. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85778. /**
  85779. * 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"
  85780. * This function works in right handed mode
  85781. * @param eye defines the final position of the entity
  85782. * @param target defines where the entity should look at
  85783. * @param up defines the up vector for the entity
  85784. * @returns the new matrix
  85785. */
  85786. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85787. /**
  85788. * 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".
  85789. * This function works in right handed mode
  85790. * @param eye defines the final position of the entity
  85791. * @param target defines where the entity should look at
  85792. * @param up defines the up vector for the entity
  85793. * @param result defines the target matrix
  85794. */
  85795. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85796. /**
  85797. * Create a left-handed orthographic projection matrix
  85798. * @param width defines the viewport width
  85799. * @param height defines the viewport height
  85800. * @param znear defines the near clip plane
  85801. * @param zfar defines the far clip plane
  85802. * @returns a new matrix as a left-handed orthographic projection matrix
  85803. */
  85804. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85805. /**
  85806. * Store a left-handed orthographic projection to a given matrix
  85807. * @param width defines the viewport width
  85808. * @param height defines the viewport height
  85809. * @param znear defines the near clip plane
  85810. * @param zfar defines the far clip plane
  85811. * @param result defines the target matrix
  85812. */
  85813. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85814. /**
  85815. * Create a left-handed orthographic projection matrix
  85816. * @param left defines the viewport left coordinate
  85817. * @param right defines the viewport right coordinate
  85818. * @param bottom defines the viewport bottom coordinate
  85819. * @param top defines the viewport top coordinate
  85820. * @param znear defines the near clip plane
  85821. * @param zfar defines the far clip plane
  85822. * @returns a new matrix as a left-handed orthographic projection matrix
  85823. */
  85824. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85825. /**
  85826. * Stores a left-handed orthographic projection into a given matrix
  85827. * @param left defines the viewport left coordinate
  85828. * @param right defines the viewport right coordinate
  85829. * @param bottom defines the viewport bottom coordinate
  85830. * @param top defines the viewport top coordinate
  85831. * @param znear defines the near clip plane
  85832. * @param zfar defines the far clip plane
  85833. * @param result defines the target matrix
  85834. */
  85835. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85836. /**
  85837. * Creates a right-handed orthographic projection matrix
  85838. * @param left defines the viewport left coordinate
  85839. * @param right defines the viewport right coordinate
  85840. * @param bottom defines the viewport bottom coordinate
  85841. * @param top defines the viewport top coordinate
  85842. * @param znear defines the near clip plane
  85843. * @param zfar defines the far clip plane
  85844. * @returns a new matrix as a right-handed orthographic projection matrix
  85845. */
  85846. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85847. /**
  85848. * Stores a right-handed orthographic projection into a given matrix
  85849. * @param left defines the viewport left coordinate
  85850. * @param right defines the viewport right coordinate
  85851. * @param bottom defines the viewport bottom coordinate
  85852. * @param top defines the viewport top coordinate
  85853. * @param znear defines the near clip plane
  85854. * @param zfar defines the far clip plane
  85855. * @param result defines the target matrix
  85856. */
  85857. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85858. /**
  85859. * Creates a left-handed perspective projection matrix
  85860. * @param width defines the viewport width
  85861. * @param height defines the viewport height
  85862. * @param znear defines the near clip plane
  85863. * @param zfar defines the far clip plane
  85864. * @returns a new matrix as a left-handed perspective projection matrix
  85865. */
  85866. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85867. /**
  85868. * Creates a left-handed perspective projection matrix
  85869. * @param fov defines the horizontal field of view
  85870. * @param aspect defines the aspect ratio
  85871. * @param znear defines the near clip plane
  85872. * @param zfar defines the far clip plane
  85873. * @returns a new matrix as a left-handed perspective projection matrix
  85874. */
  85875. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85876. /**
  85877. * Stores a left-handed perspective projection into a given matrix
  85878. * @param fov defines the horizontal field of view
  85879. * @param aspect defines the aspect ratio
  85880. * @param znear defines the near clip plane
  85881. * @param zfar defines the far clip plane
  85882. * @param result defines the target matrix
  85883. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85884. */
  85885. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85886. /**
  85887. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85888. * @param fov defines the horizontal field of view
  85889. * @param aspect defines the aspect ratio
  85890. * @param znear defines the near clip plane
  85891. * @param zfar not used as infinity is used as far clip
  85892. * @param result defines the target matrix
  85893. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85894. */
  85895. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85896. /**
  85897. * Creates a right-handed perspective projection matrix
  85898. * @param fov defines the horizontal field of view
  85899. * @param aspect defines the aspect ratio
  85900. * @param znear defines the near clip plane
  85901. * @param zfar defines the far clip plane
  85902. * @returns a new matrix as a right-handed perspective projection matrix
  85903. */
  85904. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85905. /**
  85906. * Stores a right-handed perspective projection into a given matrix
  85907. * @param fov defines the horizontal field of view
  85908. * @param aspect defines the aspect ratio
  85909. * @param znear defines the near clip plane
  85910. * @param zfar defines the far clip plane
  85911. * @param result defines the target matrix
  85912. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85913. */
  85914. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85915. /**
  85916. * Stores a right-handed perspective projection into a given matrix
  85917. * @param fov defines the horizontal field of view
  85918. * @param aspect defines the aspect ratio
  85919. * @param znear defines the near clip plane
  85920. * @param zfar not used as infinity is used as far clip
  85921. * @param result defines the target matrix
  85922. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85923. */
  85924. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85925. /**
  85926. * Stores a perspective projection for WebVR info a given matrix
  85927. * @param fov defines the field of view
  85928. * @param znear defines the near clip plane
  85929. * @param zfar defines the far clip plane
  85930. * @param result defines the target matrix
  85931. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85932. */
  85933. static PerspectiveFovWebVRToRef(fov: {
  85934. upDegrees: number;
  85935. downDegrees: number;
  85936. leftDegrees: number;
  85937. rightDegrees: number;
  85938. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85939. /**
  85940. * Computes a complete transformation matrix
  85941. * @param viewport defines the viewport to use
  85942. * @param world defines the world matrix
  85943. * @param view defines the view matrix
  85944. * @param projection defines the projection matrix
  85945. * @param zmin defines the near clip plane
  85946. * @param zmax defines the far clip plane
  85947. * @returns the transformation matrix
  85948. */
  85949. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85950. /**
  85951. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85952. * @param matrix defines the matrix to use
  85953. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85954. */
  85955. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85956. /**
  85957. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85958. * @param matrix defines the matrix to use
  85959. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85960. */
  85961. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85962. /**
  85963. * Compute the transpose of a given matrix
  85964. * @param matrix defines the matrix to transpose
  85965. * @returns the new matrix
  85966. */
  85967. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85968. /**
  85969. * Compute the transpose of a matrix and store it in a target matrix
  85970. * @param matrix defines the matrix to transpose
  85971. * @param result defines the target matrix
  85972. */
  85973. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85974. /**
  85975. * Computes a reflection matrix from a plane
  85976. * @param plane defines the reflection plane
  85977. * @returns a new matrix
  85978. */
  85979. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85980. /**
  85981. * Computes a reflection matrix from a plane
  85982. * @param plane defines the reflection plane
  85983. * @param result defines the target matrix
  85984. */
  85985. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85986. /**
  85987. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85988. * @param xaxis defines the value of the 1st axis
  85989. * @param yaxis defines the value of the 2nd axis
  85990. * @param zaxis defines the value of the 3rd axis
  85991. * @param result defines the target matrix
  85992. */
  85993. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85994. /**
  85995. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85996. * @param quat defines the quaternion to use
  85997. * @param result defines the target matrix
  85998. */
  85999. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  86000. }
  86001. /**
  86002. * @hidden
  86003. */
  86004. export class TmpVectors {
  86005. static Vector2: Vector2[];
  86006. static Vector3: Vector3[];
  86007. static Vector4: Vector4[];
  86008. static Quaternion: Quaternion[];
  86009. static Matrix: Matrix[];
  86010. }
  86011. }
  86012. declare module BABYLON {
  86013. /**
  86014. * Defines potential orientation for back face culling
  86015. */
  86016. export enum Orientation {
  86017. /**
  86018. * Clockwise
  86019. */
  86020. CW = 0,
  86021. /** Counter clockwise */
  86022. CCW = 1
  86023. }
  86024. /** Class used to represent a Bezier curve */
  86025. export class BezierCurve {
  86026. /**
  86027. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  86028. * @param t defines the time
  86029. * @param x1 defines the left coordinate on X axis
  86030. * @param y1 defines the left coordinate on Y axis
  86031. * @param x2 defines the right coordinate on X axis
  86032. * @param y2 defines the right coordinate on Y axis
  86033. * @returns the interpolated value
  86034. */
  86035. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  86036. }
  86037. /**
  86038. * Defines angle representation
  86039. */
  86040. export class Angle {
  86041. private _radians;
  86042. /**
  86043. * Creates an Angle object of "radians" radians (float).
  86044. * @param radians the angle in radians
  86045. */
  86046. constructor(radians: number);
  86047. /**
  86048. * Get value in degrees
  86049. * @returns the Angle value in degrees (float)
  86050. */
  86051. degrees(): number;
  86052. /**
  86053. * Get value in radians
  86054. * @returns the Angle value in radians (float)
  86055. */
  86056. radians(): number;
  86057. /**
  86058. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  86059. * @param a defines first point as the origin
  86060. * @param b defines point
  86061. * @returns a new Angle
  86062. */
  86063. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  86064. /**
  86065. * Gets a new Angle object from the given float in radians
  86066. * @param radians defines the angle value in radians
  86067. * @returns a new Angle
  86068. */
  86069. static FromRadians(radians: number): Angle;
  86070. /**
  86071. * Gets a new Angle object from the given float in degrees
  86072. * @param degrees defines the angle value in degrees
  86073. * @returns a new Angle
  86074. */
  86075. static FromDegrees(degrees: number): Angle;
  86076. }
  86077. /**
  86078. * This represents an arc in a 2d space.
  86079. */
  86080. export class Arc2 {
  86081. /** Defines the start point of the arc */
  86082. startPoint: Vector2;
  86083. /** Defines the mid point of the arc */
  86084. midPoint: Vector2;
  86085. /** Defines the end point of the arc */
  86086. endPoint: Vector2;
  86087. /**
  86088. * Defines the center point of the arc.
  86089. */
  86090. centerPoint: Vector2;
  86091. /**
  86092. * Defines the radius of the arc.
  86093. */
  86094. radius: number;
  86095. /**
  86096. * Defines the angle of the arc (from mid point to end point).
  86097. */
  86098. angle: Angle;
  86099. /**
  86100. * Defines the start angle of the arc (from start point to middle point).
  86101. */
  86102. startAngle: Angle;
  86103. /**
  86104. * Defines the orientation of the arc (clock wise/counter clock wise).
  86105. */
  86106. orientation: Orientation;
  86107. /**
  86108. * Creates an Arc object from the three given points : start, middle and end.
  86109. * @param startPoint Defines the start point of the arc
  86110. * @param midPoint Defines the midlle point of the arc
  86111. * @param endPoint Defines the end point of the arc
  86112. */
  86113. constructor(
  86114. /** Defines the start point of the arc */
  86115. startPoint: Vector2,
  86116. /** Defines the mid point of the arc */
  86117. midPoint: Vector2,
  86118. /** Defines the end point of the arc */
  86119. endPoint: Vector2);
  86120. }
  86121. /**
  86122. * Represents a 2D path made up of multiple 2D points
  86123. */
  86124. export class Path2 {
  86125. private _points;
  86126. private _length;
  86127. /**
  86128. * If the path start and end point are the same
  86129. */
  86130. closed: boolean;
  86131. /**
  86132. * Creates a Path2 object from the starting 2D coordinates x and y.
  86133. * @param x the starting points x value
  86134. * @param y the starting points y value
  86135. */
  86136. constructor(x: number, y: number);
  86137. /**
  86138. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  86139. * @param x the added points x value
  86140. * @param y the added points y value
  86141. * @returns the updated Path2.
  86142. */
  86143. addLineTo(x: number, y: number): Path2;
  86144. /**
  86145. * 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.
  86146. * @param midX middle point x value
  86147. * @param midY middle point y value
  86148. * @param endX end point x value
  86149. * @param endY end point y value
  86150. * @param numberOfSegments (default: 36)
  86151. * @returns the updated Path2.
  86152. */
  86153. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  86154. /**
  86155. * Closes the Path2.
  86156. * @returns the Path2.
  86157. */
  86158. close(): Path2;
  86159. /**
  86160. * Gets the sum of the distance between each sequential point in the path
  86161. * @returns the Path2 total length (float).
  86162. */
  86163. length(): number;
  86164. /**
  86165. * Gets the points which construct the path
  86166. * @returns the Path2 internal array of points.
  86167. */
  86168. getPoints(): Vector2[];
  86169. /**
  86170. * Retreives the point at the distance aways from the starting point
  86171. * @param normalizedLengthPosition the length along the path to retreive the point from
  86172. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  86173. */
  86174. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  86175. /**
  86176. * Creates a new path starting from an x and y position
  86177. * @param x starting x value
  86178. * @param y starting y value
  86179. * @returns a new Path2 starting at the coordinates (x, y).
  86180. */
  86181. static StartingAt(x: number, y: number): Path2;
  86182. }
  86183. /**
  86184. * Represents a 3D path made up of multiple 3D points
  86185. */
  86186. export class Path3D {
  86187. /**
  86188. * an array of Vector3, the curve axis of the Path3D
  86189. */
  86190. path: Vector3[];
  86191. private _curve;
  86192. private _distances;
  86193. private _tangents;
  86194. private _normals;
  86195. private _binormals;
  86196. private _raw;
  86197. private _alignTangentsWithPath;
  86198. private readonly _pointAtData;
  86199. /**
  86200. * new Path3D(path, normal, raw)
  86201. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  86202. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  86203. * @param path an array of Vector3, the curve axis of the Path3D
  86204. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  86205. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  86206. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  86207. */
  86208. constructor(
  86209. /**
  86210. * an array of Vector3, the curve axis of the Path3D
  86211. */
  86212. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  86213. /**
  86214. * Returns the Path3D array of successive Vector3 designing its curve.
  86215. * @returns the Path3D array of successive Vector3 designing its curve.
  86216. */
  86217. getCurve(): Vector3[];
  86218. /**
  86219. * Returns the Path3D array of successive Vector3 designing its curve.
  86220. * @returns the Path3D array of successive Vector3 designing its curve.
  86221. */
  86222. getPoints(): Vector3[];
  86223. /**
  86224. * @returns the computed length (float) of the path.
  86225. */
  86226. length(): number;
  86227. /**
  86228. * Returns an array populated with tangent vectors on each Path3D curve point.
  86229. * @returns an array populated with tangent vectors on each Path3D curve point.
  86230. */
  86231. getTangents(): Vector3[];
  86232. /**
  86233. * Returns an array populated with normal vectors on each Path3D curve point.
  86234. * @returns an array populated with normal vectors on each Path3D curve point.
  86235. */
  86236. getNormals(): Vector3[];
  86237. /**
  86238. * Returns an array populated with binormal vectors on each Path3D curve point.
  86239. * @returns an array populated with binormal vectors on each Path3D curve point.
  86240. */
  86241. getBinormals(): Vector3[];
  86242. /**
  86243. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  86244. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  86245. */
  86246. getDistances(): number[];
  86247. /**
  86248. * Returns an interpolated point along this path
  86249. * @param position the position of the point along this path, from 0.0 to 1.0
  86250. * @returns a new Vector3 as the point
  86251. */
  86252. getPointAt(position: number): Vector3;
  86253. /**
  86254. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  86255. * @param position the position of the point along this path, from 0.0 to 1.0
  86256. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  86257. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  86258. */
  86259. getTangentAt(position: number, interpolated?: boolean): Vector3;
  86260. /**
  86261. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  86262. * @param position the position of the point along this path, from 0.0 to 1.0
  86263. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  86264. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  86265. */
  86266. getNormalAt(position: number, interpolated?: boolean): Vector3;
  86267. /**
  86268. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  86269. * @param position the position of the point along this path, from 0.0 to 1.0
  86270. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  86271. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  86272. */
  86273. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  86274. /**
  86275. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  86276. * @param position the position of the point along this path, from 0.0 to 1.0
  86277. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  86278. */
  86279. getDistanceAt(position: number): number;
  86280. /**
  86281. * Returns the array index of the previous point of an interpolated point along this path
  86282. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  86283. * @returns the array index
  86284. */
  86285. getPreviousPointIndexAt(position: number): number;
  86286. /**
  86287. * 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)
  86288. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  86289. * @returns the sub position
  86290. */
  86291. getSubPositionAt(position: number): number;
  86292. /**
  86293. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  86294. * @param target the vector of which to get the closest position to
  86295. * @returns the position of the closest virtual point on this path to the target vector
  86296. */
  86297. getClosestPositionTo(target: Vector3): number;
  86298. /**
  86299. * Returns a sub path (slice) of this path
  86300. * @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
  86301. * @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
  86302. * @returns a sub path (slice) of this path
  86303. */
  86304. slice(start?: number, end?: number): Path3D;
  86305. /**
  86306. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  86307. * @param path path which all values are copied into the curves points
  86308. * @param firstNormal which should be projected onto the curve
  86309. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  86310. * @returns the same object updated.
  86311. */
  86312. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  86313. private _compute;
  86314. private _getFirstNonNullVector;
  86315. private _getLastNonNullVector;
  86316. private _normalVector;
  86317. /**
  86318. * Updates the point at data for an interpolated point along this curve
  86319. * @param position the position of the point along this curve, from 0.0 to 1.0
  86320. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  86321. * @returns the (updated) point at data
  86322. */
  86323. private _updatePointAtData;
  86324. /**
  86325. * Updates the point at data from the specified parameters
  86326. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  86327. * @param point the interpolated point
  86328. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  86329. */
  86330. private _setPointAtData;
  86331. /**
  86332. * Updates the point at interpolation matrix for the tangents, normals and binormals
  86333. */
  86334. private _updateInterpolationMatrix;
  86335. }
  86336. /**
  86337. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  86338. * A Curve3 is designed from a series of successive Vector3.
  86339. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  86340. */
  86341. export class Curve3 {
  86342. private _points;
  86343. private _length;
  86344. /**
  86345. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  86346. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  86347. * @param v1 (Vector3) the control point
  86348. * @param v2 (Vector3) the end point of the Quadratic Bezier
  86349. * @param nbPoints (integer) the wanted number of points in the curve
  86350. * @returns the created Curve3
  86351. */
  86352. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86353. /**
  86354. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  86355. * @param v0 (Vector3) the origin point of the Cubic Bezier
  86356. * @param v1 (Vector3) the first control point
  86357. * @param v2 (Vector3) the second control point
  86358. * @param v3 (Vector3) the end point of the Cubic Bezier
  86359. * @param nbPoints (integer) the wanted number of points in the curve
  86360. * @returns the created Curve3
  86361. */
  86362. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86363. /**
  86364. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  86365. * @param p1 (Vector3) the origin point of the Hermite Spline
  86366. * @param t1 (Vector3) the tangent vector at the origin point
  86367. * @param p2 (Vector3) the end point of the Hermite Spline
  86368. * @param t2 (Vector3) the tangent vector at the end point
  86369. * @param nbPoints (integer) the wanted number of points in the curve
  86370. * @returns the created Curve3
  86371. */
  86372. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  86373. /**
  86374. * Returns a Curve3 object along a CatmullRom Spline curve :
  86375. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  86376. * @param nbPoints (integer) the wanted number of points between each curve control points
  86377. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  86378. * @returns the created Curve3
  86379. */
  86380. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  86381. /**
  86382. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  86383. * A Curve3 is designed from a series of successive Vector3.
  86384. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  86385. * @param points points which make up the curve
  86386. */
  86387. constructor(points: Vector3[]);
  86388. /**
  86389. * @returns the Curve3 stored array of successive Vector3
  86390. */
  86391. getPoints(): Vector3[];
  86392. /**
  86393. * @returns the computed length (float) of the curve.
  86394. */
  86395. length(): number;
  86396. /**
  86397. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  86398. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  86399. * curveA and curveB keep unchanged.
  86400. * @param curve the curve to continue from this curve
  86401. * @returns the newly constructed curve
  86402. */
  86403. continue(curve: DeepImmutable<Curve3>): Curve3;
  86404. private _computeLength;
  86405. }
  86406. }
  86407. declare module BABYLON {
  86408. /**
  86409. * This represents the main contract an easing function should follow.
  86410. * Easing functions are used throughout the animation system.
  86411. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86412. */
  86413. export interface IEasingFunction {
  86414. /**
  86415. * Given an input gradient between 0 and 1, this returns the corrseponding value
  86416. * of the easing function.
  86417. * The link below provides some of the most common examples of easing functions.
  86418. * @see https://easings.net/
  86419. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86420. * @returns the corresponding value on the curve defined by the easing function
  86421. */
  86422. ease(gradient: number): number;
  86423. }
  86424. /**
  86425. * Base class used for every default easing function.
  86426. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86427. */
  86428. export class EasingFunction implements IEasingFunction {
  86429. /**
  86430. * Interpolation follows the mathematical formula associated with the easing function.
  86431. */
  86432. static readonly EASINGMODE_EASEIN: number;
  86433. /**
  86434. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  86435. */
  86436. static readonly EASINGMODE_EASEOUT: number;
  86437. /**
  86438. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  86439. */
  86440. static readonly EASINGMODE_EASEINOUT: number;
  86441. private _easingMode;
  86442. /**
  86443. * Sets the easing mode of the current function.
  86444. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  86445. */
  86446. setEasingMode(easingMode: number): void;
  86447. /**
  86448. * Gets the current easing mode.
  86449. * @returns the easing mode
  86450. */
  86451. getEasingMode(): number;
  86452. /**
  86453. * @hidden
  86454. */
  86455. easeInCore(gradient: number): number;
  86456. /**
  86457. * Given an input gradient between 0 and 1, this returns the corresponding value
  86458. * of the easing function.
  86459. * @param gradient Defines the value between 0 and 1 we want the easing value for
  86460. * @returns the corresponding value on the curve defined by the easing function
  86461. */
  86462. ease(gradient: number): number;
  86463. }
  86464. /**
  86465. * Easing function with a circle shape (see link below).
  86466. * @see https://easings.net/#easeInCirc
  86467. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86468. */
  86469. export class CircleEase extends EasingFunction implements IEasingFunction {
  86470. /** @hidden */
  86471. easeInCore(gradient: number): number;
  86472. }
  86473. /**
  86474. * Easing function with a ease back shape (see link below).
  86475. * @see https://easings.net/#easeInBack
  86476. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86477. */
  86478. export class BackEase extends EasingFunction implements IEasingFunction {
  86479. /** Defines the amplitude of the function */
  86480. amplitude: number;
  86481. /**
  86482. * Instantiates a back ease easing
  86483. * @see https://easings.net/#easeInBack
  86484. * @param amplitude Defines the amplitude of the function
  86485. */
  86486. constructor(
  86487. /** Defines the amplitude of the function */
  86488. amplitude?: number);
  86489. /** @hidden */
  86490. easeInCore(gradient: number): number;
  86491. }
  86492. /**
  86493. * Easing function with a bouncing shape (see link below).
  86494. * @see https://easings.net/#easeInBounce
  86495. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86496. */
  86497. export class BounceEase extends EasingFunction implements IEasingFunction {
  86498. /** Defines the number of bounces */
  86499. bounces: number;
  86500. /** Defines the amplitude of the bounce */
  86501. bounciness: number;
  86502. /**
  86503. * Instantiates a bounce easing
  86504. * @see https://easings.net/#easeInBounce
  86505. * @param bounces Defines the number of bounces
  86506. * @param bounciness Defines the amplitude of the bounce
  86507. */
  86508. constructor(
  86509. /** Defines the number of bounces */
  86510. bounces?: number,
  86511. /** Defines the amplitude of the bounce */
  86512. bounciness?: number);
  86513. /** @hidden */
  86514. easeInCore(gradient: number): number;
  86515. }
  86516. /**
  86517. * Easing function with a power of 3 shape (see link below).
  86518. * @see https://easings.net/#easeInCubic
  86519. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86520. */
  86521. export class CubicEase extends EasingFunction implements IEasingFunction {
  86522. /** @hidden */
  86523. easeInCore(gradient: number): number;
  86524. }
  86525. /**
  86526. * Easing function with an elastic shape (see link below).
  86527. * @see https://easings.net/#easeInElastic
  86528. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86529. */
  86530. export class ElasticEase extends EasingFunction implements IEasingFunction {
  86531. /** Defines the number of oscillations*/
  86532. oscillations: number;
  86533. /** Defines the amplitude of the oscillations*/
  86534. springiness: number;
  86535. /**
  86536. * Instantiates an elastic easing function
  86537. * @see https://easings.net/#easeInElastic
  86538. * @param oscillations Defines the number of oscillations
  86539. * @param springiness Defines the amplitude of the oscillations
  86540. */
  86541. constructor(
  86542. /** Defines the number of oscillations*/
  86543. oscillations?: number,
  86544. /** Defines the amplitude of the oscillations*/
  86545. springiness?: number);
  86546. /** @hidden */
  86547. easeInCore(gradient: number): number;
  86548. }
  86549. /**
  86550. * Easing function with an exponential shape (see link below).
  86551. * @see https://easings.net/#easeInExpo
  86552. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86553. */
  86554. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  86555. /** Defines the exponent of the function */
  86556. exponent: number;
  86557. /**
  86558. * Instantiates an exponential easing function
  86559. * @see https://easings.net/#easeInExpo
  86560. * @param exponent Defines the exponent of the function
  86561. */
  86562. constructor(
  86563. /** Defines the exponent of the function */
  86564. exponent?: number);
  86565. /** @hidden */
  86566. easeInCore(gradient: number): number;
  86567. }
  86568. /**
  86569. * Easing function with a power shape (see link below).
  86570. * @see https://easings.net/#easeInQuad
  86571. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86572. */
  86573. export class PowerEase extends EasingFunction implements IEasingFunction {
  86574. /** Defines the power of the function */
  86575. power: number;
  86576. /**
  86577. * Instantiates an power base easing function
  86578. * @see https://easings.net/#easeInQuad
  86579. * @param power Defines the power of the function
  86580. */
  86581. constructor(
  86582. /** Defines the power of the function */
  86583. power?: number);
  86584. /** @hidden */
  86585. easeInCore(gradient: number): number;
  86586. }
  86587. /**
  86588. * Easing function with a power of 2 shape (see link below).
  86589. * @see https://easings.net/#easeInQuad
  86590. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86591. */
  86592. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  86593. /** @hidden */
  86594. easeInCore(gradient: number): number;
  86595. }
  86596. /**
  86597. * Easing function with a power of 4 shape (see link below).
  86598. * @see https://easings.net/#easeInQuart
  86599. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86600. */
  86601. export class QuarticEase extends EasingFunction implements IEasingFunction {
  86602. /** @hidden */
  86603. easeInCore(gradient: number): number;
  86604. }
  86605. /**
  86606. * Easing function with a power of 5 shape (see link below).
  86607. * @see https://easings.net/#easeInQuint
  86608. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86609. */
  86610. export class QuinticEase extends EasingFunction implements IEasingFunction {
  86611. /** @hidden */
  86612. easeInCore(gradient: number): number;
  86613. }
  86614. /**
  86615. * Easing function with a sin shape (see link below).
  86616. * @see https://easings.net/#easeInSine
  86617. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86618. */
  86619. export class SineEase extends EasingFunction implements IEasingFunction {
  86620. /** @hidden */
  86621. easeInCore(gradient: number): number;
  86622. }
  86623. /**
  86624. * Easing function with a bezier shape (see link below).
  86625. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86626. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  86627. */
  86628. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  86629. /** Defines the x component of the start tangent in the bezier curve */
  86630. x1: number;
  86631. /** Defines the y component of the start tangent in the bezier curve */
  86632. y1: number;
  86633. /** Defines the x component of the end tangent in the bezier curve */
  86634. x2: number;
  86635. /** Defines the y component of the end tangent in the bezier curve */
  86636. y2: number;
  86637. /**
  86638. * Instantiates a bezier function
  86639. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  86640. * @param x1 Defines the x component of the start tangent in the bezier curve
  86641. * @param y1 Defines the y component of the start tangent in the bezier curve
  86642. * @param x2 Defines the x component of the end tangent in the bezier curve
  86643. * @param y2 Defines the y component of the end tangent in the bezier curve
  86644. */
  86645. constructor(
  86646. /** Defines the x component of the start tangent in the bezier curve */
  86647. x1?: number,
  86648. /** Defines the y component of the start tangent in the bezier curve */
  86649. y1?: number,
  86650. /** Defines the x component of the end tangent in the bezier curve */
  86651. x2?: number,
  86652. /** Defines the y component of the end tangent in the bezier curve */
  86653. y2?: number);
  86654. /** @hidden */
  86655. easeInCore(gradient: number): number;
  86656. }
  86657. }
  86658. declare module BABYLON {
  86659. /**
  86660. * Class used to hold a RBG color
  86661. */
  86662. export class Color3 {
  86663. /**
  86664. * Defines the red component (between 0 and 1, default is 0)
  86665. */
  86666. r: number;
  86667. /**
  86668. * Defines the green component (between 0 and 1, default is 0)
  86669. */
  86670. g: number;
  86671. /**
  86672. * Defines the blue component (between 0 and 1, default is 0)
  86673. */
  86674. b: number;
  86675. /**
  86676. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  86677. * @param r defines the red component (between 0 and 1, default is 0)
  86678. * @param g defines the green component (between 0 and 1, default is 0)
  86679. * @param b defines the blue component (between 0 and 1, default is 0)
  86680. */
  86681. constructor(
  86682. /**
  86683. * Defines the red component (between 0 and 1, default is 0)
  86684. */
  86685. r?: number,
  86686. /**
  86687. * Defines the green component (between 0 and 1, default is 0)
  86688. */
  86689. g?: number,
  86690. /**
  86691. * Defines the blue component (between 0 and 1, default is 0)
  86692. */
  86693. b?: number);
  86694. /**
  86695. * Creates a string with the Color3 current values
  86696. * @returns the string representation of the Color3 object
  86697. */
  86698. toString(): string;
  86699. /**
  86700. * Returns the string "Color3"
  86701. * @returns "Color3"
  86702. */
  86703. getClassName(): string;
  86704. /**
  86705. * Compute the Color3 hash code
  86706. * @returns an unique number that can be used to hash Color3 objects
  86707. */
  86708. getHashCode(): number;
  86709. /**
  86710. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86711. * @param array defines the array where to store the r,g,b components
  86712. * @param index defines an optional index in the target array to define where to start storing values
  86713. * @returns the current Color3 object
  86714. */
  86715. toArray(array: FloatArray, index?: number): Color3;
  86716. /**
  86717. * Update the current color with values stored in an array from the starting index of the given array
  86718. * @param array defines the source array
  86719. * @param offset defines an offset in the source array
  86720. * @returns the current Color3 object
  86721. */
  86722. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86723. /**
  86724. * Returns a new Color4 object from the current Color3 and the given alpha
  86725. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86726. * @returns a new Color4 object
  86727. */
  86728. toColor4(alpha?: number): Color4;
  86729. /**
  86730. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86731. * @returns the new array
  86732. */
  86733. asArray(): number[];
  86734. /**
  86735. * Returns the luminance value
  86736. * @returns a float value
  86737. */
  86738. toLuminance(): number;
  86739. /**
  86740. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86741. * @param otherColor defines the second operand
  86742. * @returns the new Color3 object
  86743. */
  86744. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86745. /**
  86746. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86747. * @param otherColor defines the second operand
  86748. * @param result defines the Color3 object where to store the result
  86749. * @returns the current Color3
  86750. */
  86751. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86752. /**
  86753. * Determines equality between Color3 objects
  86754. * @param otherColor defines the second operand
  86755. * @returns true if the rgb values are equal to the given ones
  86756. */
  86757. equals(otherColor: DeepImmutable<Color3>): boolean;
  86758. /**
  86759. * Determines equality between the current Color3 object and a set of r,b,g values
  86760. * @param r defines the red component to check
  86761. * @param g defines the green component to check
  86762. * @param b defines the blue component to check
  86763. * @returns true if the rgb values are equal to the given ones
  86764. */
  86765. equalsFloats(r: number, g: number, b: number): boolean;
  86766. /**
  86767. * Multiplies in place each rgb value by scale
  86768. * @param scale defines the scaling factor
  86769. * @returns the updated Color3
  86770. */
  86771. scale(scale: number): Color3;
  86772. /**
  86773. * Multiplies the rgb values by scale and stores the result into "result"
  86774. * @param scale defines the scaling factor
  86775. * @param result defines the Color3 object where to store the result
  86776. * @returns the unmodified current Color3
  86777. */
  86778. scaleToRef(scale: number, result: Color3): Color3;
  86779. /**
  86780. * Scale the current Color3 values by a factor and add the result to a given Color3
  86781. * @param scale defines the scale factor
  86782. * @param result defines color to store the result into
  86783. * @returns the unmodified current Color3
  86784. */
  86785. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86786. /**
  86787. * Clamps the rgb values by the min and max values and stores the result into "result"
  86788. * @param min defines minimum clamping value (default is 0)
  86789. * @param max defines maximum clamping value (default is 1)
  86790. * @param result defines color to store the result into
  86791. * @returns the original Color3
  86792. */
  86793. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86794. /**
  86795. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86796. * @param otherColor defines the second operand
  86797. * @returns the new Color3
  86798. */
  86799. add(otherColor: DeepImmutable<Color3>): Color3;
  86800. /**
  86801. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86802. * @param otherColor defines the second operand
  86803. * @param result defines Color3 object to store the result into
  86804. * @returns the unmodified current Color3
  86805. */
  86806. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86807. /**
  86808. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86809. * @param otherColor defines the second operand
  86810. * @returns the new Color3
  86811. */
  86812. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86813. /**
  86814. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86815. * @param otherColor defines the second operand
  86816. * @param result defines Color3 object to store the result into
  86817. * @returns the unmodified current Color3
  86818. */
  86819. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86820. /**
  86821. * Copy the current object
  86822. * @returns a new Color3 copied the current one
  86823. */
  86824. clone(): Color3;
  86825. /**
  86826. * Copies the rgb values from the source in the current Color3
  86827. * @param source defines the source Color3 object
  86828. * @returns the updated Color3 object
  86829. */
  86830. copyFrom(source: DeepImmutable<Color3>): Color3;
  86831. /**
  86832. * Updates the Color3 rgb values from the given floats
  86833. * @param r defines the red component to read from
  86834. * @param g defines the green component to read from
  86835. * @param b defines the blue component to read from
  86836. * @returns the current Color3 object
  86837. */
  86838. copyFromFloats(r: number, g: number, b: number): Color3;
  86839. /**
  86840. * Updates the Color3 rgb values from the given floats
  86841. * @param r defines the red component to read from
  86842. * @param g defines the green component to read from
  86843. * @param b defines the blue component to read from
  86844. * @returns the current Color3 object
  86845. */
  86846. set(r: number, g: number, b: number): Color3;
  86847. /**
  86848. * Compute the Color3 hexadecimal code as a string
  86849. * @returns a string containing the hexadecimal representation of the Color3 object
  86850. */
  86851. toHexString(): string;
  86852. /**
  86853. * Computes a new Color3 converted from the current one to linear space
  86854. * @returns a new Color3 object
  86855. */
  86856. toLinearSpace(): Color3;
  86857. /**
  86858. * Converts current color in rgb space to HSV values
  86859. * @returns a new color3 representing the HSV values
  86860. */
  86861. toHSV(): Color3;
  86862. /**
  86863. * Converts current color in rgb space to HSV values
  86864. * @param result defines the Color3 where to store the HSV values
  86865. */
  86866. toHSVToRef(result: Color3): void;
  86867. /**
  86868. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86869. * @param convertedColor defines the Color3 object where to store the linear space version
  86870. * @returns the unmodified Color3
  86871. */
  86872. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86873. /**
  86874. * Computes a new Color3 converted from the current one to gamma space
  86875. * @returns a new Color3 object
  86876. */
  86877. toGammaSpace(): Color3;
  86878. /**
  86879. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86880. * @param convertedColor defines the Color3 object where to store the gamma space version
  86881. * @returns the unmodified Color3
  86882. */
  86883. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86884. private static _BlackReadOnly;
  86885. /**
  86886. * Convert Hue, saturation and value to a Color3 (RGB)
  86887. * @param hue defines the hue
  86888. * @param saturation defines the saturation
  86889. * @param value defines the value
  86890. * @param result defines the Color3 where to store the RGB values
  86891. */
  86892. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86893. /**
  86894. * Creates a new Color3 from the string containing valid hexadecimal values
  86895. * @param hex defines a string containing valid hexadecimal values
  86896. * @returns a new Color3 object
  86897. */
  86898. static FromHexString(hex: string): Color3;
  86899. /**
  86900. * Creates a new Color3 from the starting index of the given array
  86901. * @param array defines the source array
  86902. * @param offset defines an offset in the source array
  86903. * @returns a new Color3 object
  86904. */
  86905. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86906. /**
  86907. * Creates a new Color3 from the starting index element of the given array
  86908. * @param array defines the source array to read from
  86909. * @param offset defines the offset in the source array
  86910. * @param result defines the target Color3 object
  86911. */
  86912. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86913. /**
  86914. * Creates a new Color3 from integer values (< 256)
  86915. * @param r defines the red component to read from (value between 0 and 255)
  86916. * @param g defines the green component to read from (value between 0 and 255)
  86917. * @param b defines the blue component to read from (value between 0 and 255)
  86918. * @returns a new Color3 object
  86919. */
  86920. static FromInts(r: number, g: number, b: number): Color3;
  86921. /**
  86922. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86923. * @param start defines the start Color3 value
  86924. * @param end defines the end Color3 value
  86925. * @param amount defines the gradient value between start and end
  86926. * @returns a new Color3 object
  86927. */
  86928. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86929. /**
  86930. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86931. * @param left defines the start value
  86932. * @param right defines the end value
  86933. * @param amount defines the gradient factor
  86934. * @param result defines the Color3 object where to store the result
  86935. */
  86936. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86937. /**
  86938. * Returns a Color3 value containing a red color
  86939. * @returns a new Color3 object
  86940. */
  86941. static Red(): Color3;
  86942. /**
  86943. * Returns a Color3 value containing a green color
  86944. * @returns a new Color3 object
  86945. */
  86946. static Green(): Color3;
  86947. /**
  86948. * Returns a Color3 value containing a blue color
  86949. * @returns a new Color3 object
  86950. */
  86951. static Blue(): Color3;
  86952. /**
  86953. * Returns a Color3 value containing a black color
  86954. * @returns a new Color3 object
  86955. */
  86956. static Black(): Color3;
  86957. /**
  86958. * Gets a Color3 value containing a black color that must not be updated
  86959. */
  86960. static get BlackReadOnly(): DeepImmutable<Color3>;
  86961. /**
  86962. * Returns a Color3 value containing a white color
  86963. * @returns a new Color3 object
  86964. */
  86965. static White(): Color3;
  86966. /**
  86967. * Returns a Color3 value containing a purple color
  86968. * @returns a new Color3 object
  86969. */
  86970. static Purple(): Color3;
  86971. /**
  86972. * Returns a Color3 value containing a magenta color
  86973. * @returns a new Color3 object
  86974. */
  86975. static Magenta(): Color3;
  86976. /**
  86977. * Returns a Color3 value containing a yellow color
  86978. * @returns a new Color3 object
  86979. */
  86980. static Yellow(): Color3;
  86981. /**
  86982. * Returns a Color3 value containing a gray color
  86983. * @returns a new Color3 object
  86984. */
  86985. static Gray(): Color3;
  86986. /**
  86987. * Returns a Color3 value containing a teal color
  86988. * @returns a new Color3 object
  86989. */
  86990. static Teal(): Color3;
  86991. /**
  86992. * Returns a Color3 value containing a random color
  86993. * @returns a new Color3 object
  86994. */
  86995. static Random(): Color3;
  86996. }
  86997. /**
  86998. * Class used to hold a RBGA color
  86999. */
  87000. export class Color4 {
  87001. /**
  87002. * Defines the red component (between 0 and 1, default is 0)
  87003. */
  87004. r: number;
  87005. /**
  87006. * Defines the green component (between 0 and 1, default is 0)
  87007. */
  87008. g: number;
  87009. /**
  87010. * Defines the blue component (between 0 and 1, default is 0)
  87011. */
  87012. b: number;
  87013. /**
  87014. * Defines the alpha component (between 0 and 1, default is 1)
  87015. */
  87016. a: number;
  87017. /**
  87018. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  87019. * @param r defines the red component (between 0 and 1, default is 0)
  87020. * @param g defines the green component (between 0 and 1, default is 0)
  87021. * @param b defines the blue component (between 0 and 1, default is 0)
  87022. * @param a defines the alpha component (between 0 and 1, default is 1)
  87023. */
  87024. constructor(
  87025. /**
  87026. * Defines the red component (between 0 and 1, default is 0)
  87027. */
  87028. r?: number,
  87029. /**
  87030. * Defines the green component (between 0 and 1, default is 0)
  87031. */
  87032. g?: number,
  87033. /**
  87034. * Defines the blue component (between 0 and 1, default is 0)
  87035. */
  87036. b?: number,
  87037. /**
  87038. * Defines the alpha component (between 0 and 1, default is 1)
  87039. */
  87040. a?: number);
  87041. /**
  87042. * Adds in place the given Color4 values to the current Color4 object
  87043. * @param right defines the second operand
  87044. * @returns the current updated Color4 object
  87045. */
  87046. addInPlace(right: DeepImmutable<Color4>): Color4;
  87047. /**
  87048. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  87049. * @returns the new array
  87050. */
  87051. asArray(): number[];
  87052. /**
  87053. * Stores from the starting index in the given array the Color4 successive values
  87054. * @param array defines the array where to store the r,g,b components
  87055. * @param index defines an optional index in the target array to define where to start storing values
  87056. * @returns the current Color4 object
  87057. */
  87058. toArray(array: number[], index?: number): Color4;
  87059. /**
  87060. * Update the current color with values stored in an array from the starting index of the given array
  87061. * @param array defines the source array
  87062. * @param offset defines an offset in the source array
  87063. * @returns the current Color4 object
  87064. */
  87065. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87066. /**
  87067. * Determines equality between Color4 objects
  87068. * @param otherColor defines the second operand
  87069. * @returns true if the rgba values are equal to the given ones
  87070. */
  87071. equals(otherColor: DeepImmutable<Color4>): boolean;
  87072. /**
  87073. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  87074. * @param right defines the second operand
  87075. * @returns a new Color4 object
  87076. */
  87077. add(right: DeepImmutable<Color4>): Color4;
  87078. /**
  87079. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  87080. * @param right defines the second operand
  87081. * @returns a new Color4 object
  87082. */
  87083. subtract(right: DeepImmutable<Color4>): Color4;
  87084. /**
  87085. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  87086. * @param right defines the second operand
  87087. * @param result defines the Color4 object where to store the result
  87088. * @returns the current Color4 object
  87089. */
  87090. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  87091. /**
  87092. * Creates a new Color4 with the current Color4 values multiplied by scale
  87093. * @param scale defines the scaling factor to apply
  87094. * @returns a new Color4 object
  87095. */
  87096. scale(scale: number): Color4;
  87097. /**
  87098. * Multiplies the current Color4 values by scale and stores the result in "result"
  87099. * @param scale defines the scaling factor to apply
  87100. * @param result defines the Color4 object where to store the result
  87101. * @returns the current unmodified Color4
  87102. */
  87103. scaleToRef(scale: number, result: Color4): Color4;
  87104. /**
  87105. * Scale the current Color4 values by a factor and add the result to a given Color4
  87106. * @param scale defines the scale factor
  87107. * @param result defines the Color4 object where to store the result
  87108. * @returns the unmodified current Color4
  87109. */
  87110. scaleAndAddToRef(scale: number, result: Color4): Color4;
  87111. /**
  87112. * Clamps the rgb values by the min and max values and stores the result into "result"
  87113. * @param min defines minimum clamping value (default is 0)
  87114. * @param max defines maximum clamping value (default is 1)
  87115. * @param result defines color to store the result into.
  87116. * @returns the cuurent Color4
  87117. */
  87118. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  87119. /**
  87120. * Multipy an Color4 value by another and return a new Color4 object
  87121. * @param color defines the Color4 value to multiply by
  87122. * @returns a new Color4 object
  87123. */
  87124. multiply(color: Color4): Color4;
  87125. /**
  87126. * Multipy a Color4 value by another and push the result in a reference value
  87127. * @param color defines the Color4 value to multiply by
  87128. * @param result defines the Color4 to fill the result in
  87129. * @returns the result Color4
  87130. */
  87131. multiplyToRef(color: Color4, result: Color4): Color4;
  87132. /**
  87133. * Creates a string with the Color4 current values
  87134. * @returns the string representation of the Color4 object
  87135. */
  87136. toString(): string;
  87137. /**
  87138. * Returns the string "Color4"
  87139. * @returns "Color4"
  87140. */
  87141. getClassName(): string;
  87142. /**
  87143. * Compute the Color4 hash code
  87144. * @returns an unique number that can be used to hash Color4 objects
  87145. */
  87146. getHashCode(): number;
  87147. /**
  87148. * Creates a new Color4 copied from the current one
  87149. * @returns a new Color4 object
  87150. */
  87151. clone(): Color4;
  87152. /**
  87153. * Copies the given Color4 values into the current one
  87154. * @param source defines the source Color4 object
  87155. * @returns the current updated Color4 object
  87156. */
  87157. copyFrom(source: Color4): Color4;
  87158. /**
  87159. * Copies the given float values into the current one
  87160. * @param r defines the red component to read from
  87161. * @param g defines the green component to read from
  87162. * @param b defines the blue component to read from
  87163. * @param a defines the alpha component to read from
  87164. * @returns the current updated Color4 object
  87165. */
  87166. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  87167. /**
  87168. * Copies the given float values into the current one
  87169. * @param r defines the red component to read from
  87170. * @param g defines the green component to read from
  87171. * @param b defines the blue component to read from
  87172. * @param a defines the alpha component to read from
  87173. * @returns the current updated Color4 object
  87174. */
  87175. set(r: number, g: number, b: number, a: number): Color4;
  87176. /**
  87177. * Compute the Color4 hexadecimal code as a string
  87178. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  87179. * @returns a string containing the hexadecimal representation of the Color4 object
  87180. */
  87181. toHexString(returnAsColor3?: boolean): string;
  87182. /**
  87183. * Computes a new Color4 converted from the current one to linear space
  87184. * @returns a new Color4 object
  87185. */
  87186. toLinearSpace(): Color4;
  87187. /**
  87188. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  87189. * @param convertedColor defines the Color4 object where to store the linear space version
  87190. * @returns the unmodified Color4
  87191. */
  87192. toLinearSpaceToRef(convertedColor: Color4): Color4;
  87193. /**
  87194. * Computes a new Color4 converted from the current one to gamma space
  87195. * @returns a new Color4 object
  87196. */
  87197. toGammaSpace(): Color4;
  87198. /**
  87199. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  87200. * @param convertedColor defines the Color4 object where to store the gamma space version
  87201. * @returns the unmodified Color4
  87202. */
  87203. toGammaSpaceToRef(convertedColor: Color4): Color4;
  87204. /**
  87205. * Creates a new Color4 from the string containing valid hexadecimal values
  87206. * @param hex defines a string containing valid hexadecimal values
  87207. * @returns a new Color4 object
  87208. */
  87209. static FromHexString(hex: string): Color4;
  87210. /**
  87211. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  87212. * @param left defines the start value
  87213. * @param right defines the end value
  87214. * @param amount defines the gradient factor
  87215. * @returns a new Color4 object
  87216. */
  87217. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  87218. /**
  87219. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  87220. * @param left defines the start value
  87221. * @param right defines the end value
  87222. * @param amount defines the gradient factor
  87223. * @param result defines the Color4 object where to store data
  87224. */
  87225. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  87226. /**
  87227. * Creates a new Color4 from a Color3 and an alpha value
  87228. * @param color3 defines the source Color3 to read from
  87229. * @param alpha defines the alpha component (1.0 by default)
  87230. * @returns a new Color4 object
  87231. */
  87232. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  87233. /**
  87234. * Creates a new Color4 from the starting index element of the given array
  87235. * @param array defines the source array to read from
  87236. * @param offset defines the offset in the source array
  87237. * @returns a new Color4 object
  87238. */
  87239. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  87240. /**
  87241. * Creates a new Color4 from the starting index element of the given array
  87242. * @param array defines the source array to read from
  87243. * @param offset defines the offset in the source array
  87244. * @param result defines the target Color4 object
  87245. */
  87246. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  87247. /**
  87248. * Creates a new Color3 from integer values (< 256)
  87249. * @param r defines the red component to read from (value between 0 and 255)
  87250. * @param g defines the green component to read from (value between 0 and 255)
  87251. * @param b defines the blue component to read from (value between 0 and 255)
  87252. * @param a defines the alpha component to read from (value between 0 and 255)
  87253. * @returns a new Color3 object
  87254. */
  87255. static FromInts(r: number, g: number, b: number, a: number): Color4;
  87256. /**
  87257. * Check the content of a given array and convert it to an array containing RGBA data
  87258. * If the original array was already containing count * 4 values then it is returned directly
  87259. * @param colors defines the array to check
  87260. * @param count defines the number of RGBA data to expect
  87261. * @returns an array containing count * 4 values (RGBA)
  87262. */
  87263. static CheckColors4(colors: number[], count: number): number[];
  87264. }
  87265. /**
  87266. * @hidden
  87267. */
  87268. export class TmpColors {
  87269. static Color3: Color3[];
  87270. static Color4: Color4[];
  87271. }
  87272. }
  87273. declare module BABYLON {
  87274. /**
  87275. * Defines an interface which represents an animation key frame
  87276. */
  87277. export interface IAnimationKey {
  87278. /**
  87279. * Frame of the key frame
  87280. */
  87281. frame: number;
  87282. /**
  87283. * Value at the specifies key frame
  87284. */
  87285. value: any;
  87286. /**
  87287. * The input tangent for the cubic hermite spline
  87288. */
  87289. inTangent?: any;
  87290. /**
  87291. * The output tangent for the cubic hermite spline
  87292. */
  87293. outTangent?: any;
  87294. /**
  87295. * The animation interpolation type
  87296. */
  87297. interpolation?: AnimationKeyInterpolation;
  87298. }
  87299. /**
  87300. * Enum for the animation key frame interpolation type
  87301. */
  87302. export enum AnimationKeyInterpolation {
  87303. /**
  87304. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  87305. */
  87306. STEP = 1
  87307. }
  87308. }
  87309. declare module BABYLON {
  87310. /**
  87311. * Represents the range of an animation
  87312. */
  87313. export class AnimationRange {
  87314. /**The name of the animation range**/
  87315. name: string;
  87316. /**The starting frame of the animation */
  87317. from: number;
  87318. /**The ending frame of the animation*/
  87319. to: number;
  87320. /**
  87321. * Initializes the range of an animation
  87322. * @param name The name of the animation range
  87323. * @param from The starting frame of the animation
  87324. * @param to The ending frame of the animation
  87325. */
  87326. constructor(
  87327. /**The name of the animation range**/
  87328. name: string,
  87329. /**The starting frame of the animation */
  87330. from: number,
  87331. /**The ending frame of the animation*/
  87332. to: number);
  87333. /**
  87334. * Makes a copy of the animation range
  87335. * @returns A copy of the animation range
  87336. */
  87337. clone(): AnimationRange;
  87338. }
  87339. }
  87340. declare module BABYLON {
  87341. /**
  87342. * Composed of a frame, and an action function
  87343. */
  87344. export class AnimationEvent {
  87345. /** The frame for which the event is triggered **/
  87346. frame: number;
  87347. /** The event to perform when triggered **/
  87348. action: (currentFrame: number) => void;
  87349. /** Specifies if the event should be triggered only once**/
  87350. onlyOnce?: boolean | undefined;
  87351. /**
  87352. * Specifies if the animation event is done
  87353. */
  87354. isDone: boolean;
  87355. /**
  87356. * Initializes the animation event
  87357. * @param frame The frame for which the event is triggered
  87358. * @param action The event to perform when triggered
  87359. * @param onlyOnce Specifies if the event should be triggered only once
  87360. */
  87361. constructor(
  87362. /** The frame for which the event is triggered **/
  87363. frame: number,
  87364. /** The event to perform when triggered **/
  87365. action: (currentFrame: number) => void,
  87366. /** Specifies if the event should be triggered only once**/
  87367. onlyOnce?: boolean | undefined);
  87368. /** @hidden */
  87369. _clone(): AnimationEvent;
  87370. }
  87371. }
  87372. declare module BABYLON {
  87373. /**
  87374. * Interface used to define a behavior
  87375. */
  87376. export interface Behavior<T> {
  87377. /** gets or sets behavior's name */
  87378. name: string;
  87379. /**
  87380. * Function called when the behavior needs to be initialized (after attaching it to a target)
  87381. */
  87382. init(): void;
  87383. /**
  87384. * Called when the behavior is attached to a target
  87385. * @param target defines the target where the behavior is attached to
  87386. */
  87387. attach(target: T): void;
  87388. /**
  87389. * Called when the behavior is detached from its target
  87390. */
  87391. detach(): void;
  87392. }
  87393. /**
  87394. * Interface implemented by classes supporting behaviors
  87395. */
  87396. export interface IBehaviorAware<T> {
  87397. /**
  87398. * Attach a behavior
  87399. * @param behavior defines the behavior to attach
  87400. * @returns the current host
  87401. */
  87402. addBehavior(behavior: Behavior<T>): T;
  87403. /**
  87404. * Remove a behavior from the current object
  87405. * @param behavior defines the behavior to detach
  87406. * @returns the current host
  87407. */
  87408. removeBehavior(behavior: Behavior<T>): T;
  87409. /**
  87410. * Gets a behavior using its name to search
  87411. * @param name defines the name to search
  87412. * @returns the behavior or null if not found
  87413. */
  87414. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  87415. }
  87416. }
  87417. declare module BABYLON {
  87418. /**
  87419. * Defines an array and its length.
  87420. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  87421. */
  87422. export interface ISmartArrayLike<T> {
  87423. /**
  87424. * The data of the array.
  87425. */
  87426. data: Array<T>;
  87427. /**
  87428. * The active length of the array.
  87429. */
  87430. length: number;
  87431. }
  87432. /**
  87433. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87434. */
  87435. export class SmartArray<T> implements ISmartArrayLike<T> {
  87436. /**
  87437. * The full set of data from the array.
  87438. */
  87439. data: Array<T>;
  87440. /**
  87441. * The active length of the array.
  87442. */
  87443. length: number;
  87444. protected _id: number;
  87445. /**
  87446. * Instantiates a Smart Array.
  87447. * @param capacity defines the default capacity of the array.
  87448. */
  87449. constructor(capacity: number);
  87450. /**
  87451. * Pushes a value at the end of the active data.
  87452. * @param value defines the object to push in the array.
  87453. */
  87454. push(value: T): void;
  87455. /**
  87456. * Iterates over the active data and apply the lambda to them.
  87457. * @param func defines the action to apply on each value.
  87458. */
  87459. forEach(func: (content: T) => void): void;
  87460. /**
  87461. * Sorts the full sets of data.
  87462. * @param compareFn defines the comparison function to apply.
  87463. */
  87464. sort(compareFn: (a: T, b: T) => number): void;
  87465. /**
  87466. * Resets the active data to an empty array.
  87467. */
  87468. reset(): void;
  87469. /**
  87470. * Releases all the data from the array as well as the array.
  87471. */
  87472. dispose(): void;
  87473. /**
  87474. * Concats the active data with a given array.
  87475. * @param array defines the data to concatenate with.
  87476. */
  87477. concat(array: any): void;
  87478. /**
  87479. * Returns the position of a value in the active data.
  87480. * @param value defines the value to find the index for
  87481. * @returns the index if found in the active data otherwise -1
  87482. */
  87483. indexOf(value: T): number;
  87484. /**
  87485. * Returns whether an element is part of the active data.
  87486. * @param value defines the value to look for
  87487. * @returns true if found in the active data otherwise false
  87488. */
  87489. contains(value: T): boolean;
  87490. private static _GlobalId;
  87491. }
  87492. /**
  87493. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  87494. * The data in this array can only be present once
  87495. */
  87496. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  87497. private _duplicateId;
  87498. /**
  87499. * Pushes a value at the end of the active data.
  87500. * THIS DOES NOT PREVENT DUPPLICATE DATA
  87501. * @param value defines the object to push in the array.
  87502. */
  87503. push(value: T): void;
  87504. /**
  87505. * Pushes a value at the end of the active data.
  87506. * If the data is already present, it won t be added again
  87507. * @param value defines the object to push in the array.
  87508. * @returns true if added false if it was already present
  87509. */
  87510. pushNoDuplicate(value: T): boolean;
  87511. /**
  87512. * Resets the active data to an empty array.
  87513. */
  87514. reset(): void;
  87515. /**
  87516. * Concats the active data with a given array.
  87517. * This ensures no dupplicate will be present in the result.
  87518. * @param array defines the data to concatenate with.
  87519. */
  87520. concatWithNoDuplicate(array: any): void;
  87521. }
  87522. }
  87523. declare module BABYLON {
  87524. /**
  87525. * @ignore
  87526. * This is a list of all the different input types that are available in the application.
  87527. * Fo instance: ArcRotateCameraGamepadInput...
  87528. */
  87529. export var CameraInputTypes: {};
  87530. /**
  87531. * This is the contract to implement in order to create a new input class.
  87532. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  87533. */
  87534. export interface ICameraInput<TCamera extends Camera> {
  87535. /**
  87536. * Defines the camera the input is attached to.
  87537. */
  87538. camera: Nullable<TCamera>;
  87539. /**
  87540. * Gets the class name of the current intput.
  87541. * @returns the class name
  87542. */
  87543. getClassName(): string;
  87544. /**
  87545. * Get the friendly name associated with the input class.
  87546. * @returns the input friendly name
  87547. */
  87548. getSimpleName(): string;
  87549. /**
  87550. * Attach the input controls to a specific dom element to get the input from.
  87551. * @param element Defines the element the controls should be listened from
  87552. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87553. */
  87554. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  87555. /**
  87556. * Detach the current controls from the specified dom element.
  87557. * @param element Defines the element to stop listening the inputs from
  87558. */
  87559. detachControl(element: Nullable<HTMLElement>): void;
  87560. /**
  87561. * Update the current camera state depending on the inputs that have been used this frame.
  87562. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87563. */
  87564. checkInputs?: () => void;
  87565. }
  87566. /**
  87567. * Represents a map of input types to input instance or input index to input instance.
  87568. */
  87569. export interface CameraInputsMap<TCamera extends Camera> {
  87570. /**
  87571. * Accessor to the input by input type.
  87572. */
  87573. [name: string]: ICameraInput<TCamera>;
  87574. /**
  87575. * Accessor to the input by input index.
  87576. */
  87577. [idx: number]: ICameraInput<TCamera>;
  87578. }
  87579. /**
  87580. * This represents the input manager used within a camera.
  87581. * It helps dealing with all the different kind of input attached to a camera.
  87582. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87583. */
  87584. export class CameraInputsManager<TCamera extends Camera> {
  87585. /**
  87586. * Defines the list of inputs attahed to the camera.
  87587. */
  87588. attached: CameraInputsMap<TCamera>;
  87589. /**
  87590. * Defines the dom element the camera is collecting inputs from.
  87591. * This is null if the controls have not been attached.
  87592. */
  87593. attachedElement: Nullable<HTMLElement>;
  87594. /**
  87595. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87596. */
  87597. noPreventDefault: boolean;
  87598. /**
  87599. * Defined the camera the input manager belongs to.
  87600. */
  87601. camera: TCamera;
  87602. /**
  87603. * Update the current camera state depending on the inputs that have been used this frame.
  87604. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  87605. */
  87606. checkInputs: () => void;
  87607. /**
  87608. * Instantiate a new Camera Input Manager.
  87609. * @param camera Defines the camera the input manager blongs to
  87610. */
  87611. constructor(camera: TCamera);
  87612. /**
  87613. * Add an input method to a camera
  87614. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  87615. * @param input camera input method
  87616. */
  87617. add(input: ICameraInput<TCamera>): void;
  87618. /**
  87619. * Remove a specific input method from a camera
  87620. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  87621. * @param inputToRemove camera input method
  87622. */
  87623. remove(inputToRemove: ICameraInput<TCamera>): void;
  87624. /**
  87625. * Remove a specific input type from a camera
  87626. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  87627. * @param inputType the type of the input to remove
  87628. */
  87629. removeByType(inputType: string): void;
  87630. private _addCheckInputs;
  87631. /**
  87632. * Attach the input controls to the currently attached dom element to listen the events from.
  87633. * @param input Defines the input to attach
  87634. */
  87635. attachInput(input: ICameraInput<TCamera>): void;
  87636. /**
  87637. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  87638. * @param element Defines the dom element to collect the events from
  87639. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  87640. */
  87641. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  87642. /**
  87643. * Detach the current manager inputs controls from a specific dom element.
  87644. * @param element Defines the dom element to collect the events from
  87645. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  87646. */
  87647. detachElement(element: HTMLElement, disconnect?: boolean): void;
  87648. /**
  87649. * Rebuild the dynamic inputCheck function from the current list of
  87650. * defined inputs in the manager.
  87651. */
  87652. rebuildInputCheck(): void;
  87653. /**
  87654. * Remove all attached input methods from a camera
  87655. */
  87656. clear(): void;
  87657. /**
  87658. * Serialize the current input manager attached to a camera.
  87659. * This ensures than once parsed,
  87660. * the input associated to the camera will be identical to the current ones
  87661. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  87662. */
  87663. serialize(serializedCamera: any): void;
  87664. /**
  87665. * Parses an input manager serialized JSON to restore the previous list of inputs
  87666. * and states associated to a camera.
  87667. * @param parsedCamera Defines the JSON to parse
  87668. */
  87669. parse(parsedCamera: any): void;
  87670. }
  87671. }
  87672. declare module BABYLON {
  87673. /**
  87674. * Class used to store data that will be store in GPU memory
  87675. */
  87676. export class Buffer {
  87677. private _engine;
  87678. private _buffer;
  87679. /** @hidden */
  87680. _data: Nullable<DataArray>;
  87681. private _updatable;
  87682. private _instanced;
  87683. private _divisor;
  87684. /**
  87685. * Gets the byte stride.
  87686. */
  87687. readonly byteStride: number;
  87688. /**
  87689. * Constructor
  87690. * @param engine the engine
  87691. * @param data the data to use for this buffer
  87692. * @param updatable whether the data is updatable
  87693. * @param stride the stride (optional)
  87694. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87695. * @param instanced whether the buffer is instanced (optional)
  87696. * @param useBytes set to true if the stride in in bytes (optional)
  87697. * @param divisor sets an optional divisor for instances (1 by default)
  87698. */
  87699. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87700. /**
  87701. * Create a new VertexBuffer based on the current buffer
  87702. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87703. * @param offset defines offset in the buffer (0 by default)
  87704. * @param size defines the size in floats of attributes (position is 3 for instance)
  87705. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87706. * @param instanced defines if the vertex buffer contains indexed data
  87707. * @param useBytes defines if the offset and stride are in bytes *
  87708. * @param divisor sets an optional divisor for instances (1 by default)
  87709. * @returns the new vertex buffer
  87710. */
  87711. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87712. /**
  87713. * Gets a boolean indicating if the Buffer is updatable?
  87714. * @returns true if the buffer is updatable
  87715. */
  87716. isUpdatable(): boolean;
  87717. /**
  87718. * Gets current buffer's data
  87719. * @returns a DataArray or null
  87720. */
  87721. getData(): Nullable<DataArray>;
  87722. /**
  87723. * Gets underlying native buffer
  87724. * @returns underlying native buffer
  87725. */
  87726. getBuffer(): Nullable<DataBuffer>;
  87727. /**
  87728. * Gets the stride in float32 units (i.e. byte stride / 4).
  87729. * May not be an integer if the byte stride is not divisible by 4.
  87730. * @returns the stride in float32 units
  87731. * @deprecated Please use byteStride instead.
  87732. */
  87733. getStrideSize(): number;
  87734. /**
  87735. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87736. * @param data defines the data to store
  87737. */
  87738. create(data?: Nullable<DataArray>): void;
  87739. /** @hidden */
  87740. _rebuild(): void;
  87741. /**
  87742. * Update current buffer data
  87743. * @param data defines the data to store
  87744. */
  87745. update(data: DataArray): void;
  87746. /**
  87747. * Updates the data directly.
  87748. * @param data the new data
  87749. * @param offset the new offset
  87750. * @param vertexCount the vertex count (optional)
  87751. * @param useBytes set to true if the offset is in bytes
  87752. */
  87753. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87754. /**
  87755. * Release all resources
  87756. */
  87757. dispose(): void;
  87758. }
  87759. /**
  87760. * Specialized buffer used to store vertex data
  87761. */
  87762. export class VertexBuffer {
  87763. /** @hidden */
  87764. _buffer: Buffer;
  87765. private _kind;
  87766. private _size;
  87767. private _ownsBuffer;
  87768. private _instanced;
  87769. private _instanceDivisor;
  87770. /**
  87771. * The byte type.
  87772. */
  87773. static readonly BYTE: number;
  87774. /**
  87775. * The unsigned byte type.
  87776. */
  87777. static readonly UNSIGNED_BYTE: number;
  87778. /**
  87779. * The short type.
  87780. */
  87781. static readonly SHORT: number;
  87782. /**
  87783. * The unsigned short type.
  87784. */
  87785. static readonly UNSIGNED_SHORT: number;
  87786. /**
  87787. * The integer type.
  87788. */
  87789. static readonly INT: number;
  87790. /**
  87791. * The unsigned integer type.
  87792. */
  87793. static readonly UNSIGNED_INT: number;
  87794. /**
  87795. * The float type.
  87796. */
  87797. static readonly FLOAT: number;
  87798. /**
  87799. * Gets or sets the instance divisor when in instanced mode
  87800. */
  87801. get instanceDivisor(): number;
  87802. set instanceDivisor(value: number);
  87803. /**
  87804. * Gets the byte stride.
  87805. */
  87806. readonly byteStride: number;
  87807. /**
  87808. * Gets the byte offset.
  87809. */
  87810. readonly byteOffset: number;
  87811. /**
  87812. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87813. */
  87814. readonly normalized: boolean;
  87815. /**
  87816. * Gets the data type of each component in the array.
  87817. */
  87818. readonly type: number;
  87819. /**
  87820. * Constructor
  87821. * @param engine the engine
  87822. * @param data the data to use for this vertex buffer
  87823. * @param kind the vertex buffer kind
  87824. * @param updatable whether the data is updatable
  87825. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87826. * @param stride the stride (optional)
  87827. * @param instanced whether the buffer is instanced (optional)
  87828. * @param offset the offset of the data (optional)
  87829. * @param size the number of components (optional)
  87830. * @param type the type of the component (optional)
  87831. * @param normalized whether the data contains normalized data (optional)
  87832. * @param useBytes set to true if stride and offset are in bytes (optional)
  87833. * @param divisor defines the instance divisor to use (1 by default)
  87834. */
  87835. 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);
  87836. /** @hidden */
  87837. _rebuild(): void;
  87838. /**
  87839. * Returns the kind of the VertexBuffer (string)
  87840. * @returns a string
  87841. */
  87842. getKind(): string;
  87843. /**
  87844. * Gets a boolean indicating if the VertexBuffer is updatable?
  87845. * @returns true if the buffer is updatable
  87846. */
  87847. isUpdatable(): boolean;
  87848. /**
  87849. * Gets current buffer's data
  87850. * @returns a DataArray or null
  87851. */
  87852. getData(): Nullable<DataArray>;
  87853. /**
  87854. * Gets underlying native buffer
  87855. * @returns underlying native buffer
  87856. */
  87857. getBuffer(): Nullable<DataBuffer>;
  87858. /**
  87859. * Gets the stride in float32 units (i.e. byte stride / 4).
  87860. * May not be an integer if the byte stride is not divisible by 4.
  87861. * @returns the stride in float32 units
  87862. * @deprecated Please use byteStride instead.
  87863. */
  87864. getStrideSize(): number;
  87865. /**
  87866. * Returns the offset as a multiple of the type byte length.
  87867. * @returns the offset in bytes
  87868. * @deprecated Please use byteOffset instead.
  87869. */
  87870. getOffset(): number;
  87871. /**
  87872. * Returns the number of components per vertex attribute (integer)
  87873. * @returns the size in float
  87874. */
  87875. getSize(): number;
  87876. /**
  87877. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87878. * @returns true if this buffer is instanced
  87879. */
  87880. getIsInstanced(): boolean;
  87881. /**
  87882. * Returns the instancing divisor, zero for non-instanced (integer).
  87883. * @returns a number
  87884. */
  87885. getInstanceDivisor(): number;
  87886. /**
  87887. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87888. * @param data defines the data to store
  87889. */
  87890. create(data?: DataArray): void;
  87891. /**
  87892. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87893. * This function will create a new buffer if the current one is not updatable
  87894. * @param data defines the data to store
  87895. */
  87896. update(data: DataArray): void;
  87897. /**
  87898. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87899. * Returns the directly updated WebGLBuffer.
  87900. * @param data the new data
  87901. * @param offset the new offset
  87902. * @param useBytes set to true if the offset is in bytes
  87903. */
  87904. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87905. /**
  87906. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87907. */
  87908. dispose(): void;
  87909. /**
  87910. * Enumerates each value of this vertex buffer as numbers.
  87911. * @param count the number of values to enumerate
  87912. * @param callback the callback function called for each value
  87913. */
  87914. forEach(count: number, callback: (value: number, index: number) => void): void;
  87915. /**
  87916. * Positions
  87917. */
  87918. static readonly PositionKind: string;
  87919. /**
  87920. * Normals
  87921. */
  87922. static readonly NormalKind: string;
  87923. /**
  87924. * Tangents
  87925. */
  87926. static readonly TangentKind: string;
  87927. /**
  87928. * Texture coordinates
  87929. */
  87930. static readonly UVKind: string;
  87931. /**
  87932. * Texture coordinates 2
  87933. */
  87934. static readonly UV2Kind: string;
  87935. /**
  87936. * Texture coordinates 3
  87937. */
  87938. static readonly UV3Kind: string;
  87939. /**
  87940. * Texture coordinates 4
  87941. */
  87942. static readonly UV4Kind: string;
  87943. /**
  87944. * Texture coordinates 5
  87945. */
  87946. static readonly UV5Kind: string;
  87947. /**
  87948. * Texture coordinates 6
  87949. */
  87950. static readonly UV6Kind: string;
  87951. /**
  87952. * Colors
  87953. */
  87954. static readonly ColorKind: string;
  87955. /**
  87956. * Matrix indices (for bones)
  87957. */
  87958. static readonly MatricesIndicesKind: string;
  87959. /**
  87960. * Matrix weights (for bones)
  87961. */
  87962. static readonly MatricesWeightsKind: string;
  87963. /**
  87964. * Additional matrix indices (for bones)
  87965. */
  87966. static readonly MatricesIndicesExtraKind: string;
  87967. /**
  87968. * Additional matrix weights (for bones)
  87969. */
  87970. static readonly MatricesWeightsExtraKind: string;
  87971. /**
  87972. * Deduces the stride given a kind.
  87973. * @param kind The kind string to deduce
  87974. * @returns The deduced stride
  87975. */
  87976. static DeduceStride(kind: string): number;
  87977. /**
  87978. * Gets the byte length of the given type.
  87979. * @param type the type
  87980. * @returns the number of bytes
  87981. */
  87982. static GetTypeByteLength(type: number): number;
  87983. /**
  87984. * Enumerates each value of the given parameters as numbers.
  87985. * @param data the data to enumerate
  87986. * @param byteOffset the byte offset of the data
  87987. * @param byteStride the byte stride of the data
  87988. * @param componentCount the number of components per element
  87989. * @param componentType the type of the component
  87990. * @param count the number of values to enumerate
  87991. * @param normalized whether the data is normalized
  87992. * @param callback the callback function called for each value
  87993. */
  87994. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87995. private static _GetFloatValue;
  87996. }
  87997. }
  87998. declare module BABYLON {
  87999. /**
  88000. * The options Interface for creating a Capsule Mesh
  88001. */
  88002. export interface ICreateCapsuleOptions {
  88003. /** The Orientation of the capsule. Default : Vector3.Up() */
  88004. orientation?: Vector3;
  88005. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  88006. subdivisions: number;
  88007. /** Number of cylindrical segments on the capsule. */
  88008. tessellation: number;
  88009. /** Height or Length of the capsule. */
  88010. height: number;
  88011. /** Radius of the capsule. */
  88012. radius: number;
  88013. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  88014. capSubdivisions: number;
  88015. /** Overwrite for the top radius. */
  88016. radiusTop?: number;
  88017. /** Overwrite for the bottom radius. */
  88018. radiusBottom?: number;
  88019. /** Overwrite for the top capSubdivisions. */
  88020. topCapSubdivisions?: number;
  88021. /** Overwrite for the bottom capSubdivisions. */
  88022. bottomCapSubdivisions?: number;
  88023. }
  88024. /**
  88025. * Class containing static functions to help procedurally build meshes
  88026. */
  88027. export class CapsuleBuilder {
  88028. /**
  88029. * Creates a capsule or a pill mesh
  88030. * @param name defines the name of the mesh
  88031. * @param options The constructors options.
  88032. * @param scene The scene the mesh is scoped to.
  88033. * @returns Capsule Mesh
  88034. */
  88035. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  88036. }
  88037. }
  88038. declare module BABYLON {
  88039. /**
  88040. * @hidden
  88041. */
  88042. export class IntersectionInfo {
  88043. bu: Nullable<number>;
  88044. bv: Nullable<number>;
  88045. distance: number;
  88046. faceId: number;
  88047. subMeshId: number;
  88048. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  88049. }
  88050. }
  88051. declare module BABYLON {
  88052. /**
  88053. * Class used to store bounding sphere information
  88054. */
  88055. export class BoundingSphere {
  88056. /**
  88057. * Gets the center of the bounding sphere in local space
  88058. */
  88059. readonly center: Vector3;
  88060. /**
  88061. * Radius of the bounding sphere in local space
  88062. */
  88063. radius: number;
  88064. /**
  88065. * Gets the center of the bounding sphere in world space
  88066. */
  88067. readonly centerWorld: Vector3;
  88068. /**
  88069. * Radius of the bounding sphere in world space
  88070. */
  88071. radiusWorld: number;
  88072. /**
  88073. * Gets the minimum vector in local space
  88074. */
  88075. readonly minimum: Vector3;
  88076. /**
  88077. * Gets the maximum vector in local space
  88078. */
  88079. readonly maximum: Vector3;
  88080. private _worldMatrix;
  88081. private static readonly TmpVector3;
  88082. /**
  88083. * Creates a new bounding sphere
  88084. * @param min defines the minimum vector (in local space)
  88085. * @param max defines the maximum vector (in local space)
  88086. * @param worldMatrix defines the new world matrix
  88087. */
  88088. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88089. /**
  88090. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  88091. * @param min defines the new minimum vector (in local space)
  88092. * @param max defines the new maximum vector (in local space)
  88093. * @param worldMatrix defines the new world matrix
  88094. */
  88095. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88096. /**
  88097. * Scale the current bounding sphere by applying a scale factor
  88098. * @param factor defines the scale factor to apply
  88099. * @returns the current bounding box
  88100. */
  88101. scale(factor: number): BoundingSphere;
  88102. /**
  88103. * Gets the world matrix of the bounding box
  88104. * @returns a matrix
  88105. */
  88106. getWorldMatrix(): DeepImmutable<Matrix>;
  88107. /** @hidden */
  88108. _update(worldMatrix: DeepImmutable<Matrix>): void;
  88109. /**
  88110. * Tests if the bounding sphere is intersecting the frustum planes
  88111. * @param frustumPlanes defines the frustum planes to test
  88112. * @returns true if there is an intersection
  88113. */
  88114. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88115. /**
  88116. * Tests if the bounding sphere center is in between the frustum planes.
  88117. * Used for optimistic fast inclusion.
  88118. * @param frustumPlanes defines the frustum planes to test
  88119. * @returns true if the sphere center is in between the frustum planes
  88120. */
  88121. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88122. /**
  88123. * Tests if a point is inside the bounding sphere
  88124. * @param point defines the point to test
  88125. * @returns true if the point is inside the bounding sphere
  88126. */
  88127. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88128. /**
  88129. * Checks if two sphere intersct
  88130. * @param sphere0 sphere 0
  88131. * @param sphere1 sphere 1
  88132. * @returns true if the speres intersect
  88133. */
  88134. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  88135. }
  88136. }
  88137. declare module BABYLON {
  88138. /**
  88139. * Class used to store bounding box information
  88140. */
  88141. export class BoundingBox implements ICullable {
  88142. /**
  88143. * Gets the 8 vectors representing the bounding box in local space
  88144. */
  88145. readonly vectors: Vector3[];
  88146. /**
  88147. * Gets the center of the bounding box in local space
  88148. */
  88149. readonly center: Vector3;
  88150. /**
  88151. * Gets the center of the bounding box in world space
  88152. */
  88153. readonly centerWorld: Vector3;
  88154. /**
  88155. * Gets the extend size in local space
  88156. */
  88157. readonly extendSize: Vector3;
  88158. /**
  88159. * Gets the extend size in world space
  88160. */
  88161. readonly extendSizeWorld: Vector3;
  88162. /**
  88163. * Gets the OBB (object bounding box) directions
  88164. */
  88165. readonly directions: Vector3[];
  88166. /**
  88167. * Gets the 8 vectors representing the bounding box in world space
  88168. */
  88169. readonly vectorsWorld: Vector3[];
  88170. /**
  88171. * Gets the minimum vector in world space
  88172. */
  88173. readonly minimumWorld: Vector3;
  88174. /**
  88175. * Gets the maximum vector in world space
  88176. */
  88177. readonly maximumWorld: Vector3;
  88178. /**
  88179. * Gets the minimum vector in local space
  88180. */
  88181. readonly minimum: Vector3;
  88182. /**
  88183. * Gets the maximum vector in local space
  88184. */
  88185. readonly maximum: Vector3;
  88186. private _worldMatrix;
  88187. private static readonly TmpVector3;
  88188. /**
  88189. * @hidden
  88190. */
  88191. _tag: number;
  88192. /**
  88193. * Creates a new bounding box
  88194. * @param min defines the minimum vector (in local space)
  88195. * @param max defines the maximum vector (in local space)
  88196. * @param worldMatrix defines the new world matrix
  88197. */
  88198. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88199. /**
  88200. * Recreates the entire bounding box from scratch as if we call the constructor in place
  88201. * @param min defines the new minimum vector (in local space)
  88202. * @param max defines the new maximum vector (in local space)
  88203. * @param worldMatrix defines the new world matrix
  88204. */
  88205. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88206. /**
  88207. * Scale the current bounding box by applying a scale factor
  88208. * @param factor defines the scale factor to apply
  88209. * @returns the current bounding box
  88210. */
  88211. scale(factor: number): BoundingBox;
  88212. /**
  88213. * Gets the world matrix of the bounding box
  88214. * @returns a matrix
  88215. */
  88216. getWorldMatrix(): DeepImmutable<Matrix>;
  88217. /** @hidden */
  88218. _update(world: DeepImmutable<Matrix>): void;
  88219. /**
  88220. * Tests if the bounding box is intersecting the frustum planes
  88221. * @param frustumPlanes defines the frustum planes to test
  88222. * @returns true if there is an intersection
  88223. */
  88224. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88225. /**
  88226. * Tests if the bounding box is entirely inside the frustum planes
  88227. * @param frustumPlanes defines the frustum planes to test
  88228. * @returns true if there is an inclusion
  88229. */
  88230. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88231. /**
  88232. * Tests if a point is inside the bounding box
  88233. * @param point defines the point to test
  88234. * @returns true if the point is inside the bounding box
  88235. */
  88236. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88237. /**
  88238. * Tests if the bounding box intersects with a bounding sphere
  88239. * @param sphere defines the sphere to test
  88240. * @returns true if there is an intersection
  88241. */
  88242. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  88243. /**
  88244. * Tests if the bounding box intersects with a box defined by a min and max vectors
  88245. * @param min defines the min vector to use
  88246. * @param max defines the max vector to use
  88247. * @returns true if there is an intersection
  88248. */
  88249. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  88250. /**
  88251. * Tests if two bounding boxes are intersections
  88252. * @param box0 defines the first box to test
  88253. * @param box1 defines the second box to test
  88254. * @returns true if there is an intersection
  88255. */
  88256. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  88257. /**
  88258. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  88259. * @param minPoint defines the minimum vector of the bounding box
  88260. * @param maxPoint defines the maximum vector of the bounding box
  88261. * @param sphereCenter defines the sphere center
  88262. * @param sphereRadius defines the sphere radius
  88263. * @returns true if there is an intersection
  88264. */
  88265. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  88266. /**
  88267. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  88268. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88269. * @param frustumPlanes defines the frustum planes to test
  88270. * @return true if there is an inclusion
  88271. */
  88272. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88273. /**
  88274. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  88275. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  88276. * @param frustumPlanes defines the frustum planes to test
  88277. * @return true if there is an intersection
  88278. */
  88279. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88280. }
  88281. }
  88282. declare module BABYLON {
  88283. /** @hidden */
  88284. export class Collider {
  88285. /** Define if a collision was found */
  88286. collisionFound: boolean;
  88287. /**
  88288. * Define last intersection point in local space
  88289. */
  88290. intersectionPoint: Vector3;
  88291. /**
  88292. * Define last collided mesh
  88293. */
  88294. collidedMesh: Nullable<AbstractMesh>;
  88295. private _collisionPoint;
  88296. private _planeIntersectionPoint;
  88297. private _tempVector;
  88298. private _tempVector2;
  88299. private _tempVector3;
  88300. private _tempVector4;
  88301. private _edge;
  88302. private _baseToVertex;
  88303. private _destinationPoint;
  88304. private _slidePlaneNormal;
  88305. private _displacementVector;
  88306. /** @hidden */
  88307. _radius: Vector3;
  88308. /** @hidden */
  88309. _retry: number;
  88310. private _velocity;
  88311. private _basePoint;
  88312. private _epsilon;
  88313. /** @hidden */
  88314. _velocityWorldLength: number;
  88315. /** @hidden */
  88316. _basePointWorld: Vector3;
  88317. private _velocityWorld;
  88318. private _normalizedVelocity;
  88319. /** @hidden */
  88320. _initialVelocity: Vector3;
  88321. /** @hidden */
  88322. _initialPosition: Vector3;
  88323. private _nearestDistance;
  88324. private _collisionMask;
  88325. get collisionMask(): number;
  88326. set collisionMask(mask: number);
  88327. /**
  88328. * Gets the plane normal used to compute the sliding response (in local space)
  88329. */
  88330. get slidePlaneNormal(): Vector3;
  88331. /** @hidden */
  88332. _initialize(source: Vector3, dir: Vector3, e: number): void;
  88333. /** @hidden */
  88334. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  88335. /** @hidden */
  88336. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  88337. /** @hidden */
  88338. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88339. /** @hidden */
  88340. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  88341. /** @hidden */
  88342. _getResponse(pos: Vector3, vel: Vector3): void;
  88343. }
  88344. }
  88345. declare module BABYLON {
  88346. /**
  88347. * Interface for cullable objects
  88348. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  88349. */
  88350. export interface ICullable {
  88351. /**
  88352. * Checks if the object or part of the object is in the frustum
  88353. * @param frustumPlanes Camera near/planes
  88354. * @returns true if the object is in frustum otherwise false
  88355. */
  88356. isInFrustum(frustumPlanes: Plane[]): boolean;
  88357. /**
  88358. * Checks if a cullable object (mesh...) is in the camera frustum
  88359. * Unlike isInFrustum this cheks the full bounding box
  88360. * @param frustumPlanes Camera near/planes
  88361. * @returns true if the object is in frustum otherwise false
  88362. */
  88363. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  88364. }
  88365. /**
  88366. * Info for a bounding data of a mesh
  88367. */
  88368. export class BoundingInfo implements ICullable {
  88369. /**
  88370. * Bounding box for the mesh
  88371. */
  88372. readonly boundingBox: BoundingBox;
  88373. /**
  88374. * Bounding sphere for the mesh
  88375. */
  88376. readonly boundingSphere: BoundingSphere;
  88377. private _isLocked;
  88378. private static readonly TmpVector3;
  88379. /**
  88380. * Constructs bounding info
  88381. * @param minimum min vector of the bounding box/sphere
  88382. * @param maximum max vector of the bounding box/sphere
  88383. * @param worldMatrix defines the new world matrix
  88384. */
  88385. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  88386. /**
  88387. * Recreates the entire bounding info from scratch as if we call the constructor in place
  88388. * @param min defines the new minimum vector (in local space)
  88389. * @param max defines the new maximum vector (in local space)
  88390. * @param worldMatrix defines the new world matrix
  88391. */
  88392. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  88393. /**
  88394. * min vector of the bounding box/sphere
  88395. */
  88396. get minimum(): Vector3;
  88397. /**
  88398. * max vector of the bounding box/sphere
  88399. */
  88400. get maximum(): Vector3;
  88401. /**
  88402. * If the info is locked and won't be updated to avoid perf overhead
  88403. */
  88404. get isLocked(): boolean;
  88405. set isLocked(value: boolean);
  88406. /**
  88407. * Updates the bounding sphere and box
  88408. * @param world world matrix to be used to update
  88409. */
  88410. update(world: DeepImmutable<Matrix>): void;
  88411. /**
  88412. * Recreate the bounding info to be centered around a specific point given a specific extend.
  88413. * @param center New center of the bounding info
  88414. * @param extend New extend of the bounding info
  88415. * @returns the current bounding info
  88416. */
  88417. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  88418. /**
  88419. * Scale the current bounding info by applying a scale factor
  88420. * @param factor defines the scale factor to apply
  88421. * @returns the current bounding info
  88422. */
  88423. scale(factor: number): BoundingInfo;
  88424. /**
  88425. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  88426. * @param frustumPlanes defines the frustum to test
  88427. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  88428. * @returns true if the bounding info is in the frustum planes
  88429. */
  88430. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  88431. /**
  88432. * Gets the world distance between the min and max points of the bounding box
  88433. */
  88434. get diagonalLength(): number;
  88435. /**
  88436. * Checks if a cullable object (mesh...) is in the camera frustum
  88437. * Unlike isInFrustum this cheks the full bounding box
  88438. * @param frustumPlanes Camera near/planes
  88439. * @returns true if the object is in frustum otherwise false
  88440. */
  88441. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  88442. /** @hidden */
  88443. _checkCollision(collider: Collider): boolean;
  88444. /**
  88445. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  88446. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88447. * @param point the point to check intersection with
  88448. * @returns if the point intersects
  88449. */
  88450. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  88451. /**
  88452. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  88453. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  88454. * @param boundingInfo the bounding info to check intersection with
  88455. * @param precise if the intersection should be done using OBB
  88456. * @returns if the bounding info intersects
  88457. */
  88458. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  88459. }
  88460. }
  88461. declare module BABYLON {
  88462. /**
  88463. * Extracts minimum and maximum values from a list of indexed positions
  88464. * @param positions defines the positions to use
  88465. * @param indices defines the indices to the positions
  88466. * @param indexStart defines the start index
  88467. * @param indexCount defines the end index
  88468. * @param bias defines bias value to add to the result
  88469. * @return minimum and maximum values
  88470. */
  88471. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  88472. minimum: Vector3;
  88473. maximum: Vector3;
  88474. };
  88475. /**
  88476. * Extracts minimum and maximum values from a list of positions
  88477. * @param positions defines the positions to use
  88478. * @param start defines the start index in the positions array
  88479. * @param count defines the number of positions to handle
  88480. * @param bias defines bias value to add to the result
  88481. * @param stride defines the stride size to use (distance between two positions in the positions array)
  88482. * @return minimum and maximum values
  88483. */
  88484. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  88485. minimum: Vector3;
  88486. maximum: Vector3;
  88487. };
  88488. }
  88489. declare module BABYLON {
  88490. /** @hidden */
  88491. export class WebGLDataBuffer extends DataBuffer {
  88492. private _buffer;
  88493. constructor(resource: WebGLBuffer);
  88494. get underlyingResource(): any;
  88495. }
  88496. }
  88497. declare module BABYLON {
  88498. /** @hidden */
  88499. export class WebGLPipelineContext implements IPipelineContext {
  88500. engine: ThinEngine;
  88501. program: Nullable<WebGLProgram>;
  88502. context?: WebGLRenderingContext;
  88503. vertexShader?: WebGLShader;
  88504. fragmentShader?: WebGLShader;
  88505. isParallelCompiled: boolean;
  88506. onCompiled?: () => void;
  88507. transformFeedback?: WebGLTransformFeedback | null;
  88508. vertexCompilationError: Nullable<string>;
  88509. fragmentCompilationError: Nullable<string>;
  88510. programLinkError: Nullable<string>;
  88511. programValidationError: Nullable<string>;
  88512. get isAsync(): boolean;
  88513. get isReady(): boolean;
  88514. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  88515. _getVertexShaderCode(): string | null;
  88516. _getFragmentShaderCode(): string | null;
  88517. }
  88518. }
  88519. declare module BABYLON {
  88520. interface ThinEngine {
  88521. /**
  88522. * Create an uniform buffer
  88523. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88524. * @param elements defines the content of the uniform buffer
  88525. * @returns the webGL uniform buffer
  88526. */
  88527. createUniformBuffer(elements: FloatArray): DataBuffer;
  88528. /**
  88529. * Create a dynamic uniform buffer
  88530. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88531. * @param elements defines the content of the uniform buffer
  88532. * @returns the webGL uniform buffer
  88533. */
  88534. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  88535. /**
  88536. * Update an existing uniform buffer
  88537. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  88538. * @param uniformBuffer defines the target uniform buffer
  88539. * @param elements defines the content to update
  88540. * @param offset defines the offset in the uniform buffer where update should start
  88541. * @param count defines the size of the data to update
  88542. */
  88543. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  88544. /**
  88545. * Bind an uniform buffer to the current webGL context
  88546. * @param buffer defines the buffer to bind
  88547. */
  88548. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  88549. /**
  88550. * Bind a buffer to the current webGL context at a given location
  88551. * @param buffer defines the buffer to bind
  88552. * @param location defines the index where to bind the buffer
  88553. */
  88554. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  88555. /**
  88556. * Bind a specific block at a given index in a specific shader program
  88557. * @param pipelineContext defines the pipeline context to use
  88558. * @param blockName defines the block name
  88559. * @param index defines the index where to bind the block
  88560. */
  88561. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  88562. }
  88563. }
  88564. declare module BABYLON {
  88565. /**
  88566. * Uniform buffer objects.
  88567. *
  88568. * Handles blocks of uniform on the GPU.
  88569. *
  88570. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88571. *
  88572. * For more information, please refer to :
  88573. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88574. */
  88575. export class UniformBuffer {
  88576. private _engine;
  88577. private _buffer;
  88578. private _data;
  88579. private _bufferData;
  88580. private _dynamic?;
  88581. private _uniformLocations;
  88582. private _uniformSizes;
  88583. private _uniformLocationPointer;
  88584. private _needSync;
  88585. private _noUBO;
  88586. private _currentEffect;
  88587. /** @hidden */
  88588. _alreadyBound: boolean;
  88589. private static _MAX_UNIFORM_SIZE;
  88590. private static _tempBuffer;
  88591. /**
  88592. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88593. * This is dynamic to allow compat with webgl 1 and 2.
  88594. * You will need to pass the name of the uniform as well as the value.
  88595. */
  88596. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88597. /**
  88598. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88599. * This is dynamic to allow compat with webgl 1 and 2.
  88600. * You will need to pass the name of the uniform as well as the value.
  88601. */
  88602. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88603. /**
  88604. * Lambda to Update a single float in a uniform buffer.
  88605. * This is dynamic to allow compat with webgl 1 and 2.
  88606. * You will need to pass the name of the uniform as well as the value.
  88607. */
  88608. updateFloat: (name: string, x: number) => void;
  88609. /**
  88610. * Lambda to Update a vec2 of float in a uniform buffer.
  88611. * This is dynamic to allow compat with webgl 1 and 2.
  88612. * You will need to pass the name of the uniform as well as the value.
  88613. */
  88614. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88615. /**
  88616. * Lambda to Update a vec3 of float in a uniform buffer.
  88617. * This is dynamic to allow compat with webgl 1 and 2.
  88618. * You will need to pass the name of the uniform as well as the value.
  88619. */
  88620. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88621. /**
  88622. * Lambda to Update a vec4 of float in a uniform buffer.
  88623. * This is dynamic to allow compat with webgl 1 and 2.
  88624. * You will need to pass the name of the uniform as well as the value.
  88625. */
  88626. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88627. /**
  88628. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88629. * This is dynamic to allow compat with webgl 1 and 2.
  88630. * You will need to pass the name of the uniform as well as the value.
  88631. */
  88632. updateMatrix: (name: string, mat: Matrix) => void;
  88633. /**
  88634. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88635. * This is dynamic to allow compat with webgl 1 and 2.
  88636. * You will need to pass the name of the uniform as well as the value.
  88637. */
  88638. updateVector3: (name: string, vector: Vector3) => void;
  88639. /**
  88640. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88641. * This is dynamic to allow compat with webgl 1 and 2.
  88642. * You will need to pass the name of the uniform as well as the value.
  88643. */
  88644. updateVector4: (name: string, vector: Vector4) => void;
  88645. /**
  88646. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88647. * This is dynamic to allow compat with webgl 1 and 2.
  88648. * You will need to pass the name of the uniform as well as the value.
  88649. */
  88650. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88651. /**
  88652. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88653. * This is dynamic to allow compat with webgl 1 and 2.
  88654. * You will need to pass the name of the uniform as well as the value.
  88655. */
  88656. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88657. /**
  88658. * Instantiates a new Uniform buffer objects.
  88659. *
  88660. * Handles blocks of uniform on the GPU.
  88661. *
  88662. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88663. *
  88664. * For more information, please refer to :
  88665. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88666. * @param engine Define the engine the buffer is associated with
  88667. * @param data Define the data contained in the buffer
  88668. * @param dynamic Define if the buffer is updatable
  88669. */
  88670. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88671. /**
  88672. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88673. * or just falling back on setUniformXXX calls.
  88674. */
  88675. get useUbo(): boolean;
  88676. /**
  88677. * Indicates if the WebGL underlying uniform buffer is in sync
  88678. * with the javascript cache data.
  88679. */
  88680. get isSync(): boolean;
  88681. /**
  88682. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88683. * Also, a dynamic UniformBuffer will disable cache verification and always
  88684. * update the underlying WebGL uniform buffer to the GPU.
  88685. * @returns if Dynamic, otherwise false
  88686. */
  88687. isDynamic(): boolean;
  88688. /**
  88689. * The data cache on JS side.
  88690. * @returns the underlying data as a float array
  88691. */
  88692. getData(): Float32Array;
  88693. /**
  88694. * The underlying WebGL Uniform buffer.
  88695. * @returns the webgl buffer
  88696. */
  88697. getBuffer(): Nullable<DataBuffer>;
  88698. /**
  88699. * std140 layout specifies how to align data within an UBO structure.
  88700. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88701. * for specs.
  88702. */
  88703. private _fillAlignment;
  88704. /**
  88705. * Adds an uniform in the buffer.
  88706. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88707. * for the layout to be correct !
  88708. * @param name Name of the uniform, as used in the uniform block in the shader.
  88709. * @param size Data size, or data directly.
  88710. */
  88711. addUniform(name: string, size: number | number[]): void;
  88712. /**
  88713. * Adds a Matrix 4x4 to the uniform buffer.
  88714. * @param name Name of the uniform, as used in the uniform block in the shader.
  88715. * @param mat A 4x4 matrix.
  88716. */
  88717. addMatrix(name: string, mat: Matrix): void;
  88718. /**
  88719. * Adds a vec2 to the uniform buffer.
  88720. * @param name Name of the uniform, as used in the uniform block in the shader.
  88721. * @param x Define the x component value of the vec2
  88722. * @param y Define the y component value of the vec2
  88723. */
  88724. addFloat2(name: string, x: number, y: number): void;
  88725. /**
  88726. * Adds a vec3 to the uniform buffer.
  88727. * @param name Name of the uniform, as used in the uniform block in the shader.
  88728. * @param x Define the x component value of the vec3
  88729. * @param y Define the y component value of the vec3
  88730. * @param z Define the z component value of the vec3
  88731. */
  88732. addFloat3(name: string, x: number, y: number, z: number): void;
  88733. /**
  88734. * Adds a vec3 to the uniform buffer.
  88735. * @param name Name of the uniform, as used in the uniform block in the shader.
  88736. * @param color Define the vec3 from a Color
  88737. */
  88738. addColor3(name: string, color: Color3): void;
  88739. /**
  88740. * Adds a vec4 to the uniform buffer.
  88741. * @param name Name of the uniform, as used in the uniform block in the shader.
  88742. * @param color Define the rgb components from a Color
  88743. * @param alpha Define the a component of the vec4
  88744. */
  88745. addColor4(name: string, color: Color3, alpha: number): void;
  88746. /**
  88747. * Adds a vec3 to the uniform buffer.
  88748. * @param name Name of the uniform, as used in the uniform block in the shader.
  88749. * @param vector Define the vec3 components from a Vector
  88750. */
  88751. addVector3(name: string, vector: Vector3): void;
  88752. /**
  88753. * Adds a Matrix 3x3 to the uniform buffer.
  88754. * @param name Name of the uniform, as used in the uniform block in the shader.
  88755. */
  88756. addMatrix3x3(name: string): void;
  88757. /**
  88758. * Adds a Matrix 2x2 to the uniform buffer.
  88759. * @param name Name of the uniform, as used in the uniform block in the shader.
  88760. */
  88761. addMatrix2x2(name: string): void;
  88762. /**
  88763. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88764. */
  88765. create(): void;
  88766. /** @hidden */
  88767. _rebuild(): void;
  88768. /**
  88769. * Updates the WebGL Uniform Buffer on the GPU.
  88770. * If the `dynamic` flag is set to true, no cache comparison is done.
  88771. * Otherwise, the buffer will be updated only if the cache differs.
  88772. */
  88773. update(): void;
  88774. /**
  88775. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88776. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88777. * @param data Define the flattened data
  88778. * @param size Define the size of the data.
  88779. */
  88780. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88781. private _valueCache;
  88782. private _cacheMatrix;
  88783. private _updateMatrix3x3ForUniform;
  88784. private _updateMatrix3x3ForEffect;
  88785. private _updateMatrix2x2ForEffect;
  88786. private _updateMatrix2x2ForUniform;
  88787. private _updateFloatForEffect;
  88788. private _updateFloatForUniform;
  88789. private _updateFloat2ForEffect;
  88790. private _updateFloat2ForUniform;
  88791. private _updateFloat3ForEffect;
  88792. private _updateFloat3ForUniform;
  88793. private _updateFloat4ForEffect;
  88794. private _updateFloat4ForUniform;
  88795. private _updateMatrixForEffect;
  88796. private _updateMatrixForUniform;
  88797. private _updateVector3ForEffect;
  88798. private _updateVector3ForUniform;
  88799. private _updateVector4ForEffect;
  88800. private _updateVector4ForUniform;
  88801. private _updateColor3ForEffect;
  88802. private _updateColor3ForUniform;
  88803. private _updateColor4ForEffect;
  88804. private _updateColor4ForUniform;
  88805. /**
  88806. * Sets a sampler uniform on the effect.
  88807. * @param name Define the name of the sampler.
  88808. * @param texture Define the texture to set in the sampler
  88809. */
  88810. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88811. /**
  88812. * Directly updates the value of the uniform in the cache AND on the GPU.
  88813. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88814. * @param data Define the flattened data
  88815. */
  88816. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88817. /**
  88818. * Binds this uniform buffer to an effect.
  88819. * @param effect Define the effect to bind the buffer to
  88820. * @param name Name of the uniform block in the shader.
  88821. */
  88822. bindToEffect(effect: Effect, name: string): void;
  88823. /**
  88824. * Disposes the uniform buffer.
  88825. */
  88826. dispose(): void;
  88827. }
  88828. }
  88829. declare module BABYLON {
  88830. /**
  88831. * Enum that determines the text-wrapping mode to use.
  88832. */
  88833. export enum InspectableType {
  88834. /**
  88835. * Checkbox for booleans
  88836. */
  88837. Checkbox = 0,
  88838. /**
  88839. * Sliders for numbers
  88840. */
  88841. Slider = 1,
  88842. /**
  88843. * Vector3
  88844. */
  88845. Vector3 = 2,
  88846. /**
  88847. * Quaternions
  88848. */
  88849. Quaternion = 3,
  88850. /**
  88851. * Color3
  88852. */
  88853. Color3 = 4,
  88854. /**
  88855. * String
  88856. */
  88857. String = 5
  88858. }
  88859. /**
  88860. * Interface used to define custom inspectable properties.
  88861. * This interface is used by the inspector to display custom property grids
  88862. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88863. */
  88864. export interface IInspectable {
  88865. /**
  88866. * Gets the label to display
  88867. */
  88868. label: string;
  88869. /**
  88870. * Gets the name of the property to edit
  88871. */
  88872. propertyName: string;
  88873. /**
  88874. * Gets the type of the editor to use
  88875. */
  88876. type: InspectableType;
  88877. /**
  88878. * Gets the minimum value of the property when using in "slider" mode
  88879. */
  88880. min?: number;
  88881. /**
  88882. * Gets the maximum value of the property when using in "slider" mode
  88883. */
  88884. max?: number;
  88885. /**
  88886. * Gets the setp to use when using in "slider" mode
  88887. */
  88888. step?: number;
  88889. }
  88890. }
  88891. declare module BABYLON {
  88892. /**
  88893. * Class used to provide helper for timing
  88894. */
  88895. export class TimingTools {
  88896. /**
  88897. * Polyfill for setImmediate
  88898. * @param action defines the action to execute after the current execution block
  88899. */
  88900. static SetImmediate(action: () => void): void;
  88901. }
  88902. }
  88903. declare module BABYLON {
  88904. /**
  88905. * Class used to enable instatition of objects by class name
  88906. */
  88907. export class InstantiationTools {
  88908. /**
  88909. * Use this object to register external classes like custom textures or material
  88910. * to allow the laoders to instantiate them
  88911. */
  88912. static RegisteredExternalClasses: {
  88913. [key: string]: Object;
  88914. };
  88915. /**
  88916. * Tries to instantiate a new object from a given class name
  88917. * @param className defines the class name to instantiate
  88918. * @returns the new object or null if the system was not able to do the instantiation
  88919. */
  88920. static Instantiate(className: string): any;
  88921. }
  88922. }
  88923. declare module BABYLON {
  88924. /**
  88925. * Define options used to create a depth texture
  88926. */
  88927. export class DepthTextureCreationOptions {
  88928. /** Specifies whether or not a stencil should be allocated in the texture */
  88929. generateStencil?: boolean;
  88930. /** Specifies whether or not bilinear filtering is enable on the texture */
  88931. bilinearFiltering?: boolean;
  88932. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88933. comparisonFunction?: number;
  88934. /** Specifies if the created texture is a cube texture */
  88935. isCube?: boolean;
  88936. }
  88937. }
  88938. declare module BABYLON {
  88939. interface ThinEngine {
  88940. /**
  88941. * Creates a depth stencil cube texture.
  88942. * This is only available in WebGL 2.
  88943. * @param size The size of face edge in the cube texture.
  88944. * @param options The options defining the cube texture.
  88945. * @returns The cube texture
  88946. */
  88947. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88948. /**
  88949. * Creates a cube texture
  88950. * @param rootUrl defines the url where the files to load is located
  88951. * @param scene defines the current scene
  88952. * @param files defines the list of files to load (1 per face)
  88953. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88954. * @param onLoad defines an optional callback raised when the texture is loaded
  88955. * @param onError defines an optional callback raised if there is an issue to load the texture
  88956. * @param format defines the format of the data
  88957. * @param forcedExtension defines the extension to use to pick the right loader
  88958. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88959. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88960. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88961. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88962. * @param loaderOptions options to be passed to the loader
  88963. * @returns the cube texture as an InternalTexture
  88964. */
  88965. 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;
  88966. /**
  88967. * Creates a cube texture
  88968. * @param rootUrl defines the url where the files to load is located
  88969. * @param scene defines the current scene
  88970. * @param files defines the list of files to load (1 per face)
  88971. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88972. * @param onLoad defines an optional callback raised when the texture is loaded
  88973. * @param onError defines an optional callback raised if there is an issue to load the texture
  88974. * @param format defines the format of the data
  88975. * @param forcedExtension defines the extension to use to pick the right loader
  88976. * @returns the cube texture as an InternalTexture
  88977. */
  88978. 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;
  88979. /**
  88980. * Creates a cube texture
  88981. * @param rootUrl defines the url where the files to load is located
  88982. * @param scene defines the current scene
  88983. * @param files defines the list of files to load (1 per face)
  88984. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88985. * @param onLoad defines an optional callback raised when the texture is loaded
  88986. * @param onError defines an optional callback raised if there is an issue to load the texture
  88987. * @param format defines the format of the data
  88988. * @param forcedExtension defines the extension to use to pick the right loader
  88989. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88990. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88991. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88992. * @returns the cube texture as an InternalTexture
  88993. */
  88994. 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;
  88995. /** @hidden */
  88996. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88997. /** @hidden */
  88998. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88999. /** @hidden */
  89000. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  89001. /** @hidden */
  89002. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  89003. /**
  89004. * @hidden
  89005. */
  89006. _setCubeMapTextureParams(texture: InternalTexture, loadMipmap: boolean): void;
  89007. }
  89008. }
  89009. declare module BABYLON {
  89010. /**
  89011. * Class for creating a cube texture
  89012. */
  89013. export class CubeTexture extends BaseTexture {
  89014. private _delayedOnLoad;
  89015. /**
  89016. * Observable triggered once the texture has been loaded.
  89017. */
  89018. onLoadObservable: Observable<CubeTexture>;
  89019. /**
  89020. * The url of the texture
  89021. */
  89022. url: string;
  89023. /**
  89024. * Gets or sets the center of the bounding box associated with the cube texture.
  89025. * It must define where the camera used to render the texture was set
  89026. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  89027. */
  89028. boundingBoxPosition: Vector3;
  89029. private _boundingBoxSize;
  89030. /**
  89031. * Gets or sets the size of the bounding box associated with the cube texture
  89032. * When defined, the cubemap will switch to local mode
  89033. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  89034. * @example https://www.babylonjs-playground.com/#RNASML
  89035. */
  89036. set boundingBoxSize(value: Vector3);
  89037. /**
  89038. * Returns the bounding box size
  89039. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  89040. */
  89041. get boundingBoxSize(): Vector3;
  89042. protected _rotationY: number;
  89043. /**
  89044. * Sets texture matrix rotation angle around Y axis in radians.
  89045. */
  89046. set rotationY(value: number);
  89047. /**
  89048. * Gets texture matrix rotation angle around Y axis radians.
  89049. */
  89050. get rotationY(): number;
  89051. /**
  89052. * Are mip maps generated for this texture or not.
  89053. */
  89054. get noMipmap(): boolean;
  89055. private _noMipmap;
  89056. private _files;
  89057. protected _forcedExtension: Nullable<string>;
  89058. private _extensions;
  89059. private _textureMatrix;
  89060. private _format;
  89061. private _createPolynomials;
  89062. private _loaderOptions;
  89063. /**
  89064. * Creates a cube texture from an array of image urls
  89065. * @param files defines an array of image urls
  89066. * @param scene defines the hosting scene
  89067. * @param noMipmap specifies if mip maps are not used
  89068. * @returns a cube texture
  89069. */
  89070. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  89071. /**
  89072. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  89073. * @param url defines the url of the prefiltered texture
  89074. * @param scene defines the scene the texture is attached to
  89075. * @param forcedExtension defines the extension of the file if different from the url
  89076. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  89077. * @return the prefiltered texture
  89078. */
  89079. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  89080. /**
  89081. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  89082. * as prefiltered data.
  89083. * @param rootUrl defines the url of the texture or the root name of the six images
  89084. * @param null defines the scene or engine the texture is attached to
  89085. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  89086. * @param noMipmap defines if mipmaps should be created or not
  89087. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  89088. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  89089. * @param onError defines a callback triggered in case of error during load
  89090. * @param format defines the internal format to use for the texture once loaded
  89091. * @param prefiltered defines whether or not the texture is created from prefiltered data
  89092. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  89093. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  89094. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  89095. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  89096. * @param loaderOptions options to be passed to the loader
  89097. * @return the cube texture
  89098. */
  89099. 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);
  89100. /**
  89101. * Get the current class name of the texture useful for serialization or dynamic coding.
  89102. * @returns "CubeTexture"
  89103. */
  89104. getClassName(): string;
  89105. /**
  89106. * Update the url (and optional buffer) of this texture if url was null during construction.
  89107. * @param url the url of the texture
  89108. * @param forcedExtension defines the extension to use
  89109. * @param onLoad callback called when the texture is loaded (defaults to null)
  89110. * @param prefiltered Defines whether the updated texture is prefiltered or not
  89111. */
  89112. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  89113. /**
  89114. * Delays loading of the cube texture
  89115. * @param forcedExtension defines the extension to use
  89116. */
  89117. delayLoad(forcedExtension?: string): void;
  89118. /**
  89119. * Returns the reflection texture matrix
  89120. * @returns the reflection texture matrix
  89121. */
  89122. getReflectionTextureMatrix(): Matrix;
  89123. /**
  89124. * Sets the reflection texture matrix
  89125. * @param value Reflection texture matrix
  89126. */
  89127. setReflectionTextureMatrix(value: Matrix): void;
  89128. /**
  89129. * Parses text to create a cube texture
  89130. * @param parsedTexture define the serialized text to read from
  89131. * @param scene defines the hosting scene
  89132. * @param rootUrl defines the root url of the cube texture
  89133. * @returns a cube texture
  89134. */
  89135. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  89136. /**
  89137. * Makes a clone, or deep copy, of the cube texture
  89138. * @returns a new cube texture
  89139. */
  89140. clone(): CubeTexture;
  89141. }
  89142. }
  89143. declare module BABYLON {
  89144. /**
  89145. * Manages the defines for the Material
  89146. */
  89147. export class MaterialDefines {
  89148. /** @hidden */
  89149. protected _keys: string[];
  89150. private _isDirty;
  89151. /** @hidden */
  89152. _renderId: number;
  89153. /** @hidden */
  89154. _areLightsDirty: boolean;
  89155. /** @hidden */
  89156. _areLightsDisposed: boolean;
  89157. /** @hidden */
  89158. _areAttributesDirty: boolean;
  89159. /** @hidden */
  89160. _areTexturesDirty: boolean;
  89161. /** @hidden */
  89162. _areFresnelDirty: boolean;
  89163. /** @hidden */
  89164. _areMiscDirty: boolean;
  89165. /** @hidden */
  89166. _arePrePassDirty: boolean;
  89167. /** @hidden */
  89168. _areImageProcessingDirty: boolean;
  89169. /** @hidden */
  89170. _normals: boolean;
  89171. /** @hidden */
  89172. _uvs: boolean;
  89173. /** @hidden */
  89174. _needNormals: boolean;
  89175. /** @hidden */
  89176. _needUVs: boolean;
  89177. [id: string]: any;
  89178. /**
  89179. * Specifies if the material needs to be re-calculated
  89180. */
  89181. get isDirty(): boolean;
  89182. /**
  89183. * Marks the material to indicate that it has been re-calculated
  89184. */
  89185. markAsProcessed(): void;
  89186. /**
  89187. * Marks the material to indicate that it needs to be re-calculated
  89188. */
  89189. markAsUnprocessed(): void;
  89190. /**
  89191. * Marks the material to indicate all of its defines need to be re-calculated
  89192. */
  89193. markAllAsDirty(): void;
  89194. /**
  89195. * Marks the material to indicate that image processing needs to be re-calculated
  89196. */
  89197. markAsImageProcessingDirty(): void;
  89198. /**
  89199. * Marks the material to indicate the lights need to be re-calculated
  89200. * @param disposed Defines whether the light is dirty due to dispose or not
  89201. */
  89202. markAsLightDirty(disposed?: boolean): void;
  89203. /**
  89204. * Marks the attribute state as changed
  89205. */
  89206. markAsAttributesDirty(): void;
  89207. /**
  89208. * Marks the texture state as changed
  89209. */
  89210. markAsTexturesDirty(): void;
  89211. /**
  89212. * Marks the fresnel state as changed
  89213. */
  89214. markAsFresnelDirty(): void;
  89215. /**
  89216. * Marks the misc state as changed
  89217. */
  89218. markAsMiscDirty(): void;
  89219. /**
  89220. * Marks the prepass state as changed
  89221. */
  89222. markAsPrePassDirty(): void;
  89223. /**
  89224. * Rebuilds the material defines
  89225. */
  89226. rebuild(): void;
  89227. /**
  89228. * Specifies if two material defines are equal
  89229. * @param other - A material define instance to compare to
  89230. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  89231. */
  89232. isEqual(other: MaterialDefines): boolean;
  89233. /**
  89234. * Clones this instance's defines to another instance
  89235. * @param other - material defines to clone values to
  89236. */
  89237. cloneTo(other: MaterialDefines): void;
  89238. /**
  89239. * Resets the material define values
  89240. */
  89241. reset(): void;
  89242. /**
  89243. * Converts the material define values to a string
  89244. * @returns - String of material define information
  89245. */
  89246. toString(): string;
  89247. }
  89248. }
  89249. declare module BABYLON {
  89250. /**
  89251. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89252. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89253. * 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;
  89254. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89255. */
  89256. export class ColorCurves {
  89257. private _dirty;
  89258. private _tempColor;
  89259. private _globalCurve;
  89260. private _highlightsCurve;
  89261. private _midtonesCurve;
  89262. private _shadowsCurve;
  89263. private _positiveCurve;
  89264. private _negativeCurve;
  89265. private _globalHue;
  89266. private _globalDensity;
  89267. private _globalSaturation;
  89268. private _globalExposure;
  89269. /**
  89270. * Gets the global Hue value.
  89271. * 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).
  89272. */
  89273. get globalHue(): number;
  89274. /**
  89275. * Sets the global Hue value.
  89276. * 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).
  89277. */
  89278. set globalHue(value: number);
  89279. /**
  89280. * Gets the global Density value.
  89281. * 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.
  89282. * Values less than zero provide a filter of opposite hue.
  89283. */
  89284. get globalDensity(): number;
  89285. /**
  89286. * Sets the global Density value.
  89287. * 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.
  89288. * Values less than zero provide a filter of opposite hue.
  89289. */
  89290. set globalDensity(value: number);
  89291. /**
  89292. * Gets the global Saturation value.
  89293. * 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.
  89294. */
  89295. get globalSaturation(): number;
  89296. /**
  89297. * Sets the global Saturation value.
  89298. * 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.
  89299. */
  89300. set globalSaturation(value: number);
  89301. /**
  89302. * Gets the global Exposure value.
  89303. * 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.
  89304. */
  89305. get globalExposure(): number;
  89306. /**
  89307. * Sets the global Exposure value.
  89308. * 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.
  89309. */
  89310. set globalExposure(value: number);
  89311. private _highlightsHue;
  89312. private _highlightsDensity;
  89313. private _highlightsSaturation;
  89314. private _highlightsExposure;
  89315. /**
  89316. * Gets the highlights Hue value.
  89317. * 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).
  89318. */
  89319. get highlightsHue(): number;
  89320. /**
  89321. * Sets the highlights Hue value.
  89322. * 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).
  89323. */
  89324. set highlightsHue(value: number);
  89325. /**
  89326. * Gets the highlights Density value.
  89327. * 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.
  89328. * Values less than zero provide a filter of opposite hue.
  89329. */
  89330. get highlightsDensity(): number;
  89331. /**
  89332. * Sets the highlights Density value.
  89333. * 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.
  89334. * Values less than zero provide a filter of opposite hue.
  89335. */
  89336. set highlightsDensity(value: number);
  89337. /**
  89338. * Gets the highlights Saturation value.
  89339. * 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.
  89340. */
  89341. get highlightsSaturation(): number;
  89342. /**
  89343. * Sets the highlights Saturation value.
  89344. * 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.
  89345. */
  89346. set highlightsSaturation(value: number);
  89347. /**
  89348. * Gets the highlights Exposure value.
  89349. * 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.
  89350. */
  89351. get highlightsExposure(): number;
  89352. /**
  89353. * Sets the highlights Exposure value.
  89354. * 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.
  89355. */
  89356. set highlightsExposure(value: number);
  89357. private _midtonesHue;
  89358. private _midtonesDensity;
  89359. private _midtonesSaturation;
  89360. private _midtonesExposure;
  89361. /**
  89362. * Gets the midtones Hue value.
  89363. * 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).
  89364. */
  89365. get midtonesHue(): number;
  89366. /**
  89367. * Sets the midtones Hue value.
  89368. * 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).
  89369. */
  89370. set midtonesHue(value: number);
  89371. /**
  89372. * Gets the midtones Density value.
  89373. * 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.
  89374. * Values less than zero provide a filter of opposite hue.
  89375. */
  89376. get midtonesDensity(): number;
  89377. /**
  89378. * Sets the midtones Density value.
  89379. * 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.
  89380. * Values less than zero provide a filter of opposite hue.
  89381. */
  89382. set midtonesDensity(value: number);
  89383. /**
  89384. * Gets the midtones Saturation value.
  89385. * 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.
  89386. */
  89387. get midtonesSaturation(): number;
  89388. /**
  89389. * Sets the midtones Saturation value.
  89390. * 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.
  89391. */
  89392. set midtonesSaturation(value: number);
  89393. /**
  89394. * Gets the midtones Exposure value.
  89395. * 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.
  89396. */
  89397. get midtonesExposure(): number;
  89398. /**
  89399. * Sets the midtones Exposure value.
  89400. * 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.
  89401. */
  89402. set midtonesExposure(value: number);
  89403. private _shadowsHue;
  89404. private _shadowsDensity;
  89405. private _shadowsSaturation;
  89406. private _shadowsExposure;
  89407. /**
  89408. * Gets the shadows Hue value.
  89409. * 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).
  89410. */
  89411. get shadowsHue(): number;
  89412. /**
  89413. * Sets the shadows Hue value.
  89414. * 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).
  89415. */
  89416. set shadowsHue(value: number);
  89417. /**
  89418. * Gets the shadows Density value.
  89419. * 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.
  89420. * Values less than zero provide a filter of opposite hue.
  89421. */
  89422. get shadowsDensity(): number;
  89423. /**
  89424. * Sets the shadows Density value.
  89425. * 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.
  89426. * Values less than zero provide a filter of opposite hue.
  89427. */
  89428. set shadowsDensity(value: number);
  89429. /**
  89430. * Gets the shadows Saturation value.
  89431. * 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.
  89432. */
  89433. get shadowsSaturation(): number;
  89434. /**
  89435. * Sets the shadows Saturation value.
  89436. * 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.
  89437. */
  89438. set shadowsSaturation(value: number);
  89439. /**
  89440. * Gets the shadows Exposure value.
  89441. * 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.
  89442. */
  89443. get shadowsExposure(): number;
  89444. /**
  89445. * Sets the shadows Exposure value.
  89446. * 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.
  89447. */
  89448. set shadowsExposure(value: number);
  89449. /**
  89450. * Returns the class name
  89451. * @returns The class name
  89452. */
  89453. getClassName(): string;
  89454. /**
  89455. * Binds the color curves to the shader.
  89456. * @param colorCurves The color curve to bind
  89457. * @param effect The effect to bind to
  89458. * @param positiveUniform The positive uniform shader parameter
  89459. * @param neutralUniform The neutral uniform shader parameter
  89460. * @param negativeUniform The negative uniform shader parameter
  89461. */
  89462. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89463. /**
  89464. * Prepare the list of uniforms associated with the ColorCurves effects.
  89465. * @param uniformsList The list of uniforms used in the effect
  89466. */
  89467. static PrepareUniforms(uniformsList: string[]): void;
  89468. /**
  89469. * Returns color grading data based on a hue, density, saturation and exposure value.
  89470. * @param filterHue The hue of the color filter.
  89471. * @param filterDensity The density of the color filter.
  89472. * @param saturation The saturation.
  89473. * @param exposure The exposure.
  89474. * @param result The result data container.
  89475. */
  89476. private getColorGradingDataToRef;
  89477. /**
  89478. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89479. * @param value The input slider value in range [-100,100].
  89480. * @returns Adjusted value.
  89481. */
  89482. private static applyColorGradingSliderNonlinear;
  89483. /**
  89484. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89485. * @param hue The hue (H) input.
  89486. * @param saturation The saturation (S) input.
  89487. * @param brightness The brightness (B) input.
  89488. * @result An RGBA color represented as Vector4.
  89489. */
  89490. private static fromHSBToRef;
  89491. /**
  89492. * Returns a value clamped between min and max
  89493. * @param value The value to clamp
  89494. * @param min The minimum of value
  89495. * @param max The maximum of value
  89496. * @returns The clamped value.
  89497. */
  89498. private static clamp;
  89499. /**
  89500. * Clones the current color curve instance.
  89501. * @return The cloned curves
  89502. */
  89503. clone(): ColorCurves;
  89504. /**
  89505. * Serializes the current color curve instance to a json representation.
  89506. * @return a JSON representation
  89507. */
  89508. serialize(): any;
  89509. /**
  89510. * Parses the color curve from a json representation.
  89511. * @param source the JSON source to parse
  89512. * @return The parsed curves
  89513. */
  89514. static Parse(source: any): ColorCurves;
  89515. }
  89516. }
  89517. declare module BABYLON {
  89518. /**
  89519. * Interface to follow in your material defines to integrate easily the
  89520. * Image proccessing functions.
  89521. * @hidden
  89522. */
  89523. export interface IImageProcessingConfigurationDefines {
  89524. IMAGEPROCESSING: boolean;
  89525. VIGNETTE: boolean;
  89526. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89527. VIGNETTEBLENDMODEOPAQUE: boolean;
  89528. TONEMAPPING: boolean;
  89529. TONEMAPPING_ACES: boolean;
  89530. CONTRAST: boolean;
  89531. EXPOSURE: boolean;
  89532. COLORCURVES: boolean;
  89533. COLORGRADING: boolean;
  89534. COLORGRADING3D: boolean;
  89535. SAMPLER3DGREENDEPTH: boolean;
  89536. SAMPLER3DBGRMAP: boolean;
  89537. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89538. }
  89539. /**
  89540. * @hidden
  89541. */
  89542. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89543. IMAGEPROCESSING: boolean;
  89544. VIGNETTE: boolean;
  89545. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89546. VIGNETTEBLENDMODEOPAQUE: boolean;
  89547. TONEMAPPING: boolean;
  89548. TONEMAPPING_ACES: boolean;
  89549. CONTRAST: boolean;
  89550. COLORCURVES: boolean;
  89551. COLORGRADING: boolean;
  89552. COLORGRADING3D: boolean;
  89553. SAMPLER3DGREENDEPTH: boolean;
  89554. SAMPLER3DBGRMAP: boolean;
  89555. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89556. EXPOSURE: boolean;
  89557. constructor();
  89558. }
  89559. /**
  89560. * This groups together the common properties used for image processing either in direct forward pass
  89561. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89562. * or not.
  89563. */
  89564. export class ImageProcessingConfiguration {
  89565. /**
  89566. * Default tone mapping applied in BabylonJS.
  89567. */
  89568. static readonly TONEMAPPING_STANDARD: number;
  89569. /**
  89570. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89571. * to other engines rendering to increase portability.
  89572. */
  89573. static readonly TONEMAPPING_ACES: number;
  89574. /**
  89575. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89576. */
  89577. colorCurves: Nullable<ColorCurves>;
  89578. private _colorCurvesEnabled;
  89579. /**
  89580. * Gets wether the color curves effect is enabled.
  89581. */
  89582. get colorCurvesEnabled(): boolean;
  89583. /**
  89584. * Sets wether the color curves effect is enabled.
  89585. */
  89586. set colorCurvesEnabled(value: boolean);
  89587. private _colorGradingTexture;
  89588. /**
  89589. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89590. */
  89591. get colorGradingTexture(): Nullable<BaseTexture>;
  89592. /**
  89593. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89594. */
  89595. set colorGradingTexture(value: Nullable<BaseTexture>);
  89596. private _colorGradingEnabled;
  89597. /**
  89598. * Gets wether the color grading effect is enabled.
  89599. */
  89600. get colorGradingEnabled(): boolean;
  89601. /**
  89602. * Sets wether the color grading effect is enabled.
  89603. */
  89604. set colorGradingEnabled(value: boolean);
  89605. private _colorGradingWithGreenDepth;
  89606. /**
  89607. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89608. */
  89609. get colorGradingWithGreenDepth(): boolean;
  89610. /**
  89611. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89612. */
  89613. set colorGradingWithGreenDepth(value: boolean);
  89614. private _colorGradingBGR;
  89615. /**
  89616. * Gets wether the color grading texture contains BGR values.
  89617. */
  89618. get colorGradingBGR(): boolean;
  89619. /**
  89620. * Sets wether the color grading texture contains BGR values.
  89621. */
  89622. set colorGradingBGR(value: boolean);
  89623. /** @hidden */
  89624. _exposure: number;
  89625. /**
  89626. * Gets the Exposure used in the effect.
  89627. */
  89628. get exposure(): number;
  89629. /**
  89630. * Sets the Exposure used in the effect.
  89631. */
  89632. set exposure(value: number);
  89633. private _toneMappingEnabled;
  89634. /**
  89635. * Gets wether the tone mapping effect is enabled.
  89636. */
  89637. get toneMappingEnabled(): boolean;
  89638. /**
  89639. * Sets wether the tone mapping effect is enabled.
  89640. */
  89641. set toneMappingEnabled(value: boolean);
  89642. private _toneMappingType;
  89643. /**
  89644. * Gets the type of tone mapping effect.
  89645. */
  89646. get toneMappingType(): number;
  89647. /**
  89648. * Sets the type of tone mapping effect used in BabylonJS.
  89649. */
  89650. set toneMappingType(value: number);
  89651. protected _contrast: number;
  89652. /**
  89653. * Gets the contrast used in the effect.
  89654. */
  89655. get contrast(): number;
  89656. /**
  89657. * Sets the contrast used in the effect.
  89658. */
  89659. set contrast(value: number);
  89660. /**
  89661. * Vignette stretch size.
  89662. */
  89663. vignetteStretch: number;
  89664. /**
  89665. * Vignette centre X Offset.
  89666. */
  89667. vignetteCentreX: number;
  89668. /**
  89669. * Vignette centre Y Offset.
  89670. */
  89671. vignetteCentreY: number;
  89672. /**
  89673. * Vignette weight or intensity of the vignette effect.
  89674. */
  89675. vignetteWeight: number;
  89676. /**
  89677. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89678. * if vignetteEnabled is set to true.
  89679. */
  89680. vignetteColor: Color4;
  89681. /**
  89682. * Camera field of view used by the Vignette effect.
  89683. */
  89684. vignetteCameraFov: number;
  89685. private _vignetteBlendMode;
  89686. /**
  89687. * Gets the vignette blend mode allowing different kind of effect.
  89688. */
  89689. get vignetteBlendMode(): number;
  89690. /**
  89691. * Sets the vignette blend mode allowing different kind of effect.
  89692. */
  89693. set vignetteBlendMode(value: number);
  89694. private _vignetteEnabled;
  89695. /**
  89696. * Gets wether the vignette effect is enabled.
  89697. */
  89698. get vignetteEnabled(): boolean;
  89699. /**
  89700. * Sets wether the vignette effect is enabled.
  89701. */
  89702. set vignetteEnabled(value: boolean);
  89703. private _applyByPostProcess;
  89704. /**
  89705. * Gets wether the image processing is applied through a post process or not.
  89706. */
  89707. get applyByPostProcess(): boolean;
  89708. /**
  89709. * Sets wether the image processing is applied through a post process or not.
  89710. */
  89711. set applyByPostProcess(value: boolean);
  89712. private _isEnabled;
  89713. /**
  89714. * Gets wether the image processing is enabled or not.
  89715. */
  89716. get isEnabled(): boolean;
  89717. /**
  89718. * Sets wether the image processing is enabled or not.
  89719. */
  89720. set isEnabled(value: boolean);
  89721. /**
  89722. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89723. */
  89724. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89725. /**
  89726. * Method called each time the image processing information changes requires to recompile the effect.
  89727. */
  89728. protected _updateParameters(): void;
  89729. /**
  89730. * Gets the current class name.
  89731. * @return "ImageProcessingConfiguration"
  89732. */
  89733. getClassName(): string;
  89734. /**
  89735. * Prepare the list of uniforms associated with the Image Processing effects.
  89736. * @param uniforms The list of uniforms used in the effect
  89737. * @param defines the list of defines currently in use
  89738. */
  89739. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89740. /**
  89741. * Prepare the list of samplers associated with the Image Processing effects.
  89742. * @param samplersList The list of uniforms used in the effect
  89743. * @param defines the list of defines currently in use
  89744. */
  89745. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89746. /**
  89747. * Prepare the list of defines associated to the shader.
  89748. * @param defines the list of defines to complete
  89749. * @param forPostProcess Define if we are currently in post process mode or not
  89750. */
  89751. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89752. /**
  89753. * Returns true if all the image processing information are ready.
  89754. * @returns True if ready, otherwise, false
  89755. */
  89756. isReady(): boolean;
  89757. /**
  89758. * Binds the image processing to the shader.
  89759. * @param effect The effect to bind to
  89760. * @param overrideAspectRatio Override the aspect ratio of the effect
  89761. */
  89762. bind(effect: Effect, overrideAspectRatio?: number): void;
  89763. /**
  89764. * Clones the current image processing instance.
  89765. * @return The cloned image processing
  89766. */
  89767. clone(): ImageProcessingConfiguration;
  89768. /**
  89769. * Serializes the current image processing instance to a json representation.
  89770. * @return a JSON representation
  89771. */
  89772. serialize(): any;
  89773. /**
  89774. * Parses the image processing from a json representation.
  89775. * @param source the JSON source to parse
  89776. * @return The parsed image processing
  89777. */
  89778. static Parse(source: any): ImageProcessingConfiguration;
  89779. private static _VIGNETTEMODE_MULTIPLY;
  89780. private static _VIGNETTEMODE_OPAQUE;
  89781. /**
  89782. * Used to apply the vignette as a mix with the pixel color.
  89783. */
  89784. static get VIGNETTEMODE_MULTIPLY(): number;
  89785. /**
  89786. * Used to apply the vignette as a replacement of the pixel color.
  89787. */
  89788. static get VIGNETTEMODE_OPAQUE(): number;
  89789. }
  89790. }
  89791. declare module BABYLON {
  89792. /** @hidden */
  89793. export var postprocessVertexShader: {
  89794. name: string;
  89795. shader: string;
  89796. };
  89797. }
  89798. declare module BABYLON {
  89799. /**
  89800. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89801. */
  89802. export type RenderTargetTextureSize = number | {
  89803. width: number;
  89804. height: number;
  89805. layers?: number;
  89806. };
  89807. interface ThinEngine {
  89808. /**
  89809. * Creates a new render target texture
  89810. * @param size defines the size of the texture
  89811. * @param options defines the options used to create the texture
  89812. * @returns a new render target texture stored in an InternalTexture
  89813. */
  89814. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89815. /**
  89816. * Creates a depth stencil texture.
  89817. * This is only available in WebGL 2 or with the depth texture extension available.
  89818. * @param size The size of face edge in the texture.
  89819. * @param options The options defining the texture.
  89820. * @returns The texture
  89821. */
  89822. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89823. /** @hidden */
  89824. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89825. }
  89826. }
  89827. declare module BABYLON {
  89828. /**
  89829. * Defines the kind of connection point for node based material
  89830. */
  89831. export enum NodeMaterialBlockConnectionPointTypes {
  89832. /** Float */
  89833. Float = 1,
  89834. /** Int */
  89835. Int = 2,
  89836. /** Vector2 */
  89837. Vector2 = 4,
  89838. /** Vector3 */
  89839. Vector3 = 8,
  89840. /** Vector4 */
  89841. Vector4 = 16,
  89842. /** Color3 */
  89843. Color3 = 32,
  89844. /** Color4 */
  89845. Color4 = 64,
  89846. /** Matrix */
  89847. Matrix = 128,
  89848. /** Custom object */
  89849. Object = 256,
  89850. /** Detect type based on connection */
  89851. AutoDetect = 1024,
  89852. /** Output type that will be defined by input type */
  89853. BasedOnInput = 2048
  89854. }
  89855. }
  89856. declare module BABYLON {
  89857. /**
  89858. * Enum used to define the target of a block
  89859. */
  89860. export enum NodeMaterialBlockTargets {
  89861. /** Vertex shader */
  89862. Vertex = 1,
  89863. /** Fragment shader */
  89864. Fragment = 2,
  89865. /** Neutral */
  89866. Neutral = 4,
  89867. /** Vertex and Fragment */
  89868. VertexAndFragment = 3
  89869. }
  89870. }
  89871. declare module BABYLON {
  89872. /**
  89873. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89874. */
  89875. export enum NodeMaterialBlockConnectionPointMode {
  89876. /** Value is an uniform */
  89877. Uniform = 0,
  89878. /** Value is a mesh attribute */
  89879. Attribute = 1,
  89880. /** Value is a varying between vertex and fragment shaders */
  89881. Varying = 2,
  89882. /** Mode is undefined */
  89883. Undefined = 3
  89884. }
  89885. }
  89886. declare module BABYLON {
  89887. /**
  89888. * Enum used to define system values e.g. values automatically provided by the system
  89889. */
  89890. export enum NodeMaterialSystemValues {
  89891. /** World */
  89892. World = 1,
  89893. /** View */
  89894. View = 2,
  89895. /** Projection */
  89896. Projection = 3,
  89897. /** ViewProjection */
  89898. ViewProjection = 4,
  89899. /** WorldView */
  89900. WorldView = 5,
  89901. /** WorldViewProjection */
  89902. WorldViewProjection = 6,
  89903. /** CameraPosition */
  89904. CameraPosition = 7,
  89905. /** Fog Color */
  89906. FogColor = 8,
  89907. /** Delta time */
  89908. DeltaTime = 9
  89909. }
  89910. }
  89911. declare module BABYLON {
  89912. /** Defines supported spaces */
  89913. export enum Space {
  89914. /** Local (object) space */
  89915. LOCAL = 0,
  89916. /** World space */
  89917. WORLD = 1,
  89918. /** Bone space */
  89919. BONE = 2
  89920. }
  89921. /** Defines the 3 main axes */
  89922. export class Axis {
  89923. /** X axis */
  89924. static X: Vector3;
  89925. /** Y axis */
  89926. static Y: Vector3;
  89927. /** Z axis */
  89928. static Z: Vector3;
  89929. }
  89930. /**
  89931. * Defines cartesian components.
  89932. */
  89933. export enum Coordinate {
  89934. /** X axis */
  89935. X = 0,
  89936. /** Y axis */
  89937. Y = 1,
  89938. /** Z axis */
  89939. Z = 2
  89940. }
  89941. }
  89942. declare module BABYLON {
  89943. /**
  89944. * Represents a camera frustum
  89945. */
  89946. export class Frustum {
  89947. /**
  89948. * Gets the planes representing the frustum
  89949. * @param transform matrix to be applied to the returned planes
  89950. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89951. */
  89952. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89953. /**
  89954. * Gets the near frustum plane transformed by the transform matrix
  89955. * @param transform transformation matrix to be applied to the resulting frustum plane
  89956. * @param frustumPlane the resuling frustum plane
  89957. */
  89958. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89959. /**
  89960. * Gets the far frustum plane transformed by the transform matrix
  89961. * @param transform transformation matrix to be applied to the resulting frustum plane
  89962. * @param frustumPlane the resuling frustum plane
  89963. */
  89964. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89965. /**
  89966. * Gets the left frustum plane transformed by the transform matrix
  89967. * @param transform transformation matrix to be applied to the resulting frustum plane
  89968. * @param frustumPlane the resuling frustum plane
  89969. */
  89970. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89971. /**
  89972. * Gets the right frustum plane transformed by the transform matrix
  89973. * @param transform transformation matrix to be applied to the resulting frustum plane
  89974. * @param frustumPlane the resuling frustum plane
  89975. */
  89976. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89977. /**
  89978. * Gets the top frustum plane transformed by the transform matrix
  89979. * @param transform transformation matrix to be applied to the resulting frustum plane
  89980. * @param frustumPlane the resuling frustum plane
  89981. */
  89982. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89983. /**
  89984. * Gets the bottom frustum plane transformed by the transform matrix
  89985. * @param transform transformation matrix to be applied to the resulting frustum plane
  89986. * @param frustumPlane the resuling frustum plane
  89987. */
  89988. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89989. /**
  89990. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89991. * @param transform transformation matrix to be applied to the resulting frustum planes
  89992. * @param frustumPlanes the resuling frustum planes
  89993. */
  89994. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89995. }
  89996. }
  89997. declare module BABYLON {
  89998. /**
  89999. * Interface for the size containing width and height
  90000. */
  90001. export interface ISize {
  90002. /**
  90003. * Width
  90004. */
  90005. width: number;
  90006. /**
  90007. * Heighht
  90008. */
  90009. height: number;
  90010. }
  90011. /**
  90012. * Size containing widht and height
  90013. */
  90014. export class Size implements ISize {
  90015. /**
  90016. * Width
  90017. */
  90018. width: number;
  90019. /**
  90020. * Height
  90021. */
  90022. height: number;
  90023. /**
  90024. * Creates a Size object from the given width and height (floats).
  90025. * @param width width of the new size
  90026. * @param height height of the new size
  90027. */
  90028. constructor(width: number, height: number);
  90029. /**
  90030. * Returns a string with the Size width and height
  90031. * @returns a string with the Size width and height
  90032. */
  90033. toString(): string;
  90034. /**
  90035. * "Size"
  90036. * @returns the string "Size"
  90037. */
  90038. getClassName(): string;
  90039. /**
  90040. * Returns the Size hash code.
  90041. * @returns a hash code for a unique width and height
  90042. */
  90043. getHashCode(): number;
  90044. /**
  90045. * Updates the current size from the given one.
  90046. * @param src the given size
  90047. */
  90048. copyFrom(src: Size): void;
  90049. /**
  90050. * Updates in place the current Size from the given floats.
  90051. * @param width width of the new size
  90052. * @param height height of the new size
  90053. * @returns the updated Size.
  90054. */
  90055. copyFromFloats(width: number, height: number): Size;
  90056. /**
  90057. * Updates in place the current Size from the given floats.
  90058. * @param width width to set
  90059. * @param height height to set
  90060. * @returns the updated Size.
  90061. */
  90062. set(width: number, height: number): Size;
  90063. /**
  90064. * Multiplies the width and height by numbers
  90065. * @param w factor to multiple the width by
  90066. * @param h factor to multiple the height by
  90067. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  90068. */
  90069. multiplyByFloats(w: number, h: number): Size;
  90070. /**
  90071. * Clones the size
  90072. * @returns a new Size copied from the given one.
  90073. */
  90074. clone(): Size;
  90075. /**
  90076. * True if the current Size and the given one width and height are strictly equal.
  90077. * @param other the other size to compare against
  90078. * @returns True if the current Size and the given one width and height are strictly equal.
  90079. */
  90080. equals(other: Size): boolean;
  90081. /**
  90082. * The surface of the Size : width * height (float).
  90083. */
  90084. get surface(): number;
  90085. /**
  90086. * Create a new size of zero
  90087. * @returns a new Size set to (0.0, 0.0)
  90088. */
  90089. static Zero(): Size;
  90090. /**
  90091. * Sums the width and height of two sizes
  90092. * @param otherSize size to add to this size
  90093. * @returns a new Size set as the addition result of the current Size and the given one.
  90094. */
  90095. add(otherSize: Size): Size;
  90096. /**
  90097. * Subtracts the width and height of two
  90098. * @param otherSize size to subtract to this size
  90099. * @returns a new Size set as the subtraction result of the given one from the current Size.
  90100. */
  90101. subtract(otherSize: Size): Size;
  90102. /**
  90103. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  90104. * @param start starting size to lerp between
  90105. * @param end end size to lerp between
  90106. * @param amount amount to lerp between the start and end values
  90107. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  90108. */
  90109. static Lerp(start: Size, end: Size, amount: number): Size;
  90110. }
  90111. }
  90112. declare module BABYLON {
  90113. /**
  90114. * Contains position and normal vectors for a vertex
  90115. */
  90116. export class PositionNormalVertex {
  90117. /** the position of the vertex (defaut: 0,0,0) */
  90118. position: Vector3;
  90119. /** the normal of the vertex (defaut: 0,1,0) */
  90120. normal: Vector3;
  90121. /**
  90122. * Creates a PositionNormalVertex
  90123. * @param position the position of the vertex (defaut: 0,0,0)
  90124. * @param normal the normal of the vertex (defaut: 0,1,0)
  90125. */
  90126. constructor(
  90127. /** the position of the vertex (defaut: 0,0,0) */
  90128. position?: Vector3,
  90129. /** the normal of the vertex (defaut: 0,1,0) */
  90130. normal?: Vector3);
  90131. /**
  90132. * Clones the PositionNormalVertex
  90133. * @returns the cloned PositionNormalVertex
  90134. */
  90135. clone(): PositionNormalVertex;
  90136. }
  90137. /**
  90138. * Contains position, normal and uv vectors for a vertex
  90139. */
  90140. export class PositionNormalTextureVertex {
  90141. /** the position of the vertex (defaut: 0,0,0) */
  90142. position: Vector3;
  90143. /** the normal of the vertex (defaut: 0,1,0) */
  90144. normal: Vector3;
  90145. /** the uv of the vertex (default: 0,0) */
  90146. uv: Vector2;
  90147. /**
  90148. * Creates a PositionNormalTextureVertex
  90149. * @param position the position of the vertex (defaut: 0,0,0)
  90150. * @param normal the normal of the vertex (defaut: 0,1,0)
  90151. * @param uv the uv of the vertex (default: 0,0)
  90152. */
  90153. constructor(
  90154. /** the position of the vertex (defaut: 0,0,0) */
  90155. position?: Vector3,
  90156. /** the normal of the vertex (defaut: 0,1,0) */
  90157. normal?: Vector3,
  90158. /** the uv of the vertex (default: 0,0) */
  90159. uv?: Vector2);
  90160. /**
  90161. * Clones the PositionNormalTextureVertex
  90162. * @returns the cloned PositionNormalTextureVertex
  90163. */
  90164. clone(): PositionNormalTextureVertex;
  90165. }
  90166. }
  90167. declare module BABYLON {
  90168. /**
  90169. * Enum defining the type of animations supported by InputBlock
  90170. */
  90171. export enum AnimatedInputBlockTypes {
  90172. /** No animation */
  90173. None = 0,
  90174. /** Time based animation. Will only work for floats */
  90175. Time = 1
  90176. }
  90177. }
  90178. declare module BABYLON {
  90179. /**
  90180. * Interface describing all the common properties and methods a shadow light needs to implement.
  90181. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  90182. * as well as binding the different shadow properties to the effects.
  90183. */
  90184. export interface IShadowLight extends Light {
  90185. /**
  90186. * The light id in the scene (used in scene.findLighById for instance)
  90187. */
  90188. id: string;
  90189. /**
  90190. * The position the shdow will be casted from.
  90191. */
  90192. position: Vector3;
  90193. /**
  90194. * In 2d mode (needCube being false), the direction used to cast the shadow.
  90195. */
  90196. direction: Vector3;
  90197. /**
  90198. * The transformed position. Position of the light in world space taking parenting in account.
  90199. */
  90200. transformedPosition: Vector3;
  90201. /**
  90202. * The transformed direction. Direction of the light in world space taking parenting in account.
  90203. */
  90204. transformedDirection: Vector3;
  90205. /**
  90206. * The friendly name of the light in the scene.
  90207. */
  90208. name: string;
  90209. /**
  90210. * Defines the shadow projection clipping minimum z value.
  90211. */
  90212. shadowMinZ: number;
  90213. /**
  90214. * Defines the shadow projection clipping maximum z value.
  90215. */
  90216. shadowMaxZ: number;
  90217. /**
  90218. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90219. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90220. */
  90221. computeTransformedInformation(): boolean;
  90222. /**
  90223. * Gets the scene the light belongs to.
  90224. * @returns The scene
  90225. */
  90226. getScene(): Scene;
  90227. /**
  90228. * Callback defining a custom Projection Matrix Builder.
  90229. * This can be used to override the default projection matrix computation.
  90230. */
  90231. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90232. /**
  90233. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90234. * @param matrix The materix to updated with the projection information
  90235. * @param viewMatrix The transform matrix of the light
  90236. * @param renderList The list of mesh to render in the map
  90237. * @returns The current light
  90238. */
  90239. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90240. /**
  90241. * Gets the current depth scale used in ESM.
  90242. * @returns The scale
  90243. */
  90244. getDepthScale(): number;
  90245. /**
  90246. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90247. * @returns true if a cube texture needs to be use
  90248. */
  90249. needCube(): boolean;
  90250. /**
  90251. * Detects if the projection matrix requires to be recomputed this frame.
  90252. * @returns true if it requires to be recomputed otherwise, false.
  90253. */
  90254. needProjectionMatrixCompute(): boolean;
  90255. /**
  90256. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90257. */
  90258. forceProjectionMatrixCompute(): void;
  90259. /**
  90260. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90261. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90262. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90263. */
  90264. getShadowDirection(faceIndex?: number): Vector3;
  90265. /**
  90266. * Gets the minZ used for shadow according to both the scene and the light.
  90267. * @param activeCamera The camera we are returning the min for
  90268. * @returns the depth min z
  90269. */
  90270. getDepthMinZ(activeCamera: Camera): number;
  90271. /**
  90272. * Gets the maxZ used for shadow according to both the scene and the light.
  90273. * @param activeCamera The camera we are returning the max for
  90274. * @returns the depth max z
  90275. */
  90276. getDepthMaxZ(activeCamera: Camera): number;
  90277. }
  90278. /**
  90279. * Base implementation IShadowLight
  90280. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  90281. */
  90282. export abstract class ShadowLight extends Light implements IShadowLight {
  90283. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  90284. protected _position: Vector3;
  90285. protected _setPosition(value: Vector3): void;
  90286. /**
  90287. * Sets the position the shadow will be casted from. Also use as the light position for both
  90288. * point and spot lights.
  90289. */
  90290. get position(): Vector3;
  90291. /**
  90292. * Sets the position the shadow will be casted from. Also use as the light position for both
  90293. * point and spot lights.
  90294. */
  90295. set position(value: Vector3);
  90296. protected _direction: Vector3;
  90297. protected _setDirection(value: Vector3): void;
  90298. /**
  90299. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  90300. * Also use as the light direction on spot and directional lights.
  90301. */
  90302. get direction(): Vector3;
  90303. /**
  90304. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  90305. * Also use as the light direction on spot and directional lights.
  90306. */
  90307. set direction(value: Vector3);
  90308. protected _shadowMinZ: number;
  90309. /**
  90310. * Gets the shadow projection clipping minimum z value.
  90311. */
  90312. get shadowMinZ(): number;
  90313. /**
  90314. * Sets the shadow projection clipping minimum z value.
  90315. */
  90316. set shadowMinZ(value: number);
  90317. protected _shadowMaxZ: number;
  90318. /**
  90319. * Sets the shadow projection clipping maximum z value.
  90320. */
  90321. get shadowMaxZ(): number;
  90322. /**
  90323. * Gets the shadow projection clipping maximum z value.
  90324. */
  90325. set shadowMaxZ(value: number);
  90326. /**
  90327. * Callback defining a custom Projection Matrix Builder.
  90328. * This can be used to override the default projection matrix computation.
  90329. */
  90330. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  90331. /**
  90332. * The transformed position. Position of the light in world space taking parenting in account.
  90333. */
  90334. transformedPosition: Vector3;
  90335. /**
  90336. * The transformed direction. Direction of the light in world space taking parenting in account.
  90337. */
  90338. transformedDirection: Vector3;
  90339. private _needProjectionMatrixCompute;
  90340. /**
  90341. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  90342. * @returns true if the information has been computed, false if it does not need to (no parenting)
  90343. */
  90344. computeTransformedInformation(): boolean;
  90345. /**
  90346. * Return the depth scale used for the shadow map.
  90347. * @returns the depth scale.
  90348. */
  90349. getDepthScale(): number;
  90350. /**
  90351. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  90352. * @param faceIndex The index of the face we are computed the direction to generate shadow
  90353. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  90354. */
  90355. getShadowDirection(faceIndex?: number): Vector3;
  90356. /**
  90357. * Returns the ShadowLight absolute position in the World.
  90358. * @returns the position vector in world space
  90359. */
  90360. getAbsolutePosition(): Vector3;
  90361. /**
  90362. * Sets the ShadowLight direction toward the passed target.
  90363. * @param target The point to target in local space
  90364. * @returns the updated ShadowLight direction
  90365. */
  90366. setDirectionToTarget(target: Vector3): Vector3;
  90367. /**
  90368. * Returns the light rotation in euler definition.
  90369. * @returns the x y z rotation in local space.
  90370. */
  90371. getRotation(): Vector3;
  90372. /**
  90373. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  90374. * @returns true if a cube texture needs to be use
  90375. */
  90376. needCube(): boolean;
  90377. /**
  90378. * Detects if the projection matrix requires to be recomputed this frame.
  90379. * @returns true if it requires to be recomputed otherwise, false.
  90380. */
  90381. needProjectionMatrixCompute(): boolean;
  90382. /**
  90383. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  90384. */
  90385. forceProjectionMatrixCompute(): void;
  90386. /** @hidden */
  90387. _initCache(): void;
  90388. /** @hidden */
  90389. _isSynchronized(): boolean;
  90390. /**
  90391. * Computes the world matrix of the node
  90392. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  90393. * @returns the world matrix
  90394. */
  90395. computeWorldMatrix(force?: boolean): Matrix;
  90396. /**
  90397. * Gets the minZ used for shadow according to both the scene and the light.
  90398. * @param activeCamera The camera we are returning the min for
  90399. * @returns the depth min z
  90400. */
  90401. getDepthMinZ(activeCamera: Camera): number;
  90402. /**
  90403. * Gets the maxZ used for shadow according to both the scene and the light.
  90404. * @param activeCamera The camera we are returning the max for
  90405. * @returns the depth max z
  90406. */
  90407. getDepthMaxZ(activeCamera: Camera): number;
  90408. /**
  90409. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  90410. * @param matrix The materix to updated with the projection information
  90411. * @param viewMatrix The transform matrix of the light
  90412. * @param renderList The list of mesh to render in the map
  90413. * @returns The current light
  90414. */
  90415. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  90416. }
  90417. }
  90418. declare module BABYLON {
  90419. /** @hidden */
  90420. export var packingFunctions: {
  90421. name: string;
  90422. shader: string;
  90423. };
  90424. }
  90425. declare module BABYLON {
  90426. /** @hidden */
  90427. export var bayerDitherFunctions: {
  90428. name: string;
  90429. shader: string;
  90430. };
  90431. }
  90432. declare module BABYLON {
  90433. /** @hidden */
  90434. export var shadowMapFragmentDeclaration: {
  90435. name: string;
  90436. shader: string;
  90437. };
  90438. }
  90439. declare module BABYLON {
  90440. /** @hidden */
  90441. export var clipPlaneFragmentDeclaration: {
  90442. name: string;
  90443. shader: string;
  90444. };
  90445. }
  90446. declare module BABYLON {
  90447. /** @hidden */
  90448. export var clipPlaneFragment: {
  90449. name: string;
  90450. shader: string;
  90451. };
  90452. }
  90453. declare module BABYLON {
  90454. /** @hidden */
  90455. export var shadowMapFragment: {
  90456. name: string;
  90457. shader: string;
  90458. };
  90459. }
  90460. declare module BABYLON {
  90461. /** @hidden */
  90462. export var shadowMapPixelShader: {
  90463. name: string;
  90464. shader: string;
  90465. };
  90466. }
  90467. declare module BABYLON {
  90468. /** @hidden */
  90469. export var bonesDeclaration: {
  90470. name: string;
  90471. shader: string;
  90472. };
  90473. }
  90474. declare module BABYLON {
  90475. /** @hidden */
  90476. export var morphTargetsVertexGlobalDeclaration: {
  90477. name: string;
  90478. shader: string;
  90479. };
  90480. }
  90481. declare module BABYLON {
  90482. /** @hidden */
  90483. export var morphTargetsVertexDeclaration: {
  90484. name: string;
  90485. shader: string;
  90486. };
  90487. }
  90488. declare module BABYLON {
  90489. /** @hidden */
  90490. export var instancesDeclaration: {
  90491. name: string;
  90492. shader: string;
  90493. };
  90494. }
  90495. declare module BABYLON {
  90496. /** @hidden */
  90497. export var helperFunctions: {
  90498. name: string;
  90499. shader: string;
  90500. };
  90501. }
  90502. declare module BABYLON {
  90503. /** @hidden */
  90504. export var shadowMapVertexDeclaration: {
  90505. name: string;
  90506. shader: string;
  90507. };
  90508. }
  90509. declare module BABYLON {
  90510. /** @hidden */
  90511. export var clipPlaneVertexDeclaration: {
  90512. name: string;
  90513. shader: string;
  90514. };
  90515. }
  90516. declare module BABYLON {
  90517. /** @hidden */
  90518. export var morphTargetsVertex: {
  90519. name: string;
  90520. shader: string;
  90521. };
  90522. }
  90523. declare module BABYLON {
  90524. /** @hidden */
  90525. export var instancesVertex: {
  90526. name: string;
  90527. shader: string;
  90528. };
  90529. }
  90530. declare module BABYLON {
  90531. /** @hidden */
  90532. export var bonesVertex: {
  90533. name: string;
  90534. shader: string;
  90535. };
  90536. }
  90537. declare module BABYLON {
  90538. /** @hidden */
  90539. export var shadowMapVertexNormalBias: {
  90540. name: string;
  90541. shader: string;
  90542. };
  90543. }
  90544. declare module BABYLON {
  90545. /** @hidden */
  90546. export var shadowMapVertexMetric: {
  90547. name: string;
  90548. shader: string;
  90549. };
  90550. }
  90551. declare module BABYLON {
  90552. /** @hidden */
  90553. export var clipPlaneVertex: {
  90554. name: string;
  90555. shader: string;
  90556. };
  90557. }
  90558. declare module BABYLON {
  90559. /** @hidden */
  90560. export var shadowMapVertexShader: {
  90561. name: string;
  90562. shader: string;
  90563. };
  90564. }
  90565. declare module BABYLON {
  90566. /** @hidden */
  90567. export var depthBoxBlurPixelShader: {
  90568. name: string;
  90569. shader: string;
  90570. };
  90571. }
  90572. declare module BABYLON {
  90573. /** @hidden */
  90574. export var shadowMapFragmentSoftTransparentShadow: {
  90575. name: string;
  90576. shader: string;
  90577. };
  90578. }
  90579. declare module BABYLON {
  90580. /**
  90581. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  90582. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  90583. */
  90584. export class EffectFallbacks implements IEffectFallbacks {
  90585. private _defines;
  90586. private _currentRank;
  90587. private _maxRank;
  90588. private _mesh;
  90589. /**
  90590. * Removes the fallback from the bound mesh.
  90591. */
  90592. unBindMesh(): void;
  90593. /**
  90594. * Adds a fallback on the specified property.
  90595. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90596. * @param define The name of the define in the shader
  90597. */
  90598. addFallback(rank: number, define: string): void;
  90599. /**
  90600. * Sets the mesh to use CPU skinning when needing to fallback.
  90601. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  90602. * @param mesh The mesh to use the fallbacks.
  90603. */
  90604. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  90605. /**
  90606. * Checks to see if more fallbacks are still availible.
  90607. */
  90608. get hasMoreFallbacks(): boolean;
  90609. /**
  90610. * Removes the defines that should be removed when falling back.
  90611. * @param currentDefines defines the current define statements for the shader.
  90612. * @param effect defines the current effect we try to compile
  90613. * @returns The resulting defines with defines of the current rank removed.
  90614. */
  90615. reduce(currentDefines: string, effect: Effect): string;
  90616. }
  90617. }
  90618. declare module BABYLON {
  90619. /**
  90620. * Interface used to define Action
  90621. */
  90622. export interface IAction {
  90623. /**
  90624. * Trigger for the action
  90625. */
  90626. trigger: number;
  90627. /** Options of the trigger */
  90628. triggerOptions: any;
  90629. /**
  90630. * Gets the trigger parameters
  90631. * @returns the trigger parameters
  90632. */
  90633. getTriggerParameter(): any;
  90634. /**
  90635. * Internal only - executes current action event
  90636. * @hidden
  90637. */
  90638. _executeCurrent(evt?: ActionEvent): void;
  90639. /**
  90640. * Serialize placeholder for child classes
  90641. * @param parent of child
  90642. * @returns the serialized object
  90643. */
  90644. serialize(parent: any): any;
  90645. /**
  90646. * Internal only
  90647. * @hidden
  90648. */
  90649. _prepare(): void;
  90650. /**
  90651. * Internal only - manager for action
  90652. * @hidden
  90653. */
  90654. _actionManager: Nullable<AbstractActionManager>;
  90655. /**
  90656. * Adds action to chain of actions, may be a DoNothingAction
  90657. * @param action defines the next action to execute
  90658. * @returns The action passed in
  90659. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90660. */
  90661. then(action: IAction): IAction;
  90662. }
  90663. /**
  90664. * The action to be carried out following a trigger
  90665. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90666. */
  90667. export class Action implements IAction {
  90668. /** the trigger, with or without parameters, for the action */
  90669. triggerOptions: any;
  90670. /**
  90671. * Trigger for the action
  90672. */
  90673. trigger: number;
  90674. /**
  90675. * Internal only - manager for action
  90676. * @hidden
  90677. */
  90678. _actionManager: ActionManager;
  90679. private _nextActiveAction;
  90680. private _child;
  90681. private _condition?;
  90682. private _triggerParameter;
  90683. /**
  90684. * An event triggered prior to action being executed.
  90685. */
  90686. onBeforeExecuteObservable: Observable<Action>;
  90687. /**
  90688. * Creates a new Action
  90689. * @param triggerOptions the trigger, with or without parameters, for the action
  90690. * @param condition an optional determinant of action
  90691. */
  90692. constructor(
  90693. /** the trigger, with or without parameters, for the action */
  90694. triggerOptions: any, condition?: Condition);
  90695. /**
  90696. * Internal only
  90697. * @hidden
  90698. */
  90699. _prepare(): void;
  90700. /**
  90701. * Gets the trigger parameters
  90702. * @returns the trigger parameters
  90703. */
  90704. getTriggerParameter(): any;
  90705. /**
  90706. * Internal only - executes current action event
  90707. * @hidden
  90708. */
  90709. _executeCurrent(evt?: ActionEvent): void;
  90710. /**
  90711. * Execute placeholder for child classes
  90712. * @param evt optional action event
  90713. */
  90714. execute(evt?: ActionEvent): void;
  90715. /**
  90716. * Skips to next active action
  90717. */
  90718. skipToNextActiveAction(): void;
  90719. /**
  90720. * Adds action to chain of actions, may be a DoNothingAction
  90721. * @param action defines the next action to execute
  90722. * @returns The action passed in
  90723. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90724. */
  90725. then(action: Action): Action;
  90726. /**
  90727. * Internal only
  90728. * @hidden
  90729. */
  90730. _getProperty(propertyPath: string): string;
  90731. /**
  90732. * Internal only
  90733. * @hidden
  90734. */
  90735. _getEffectiveTarget(target: any, propertyPath: string): any;
  90736. /**
  90737. * Serialize placeholder for child classes
  90738. * @param parent of child
  90739. * @returns the serialized object
  90740. */
  90741. serialize(parent: any): any;
  90742. /**
  90743. * Internal only called by serialize
  90744. * @hidden
  90745. */
  90746. protected _serialize(serializedAction: any, parent?: any): any;
  90747. /**
  90748. * Internal only
  90749. * @hidden
  90750. */
  90751. static _SerializeValueAsString: (value: any) => string;
  90752. /**
  90753. * Internal only
  90754. * @hidden
  90755. */
  90756. static _GetTargetProperty: (target: Scene | Node) => {
  90757. name: string;
  90758. targetType: string;
  90759. value: string;
  90760. };
  90761. }
  90762. }
  90763. declare module BABYLON {
  90764. /**
  90765. * A Condition applied to an Action
  90766. */
  90767. export class Condition {
  90768. /**
  90769. * Internal only - manager for action
  90770. * @hidden
  90771. */
  90772. _actionManager: ActionManager;
  90773. /**
  90774. * Internal only
  90775. * @hidden
  90776. */
  90777. _evaluationId: number;
  90778. /**
  90779. * Internal only
  90780. * @hidden
  90781. */
  90782. _currentResult: boolean;
  90783. /**
  90784. * Creates a new Condition
  90785. * @param actionManager the manager of the action the condition is applied to
  90786. */
  90787. constructor(actionManager: ActionManager);
  90788. /**
  90789. * Check if the current condition is valid
  90790. * @returns a boolean
  90791. */
  90792. isValid(): boolean;
  90793. /**
  90794. * Internal only
  90795. * @hidden
  90796. */
  90797. _getProperty(propertyPath: string): string;
  90798. /**
  90799. * Internal only
  90800. * @hidden
  90801. */
  90802. _getEffectiveTarget(target: any, propertyPath: string): any;
  90803. /**
  90804. * Serialize placeholder for child classes
  90805. * @returns the serialized object
  90806. */
  90807. serialize(): any;
  90808. /**
  90809. * Internal only
  90810. * @hidden
  90811. */
  90812. protected _serialize(serializedCondition: any): any;
  90813. }
  90814. /**
  90815. * Defines specific conditional operators as extensions of Condition
  90816. */
  90817. export class ValueCondition extends Condition {
  90818. /** path to specify the property of the target the conditional operator uses */
  90819. propertyPath: string;
  90820. /** the value compared by the conditional operator against the current value of the property */
  90821. value: any;
  90822. /** the conditional operator, default ValueCondition.IsEqual */
  90823. operator: number;
  90824. /**
  90825. * Internal only
  90826. * @hidden
  90827. */
  90828. private static _IsEqual;
  90829. /**
  90830. * Internal only
  90831. * @hidden
  90832. */
  90833. private static _IsDifferent;
  90834. /**
  90835. * Internal only
  90836. * @hidden
  90837. */
  90838. private static _IsGreater;
  90839. /**
  90840. * Internal only
  90841. * @hidden
  90842. */
  90843. private static _IsLesser;
  90844. /**
  90845. * returns the number for IsEqual
  90846. */
  90847. static get IsEqual(): number;
  90848. /**
  90849. * Returns the number for IsDifferent
  90850. */
  90851. static get IsDifferent(): number;
  90852. /**
  90853. * Returns the number for IsGreater
  90854. */
  90855. static get IsGreater(): number;
  90856. /**
  90857. * Returns the number for IsLesser
  90858. */
  90859. static get IsLesser(): number;
  90860. /**
  90861. * Internal only The action manager for the condition
  90862. * @hidden
  90863. */
  90864. _actionManager: ActionManager;
  90865. /**
  90866. * Internal only
  90867. * @hidden
  90868. */
  90869. private _target;
  90870. /**
  90871. * Internal only
  90872. * @hidden
  90873. */
  90874. private _effectiveTarget;
  90875. /**
  90876. * Internal only
  90877. * @hidden
  90878. */
  90879. private _property;
  90880. /**
  90881. * Creates a new ValueCondition
  90882. * @param actionManager manager for the action the condition applies to
  90883. * @param target for the action
  90884. * @param propertyPath path to specify the property of the target the conditional operator uses
  90885. * @param value the value compared by the conditional operator against the current value of the property
  90886. * @param operator the conditional operator, default ValueCondition.IsEqual
  90887. */
  90888. constructor(actionManager: ActionManager, target: any,
  90889. /** path to specify the property of the target the conditional operator uses */
  90890. propertyPath: string,
  90891. /** the value compared by the conditional operator against the current value of the property */
  90892. value: any,
  90893. /** the conditional operator, default ValueCondition.IsEqual */
  90894. operator?: number);
  90895. /**
  90896. * Compares the given value with the property value for the specified conditional operator
  90897. * @returns the result of the comparison
  90898. */
  90899. isValid(): boolean;
  90900. /**
  90901. * Serialize the ValueCondition into a JSON compatible object
  90902. * @returns serialization object
  90903. */
  90904. serialize(): any;
  90905. /**
  90906. * Gets the name of the conditional operator for the ValueCondition
  90907. * @param operator the conditional operator
  90908. * @returns the name
  90909. */
  90910. static GetOperatorName(operator: number): string;
  90911. }
  90912. /**
  90913. * Defines a predicate condition as an extension of Condition
  90914. */
  90915. export class PredicateCondition extends Condition {
  90916. /** defines the predicate function used to validate the condition */
  90917. predicate: () => boolean;
  90918. /**
  90919. * Internal only - manager for action
  90920. * @hidden
  90921. */
  90922. _actionManager: ActionManager;
  90923. /**
  90924. * Creates a new PredicateCondition
  90925. * @param actionManager manager for the action the condition applies to
  90926. * @param predicate defines the predicate function used to validate the condition
  90927. */
  90928. constructor(actionManager: ActionManager,
  90929. /** defines the predicate function used to validate the condition */
  90930. predicate: () => boolean);
  90931. /**
  90932. * @returns the validity of the predicate condition
  90933. */
  90934. isValid(): boolean;
  90935. }
  90936. /**
  90937. * Defines a state condition as an extension of Condition
  90938. */
  90939. export class StateCondition extends Condition {
  90940. /** Value to compare with target state */
  90941. value: string;
  90942. /**
  90943. * Internal only - manager for action
  90944. * @hidden
  90945. */
  90946. _actionManager: ActionManager;
  90947. /**
  90948. * Internal only
  90949. * @hidden
  90950. */
  90951. private _target;
  90952. /**
  90953. * Creates a new StateCondition
  90954. * @param actionManager manager for the action the condition applies to
  90955. * @param target of the condition
  90956. * @param value to compare with target state
  90957. */
  90958. constructor(actionManager: ActionManager, target: any,
  90959. /** Value to compare with target state */
  90960. value: string);
  90961. /**
  90962. * Gets a boolean indicating if the current condition is met
  90963. * @returns the validity of the state
  90964. */
  90965. isValid(): boolean;
  90966. /**
  90967. * Serialize the StateCondition into a JSON compatible object
  90968. * @returns serialization object
  90969. */
  90970. serialize(): any;
  90971. }
  90972. }
  90973. declare module BABYLON {
  90974. /**
  90975. * This defines an action responsible to toggle a boolean once triggered.
  90976. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90977. */
  90978. export class SwitchBooleanAction extends Action {
  90979. /**
  90980. * The path to the boolean property in the target object
  90981. */
  90982. propertyPath: string;
  90983. private _target;
  90984. private _effectiveTarget;
  90985. private _property;
  90986. /**
  90987. * Instantiate the action
  90988. * @param triggerOptions defines the trigger options
  90989. * @param target defines the object containing the boolean
  90990. * @param propertyPath defines the path to the boolean property in the target object
  90991. * @param condition defines the trigger related conditions
  90992. */
  90993. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90994. /** @hidden */
  90995. _prepare(): void;
  90996. /**
  90997. * Execute the action toggle the boolean value.
  90998. */
  90999. execute(): void;
  91000. /**
  91001. * Serializes the actions and its related information.
  91002. * @param parent defines the object to serialize in
  91003. * @returns the serialized object
  91004. */
  91005. serialize(parent: any): any;
  91006. }
  91007. /**
  91008. * This defines an action responsible to set a the state field of the target
  91009. * to a desired value once triggered.
  91010. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91011. */
  91012. export class SetStateAction extends Action {
  91013. /**
  91014. * The value to store in the state field.
  91015. */
  91016. value: string;
  91017. private _target;
  91018. /**
  91019. * Instantiate the action
  91020. * @param triggerOptions defines the trigger options
  91021. * @param target defines the object containing the state property
  91022. * @param value defines the value to store in the state field
  91023. * @param condition defines the trigger related conditions
  91024. */
  91025. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91026. /**
  91027. * Execute the action and store the value on the target state property.
  91028. */
  91029. execute(): void;
  91030. /**
  91031. * Serializes the actions and its related information.
  91032. * @param parent defines the object to serialize in
  91033. * @returns the serialized object
  91034. */
  91035. serialize(parent: any): any;
  91036. }
  91037. /**
  91038. * This defines an action responsible to set a property of the target
  91039. * to a desired value once triggered.
  91040. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91041. */
  91042. export class SetValueAction extends Action {
  91043. /**
  91044. * The path of the property to set in the target.
  91045. */
  91046. propertyPath: string;
  91047. /**
  91048. * The value to set in the property
  91049. */
  91050. value: any;
  91051. private _target;
  91052. private _effectiveTarget;
  91053. private _property;
  91054. /**
  91055. * Instantiate the action
  91056. * @param triggerOptions defines the trigger options
  91057. * @param target defines the object containing the property
  91058. * @param propertyPath defines the path of the property to set in the target
  91059. * @param value defines the value to set in the property
  91060. * @param condition defines the trigger related conditions
  91061. */
  91062. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91063. /** @hidden */
  91064. _prepare(): void;
  91065. /**
  91066. * Execute the action and set the targetted property to the desired value.
  91067. */
  91068. execute(): void;
  91069. /**
  91070. * Serializes the actions and its related information.
  91071. * @param parent defines the object to serialize in
  91072. * @returns the serialized object
  91073. */
  91074. serialize(parent: any): any;
  91075. }
  91076. /**
  91077. * This defines an action responsible to increment the target value
  91078. * to a desired value once triggered.
  91079. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91080. */
  91081. export class IncrementValueAction extends Action {
  91082. /**
  91083. * The path of the property to increment in the target.
  91084. */
  91085. propertyPath: string;
  91086. /**
  91087. * The value we should increment the property by.
  91088. */
  91089. value: any;
  91090. private _target;
  91091. private _effectiveTarget;
  91092. private _property;
  91093. /**
  91094. * Instantiate the action
  91095. * @param triggerOptions defines the trigger options
  91096. * @param target defines the object containing the property
  91097. * @param propertyPath defines the path of the property to increment in the target
  91098. * @param value defines the value value we should increment the property by
  91099. * @param condition defines the trigger related conditions
  91100. */
  91101. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91102. /** @hidden */
  91103. _prepare(): void;
  91104. /**
  91105. * Execute the action and increment the target of the value amount.
  91106. */
  91107. execute(): void;
  91108. /**
  91109. * Serializes the actions and its related information.
  91110. * @param parent defines the object to serialize in
  91111. * @returns the serialized object
  91112. */
  91113. serialize(parent: any): any;
  91114. }
  91115. /**
  91116. * This defines an action responsible to start an animation once triggered.
  91117. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91118. */
  91119. export class PlayAnimationAction extends Action {
  91120. /**
  91121. * Where the animation should start (animation frame)
  91122. */
  91123. from: number;
  91124. /**
  91125. * Where the animation should stop (animation frame)
  91126. */
  91127. to: number;
  91128. /**
  91129. * Define if the animation should loop or stop after the first play.
  91130. */
  91131. loop?: boolean;
  91132. private _target;
  91133. /**
  91134. * Instantiate the action
  91135. * @param triggerOptions defines the trigger options
  91136. * @param target defines the target animation or animation name
  91137. * @param from defines from where the animation should start (animation frame)
  91138. * @param end defines where the animation should stop (animation frame)
  91139. * @param loop defines if the animation should loop or stop after the first play
  91140. * @param condition defines the trigger related conditions
  91141. */
  91142. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  91143. /** @hidden */
  91144. _prepare(): void;
  91145. /**
  91146. * Execute the action and play the animation.
  91147. */
  91148. execute(): void;
  91149. /**
  91150. * Serializes the actions and its related information.
  91151. * @param parent defines the object to serialize in
  91152. * @returns the serialized object
  91153. */
  91154. serialize(parent: any): any;
  91155. }
  91156. /**
  91157. * This defines an action responsible to stop an animation once triggered.
  91158. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91159. */
  91160. export class StopAnimationAction extends Action {
  91161. private _target;
  91162. /**
  91163. * Instantiate the action
  91164. * @param triggerOptions defines the trigger options
  91165. * @param target defines the target animation or animation name
  91166. * @param condition defines the trigger related conditions
  91167. */
  91168. constructor(triggerOptions: any, target: any, condition?: Condition);
  91169. /** @hidden */
  91170. _prepare(): void;
  91171. /**
  91172. * Execute the action and stop the animation.
  91173. */
  91174. execute(): void;
  91175. /**
  91176. * Serializes the actions and its related information.
  91177. * @param parent defines the object to serialize in
  91178. * @returns the serialized object
  91179. */
  91180. serialize(parent: any): any;
  91181. }
  91182. /**
  91183. * This defines an action responsible that does nothing once triggered.
  91184. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91185. */
  91186. export class DoNothingAction extends Action {
  91187. /**
  91188. * Instantiate the action
  91189. * @param triggerOptions defines the trigger options
  91190. * @param condition defines the trigger related conditions
  91191. */
  91192. constructor(triggerOptions?: any, condition?: Condition);
  91193. /**
  91194. * Execute the action and do nothing.
  91195. */
  91196. execute(): void;
  91197. /**
  91198. * Serializes the actions and its related information.
  91199. * @param parent defines the object to serialize in
  91200. * @returns the serialized object
  91201. */
  91202. serialize(parent: any): any;
  91203. }
  91204. /**
  91205. * This defines an action responsible to trigger several actions once triggered.
  91206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91207. */
  91208. export class CombineAction extends Action {
  91209. /**
  91210. * The list of aggregated animations to run.
  91211. */
  91212. children: Action[];
  91213. /**
  91214. * Instantiate the action
  91215. * @param triggerOptions defines the trigger options
  91216. * @param children defines the list of aggregated animations to run
  91217. * @param condition defines the trigger related conditions
  91218. */
  91219. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  91220. /** @hidden */
  91221. _prepare(): void;
  91222. /**
  91223. * Execute the action and executes all the aggregated actions.
  91224. */
  91225. execute(evt: ActionEvent): void;
  91226. /**
  91227. * Serializes the actions and its related information.
  91228. * @param parent defines the object to serialize in
  91229. * @returns the serialized object
  91230. */
  91231. serialize(parent: any): any;
  91232. }
  91233. /**
  91234. * This defines an action responsible to run code (external event) once triggered.
  91235. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91236. */
  91237. export class ExecuteCodeAction extends Action {
  91238. /**
  91239. * The callback function to run.
  91240. */
  91241. func: (evt: ActionEvent) => void;
  91242. /**
  91243. * Instantiate the action
  91244. * @param triggerOptions defines the trigger options
  91245. * @param func defines the callback function to run
  91246. * @param condition defines the trigger related conditions
  91247. */
  91248. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  91249. /**
  91250. * Execute the action and run the attached code.
  91251. */
  91252. execute(evt: ActionEvent): void;
  91253. }
  91254. /**
  91255. * This defines an action responsible to set the parent property of the target once triggered.
  91256. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91257. */
  91258. export class SetParentAction extends Action {
  91259. private _parent;
  91260. private _target;
  91261. /**
  91262. * Instantiate the action
  91263. * @param triggerOptions defines the trigger options
  91264. * @param target defines the target containing the parent property
  91265. * @param parent defines from where the animation should start (animation frame)
  91266. * @param condition defines the trigger related conditions
  91267. */
  91268. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  91269. /** @hidden */
  91270. _prepare(): void;
  91271. /**
  91272. * Execute the action and set the parent property.
  91273. */
  91274. execute(): void;
  91275. /**
  91276. * Serializes the actions and its related information.
  91277. * @param parent defines the object to serialize in
  91278. * @returns the serialized object
  91279. */
  91280. serialize(parent: any): any;
  91281. }
  91282. }
  91283. declare module BABYLON {
  91284. /**
  91285. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  91286. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91287. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  91288. */
  91289. export class ActionManager extends AbstractActionManager {
  91290. /**
  91291. * Nothing
  91292. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91293. */
  91294. static readonly NothingTrigger: number;
  91295. /**
  91296. * On pick
  91297. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91298. */
  91299. static readonly OnPickTrigger: number;
  91300. /**
  91301. * On left pick
  91302. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91303. */
  91304. static readonly OnLeftPickTrigger: number;
  91305. /**
  91306. * On right pick
  91307. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91308. */
  91309. static readonly OnRightPickTrigger: number;
  91310. /**
  91311. * On center pick
  91312. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91313. */
  91314. static readonly OnCenterPickTrigger: number;
  91315. /**
  91316. * On pick down
  91317. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91318. */
  91319. static readonly OnPickDownTrigger: number;
  91320. /**
  91321. * On double pick
  91322. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91323. */
  91324. static readonly OnDoublePickTrigger: number;
  91325. /**
  91326. * On pick up
  91327. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91328. */
  91329. static readonly OnPickUpTrigger: number;
  91330. /**
  91331. * On pick out.
  91332. * This trigger will only be raised if you also declared a OnPickDown
  91333. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91334. */
  91335. static readonly OnPickOutTrigger: number;
  91336. /**
  91337. * On long press
  91338. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91339. */
  91340. static readonly OnLongPressTrigger: number;
  91341. /**
  91342. * On pointer over
  91343. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91344. */
  91345. static readonly OnPointerOverTrigger: number;
  91346. /**
  91347. * On pointer out
  91348. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91349. */
  91350. static readonly OnPointerOutTrigger: number;
  91351. /**
  91352. * On every frame
  91353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91354. */
  91355. static readonly OnEveryFrameTrigger: number;
  91356. /**
  91357. * On intersection enter
  91358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91359. */
  91360. static readonly OnIntersectionEnterTrigger: number;
  91361. /**
  91362. * On intersection exit
  91363. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91364. */
  91365. static readonly OnIntersectionExitTrigger: number;
  91366. /**
  91367. * On key down
  91368. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91369. */
  91370. static readonly OnKeyDownTrigger: number;
  91371. /**
  91372. * On key up
  91373. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91374. */
  91375. static readonly OnKeyUpTrigger: number;
  91376. private _scene;
  91377. /**
  91378. * Creates a new action manager
  91379. * @param scene defines the hosting scene
  91380. */
  91381. constructor(scene: Scene);
  91382. /**
  91383. * Releases all associated resources
  91384. */
  91385. dispose(): void;
  91386. /**
  91387. * Gets hosting scene
  91388. * @returns the hosting scene
  91389. */
  91390. getScene(): Scene;
  91391. /**
  91392. * Does this action manager handles actions of any of the given triggers
  91393. * @param triggers defines the triggers to be tested
  91394. * @return a boolean indicating whether one (or more) of the triggers is handled
  91395. */
  91396. hasSpecificTriggers(triggers: number[]): boolean;
  91397. /**
  91398. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91399. * speed.
  91400. * @param triggerA defines the trigger to be tested
  91401. * @param triggerB defines the trigger to be tested
  91402. * @return a boolean indicating whether one (or more) of the triggers is handled
  91403. */
  91404. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91405. /**
  91406. * Does this action manager handles actions of a given trigger
  91407. * @param trigger defines the trigger to be tested
  91408. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91409. * @return whether the trigger is handled
  91410. */
  91411. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91412. /**
  91413. * Does this action manager has pointer triggers
  91414. */
  91415. get hasPointerTriggers(): boolean;
  91416. /**
  91417. * Does this action manager has pick triggers
  91418. */
  91419. get hasPickTriggers(): boolean;
  91420. /**
  91421. * Registers an action to this action manager
  91422. * @param action defines the action to be registered
  91423. * @return the action amended (prepared) after registration
  91424. */
  91425. registerAction(action: IAction): Nullable<IAction>;
  91426. /**
  91427. * Unregisters an action to this action manager
  91428. * @param action defines the action to be unregistered
  91429. * @return a boolean indicating whether the action has been unregistered
  91430. */
  91431. unregisterAction(action: IAction): Boolean;
  91432. /**
  91433. * Process a specific trigger
  91434. * @param trigger defines the trigger to process
  91435. * @param evt defines the event details to be processed
  91436. */
  91437. processTrigger(trigger: number, evt?: IActionEvent): void;
  91438. /** @hidden */
  91439. _getEffectiveTarget(target: any, propertyPath: string): any;
  91440. /** @hidden */
  91441. _getProperty(propertyPath: string): string;
  91442. /**
  91443. * Serialize this manager to a JSON object
  91444. * @param name defines the property name to store this manager
  91445. * @returns a JSON representation of this manager
  91446. */
  91447. serialize(name: string): any;
  91448. /**
  91449. * Creates a new ActionManager from a JSON data
  91450. * @param parsedActions defines the JSON data to read from
  91451. * @param object defines the hosting mesh
  91452. * @param scene defines the hosting scene
  91453. */
  91454. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91455. /**
  91456. * Get a trigger name by index
  91457. * @param trigger defines the trigger index
  91458. * @returns a trigger name
  91459. */
  91460. static GetTriggerName(trigger: number): string;
  91461. }
  91462. }
  91463. declare module BABYLON {
  91464. /**
  91465. * Class used to represent a sprite
  91466. * @see https://doc.babylonjs.com/babylon101/sprites
  91467. */
  91468. export class Sprite implements IAnimatable {
  91469. /** defines the name */
  91470. name: string;
  91471. /** Gets or sets the current world position */
  91472. position: Vector3;
  91473. /** Gets or sets the main color */
  91474. color: Color4;
  91475. /** Gets or sets the width */
  91476. width: number;
  91477. /** Gets or sets the height */
  91478. height: number;
  91479. /** Gets or sets rotation angle */
  91480. angle: number;
  91481. /** Gets or sets the cell index in the sprite sheet */
  91482. cellIndex: number;
  91483. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91484. cellRef: string;
  91485. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91486. invertU: boolean;
  91487. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91488. invertV: boolean;
  91489. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91490. disposeWhenFinishedAnimating: boolean;
  91491. /** Gets the list of attached animations */
  91492. animations: Nullable<Array<Animation>>;
  91493. /** Gets or sets a boolean indicating if the sprite can be picked */
  91494. isPickable: boolean;
  91495. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  91496. useAlphaForPicking: boolean;
  91497. /** @hidden */
  91498. _xOffset: number;
  91499. /** @hidden */
  91500. _yOffset: number;
  91501. /** @hidden */
  91502. _xSize: number;
  91503. /** @hidden */
  91504. _ySize: number;
  91505. /**
  91506. * Gets or sets the associated action manager
  91507. */
  91508. actionManager: Nullable<ActionManager>;
  91509. /**
  91510. * An event triggered when the control has been disposed
  91511. */
  91512. onDisposeObservable: Observable<Sprite>;
  91513. private _animationStarted;
  91514. private _loopAnimation;
  91515. private _fromIndex;
  91516. private _toIndex;
  91517. private _delay;
  91518. private _direction;
  91519. private _manager;
  91520. private _time;
  91521. private _onAnimationEnd;
  91522. /**
  91523. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91524. */
  91525. isVisible: boolean;
  91526. /**
  91527. * Gets or sets the sprite size
  91528. */
  91529. get size(): number;
  91530. set size(value: number);
  91531. /**
  91532. * Returns a boolean indicating if the animation is started
  91533. */
  91534. get animationStarted(): boolean;
  91535. /**
  91536. * Gets or sets the unique id of the sprite
  91537. */
  91538. uniqueId: number;
  91539. /**
  91540. * Gets the manager of this sprite
  91541. */
  91542. get manager(): ISpriteManager;
  91543. /**
  91544. * Creates a new Sprite
  91545. * @param name defines the name
  91546. * @param manager defines the manager
  91547. */
  91548. constructor(
  91549. /** defines the name */
  91550. name: string, manager: ISpriteManager);
  91551. /**
  91552. * Returns the string "Sprite"
  91553. * @returns "Sprite"
  91554. */
  91555. getClassName(): string;
  91556. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  91557. get fromIndex(): number;
  91558. set fromIndex(value: number);
  91559. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  91560. get toIndex(): number;
  91561. set toIndex(value: number);
  91562. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  91563. get loopAnimation(): boolean;
  91564. set loopAnimation(value: boolean);
  91565. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  91566. get delay(): number;
  91567. set delay(value: number);
  91568. /**
  91569. * Starts an animation
  91570. * @param from defines the initial key
  91571. * @param to defines the end key
  91572. * @param loop defines if the animation must loop
  91573. * @param delay defines the start delay (in ms)
  91574. * @param onAnimationEnd defines a callback to call when animation ends
  91575. */
  91576. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  91577. /** Stops current animation (if any) */
  91578. stopAnimation(): void;
  91579. /** @hidden */
  91580. _animate(deltaTime: number): void;
  91581. /** Release associated resources */
  91582. dispose(): void;
  91583. /**
  91584. * Serializes the sprite to a JSON object
  91585. * @returns the JSON object
  91586. */
  91587. serialize(): any;
  91588. /**
  91589. * Parses a JSON object to create a new sprite
  91590. * @param parsedSprite The JSON object to parse
  91591. * @param manager defines the hosting manager
  91592. * @returns the new sprite
  91593. */
  91594. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  91595. }
  91596. }
  91597. declare module BABYLON {
  91598. /**
  91599. * Information about the result of picking within a scene
  91600. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91601. */
  91602. export class PickingInfo {
  91603. /** @hidden */
  91604. _pickingUnavailable: boolean;
  91605. /**
  91606. * If the pick collided with an object
  91607. */
  91608. hit: boolean;
  91609. /**
  91610. * Distance away where the pick collided
  91611. */
  91612. distance: number;
  91613. /**
  91614. * The location of pick collision
  91615. */
  91616. pickedPoint: Nullable<Vector3>;
  91617. /**
  91618. * The mesh corresponding the the pick collision
  91619. */
  91620. pickedMesh: Nullable<AbstractMesh>;
  91621. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91622. bu: number;
  91623. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91624. bv: number;
  91625. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91626. faceId: number;
  91627. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91628. subMeshFaceId: number;
  91629. /** Id of the the submesh that was picked */
  91630. subMeshId: number;
  91631. /** If a sprite was picked, this will be the sprite the pick collided with */
  91632. pickedSprite: Nullable<Sprite>;
  91633. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  91634. thinInstanceIndex: number;
  91635. /**
  91636. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91637. */
  91638. originMesh: Nullable<AbstractMesh>;
  91639. /**
  91640. * The ray that was used to perform the picking.
  91641. */
  91642. ray: Nullable<Ray>;
  91643. /**
  91644. * Gets the normal correspodning to the face the pick collided with
  91645. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91646. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91647. * @returns The normal correspodning to the face the pick collided with
  91648. */
  91649. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91650. /**
  91651. * Gets the texture coordinates of where the pick occured
  91652. * @returns the vector containing the coordnates of the texture
  91653. */
  91654. getTextureCoordinates(): Nullable<Vector2>;
  91655. }
  91656. }
  91657. declare module BABYLON {
  91658. /**
  91659. * Class representing a ray with position and direction
  91660. */
  91661. export class Ray {
  91662. /** origin point */
  91663. origin: Vector3;
  91664. /** direction */
  91665. direction: Vector3;
  91666. /** length of the ray */
  91667. length: number;
  91668. private static readonly _TmpVector3;
  91669. private _tmpRay;
  91670. /**
  91671. * Creates a new ray
  91672. * @param origin origin point
  91673. * @param direction direction
  91674. * @param length length of the ray
  91675. */
  91676. constructor(
  91677. /** origin point */
  91678. origin: Vector3,
  91679. /** direction */
  91680. direction: Vector3,
  91681. /** length of the ray */
  91682. length?: number);
  91683. /**
  91684. * Checks if the ray intersects a box
  91685. * This does not account for the ray lenght by design to improve perfs.
  91686. * @param minimum bound of the box
  91687. * @param maximum bound of the box
  91688. * @param intersectionTreshold extra extend to be added to the box in all direction
  91689. * @returns if the box was hit
  91690. */
  91691. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91692. /**
  91693. * Checks if the ray intersects a box
  91694. * This does not account for the ray lenght by design to improve perfs.
  91695. * @param box the bounding box to check
  91696. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91697. * @returns if the box was hit
  91698. */
  91699. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91700. /**
  91701. * If the ray hits a sphere
  91702. * @param sphere the bounding sphere to check
  91703. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91704. * @returns true if it hits the sphere
  91705. */
  91706. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91707. /**
  91708. * If the ray hits a triange
  91709. * @param vertex0 triangle vertex
  91710. * @param vertex1 triangle vertex
  91711. * @param vertex2 triangle vertex
  91712. * @returns intersection information if hit
  91713. */
  91714. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91715. /**
  91716. * Checks if ray intersects a plane
  91717. * @param plane the plane to check
  91718. * @returns the distance away it was hit
  91719. */
  91720. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91721. /**
  91722. * Calculate the intercept of a ray on a given axis
  91723. * @param axis to check 'x' | 'y' | 'z'
  91724. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91725. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91726. */
  91727. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91728. /**
  91729. * Checks if ray intersects a mesh
  91730. * @param mesh the mesh to check
  91731. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91732. * @returns picking info of the intersecton
  91733. */
  91734. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91735. /**
  91736. * Checks if ray intersects a mesh
  91737. * @param meshes the meshes to check
  91738. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91739. * @param results array to store result in
  91740. * @returns Array of picking infos
  91741. */
  91742. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91743. private _comparePickingInfo;
  91744. private static smallnum;
  91745. private static rayl;
  91746. /**
  91747. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91748. * @param sega the first point of the segment to test the intersection against
  91749. * @param segb the second point of the segment to test the intersection against
  91750. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91751. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91752. */
  91753. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91754. /**
  91755. * Update the ray from viewport position
  91756. * @param x position
  91757. * @param y y position
  91758. * @param viewportWidth viewport width
  91759. * @param viewportHeight viewport height
  91760. * @param world world matrix
  91761. * @param view view matrix
  91762. * @param projection projection matrix
  91763. * @returns this ray updated
  91764. */
  91765. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91766. /**
  91767. * Creates a ray with origin and direction of 0,0,0
  91768. * @returns the new ray
  91769. */
  91770. static Zero(): Ray;
  91771. /**
  91772. * Creates a new ray from screen space and viewport
  91773. * @param x position
  91774. * @param y y position
  91775. * @param viewportWidth viewport width
  91776. * @param viewportHeight viewport height
  91777. * @param world world matrix
  91778. * @param view view matrix
  91779. * @param projection projection matrix
  91780. * @returns new ray
  91781. */
  91782. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91783. /**
  91784. * 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
  91785. * transformed to the given world matrix.
  91786. * @param origin The origin point
  91787. * @param end The end point
  91788. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91789. * @returns the new ray
  91790. */
  91791. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91792. /**
  91793. * Transforms a ray by a matrix
  91794. * @param ray ray to transform
  91795. * @param matrix matrix to apply
  91796. * @returns the resulting new ray
  91797. */
  91798. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91799. /**
  91800. * Transforms a ray by a matrix
  91801. * @param ray ray to transform
  91802. * @param matrix matrix to apply
  91803. * @param result ray to store result in
  91804. */
  91805. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91806. /**
  91807. * Unproject a ray from screen space to object space
  91808. * @param sourceX defines the screen space x coordinate to use
  91809. * @param sourceY defines the screen space y coordinate to use
  91810. * @param viewportWidth defines the current width of the viewport
  91811. * @param viewportHeight defines the current height of the viewport
  91812. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91813. * @param view defines the view matrix to use
  91814. * @param projection defines the projection matrix to use
  91815. */
  91816. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91817. }
  91818. /**
  91819. * Type used to define predicate used to select faces when a mesh intersection is detected
  91820. */
  91821. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91822. interface Scene {
  91823. /** @hidden */
  91824. _tempPickingRay: Nullable<Ray>;
  91825. /** @hidden */
  91826. _cachedRayForTransform: Ray;
  91827. /** @hidden */
  91828. _pickWithRayInverseMatrix: Matrix;
  91829. /** @hidden */
  91830. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91831. /** @hidden */
  91832. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91833. /** @hidden */
  91834. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91835. }
  91836. }
  91837. declare module BABYLON {
  91838. /**
  91839. * Groups all the scene component constants in one place to ease maintenance.
  91840. * @hidden
  91841. */
  91842. export class SceneComponentConstants {
  91843. static readonly NAME_EFFECTLAYER: string;
  91844. static readonly NAME_LAYER: string;
  91845. static readonly NAME_LENSFLARESYSTEM: string;
  91846. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91847. static readonly NAME_PARTICLESYSTEM: string;
  91848. static readonly NAME_GAMEPAD: string;
  91849. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91850. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91851. static readonly NAME_PREPASSRENDERER: string;
  91852. static readonly NAME_DEPTHRENDERER: string;
  91853. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91854. static readonly NAME_SPRITE: string;
  91855. static readonly NAME_SUBSURFACE: string;
  91856. static readonly NAME_OUTLINERENDERER: string;
  91857. static readonly NAME_PROCEDURALTEXTURE: string;
  91858. static readonly NAME_SHADOWGENERATOR: string;
  91859. static readonly NAME_OCTREE: string;
  91860. static readonly NAME_PHYSICSENGINE: string;
  91861. static readonly NAME_AUDIO: string;
  91862. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91863. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91864. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91865. static readonly STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91866. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91867. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91868. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91869. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91870. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91871. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91872. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91873. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91874. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91875. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91876. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91877. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91878. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91879. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91880. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91881. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91882. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91883. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91884. static readonly STEP_AFTERRENDER_AUDIO: number;
  91885. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91886. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91887. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91888. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91889. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91890. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91891. static readonly STEP_POINTERMOVE_SPRITE: number;
  91892. static readonly STEP_POINTERDOWN_SPRITE: number;
  91893. static readonly STEP_POINTERUP_SPRITE: number;
  91894. }
  91895. /**
  91896. * This represents a scene component.
  91897. *
  91898. * This is used to decouple the dependency the scene is having on the different workloads like
  91899. * layers, post processes...
  91900. */
  91901. export interface ISceneComponent {
  91902. /**
  91903. * The name of the component. Each component must have a unique name.
  91904. */
  91905. name: string;
  91906. /**
  91907. * The scene the component belongs to.
  91908. */
  91909. scene: Scene;
  91910. /**
  91911. * Register the component to one instance of a scene.
  91912. */
  91913. register(): void;
  91914. /**
  91915. * Rebuilds the elements related to this component in case of
  91916. * context lost for instance.
  91917. */
  91918. rebuild(): void;
  91919. /**
  91920. * Disposes the component and the associated ressources.
  91921. */
  91922. dispose(): void;
  91923. }
  91924. /**
  91925. * This represents a SERIALIZABLE scene component.
  91926. *
  91927. * This extends Scene Component to add Serialization methods on top.
  91928. */
  91929. export interface ISceneSerializableComponent extends ISceneComponent {
  91930. /**
  91931. * Adds all the elements from the container to the scene
  91932. * @param container the container holding the elements
  91933. */
  91934. addFromContainer(container: AbstractScene): void;
  91935. /**
  91936. * Removes all the elements in the container from the scene
  91937. * @param container contains the elements to remove
  91938. * @param dispose if the removed element should be disposed (default: false)
  91939. */
  91940. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91941. /**
  91942. * Serializes the component data to the specified json object
  91943. * @param serializationObject The object to serialize to
  91944. */
  91945. serialize(serializationObject: any): void;
  91946. }
  91947. /**
  91948. * Strong typing of a Mesh related stage step action
  91949. */
  91950. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91951. /**
  91952. * Strong typing of a Evaluate Sub Mesh related stage step action
  91953. */
  91954. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91955. /**
  91956. * Strong typing of a pre active Mesh related stage step action
  91957. */
  91958. export type PreActiveMeshStageAction = (mesh: AbstractMesh) => void;
  91959. /**
  91960. * Strong typing of a Camera related stage step action
  91961. */
  91962. export type CameraStageAction = (camera: Camera) => void;
  91963. /**
  91964. * Strong typing of a Camera Frame buffer related stage step action
  91965. */
  91966. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91967. /**
  91968. * Strong typing of a Render Target related stage step action
  91969. */
  91970. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91971. /**
  91972. * Strong typing of a RenderingGroup related stage step action
  91973. */
  91974. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91975. /**
  91976. * Strong typing of a Mesh Render related stage step action
  91977. */
  91978. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91979. /**
  91980. * Strong typing of a simple stage step action
  91981. */
  91982. export type SimpleStageAction = () => void;
  91983. /**
  91984. * Strong typing of a render target action.
  91985. */
  91986. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91987. /**
  91988. * Strong typing of a pointer move action.
  91989. */
  91990. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91991. /**
  91992. * Strong typing of a pointer up/down action.
  91993. */
  91994. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91995. /**
  91996. * Representation of a stage in the scene (Basically a list of ordered steps)
  91997. * @hidden
  91998. */
  91999. export class Stage<T extends Function> extends Array<{
  92000. index: number;
  92001. component: ISceneComponent;
  92002. action: T;
  92003. }> {
  92004. /**
  92005. * Hide ctor from the rest of the world.
  92006. * @param items The items to add.
  92007. */
  92008. private constructor();
  92009. /**
  92010. * Creates a new Stage.
  92011. * @returns A new instance of a Stage
  92012. */
  92013. static Create<T extends Function>(): Stage<T>;
  92014. /**
  92015. * Registers a step in an ordered way in the targeted stage.
  92016. * @param index Defines the position to register the step in
  92017. * @param component Defines the component attached to the step
  92018. * @param action Defines the action to launch during the step
  92019. */
  92020. registerStep(index: number, component: ISceneComponent, action: T): void;
  92021. /**
  92022. * Clears all the steps from the stage.
  92023. */
  92024. clear(): void;
  92025. }
  92026. }
  92027. declare module BABYLON {
  92028. interface Scene {
  92029. /** @hidden */
  92030. _pointerOverSprite: Nullable<Sprite>;
  92031. /** @hidden */
  92032. _pickedDownSprite: Nullable<Sprite>;
  92033. /** @hidden */
  92034. _tempSpritePickingRay: Nullable<Ray>;
  92035. /**
  92036. * All of the sprite managers added to this scene
  92037. * @see https://doc.babylonjs.com/babylon101/sprites
  92038. */
  92039. spriteManagers: Array<ISpriteManager>;
  92040. /**
  92041. * An event triggered when sprites rendering is about to start
  92042. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92043. */
  92044. onBeforeSpritesRenderingObservable: Observable<Scene>;
  92045. /**
  92046. * An event triggered when sprites rendering is done
  92047. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  92048. */
  92049. onAfterSpritesRenderingObservable: Observable<Scene>;
  92050. /** @hidden */
  92051. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92052. /** Launch a ray to try to pick a sprite in the scene
  92053. * @param x position on screen
  92054. * @param y position on screen
  92055. * @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
  92056. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92057. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92058. * @returns a PickingInfo
  92059. */
  92060. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92061. /** Use the given ray to pick a sprite in the scene
  92062. * @param ray The ray (in world space) to use to pick meshes
  92063. * @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
  92064. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92065. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92066. * @returns a PickingInfo
  92067. */
  92068. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  92069. /** @hidden */
  92070. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92071. /** Launch a ray to try to pick sprites in the scene
  92072. * @param x position on screen
  92073. * @param y position on screen
  92074. * @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
  92075. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92076. * @returns a PickingInfo array
  92077. */
  92078. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92079. /** Use the given ray to pick sprites in the scene
  92080. * @param ray The ray (in world space) to use to pick meshes
  92081. * @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
  92082. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  92083. * @returns a PickingInfo array
  92084. */
  92085. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  92086. /**
  92087. * Force the sprite under the pointer
  92088. * @param sprite defines the sprite to use
  92089. */
  92090. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  92091. /**
  92092. * Gets the sprite under the pointer
  92093. * @returns a Sprite or null if no sprite is under the pointer
  92094. */
  92095. getPointerOverSprite(): Nullable<Sprite>;
  92096. }
  92097. /**
  92098. * Defines the sprite scene component responsible to manage sprites
  92099. * in a given scene.
  92100. */
  92101. export class SpriteSceneComponent implements ISceneComponent {
  92102. /**
  92103. * The component name helpfull to identify the component in the list of scene components.
  92104. */
  92105. readonly name: string;
  92106. /**
  92107. * The scene the component belongs to.
  92108. */
  92109. scene: Scene;
  92110. /** @hidden */
  92111. private _spritePredicate;
  92112. /**
  92113. * Creates a new instance of the component for the given scene
  92114. * @param scene Defines the scene to register the component in
  92115. */
  92116. constructor(scene: Scene);
  92117. /**
  92118. * Registers the component in a given scene
  92119. */
  92120. register(): void;
  92121. /**
  92122. * Rebuilds the elements related to this component in case of
  92123. * context lost for instance.
  92124. */
  92125. rebuild(): void;
  92126. /**
  92127. * Disposes the component and the associated ressources.
  92128. */
  92129. dispose(): void;
  92130. private _pickSpriteButKeepRay;
  92131. private _pointerMove;
  92132. private _pointerDown;
  92133. private _pointerUp;
  92134. }
  92135. }
  92136. declare module BABYLON {
  92137. /** @hidden */
  92138. export var fogFragmentDeclaration: {
  92139. name: string;
  92140. shader: string;
  92141. };
  92142. }
  92143. declare module BABYLON {
  92144. /** @hidden */
  92145. export var fogFragment: {
  92146. name: string;
  92147. shader: string;
  92148. };
  92149. }
  92150. declare module BABYLON {
  92151. /** @hidden */
  92152. export var imageProcessingCompatibility: {
  92153. name: string;
  92154. shader: string;
  92155. };
  92156. }
  92157. declare module BABYLON {
  92158. /** @hidden */
  92159. export var spritesPixelShader: {
  92160. name: string;
  92161. shader: string;
  92162. };
  92163. }
  92164. declare module BABYLON {
  92165. /** @hidden */
  92166. export var fogVertexDeclaration: {
  92167. name: string;
  92168. shader: string;
  92169. };
  92170. }
  92171. declare module BABYLON {
  92172. /** @hidden */
  92173. export var spritesVertexShader: {
  92174. name: string;
  92175. shader: string;
  92176. };
  92177. }
  92178. declare module BABYLON {
  92179. /**
  92180. * Defines the minimum interface to fullfil in order to be a sprite manager.
  92181. */
  92182. export interface ISpriteManager extends IDisposable {
  92183. /**
  92184. * Gets manager's name
  92185. */
  92186. name: string;
  92187. /**
  92188. * Restricts the camera to viewing objects with the same layerMask.
  92189. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  92190. */
  92191. layerMask: number;
  92192. /**
  92193. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92194. */
  92195. isPickable: boolean;
  92196. /**
  92197. * Gets the hosting scene
  92198. */
  92199. scene: Scene;
  92200. /**
  92201. * Specifies the rendering group id for this mesh (0 by default)
  92202. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92203. */
  92204. renderingGroupId: number;
  92205. /**
  92206. * Defines the list of sprites managed by the manager.
  92207. */
  92208. sprites: Array<Sprite>;
  92209. /**
  92210. * Gets or sets the spritesheet texture
  92211. */
  92212. texture: Texture;
  92213. /** Defines the default width of a cell in the spritesheet */
  92214. cellWidth: number;
  92215. /** Defines the default height of a cell in the spritesheet */
  92216. cellHeight: number;
  92217. /**
  92218. * Tests the intersection of a sprite with a specific ray.
  92219. * @param ray The ray we are sending to test the collision
  92220. * @param camera The camera space we are sending rays in
  92221. * @param predicate A predicate allowing excluding sprites from the list of object to test
  92222. * @param fastCheck defines if the first intersection will be used (and not the closest)
  92223. * @returns picking info or null.
  92224. */
  92225. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  92226. /**
  92227. * Intersects the sprites with a ray
  92228. * @param ray defines the ray to intersect with
  92229. * @param camera defines the current active camera
  92230. * @param predicate defines a predicate used to select candidate sprites
  92231. * @returns null if no hit or a PickingInfo array
  92232. */
  92233. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  92234. /**
  92235. * Renders the list of sprites on screen.
  92236. */
  92237. render(): void;
  92238. }
  92239. /**
  92240. * Class used to manage multiple sprites on the same spritesheet
  92241. * @see https://doc.babylonjs.com/babylon101/sprites
  92242. */
  92243. export class SpriteManager implements ISpriteManager {
  92244. /** defines the manager's name */
  92245. name: string;
  92246. /** Define the Url to load snippets */
  92247. static SnippetUrl: string;
  92248. /** Snippet ID if the manager was created from the snippet server */
  92249. snippetId: string;
  92250. /** Gets the list of sprites */
  92251. sprites: Sprite[];
  92252. /** Gets or sets the rendering group id (0 by default) */
  92253. renderingGroupId: number;
  92254. /** Gets or sets camera layer mask */
  92255. layerMask: number;
  92256. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  92257. fogEnabled: boolean;
  92258. /** Gets or sets a boolean indicating if the sprites are pickable */
  92259. isPickable: boolean;
  92260. /** Defines the default width of a cell in the spritesheet */
  92261. cellWidth: number;
  92262. /** Defines the default height of a cell in the spritesheet */
  92263. cellHeight: number;
  92264. /** Associative array from JSON sprite data file */
  92265. private _cellData;
  92266. /** Array of sprite names from JSON sprite data file */
  92267. private _spriteMap;
  92268. /** True when packed cell data from JSON file is ready*/
  92269. private _packedAndReady;
  92270. private _textureContent;
  92271. private _useInstancing;
  92272. /**
  92273. * An event triggered when the manager is disposed.
  92274. */
  92275. onDisposeObservable: Observable<SpriteManager>;
  92276. private _onDisposeObserver;
  92277. /**
  92278. * Callback called when the manager is disposed
  92279. */
  92280. set onDispose(callback: () => void);
  92281. private _capacity;
  92282. private _fromPacked;
  92283. private _spriteTexture;
  92284. private _epsilon;
  92285. private _scene;
  92286. private _vertexData;
  92287. private _buffer;
  92288. private _vertexBuffers;
  92289. private _spriteBuffer;
  92290. private _indexBuffer;
  92291. private _effectBase;
  92292. private _effectFog;
  92293. private _vertexBufferSize;
  92294. /**
  92295. * Gets or sets the unique id of the sprite
  92296. */
  92297. uniqueId: number;
  92298. /**
  92299. * Gets the array of sprites
  92300. */
  92301. get children(): Sprite[];
  92302. /**
  92303. * Gets the hosting scene
  92304. */
  92305. get scene(): Scene;
  92306. /**
  92307. * Gets the capacity of the manager
  92308. */
  92309. get capacity(): number;
  92310. /**
  92311. * Gets or sets the spritesheet texture
  92312. */
  92313. get texture(): Texture;
  92314. set texture(value: Texture);
  92315. private _blendMode;
  92316. /**
  92317. * Blend mode use to render the particle, it can be any of
  92318. * the static Constants.ALPHA_x properties provided in this class.
  92319. * Default value is Constants.ALPHA_COMBINE
  92320. */
  92321. get blendMode(): number;
  92322. set blendMode(blendMode: number);
  92323. /** Disables writing to the depth buffer when rendering the sprites.
  92324. * It can be handy to disable depth writing when using textures without alpha channel
  92325. * and setting some specific blend modes.
  92326. */
  92327. disableDepthWrite: boolean;
  92328. /**
  92329. * Creates a new sprite manager
  92330. * @param name defines the manager's name
  92331. * @param imgUrl defines the sprite sheet url
  92332. * @param capacity defines the maximum allowed number of sprites
  92333. * @param cellSize defines the size of a sprite cell
  92334. * @param scene defines the hosting scene
  92335. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  92336. * @param samplingMode defines the smapling mode to use with spritesheet
  92337. * @param fromPacked set to false; do not alter
  92338. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  92339. */
  92340. constructor(
  92341. /** defines the manager's name */
  92342. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  92343. /**
  92344. * Returns the string "SpriteManager"
  92345. * @returns "SpriteManager"
  92346. */
  92347. getClassName(): string;
  92348. private _makePacked;
  92349. private _appendSpriteVertex;
  92350. private _checkTextureAlpha;
  92351. /**
  92352. * Intersects the sprites with a ray
  92353. * @param ray defines the ray to intersect with
  92354. * @param camera defines the current active camera
  92355. * @param predicate defines a predicate used to select candidate sprites
  92356. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  92357. * @returns null if no hit or a PickingInfo
  92358. */
  92359. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  92360. /**
  92361. * Intersects the sprites with a ray
  92362. * @param ray defines the ray to intersect with
  92363. * @param camera defines the current active camera
  92364. * @param predicate defines a predicate used to select candidate sprites
  92365. * @returns null if no hit or a PickingInfo array
  92366. */
  92367. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  92368. /**
  92369. * Render all child sprites
  92370. */
  92371. render(): void;
  92372. /**
  92373. * Release associated resources
  92374. */
  92375. dispose(): void;
  92376. /**
  92377. * Serializes the sprite manager to a JSON object
  92378. * @param serializeTexture defines if the texture must be serialized as well
  92379. * @returns the JSON object
  92380. */
  92381. serialize(serializeTexture?: boolean): any;
  92382. /**
  92383. * Parses a JSON object to create a new sprite manager.
  92384. * @param parsedManager The JSON object to parse
  92385. * @param scene The scene to create the sprite managerin
  92386. * @param rootUrl The root url to use to load external dependencies like texture
  92387. * @returns the new sprite manager
  92388. */
  92389. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  92390. /**
  92391. * Creates a sprite manager from a snippet saved in a remote file
  92392. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  92393. * @param url defines the url to load from
  92394. * @param scene defines the hosting scene
  92395. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92396. * @returns a promise that will resolve to the new sprite manager
  92397. */
  92398. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92399. /**
  92400. * Creates a sprite manager from a snippet saved by the sprite editor
  92401. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  92402. * @param scene defines the hosting scene
  92403. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  92404. * @returns a promise that will resolve to the new sprite manager
  92405. */
  92406. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  92407. }
  92408. }
  92409. declare module BABYLON {
  92410. /** Interface used by value gradients (color, factor, ...) */
  92411. export interface IValueGradient {
  92412. /**
  92413. * Gets or sets the gradient value (between 0 and 1)
  92414. */
  92415. gradient: number;
  92416. }
  92417. /** Class used to store color4 gradient */
  92418. export class ColorGradient implements IValueGradient {
  92419. /**
  92420. * Gets or sets the gradient value (between 0 and 1)
  92421. */
  92422. gradient: number;
  92423. /**
  92424. * Gets or sets first associated color
  92425. */
  92426. color1: Color4;
  92427. /**
  92428. * Gets or sets second associated color
  92429. */
  92430. color2?: Color4 | undefined;
  92431. /**
  92432. * Creates a new color4 gradient
  92433. * @param gradient gets or sets the gradient value (between 0 and 1)
  92434. * @param color1 gets or sets first associated color
  92435. * @param color2 gets or sets first second color
  92436. */
  92437. constructor(
  92438. /**
  92439. * Gets or sets the gradient value (between 0 and 1)
  92440. */
  92441. gradient: number,
  92442. /**
  92443. * Gets or sets first associated color
  92444. */
  92445. color1: Color4,
  92446. /**
  92447. * Gets or sets second associated color
  92448. */
  92449. color2?: Color4 | undefined);
  92450. /**
  92451. * Will get a color picked randomly between color1 and color2.
  92452. * If color2 is undefined then color1 will be used
  92453. * @param result defines the target Color4 to store the result in
  92454. */
  92455. getColorToRef(result: Color4): void;
  92456. }
  92457. /** Class used to store color 3 gradient */
  92458. export class Color3Gradient implements IValueGradient {
  92459. /**
  92460. * Gets or sets the gradient value (between 0 and 1)
  92461. */
  92462. gradient: number;
  92463. /**
  92464. * Gets or sets the associated color
  92465. */
  92466. color: Color3;
  92467. /**
  92468. * Creates a new color3 gradient
  92469. * @param gradient gets or sets the gradient value (between 0 and 1)
  92470. * @param color gets or sets associated color
  92471. */
  92472. constructor(
  92473. /**
  92474. * Gets or sets the gradient value (between 0 and 1)
  92475. */
  92476. gradient: number,
  92477. /**
  92478. * Gets or sets the associated color
  92479. */
  92480. color: Color3);
  92481. }
  92482. /** Class used to store factor gradient */
  92483. export class FactorGradient implements IValueGradient {
  92484. /**
  92485. * Gets or sets the gradient value (between 0 and 1)
  92486. */
  92487. gradient: number;
  92488. /**
  92489. * Gets or sets first associated factor
  92490. */
  92491. factor1: number;
  92492. /**
  92493. * Gets or sets second associated factor
  92494. */
  92495. factor2?: number | undefined;
  92496. /**
  92497. * Creates a new factor gradient
  92498. * @param gradient gets or sets the gradient value (between 0 and 1)
  92499. * @param factor1 gets or sets first associated factor
  92500. * @param factor2 gets or sets second associated factor
  92501. */
  92502. constructor(
  92503. /**
  92504. * Gets or sets the gradient value (between 0 and 1)
  92505. */
  92506. gradient: number,
  92507. /**
  92508. * Gets or sets first associated factor
  92509. */
  92510. factor1: number,
  92511. /**
  92512. * Gets or sets second associated factor
  92513. */
  92514. factor2?: number | undefined);
  92515. /**
  92516. * Will get a number picked randomly between factor1 and factor2.
  92517. * If factor2 is undefined then factor1 will be used
  92518. * @returns the picked number
  92519. */
  92520. getFactor(): number;
  92521. }
  92522. /**
  92523. * Helper used to simplify some generic gradient tasks
  92524. */
  92525. export class GradientHelper {
  92526. /**
  92527. * Gets the current gradient from an array of IValueGradient
  92528. * @param ratio defines the current ratio to get
  92529. * @param gradients defines the array of IValueGradient
  92530. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  92531. */
  92532. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  92533. }
  92534. }
  92535. declare module BABYLON {
  92536. interface ThinEngine {
  92537. /**
  92538. * Creates a raw texture
  92539. * @param data defines the data to store in the texture
  92540. * @param width defines the width of the texture
  92541. * @param height defines the height of the texture
  92542. * @param format defines the format of the data
  92543. * @param generateMipMaps defines if the engine should generate the mip levels
  92544. * @param invertY defines if data must be stored with Y axis inverted
  92545. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  92546. * @param compression defines the compression used (null by default)
  92547. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92548. * @returns the raw texture inside an InternalTexture
  92549. */
  92550. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  92551. /**
  92552. * Update a raw texture
  92553. * @param texture defines the texture to update
  92554. * @param data defines the data to store in the texture
  92555. * @param format defines the format of the data
  92556. * @param invertY defines if data must be stored with Y axis inverted
  92557. */
  92558. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92559. /**
  92560. * Update a raw texture
  92561. * @param texture defines the texture to update
  92562. * @param data defines the data to store in the texture
  92563. * @param format defines the format of the data
  92564. * @param invertY defines if data must be stored with Y axis inverted
  92565. * @param compression defines the compression used (null by default)
  92566. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92567. */
  92568. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  92569. /**
  92570. * Creates a new raw cube texture
  92571. * @param data defines the array of data to use to create each face
  92572. * @param size defines the size of the textures
  92573. * @param format defines the format of the data
  92574. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92575. * @param generateMipMaps defines if the engine should generate the mip levels
  92576. * @param invertY defines if data must be stored with Y axis inverted
  92577. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92578. * @param compression defines the compression used (null by default)
  92579. * @returns the cube texture as an InternalTexture
  92580. */
  92581. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  92582. /**
  92583. * Update a raw cube texture
  92584. * @param texture defines the texture to udpdate
  92585. * @param data defines the data to store
  92586. * @param format defines the data format
  92587. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92588. * @param invertY defines if data must be stored with Y axis inverted
  92589. */
  92590. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  92591. /**
  92592. * Update a raw cube texture
  92593. * @param texture defines the texture to udpdate
  92594. * @param data defines the data to store
  92595. * @param format defines the data format
  92596. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92597. * @param invertY defines if data must be stored with Y axis inverted
  92598. * @param compression defines the compression used (null by default)
  92599. */
  92600. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  92601. /**
  92602. * Update a raw cube texture
  92603. * @param texture defines the texture to udpdate
  92604. * @param data defines the data to store
  92605. * @param format defines the data format
  92606. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  92607. * @param invertY defines if data must be stored with Y axis inverted
  92608. * @param compression defines the compression used (null by default)
  92609. * @param level defines which level of the texture to update
  92610. */
  92611. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  92612. /**
  92613. * Creates a new raw cube texture from a specified url
  92614. * @param url defines the url where the data is located
  92615. * @param scene defines the current scene
  92616. * @param size defines the size of the textures
  92617. * @param format defines the format of the data
  92618. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92619. * @param noMipmap defines if the engine should avoid generating the mip levels
  92620. * @param callback defines a callback used to extract texture data from loaded data
  92621. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92622. * @param onLoad defines a callback called when texture is loaded
  92623. * @param onError defines a callback called if there is an error
  92624. * @returns the cube texture as an InternalTexture
  92625. */
  92626. 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;
  92627. /**
  92628. * Creates a new raw cube texture from a specified url
  92629. * @param url defines the url where the data is located
  92630. * @param scene defines the current scene
  92631. * @param size defines the size of the textures
  92632. * @param format defines the format of the data
  92633. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  92634. * @param noMipmap defines if the engine should avoid generating the mip levels
  92635. * @param callback defines a callback used to extract texture data from loaded data
  92636. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  92637. * @param onLoad defines a callback called when texture is loaded
  92638. * @param onError defines a callback called if there is an error
  92639. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92640. * @param invertY defines if data must be stored with Y axis inverted
  92641. * @returns the cube texture as an InternalTexture
  92642. */
  92643. 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;
  92644. /**
  92645. * Creates a new raw 3D texture
  92646. * @param data defines the data used to create the texture
  92647. * @param width defines the width of the texture
  92648. * @param height defines the height of the texture
  92649. * @param depth defines the depth of the texture
  92650. * @param format defines the format of the texture
  92651. * @param generateMipMaps defines if the engine must generate mip levels
  92652. * @param invertY defines if data must be stored with Y axis inverted
  92653. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92654. * @param compression defines the compressed used (can be null)
  92655. * @param textureType defines the compressed used (can be null)
  92656. * @returns a new raw 3D texture (stored in an InternalTexture)
  92657. */
  92658. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92659. /**
  92660. * Update a raw 3D texture
  92661. * @param texture defines the texture to update
  92662. * @param data defines the data to store
  92663. * @param format defines the data format
  92664. * @param invertY defines if data must be stored with Y axis inverted
  92665. */
  92666. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92667. /**
  92668. * Update a raw 3D texture
  92669. * @param texture defines the texture to update
  92670. * @param data defines the data to store
  92671. * @param format defines the data format
  92672. * @param invertY defines if data must be stored with Y axis inverted
  92673. * @param compression defines the used compression (can be null)
  92674. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92675. */
  92676. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92677. /**
  92678. * Creates a new raw 2D array texture
  92679. * @param data defines the data used to create the texture
  92680. * @param width defines the width of the texture
  92681. * @param height defines the height of the texture
  92682. * @param depth defines the number of layers of the texture
  92683. * @param format defines the format of the texture
  92684. * @param generateMipMaps defines if the engine must generate mip levels
  92685. * @param invertY defines if data must be stored with Y axis inverted
  92686. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  92687. * @param compression defines the compressed used (can be null)
  92688. * @param textureType defines the compressed used (can be null)
  92689. * @returns a new raw 2D array texture (stored in an InternalTexture)
  92690. */
  92691. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  92692. /**
  92693. * Update a raw 2D array texture
  92694. * @param texture defines the texture to update
  92695. * @param data defines the data to store
  92696. * @param format defines the data format
  92697. * @param invertY defines if data must be stored with Y axis inverted
  92698. */
  92699. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92700. /**
  92701. * Update a raw 2D array texture
  92702. * @param texture defines the texture to update
  92703. * @param data defines the data to store
  92704. * @param format defines the data format
  92705. * @param invertY defines if data must be stored with Y axis inverted
  92706. * @param compression defines the used compression (can be null)
  92707. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92708. */
  92709. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92710. }
  92711. }
  92712. declare module BABYLON {
  92713. /**
  92714. * Raw texture can help creating a texture directly from an array of data.
  92715. * This can be super useful if you either get the data from an uncompressed source or
  92716. * if you wish to create your texture pixel by pixel.
  92717. */
  92718. export class RawTexture extends Texture {
  92719. /**
  92720. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92721. */
  92722. format: number;
  92723. /**
  92724. * Instantiates a new RawTexture.
  92725. * Raw texture can help creating a texture directly from an array of data.
  92726. * This can be super useful if you either get the data from an uncompressed source or
  92727. * if you wish to create your texture pixel by pixel.
  92728. * @param data define the array of data to use to create the texture
  92729. * @param width define the width of the texture
  92730. * @param height define the height of the texture
  92731. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92732. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92733. * @param generateMipMaps define whether mip maps should be generated or not
  92734. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92735. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92736. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92737. */
  92738. constructor(data: ArrayBufferView, width: number, height: number,
  92739. /**
  92740. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92741. */
  92742. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92743. /**
  92744. * Updates the texture underlying data.
  92745. * @param data Define the new data of the texture
  92746. */
  92747. update(data: ArrayBufferView): void;
  92748. /**
  92749. * Creates a luminance texture from some data.
  92750. * @param data Define the texture data
  92751. * @param width Define the width of the texture
  92752. * @param height Define the height of the texture
  92753. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92754. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92755. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92756. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92757. * @returns the luminance texture
  92758. */
  92759. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92760. /**
  92761. * Creates a luminance alpha texture from some data.
  92762. * @param data Define the texture data
  92763. * @param width Define the width of the texture
  92764. * @param height Define the height of the texture
  92765. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92766. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92767. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92768. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92769. * @returns the luminance alpha texture
  92770. */
  92771. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92772. /**
  92773. * Creates an alpha texture from some data.
  92774. * @param data Define the texture data
  92775. * @param width Define the width of the texture
  92776. * @param height Define the height of the texture
  92777. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92778. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92779. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92780. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92781. * @returns the alpha texture
  92782. */
  92783. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92784. /**
  92785. * Creates a RGB texture from some data.
  92786. * @param data Define the texture data
  92787. * @param width Define the width of the texture
  92788. * @param height Define the height of the texture
  92789. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92790. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92791. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92792. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92793. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92794. * @returns the RGB alpha texture
  92795. */
  92796. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92797. /**
  92798. * Creates a RGBA texture from some data.
  92799. * @param data Define the texture data
  92800. * @param width Define the width of the texture
  92801. * @param height Define the height of the texture
  92802. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92803. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92804. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92805. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92806. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92807. * @returns the RGBA texture
  92808. */
  92809. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92810. /**
  92811. * Creates a R texture from some data.
  92812. * @param data Define the texture data
  92813. * @param width Define the width of the texture
  92814. * @param height Define the height of the texture
  92815. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92816. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92817. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92818. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92819. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92820. * @returns the R texture
  92821. */
  92822. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92823. }
  92824. }
  92825. declare module BABYLON {
  92826. interface ThinEngine {
  92827. /**
  92828. * Update a dynamic index buffer
  92829. * @param indexBuffer defines the target index buffer
  92830. * @param indices defines the data to update
  92831. * @param offset defines the offset in the target index buffer where update should start
  92832. */
  92833. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92834. /**
  92835. * Updates a dynamic vertex buffer.
  92836. * @param vertexBuffer the vertex buffer to update
  92837. * @param data the data used to update the vertex buffer
  92838. * @param byteOffset the byte offset of the data
  92839. * @param byteLength the byte length of the data
  92840. */
  92841. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92842. }
  92843. }
  92844. declare module BABYLON {
  92845. interface AbstractScene {
  92846. /**
  92847. * The list of procedural textures added to the scene
  92848. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92849. */
  92850. proceduralTextures: Array<ProceduralTexture>;
  92851. }
  92852. /**
  92853. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92854. * in a given scene.
  92855. */
  92856. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92857. /**
  92858. * The component name helpfull to identify the component in the list of scene components.
  92859. */
  92860. readonly name: string;
  92861. /**
  92862. * The scene the component belongs to.
  92863. */
  92864. scene: Scene;
  92865. /**
  92866. * Creates a new instance of the component for the given scene
  92867. * @param scene Defines the scene to register the component in
  92868. */
  92869. constructor(scene: Scene);
  92870. /**
  92871. * Registers the component in a given scene
  92872. */
  92873. register(): void;
  92874. /**
  92875. * Rebuilds the elements related to this component in case of
  92876. * context lost for instance.
  92877. */
  92878. rebuild(): void;
  92879. /**
  92880. * Disposes the component and the associated ressources.
  92881. */
  92882. dispose(): void;
  92883. private _beforeClear;
  92884. }
  92885. }
  92886. declare module BABYLON {
  92887. interface ThinEngine {
  92888. /**
  92889. * Creates a new render target cube texture
  92890. * @param size defines the size of the texture
  92891. * @param options defines the options used to create the texture
  92892. * @returns a new render target cube texture stored in an InternalTexture
  92893. */
  92894. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92895. }
  92896. }
  92897. declare module BABYLON {
  92898. /** @hidden */
  92899. export var proceduralVertexShader: {
  92900. name: string;
  92901. shader: string;
  92902. };
  92903. }
  92904. declare module BABYLON {
  92905. /**
  92906. * 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.
  92907. * This is the base class of any Procedural texture and contains most of the shareable code.
  92908. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92909. */
  92910. export class ProceduralTexture extends Texture {
  92911. /**
  92912. * Define if the texture is enabled or not (disabled texture will not render)
  92913. */
  92914. isEnabled: boolean;
  92915. /**
  92916. * Define if the texture must be cleared before rendering (default is true)
  92917. */
  92918. autoClear: boolean;
  92919. /**
  92920. * Callback called when the texture is generated
  92921. */
  92922. onGenerated: () => void;
  92923. /**
  92924. * Event raised when the texture is generated
  92925. */
  92926. onGeneratedObservable: Observable<ProceduralTexture>;
  92927. /**
  92928. * Event raised before the texture is generated
  92929. */
  92930. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92931. /**
  92932. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92933. */
  92934. nodeMaterialSource: Nullable<NodeMaterial>;
  92935. /** @hidden */
  92936. _generateMipMaps: boolean;
  92937. /** @hidden **/
  92938. _effect: Effect;
  92939. /** @hidden */
  92940. _textures: {
  92941. [key: string]: Texture;
  92942. };
  92943. /** @hidden */
  92944. protected _fallbackTexture: Nullable<Texture>;
  92945. private _size;
  92946. private _currentRefreshId;
  92947. private _frameId;
  92948. private _refreshRate;
  92949. private _vertexBuffers;
  92950. private _indexBuffer;
  92951. private _uniforms;
  92952. private _samplers;
  92953. private _fragment;
  92954. private _floats;
  92955. private _ints;
  92956. private _floatsArrays;
  92957. private _colors3;
  92958. private _colors4;
  92959. private _vectors2;
  92960. private _vectors3;
  92961. private _matrices;
  92962. private _fallbackTextureUsed;
  92963. private _fullEngine;
  92964. private _cachedDefines;
  92965. private _contentUpdateId;
  92966. private _contentData;
  92967. /**
  92968. * Instantiates a new procedural texture.
  92969. * 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.
  92970. * This is the base class of any Procedural texture and contains most of the shareable code.
  92971. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92972. * @param name Define the name of the texture
  92973. * @param size Define the size of the texture to create
  92974. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92975. * @param scene Define the scene the texture belongs to
  92976. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92977. * @param generateMipMaps Define if the texture should creates mip maps or not
  92978. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92979. * @param textureType The FBO internal texture type
  92980. */
  92981. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  92982. /**
  92983. * The effect that is created when initializing the post process.
  92984. * @returns The created effect corresponding the the postprocess.
  92985. */
  92986. getEffect(): Effect;
  92987. /**
  92988. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92989. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92990. */
  92991. getContent(): Nullable<ArrayBufferView>;
  92992. private _createIndexBuffer;
  92993. /** @hidden */
  92994. _rebuild(): void;
  92995. /**
  92996. * Resets the texture in order to recreate its associated resources.
  92997. * This can be called in case of context loss
  92998. */
  92999. reset(): void;
  93000. protected _getDefines(): string;
  93001. /**
  93002. * Is the texture ready to be used ? (rendered at least once)
  93003. * @returns true if ready, otherwise, false.
  93004. */
  93005. isReady(): boolean;
  93006. /**
  93007. * Resets the refresh counter of the texture and start bak from scratch.
  93008. * Could be useful to regenerate the texture if it is setup to render only once.
  93009. */
  93010. resetRefreshCounter(): void;
  93011. /**
  93012. * Set the fragment shader to use in order to render the texture.
  93013. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  93014. */
  93015. setFragment(fragment: any): void;
  93016. /**
  93017. * Define the refresh rate of the texture or the rendering frequency.
  93018. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93019. */
  93020. get refreshRate(): number;
  93021. set refreshRate(value: number);
  93022. /** @hidden */
  93023. _shouldRender(): boolean;
  93024. /**
  93025. * Get the size the texture is rendering at.
  93026. * @returns the size (on cube texture it is always squared)
  93027. */
  93028. getRenderSize(): RenderTargetTextureSize;
  93029. /**
  93030. * Resize the texture to new value.
  93031. * @param size Define the new size the texture should have
  93032. * @param generateMipMaps Define whether the new texture should create mip maps
  93033. */
  93034. resize(size: number, generateMipMaps: boolean): void;
  93035. private _checkUniform;
  93036. /**
  93037. * Set a texture in the shader program used to render.
  93038. * @param name Define the name of the uniform samplers as defined in the shader
  93039. * @param texture Define the texture to bind to this sampler
  93040. * @return the texture itself allowing "fluent" like uniform updates
  93041. */
  93042. setTexture(name: string, texture: Texture): ProceduralTexture;
  93043. /**
  93044. * Set a float in the shader.
  93045. * @param name Define the name of the uniform as defined in the shader
  93046. * @param value Define the value to give to the uniform
  93047. * @return the texture itself allowing "fluent" like uniform updates
  93048. */
  93049. setFloat(name: string, value: number): ProceduralTexture;
  93050. /**
  93051. * Set a int in the shader.
  93052. * @param name Define the name of the uniform as defined in the shader
  93053. * @param value Define the value to give to the uniform
  93054. * @return the texture itself allowing "fluent" like uniform updates
  93055. */
  93056. setInt(name: string, value: number): ProceduralTexture;
  93057. /**
  93058. * Set an array of floats in the shader.
  93059. * @param name Define the name of the uniform as defined in the shader
  93060. * @param value Define the value to give to the uniform
  93061. * @return the texture itself allowing "fluent" like uniform updates
  93062. */
  93063. setFloats(name: string, value: number[]): ProceduralTexture;
  93064. /**
  93065. * Set a vec3 in the shader from a Color3.
  93066. * @param name Define the name of the uniform as defined in the shader
  93067. * @param value Define the value to give to the uniform
  93068. * @return the texture itself allowing "fluent" like uniform updates
  93069. */
  93070. setColor3(name: string, value: Color3): ProceduralTexture;
  93071. /**
  93072. * Set a vec4 in the shader from a Color4.
  93073. * @param name Define the name of the uniform as defined in the shader
  93074. * @param value Define the value to give to the uniform
  93075. * @return the texture itself allowing "fluent" like uniform updates
  93076. */
  93077. setColor4(name: string, value: Color4): ProceduralTexture;
  93078. /**
  93079. * Set a vec2 in the shader from a Vector2.
  93080. * @param name Define the name of the uniform as defined in the shader
  93081. * @param value Define the value to give to the uniform
  93082. * @return the texture itself allowing "fluent" like uniform updates
  93083. */
  93084. setVector2(name: string, value: Vector2): ProceduralTexture;
  93085. /**
  93086. * Set a vec3 in the shader from a Vector3.
  93087. * @param name Define the name of the uniform as defined in the shader
  93088. * @param value Define the value to give to the uniform
  93089. * @return the texture itself allowing "fluent" like uniform updates
  93090. */
  93091. setVector3(name: string, value: Vector3): ProceduralTexture;
  93092. /**
  93093. * Set a mat4 in the shader from a MAtrix.
  93094. * @param name Define the name of the uniform as defined in the shader
  93095. * @param value Define the value to give to the uniform
  93096. * @return the texture itself allowing "fluent" like uniform updates
  93097. */
  93098. setMatrix(name: string, value: Matrix): ProceduralTexture;
  93099. /**
  93100. * Render the texture to its associated render target.
  93101. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  93102. */
  93103. render(useCameraPostProcess?: boolean): void;
  93104. /**
  93105. * Clone the texture.
  93106. * @returns the cloned texture
  93107. */
  93108. clone(): ProceduralTexture;
  93109. /**
  93110. * Dispose the texture and release its asoociated resources.
  93111. */
  93112. dispose(): void;
  93113. }
  93114. }
  93115. declare module BABYLON {
  93116. /**
  93117. * This represents the base class for particle system in Babylon.
  93118. * 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.
  93119. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93120. * @example https://doc.babylonjs.com/babylon101/particles
  93121. */
  93122. export class BaseParticleSystem {
  93123. /**
  93124. * Source color is added to the destination color without alpha affecting the result
  93125. */
  93126. static BLENDMODE_ONEONE: number;
  93127. /**
  93128. * Blend current color and particle color using particle’s alpha
  93129. */
  93130. static BLENDMODE_STANDARD: number;
  93131. /**
  93132. * Add current color and particle color multiplied by particle’s alpha
  93133. */
  93134. static BLENDMODE_ADD: number;
  93135. /**
  93136. * Multiply current color with particle color
  93137. */
  93138. static BLENDMODE_MULTIPLY: number;
  93139. /**
  93140. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  93141. */
  93142. static BLENDMODE_MULTIPLYADD: number;
  93143. /**
  93144. * List of animations used by the particle system.
  93145. */
  93146. animations: Animation[];
  93147. /**
  93148. * Gets or sets the unique id of the particle system
  93149. */
  93150. uniqueId: number;
  93151. /**
  93152. * The id of the Particle system.
  93153. */
  93154. id: string;
  93155. /**
  93156. * The friendly name of the Particle system.
  93157. */
  93158. name: string;
  93159. /**
  93160. * Snippet ID if the particle system was created from the snippet server
  93161. */
  93162. snippetId: string;
  93163. /**
  93164. * The rendering group used by the Particle system to chose when to render.
  93165. */
  93166. renderingGroupId: number;
  93167. /**
  93168. * The emitter represents the Mesh or position we are attaching the particle system to.
  93169. */
  93170. emitter: Nullable<AbstractMesh | Vector3>;
  93171. /**
  93172. * The maximum number of particles to emit per frame
  93173. */
  93174. emitRate: number;
  93175. /**
  93176. * If you want to launch only a few particles at once, that can be done, as well.
  93177. */
  93178. manualEmitCount: number;
  93179. /**
  93180. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  93181. */
  93182. updateSpeed: number;
  93183. /**
  93184. * The amount of time the particle system is running (depends of the overall update speed).
  93185. */
  93186. targetStopDuration: number;
  93187. /**
  93188. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  93189. */
  93190. disposeOnStop: boolean;
  93191. /**
  93192. * Minimum power of emitting particles.
  93193. */
  93194. minEmitPower: number;
  93195. /**
  93196. * Maximum power of emitting particles.
  93197. */
  93198. maxEmitPower: number;
  93199. /**
  93200. * Minimum life time of emitting particles.
  93201. */
  93202. minLifeTime: number;
  93203. /**
  93204. * Maximum life time of emitting particles.
  93205. */
  93206. maxLifeTime: number;
  93207. /**
  93208. * Minimum Size of emitting particles.
  93209. */
  93210. minSize: number;
  93211. /**
  93212. * Maximum Size of emitting particles.
  93213. */
  93214. maxSize: number;
  93215. /**
  93216. * Minimum scale of emitting particles on X axis.
  93217. */
  93218. minScaleX: number;
  93219. /**
  93220. * Maximum scale of emitting particles on X axis.
  93221. */
  93222. maxScaleX: number;
  93223. /**
  93224. * Minimum scale of emitting particles on Y axis.
  93225. */
  93226. minScaleY: number;
  93227. /**
  93228. * Maximum scale of emitting particles on Y axis.
  93229. */
  93230. maxScaleY: number;
  93231. /**
  93232. * Gets or sets the minimal initial rotation in radians.
  93233. */
  93234. minInitialRotation: number;
  93235. /**
  93236. * Gets or sets the maximal initial rotation in radians.
  93237. */
  93238. maxInitialRotation: number;
  93239. /**
  93240. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  93241. */
  93242. minAngularSpeed: number;
  93243. /**
  93244. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  93245. */
  93246. maxAngularSpeed: number;
  93247. /**
  93248. * The texture used to render each particle. (this can be a spritesheet)
  93249. */
  93250. particleTexture: Nullable<BaseTexture>;
  93251. /**
  93252. * The layer mask we are rendering the particles through.
  93253. */
  93254. layerMask: number;
  93255. /**
  93256. * This can help using your own shader to render the particle system.
  93257. * The according effect will be created
  93258. */
  93259. customShader: any;
  93260. /**
  93261. * By default particle system starts as soon as they are created. This prevents the
  93262. * automatic start to happen and let you decide when to start emitting particles.
  93263. */
  93264. preventAutoStart: boolean;
  93265. private _noiseTexture;
  93266. /**
  93267. * Gets or sets a texture used to add random noise to particle positions
  93268. */
  93269. get noiseTexture(): Nullable<ProceduralTexture>;
  93270. set noiseTexture(value: Nullable<ProceduralTexture>);
  93271. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  93272. noiseStrength: Vector3;
  93273. /**
  93274. * Callback triggered when the particle animation is ending.
  93275. */
  93276. onAnimationEnd: Nullable<() => void>;
  93277. /**
  93278. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  93279. */
  93280. blendMode: number;
  93281. /**
  93282. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  93283. * to override the particles.
  93284. */
  93285. forceDepthWrite: boolean;
  93286. /** 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 */
  93287. preWarmCycles: number;
  93288. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  93289. preWarmStepOffset: number;
  93290. /**
  93291. * 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)
  93292. */
  93293. spriteCellChangeSpeed: number;
  93294. /**
  93295. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  93296. */
  93297. startSpriteCellID: number;
  93298. /**
  93299. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  93300. */
  93301. endSpriteCellID: number;
  93302. /**
  93303. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  93304. */
  93305. spriteCellWidth: number;
  93306. /**
  93307. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  93308. */
  93309. spriteCellHeight: number;
  93310. /**
  93311. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  93312. */
  93313. spriteRandomStartCell: boolean;
  93314. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  93315. translationPivot: Vector2;
  93316. /** @hidden */
  93317. protected _isAnimationSheetEnabled: boolean;
  93318. /**
  93319. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  93320. */
  93321. beginAnimationOnStart: boolean;
  93322. /**
  93323. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  93324. */
  93325. beginAnimationFrom: number;
  93326. /**
  93327. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  93328. */
  93329. beginAnimationTo: number;
  93330. /**
  93331. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  93332. */
  93333. beginAnimationLoop: boolean;
  93334. /**
  93335. * Gets or sets a world offset applied to all particles
  93336. */
  93337. worldOffset: Vector3;
  93338. /**
  93339. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  93340. */
  93341. get isAnimationSheetEnabled(): boolean;
  93342. set isAnimationSheetEnabled(value: boolean);
  93343. /**
  93344. * Get hosting scene
  93345. * @returns the scene
  93346. */
  93347. getScene(): Nullable<Scene>;
  93348. /**
  93349. * You can use gravity if you want to give an orientation to your particles.
  93350. */
  93351. gravity: Vector3;
  93352. protected _colorGradients: Nullable<Array<ColorGradient>>;
  93353. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  93354. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  93355. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  93356. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  93357. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  93358. protected _dragGradients: Nullable<Array<FactorGradient>>;
  93359. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  93360. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  93361. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  93362. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  93363. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  93364. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  93365. /**
  93366. * Defines the delay in milliseconds before starting the system (0 by default)
  93367. */
  93368. startDelay: number;
  93369. /**
  93370. * Gets the current list of drag gradients.
  93371. * You must use addDragGradient and removeDragGradient to udpate this list
  93372. * @returns the list of drag gradients
  93373. */
  93374. getDragGradients(): Nullable<Array<FactorGradient>>;
  93375. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  93376. limitVelocityDamping: number;
  93377. /**
  93378. * Gets the current list of limit velocity gradients.
  93379. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  93380. * @returns the list of limit velocity gradients
  93381. */
  93382. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  93383. /**
  93384. * Gets the current list of color gradients.
  93385. * You must use addColorGradient and removeColorGradient to udpate this list
  93386. * @returns the list of color gradients
  93387. */
  93388. getColorGradients(): Nullable<Array<ColorGradient>>;
  93389. /**
  93390. * Gets the current list of size gradients.
  93391. * You must use addSizeGradient and removeSizeGradient to udpate this list
  93392. * @returns the list of size gradients
  93393. */
  93394. getSizeGradients(): Nullable<Array<FactorGradient>>;
  93395. /**
  93396. * Gets the current list of color remap gradients.
  93397. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  93398. * @returns the list of color remap gradients
  93399. */
  93400. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  93401. /**
  93402. * Gets the current list of alpha remap gradients.
  93403. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  93404. * @returns the list of alpha remap gradients
  93405. */
  93406. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  93407. /**
  93408. * Gets the current list of life time gradients.
  93409. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  93410. * @returns the list of life time gradients
  93411. */
  93412. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  93413. /**
  93414. * Gets the current list of angular speed gradients.
  93415. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  93416. * @returns the list of angular speed gradients
  93417. */
  93418. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  93419. /**
  93420. * Gets the current list of velocity gradients.
  93421. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  93422. * @returns the list of velocity gradients
  93423. */
  93424. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  93425. /**
  93426. * Gets the current list of start size gradients.
  93427. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  93428. * @returns the list of start size gradients
  93429. */
  93430. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  93431. /**
  93432. * Gets the current list of emit rate gradients.
  93433. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  93434. * @returns the list of emit rate gradients
  93435. */
  93436. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  93437. /**
  93438. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93439. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93440. */
  93441. get direction1(): Vector3;
  93442. set direction1(value: Vector3);
  93443. /**
  93444. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93445. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93446. */
  93447. get direction2(): Vector3;
  93448. set direction2(value: Vector3);
  93449. /**
  93450. * 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.
  93451. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93452. */
  93453. get minEmitBox(): Vector3;
  93454. set minEmitBox(value: Vector3);
  93455. /**
  93456. * 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.
  93457. * This only works when particleEmitterTyps is a BoxParticleEmitter
  93458. */
  93459. get maxEmitBox(): Vector3;
  93460. set maxEmitBox(value: Vector3);
  93461. /**
  93462. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93463. */
  93464. color1: Color4;
  93465. /**
  93466. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  93467. */
  93468. color2: Color4;
  93469. /**
  93470. * Color the particle will have at the end of its lifetime
  93471. */
  93472. colorDead: Color4;
  93473. /**
  93474. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  93475. */
  93476. textureMask: Color4;
  93477. /**
  93478. * The particle emitter type defines the emitter used by the particle system.
  93479. * It can be for example box, sphere, or cone...
  93480. */
  93481. particleEmitterType: IParticleEmitterType;
  93482. /** @hidden */
  93483. _isSubEmitter: boolean;
  93484. /**
  93485. * Gets or sets the billboard mode to use when isBillboardBased = true.
  93486. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  93487. */
  93488. billboardMode: number;
  93489. protected _isBillboardBased: boolean;
  93490. /**
  93491. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  93492. */
  93493. get isBillboardBased(): boolean;
  93494. set isBillboardBased(value: boolean);
  93495. /**
  93496. * The scene the particle system belongs to.
  93497. */
  93498. protected _scene: Nullable<Scene>;
  93499. /**
  93500. * The engine the particle system belongs to.
  93501. */
  93502. protected _engine: ThinEngine;
  93503. /**
  93504. * Local cache of defines for image processing.
  93505. */
  93506. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  93507. /**
  93508. * Default configuration related to image processing available in the standard Material.
  93509. */
  93510. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  93511. /**
  93512. * Gets the image processing configuration used either in this material.
  93513. */
  93514. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  93515. /**
  93516. * Sets the Default image processing configuration used either in the this material.
  93517. *
  93518. * If sets to null, the scene one is in use.
  93519. */
  93520. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  93521. /**
  93522. * Attaches a new image processing configuration to the Standard Material.
  93523. * @param configuration
  93524. */
  93525. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  93526. /** @hidden */
  93527. protected _reset(): void;
  93528. /** @hidden */
  93529. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  93530. /**
  93531. * Instantiates a particle system.
  93532. * 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.
  93533. * @param name The name of the particle system
  93534. */
  93535. constructor(name: string);
  93536. /**
  93537. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  93538. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93539. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93540. * @returns the emitter
  93541. */
  93542. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  93543. /**
  93544. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  93545. * @param radius The radius of the hemisphere to emit from
  93546. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93547. * @returns the emitter
  93548. */
  93549. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  93550. /**
  93551. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  93552. * @param radius The radius of the sphere to emit from
  93553. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  93554. * @returns the emitter
  93555. */
  93556. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  93557. /**
  93558. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  93559. * @param radius The radius of the sphere to emit from
  93560. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  93561. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  93562. * @returns the emitter
  93563. */
  93564. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  93565. /**
  93566. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  93567. * @param radius The radius of the emission cylinder
  93568. * @param height The height of the emission cylinder
  93569. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  93570. * @param directionRandomizer How much to randomize the particle direction [0-1]
  93571. * @returns the emitter
  93572. */
  93573. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  93574. /**
  93575. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  93576. * @param radius The radius of the cylinder to emit from
  93577. * @param height The height of the emission cylinder
  93578. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93579. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  93580. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  93581. * @returns the emitter
  93582. */
  93583. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  93584. /**
  93585. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  93586. * @param radius The radius of the cone to emit from
  93587. * @param angle The base angle of the cone
  93588. * @returns the emitter
  93589. */
  93590. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  93591. /**
  93592. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  93593. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  93594. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  93595. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93596. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  93597. * @returns the emitter
  93598. */
  93599. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  93600. }
  93601. }
  93602. declare module BABYLON {
  93603. /**
  93604. * Type of sub emitter
  93605. */
  93606. export enum SubEmitterType {
  93607. /**
  93608. * Attached to the particle over it's lifetime
  93609. */
  93610. ATTACHED = 0,
  93611. /**
  93612. * Created when the particle dies
  93613. */
  93614. END = 1
  93615. }
  93616. /**
  93617. * Sub emitter class used to emit particles from an existing particle
  93618. */
  93619. export class SubEmitter {
  93620. /**
  93621. * the particle system to be used by the sub emitter
  93622. */
  93623. particleSystem: ParticleSystem;
  93624. /**
  93625. * Type of the submitter (Default: END)
  93626. */
  93627. type: SubEmitterType;
  93628. /**
  93629. * 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)
  93630. * Note: This only is supported when using an emitter of type Mesh
  93631. */
  93632. inheritDirection: boolean;
  93633. /**
  93634. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  93635. */
  93636. inheritedVelocityAmount: number;
  93637. /**
  93638. * Creates a sub emitter
  93639. * @param particleSystem the particle system to be used by the sub emitter
  93640. */
  93641. constructor(
  93642. /**
  93643. * the particle system to be used by the sub emitter
  93644. */
  93645. particleSystem: ParticleSystem);
  93646. /**
  93647. * Clones the sub emitter
  93648. * @returns the cloned sub emitter
  93649. */
  93650. clone(): SubEmitter;
  93651. /**
  93652. * Serialize current object to a JSON object
  93653. * @returns the serialized object
  93654. */
  93655. serialize(): any;
  93656. /** @hidden */
  93657. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  93658. /**
  93659. * Creates a new SubEmitter from a serialized JSON version
  93660. * @param serializationObject defines the JSON object to read from
  93661. * @param sceneOrEngine defines the hosting scene or the hosting engine
  93662. * @param rootUrl defines the rootUrl for data loading
  93663. * @returns a new SubEmitter
  93664. */
  93665. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  93666. /** Release associated resources */
  93667. dispose(): void;
  93668. }
  93669. }
  93670. declare module BABYLON {
  93671. /** @hidden */
  93672. export var imageProcessingDeclaration: {
  93673. name: string;
  93674. shader: string;
  93675. };
  93676. }
  93677. declare module BABYLON {
  93678. /** @hidden */
  93679. export var imageProcessingFunctions: {
  93680. name: string;
  93681. shader: string;
  93682. };
  93683. }
  93684. declare module BABYLON {
  93685. /** @hidden */
  93686. export var particlesPixelShader: {
  93687. name: string;
  93688. shader: string;
  93689. };
  93690. }
  93691. declare module BABYLON {
  93692. /** @hidden */
  93693. export var particlesVertexShader: {
  93694. name: string;
  93695. shader: string;
  93696. };
  93697. }
  93698. declare module BABYLON {
  93699. /**
  93700. * Interface used to define entities containing multiple clip planes
  93701. */
  93702. export interface IClipPlanesHolder {
  93703. /**
  93704. * Gets or sets the active clipplane 1
  93705. */
  93706. clipPlane: Nullable<Plane>;
  93707. /**
  93708. * Gets or sets the active clipplane 2
  93709. */
  93710. clipPlane2: Nullable<Plane>;
  93711. /**
  93712. * Gets or sets the active clipplane 3
  93713. */
  93714. clipPlane3: Nullable<Plane>;
  93715. /**
  93716. * Gets or sets the active clipplane 4
  93717. */
  93718. clipPlane4: Nullable<Plane>;
  93719. /**
  93720. * Gets or sets the active clipplane 5
  93721. */
  93722. clipPlane5: Nullable<Plane>;
  93723. /**
  93724. * Gets or sets the active clipplane 6
  93725. */
  93726. clipPlane6: Nullable<Plane>;
  93727. }
  93728. }
  93729. declare module BABYLON {
  93730. /**
  93731. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93732. *
  93733. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93734. *
  93735. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93736. */
  93737. export class ThinMaterialHelper {
  93738. /**
  93739. * Binds the clip plane information from the holder to the effect.
  93740. * @param effect The effect we are binding the data to
  93741. * @param holder The entity containing the clip plane information
  93742. */
  93743. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93744. }
  93745. }
  93746. declare module BABYLON {
  93747. interface ThinEngine {
  93748. /**
  93749. * Sets alpha constants used by some alpha blending modes
  93750. * @param r defines the red component
  93751. * @param g defines the green component
  93752. * @param b defines the blue component
  93753. * @param a defines the alpha component
  93754. */
  93755. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93756. /**
  93757. * Sets the current alpha mode
  93758. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93759. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93760. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93761. */
  93762. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93763. /**
  93764. * Gets the current alpha mode
  93765. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93766. * @returns the current alpha mode
  93767. */
  93768. getAlphaMode(): number;
  93769. /**
  93770. * Sets the current alpha equation
  93771. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93772. */
  93773. setAlphaEquation(equation: number): void;
  93774. /**
  93775. * Gets the current alpha equation.
  93776. * @returns the current alpha equation
  93777. */
  93778. getAlphaEquation(): number;
  93779. }
  93780. }
  93781. declare module BABYLON {
  93782. /**
  93783. * This represents a particle system in Babylon.
  93784. * 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.
  93785. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93786. * @example https://doc.babylonjs.com/babylon101/particles
  93787. */
  93788. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93789. /**
  93790. * Billboard mode will only apply to Y axis
  93791. */
  93792. static readonly BILLBOARDMODE_Y: number;
  93793. /**
  93794. * Billboard mode will apply to all axes
  93795. */
  93796. static readonly BILLBOARDMODE_ALL: number;
  93797. /**
  93798. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93799. */
  93800. static readonly BILLBOARDMODE_STRETCHED: number;
  93801. /**
  93802. * This function can be defined to provide custom update for active particles.
  93803. * This function will be called instead of regular update (age, position, color, etc.).
  93804. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93805. */
  93806. updateFunction: (particles: Particle[]) => void;
  93807. private _emitterWorldMatrix;
  93808. /**
  93809. * This function can be defined to specify initial direction for every new particle.
  93810. * It by default use the emitterType defined function
  93811. */
  93812. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93813. /**
  93814. * This function can be defined to specify initial position for every new particle.
  93815. * It by default use the emitterType defined function
  93816. */
  93817. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93818. /**
  93819. * @hidden
  93820. */
  93821. _inheritedVelocityOffset: Vector3;
  93822. /**
  93823. * An event triggered when the system is disposed
  93824. */
  93825. onDisposeObservable: Observable<IParticleSystem>;
  93826. /**
  93827. * An event triggered when the system is stopped
  93828. */
  93829. onStoppedObservable: Observable<IParticleSystem>;
  93830. private _onDisposeObserver;
  93831. /**
  93832. * Sets a callback that will be triggered when the system is disposed
  93833. */
  93834. set onDispose(callback: () => void);
  93835. private _particles;
  93836. private _epsilon;
  93837. private _capacity;
  93838. private _stockParticles;
  93839. private _newPartsExcess;
  93840. private _vertexData;
  93841. private _vertexBuffer;
  93842. private _vertexBuffers;
  93843. private _spriteBuffer;
  93844. private _indexBuffer;
  93845. private _effect;
  93846. private _customEffect;
  93847. private _cachedDefines;
  93848. private _scaledColorStep;
  93849. private _colorDiff;
  93850. private _scaledDirection;
  93851. private _scaledGravity;
  93852. private _currentRenderId;
  93853. private _alive;
  93854. private _useInstancing;
  93855. private _vertexArrayObject;
  93856. private _started;
  93857. private _stopped;
  93858. private _actualFrame;
  93859. private _scaledUpdateSpeed;
  93860. private _vertexBufferSize;
  93861. /** @hidden */
  93862. _currentEmitRateGradient: Nullable<FactorGradient>;
  93863. /** @hidden */
  93864. _currentEmitRate1: number;
  93865. /** @hidden */
  93866. _currentEmitRate2: number;
  93867. /** @hidden */
  93868. _currentStartSizeGradient: Nullable<FactorGradient>;
  93869. /** @hidden */
  93870. _currentStartSize1: number;
  93871. /** @hidden */
  93872. _currentStartSize2: number;
  93873. private readonly _rawTextureWidth;
  93874. private _rampGradientsTexture;
  93875. private _useRampGradients;
  93876. /** Gets or sets a matrix to use to compute projection */
  93877. defaultProjectionMatrix: Matrix;
  93878. /** Gets or sets a matrix to use to compute view */
  93879. defaultViewMatrix: Matrix;
  93880. /** Gets or sets a boolean indicating that ramp gradients must be used
  93881. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93882. */
  93883. get useRampGradients(): boolean;
  93884. set useRampGradients(value: boolean);
  93885. /**
  93886. * 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.
  93887. * 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: [])
  93888. */
  93889. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93890. private _subEmitters;
  93891. /**
  93892. * @hidden
  93893. * If the particle systems emitter should be disposed when the particle system is disposed
  93894. */
  93895. _disposeEmitterOnDispose: boolean;
  93896. /**
  93897. * The current active Sub-systems, this property is used by the root particle system only.
  93898. */
  93899. activeSubSystems: Array<ParticleSystem>;
  93900. /**
  93901. * Specifies if the particles are updated in emitter local space or world space
  93902. */
  93903. isLocal: boolean;
  93904. private _rootParticleSystem;
  93905. /**
  93906. * Gets the current list of active particles
  93907. */
  93908. get particles(): Particle[];
  93909. /**
  93910. * Gets the number of particles active at the same time.
  93911. * @returns The number of active particles.
  93912. */
  93913. getActiveCount(): number;
  93914. /**
  93915. * Returns the string "ParticleSystem"
  93916. * @returns a string containing the class name
  93917. */
  93918. getClassName(): string;
  93919. /**
  93920. * Gets a boolean indicating that the system is stopping
  93921. * @returns true if the system is currently stopping
  93922. */
  93923. isStopping(): boolean;
  93924. /**
  93925. * Gets the custom effect used to render the particles
  93926. * @param blendMode Blend mode for which the effect should be retrieved
  93927. * @returns The effect
  93928. */
  93929. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93930. /**
  93931. * Sets the custom effect used to render the particles
  93932. * @param effect The effect to set
  93933. * @param blendMode Blend mode for which the effect should be set
  93934. */
  93935. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93936. /** @hidden */
  93937. private _onBeforeDrawParticlesObservable;
  93938. /**
  93939. * Observable that will be called just before the particles are drawn
  93940. */
  93941. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93942. /**
  93943. * Gets the name of the particle vertex shader
  93944. */
  93945. get vertexShaderName(): string;
  93946. /**
  93947. * Instantiates a particle system.
  93948. * 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.
  93949. * @param name The name of the particle system
  93950. * @param capacity The max number of particles alive at the same time
  93951. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93952. * @param customEffect a custom effect used to change the way particles are rendered by default
  93953. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93954. * @param epsilon Offset used to render the particles
  93955. */
  93956. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93957. private _addFactorGradient;
  93958. private _removeFactorGradient;
  93959. /**
  93960. * Adds a new life time gradient
  93961. * @param gradient defines the gradient to use (between 0 and 1)
  93962. * @param factor defines the life time factor to affect to the specified gradient
  93963. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93964. * @returns the current particle system
  93965. */
  93966. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93967. /**
  93968. * Remove a specific life time gradient
  93969. * @param gradient defines the gradient to remove
  93970. * @returns the current particle system
  93971. */
  93972. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93973. /**
  93974. * Adds a new size gradient
  93975. * @param gradient defines the gradient to use (between 0 and 1)
  93976. * @param factor defines the size factor to affect to the specified gradient
  93977. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93978. * @returns the current particle system
  93979. */
  93980. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93981. /**
  93982. * Remove a specific size gradient
  93983. * @param gradient defines the gradient to remove
  93984. * @returns the current particle system
  93985. */
  93986. removeSizeGradient(gradient: number): IParticleSystem;
  93987. /**
  93988. * Adds a new color remap gradient
  93989. * @param gradient defines the gradient to use (between 0 and 1)
  93990. * @param min defines the color remap minimal range
  93991. * @param max defines the color remap maximal range
  93992. * @returns the current particle system
  93993. */
  93994. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93995. /**
  93996. * Remove a specific color remap gradient
  93997. * @param gradient defines the gradient to remove
  93998. * @returns the current particle system
  93999. */
  94000. removeColorRemapGradient(gradient: number): IParticleSystem;
  94001. /**
  94002. * Adds a new alpha remap gradient
  94003. * @param gradient defines the gradient to use (between 0 and 1)
  94004. * @param min defines the alpha remap minimal range
  94005. * @param max defines the alpha remap maximal range
  94006. * @returns the current particle system
  94007. */
  94008. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94009. /**
  94010. * Remove a specific alpha remap gradient
  94011. * @param gradient defines the gradient to remove
  94012. * @returns the current particle system
  94013. */
  94014. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  94015. /**
  94016. * Adds a new angular speed gradient
  94017. * @param gradient defines the gradient to use (between 0 and 1)
  94018. * @param factor defines the angular speed to affect to the specified gradient
  94019. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94020. * @returns the current particle system
  94021. */
  94022. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94023. /**
  94024. * Remove a specific angular speed gradient
  94025. * @param gradient defines the gradient to remove
  94026. * @returns the current particle system
  94027. */
  94028. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94029. /**
  94030. * Adds a new velocity gradient
  94031. * @param gradient defines the gradient to use (between 0 and 1)
  94032. * @param factor defines the velocity to affect to the specified gradient
  94033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94034. * @returns the current particle system
  94035. */
  94036. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94037. /**
  94038. * Remove a specific velocity gradient
  94039. * @param gradient defines the gradient to remove
  94040. * @returns the current particle system
  94041. */
  94042. removeVelocityGradient(gradient: number): IParticleSystem;
  94043. /**
  94044. * Adds a new limit velocity gradient
  94045. * @param gradient defines the gradient to use (between 0 and 1)
  94046. * @param factor defines the limit velocity value to affect to the specified gradient
  94047. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94048. * @returns the current particle system
  94049. */
  94050. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94051. /**
  94052. * Remove a specific limit velocity gradient
  94053. * @param gradient defines the gradient to remove
  94054. * @returns the current particle system
  94055. */
  94056. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94057. /**
  94058. * Adds a new drag gradient
  94059. * @param gradient defines the gradient to use (between 0 and 1)
  94060. * @param factor defines the drag value to affect to the specified gradient
  94061. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94062. * @returns the current particle system
  94063. */
  94064. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94065. /**
  94066. * Remove a specific drag gradient
  94067. * @param gradient defines the gradient to remove
  94068. * @returns the current particle system
  94069. */
  94070. removeDragGradient(gradient: number): IParticleSystem;
  94071. /**
  94072. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94073. * @param gradient defines the gradient to use (between 0 and 1)
  94074. * @param factor defines the emit rate value to affect to the specified gradient
  94075. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94076. * @returns the current particle system
  94077. */
  94078. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94079. /**
  94080. * Remove a specific emit rate gradient
  94081. * @param gradient defines the gradient to remove
  94082. * @returns the current particle system
  94083. */
  94084. removeEmitRateGradient(gradient: number): IParticleSystem;
  94085. /**
  94086. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94087. * @param gradient defines the gradient to use (between 0 and 1)
  94088. * @param factor defines the start size value to affect to the specified gradient
  94089. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94090. * @returns the current particle system
  94091. */
  94092. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94093. /**
  94094. * Remove a specific start size gradient
  94095. * @param gradient defines the gradient to remove
  94096. * @returns the current particle system
  94097. */
  94098. removeStartSizeGradient(gradient: number): IParticleSystem;
  94099. private _createRampGradientTexture;
  94100. /**
  94101. * Gets the current list of ramp gradients.
  94102. * You must use addRampGradient and removeRampGradient to udpate this list
  94103. * @returns the list of ramp gradients
  94104. */
  94105. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94106. /** Force the system to rebuild all gradients that need to be resync */
  94107. forceRefreshGradients(): void;
  94108. private _syncRampGradientTexture;
  94109. /**
  94110. * Adds a new ramp gradient used to remap particle colors
  94111. * @param gradient defines the gradient to use (between 0 and 1)
  94112. * @param color defines the color to affect to the specified gradient
  94113. * @returns the current particle system
  94114. */
  94115. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  94116. /**
  94117. * Remove a specific ramp gradient
  94118. * @param gradient defines the gradient to remove
  94119. * @returns the current particle system
  94120. */
  94121. removeRampGradient(gradient: number): ParticleSystem;
  94122. /**
  94123. * Adds a new color gradient
  94124. * @param gradient defines the gradient to use (between 0 and 1)
  94125. * @param color1 defines the color to affect to the specified gradient
  94126. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94127. * @returns this particle system
  94128. */
  94129. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94130. /**
  94131. * Remove a specific color gradient
  94132. * @param gradient defines the gradient to remove
  94133. * @returns this particle system
  94134. */
  94135. removeColorGradient(gradient: number): IParticleSystem;
  94136. private _fetchR;
  94137. protected _reset(): void;
  94138. private _resetEffect;
  94139. private _createVertexBuffers;
  94140. private _createIndexBuffer;
  94141. /**
  94142. * Gets the maximum number of particles active at the same time.
  94143. * @returns The max number of active particles.
  94144. */
  94145. getCapacity(): number;
  94146. /**
  94147. * Gets whether there are still active particles in the system.
  94148. * @returns True if it is alive, otherwise false.
  94149. */
  94150. isAlive(): boolean;
  94151. /**
  94152. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94153. * @returns True if it has been started, otherwise false.
  94154. */
  94155. isStarted(): boolean;
  94156. private _prepareSubEmitterInternalArray;
  94157. /**
  94158. * Starts the particle system and begins to emit
  94159. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  94160. */
  94161. start(delay?: number): void;
  94162. /**
  94163. * Stops the particle system.
  94164. * @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.
  94165. */
  94166. stop(stopSubEmitters?: boolean): void;
  94167. /**
  94168. * Remove all active particles
  94169. */
  94170. reset(): void;
  94171. /**
  94172. * @hidden (for internal use only)
  94173. */
  94174. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  94175. /**
  94176. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  94177. * Its lifetime will start back at 0.
  94178. */
  94179. recycleParticle: (particle: Particle) => void;
  94180. private _stopSubEmitters;
  94181. private _createParticle;
  94182. private _removeFromRoot;
  94183. private _emitFromParticle;
  94184. private _update;
  94185. /** @hidden */
  94186. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  94187. /** @hidden */
  94188. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  94189. /**
  94190. * Fill the defines array according to the current settings of the particle system
  94191. * @param defines Array to be updated
  94192. * @param blendMode blend mode to take into account when updating the array
  94193. */
  94194. fillDefines(defines: Array<string>, blendMode: number): void;
  94195. /**
  94196. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94197. * @param uniforms Uniforms array to fill
  94198. * @param attributes Attributes array to fill
  94199. * @param samplers Samplers array to fill
  94200. */
  94201. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94202. /** @hidden */
  94203. private _getEffect;
  94204. /**
  94205. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  94206. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  94207. */
  94208. animate(preWarmOnly?: boolean): void;
  94209. private _appendParticleVertices;
  94210. /**
  94211. * Rebuilds the particle system.
  94212. */
  94213. rebuild(): void;
  94214. /**
  94215. * Is this system ready to be used/rendered
  94216. * @return true if the system is ready
  94217. */
  94218. isReady(): boolean;
  94219. private _render;
  94220. /**
  94221. * Renders the particle system in its current state.
  94222. * @returns the current number of particles
  94223. */
  94224. render(): number;
  94225. /**
  94226. * Disposes the particle system and free the associated resources
  94227. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94228. */
  94229. dispose(disposeTexture?: boolean): void;
  94230. /**
  94231. * Clones the particle system.
  94232. * @param name The name of the cloned object
  94233. * @param newEmitter The new emitter to use
  94234. * @returns the cloned particle system
  94235. */
  94236. clone(name: string, newEmitter: any): ParticleSystem;
  94237. /**
  94238. * Serializes the particle system to a JSON object
  94239. * @param serializeTexture defines if the texture must be serialized as well
  94240. * @returns the JSON object
  94241. */
  94242. serialize(serializeTexture?: boolean): any;
  94243. /** @hidden */
  94244. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  94245. /** @hidden */
  94246. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  94247. /**
  94248. * Parses a JSON object to create a particle system.
  94249. * @param parsedParticleSystem The JSON object to parse
  94250. * @param sceneOrEngine The scene or the engine to create the particle system in
  94251. * @param rootUrl The root url to use to load external dependencies like texture
  94252. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  94253. * @returns the Parsed particle system
  94254. */
  94255. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  94256. }
  94257. }
  94258. declare module BABYLON {
  94259. /**
  94260. * A particle represents one of the element emitted by a particle system.
  94261. * This is mainly define by its coordinates, direction, velocity and age.
  94262. */
  94263. export class Particle {
  94264. /**
  94265. * The particle system the particle belongs to.
  94266. */
  94267. particleSystem: ParticleSystem;
  94268. private static _Count;
  94269. /**
  94270. * Unique ID of the particle
  94271. */
  94272. id: number;
  94273. /**
  94274. * The world position of the particle in the scene.
  94275. */
  94276. position: Vector3;
  94277. /**
  94278. * The world direction of the particle in the scene.
  94279. */
  94280. direction: Vector3;
  94281. /**
  94282. * The color of the particle.
  94283. */
  94284. color: Color4;
  94285. /**
  94286. * The color change of the particle per step.
  94287. */
  94288. colorStep: Color4;
  94289. /**
  94290. * Defines how long will the life of the particle be.
  94291. */
  94292. lifeTime: number;
  94293. /**
  94294. * The current age of the particle.
  94295. */
  94296. age: number;
  94297. /**
  94298. * The current size of the particle.
  94299. */
  94300. size: number;
  94301. /**
  94302. * The current scale of the particle.
  94303. */
  94304. scale: Vector2;
  94305. /**
  94306. * The current angle of the particle.
  94307. */
  94308. angle: number;
  94309. /**
  94310. * Defines how fast is the angle changing.
  94311. */
  94312. angularSpeed: number;
  94313. /**
  94314. * Defines the cell index used by the particle to be rendered from a sprite.
  94315. */
  94316. cellIndex: number;
  94317. /**
  94318. * The information required to support color remapping
  94319. */
  94320. remapData: Vector4;
  94321. /** @hidden */
  94322. _randomCellOffset?: number;
  94323. /** @hidden */
  94324. _initialDirection: Nullable<Vector3>;
  94325. /** @hidden */
  94326. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  94327. /** @hidden */
  94328. _initialStartSpriteCellID: number;
  94329. /** @hidden */
  94330. _initialEndSpriteCellID: number;
  94331. /** @hidden */
  94332. _currentColorGradient: Nullable<ColorGradient>;
  94333. /** @hidden */
  94334. _currentColor1: Color4;
  94335. /** @hidden */
  94336. _currentColor2: Color4;
  94337. /** @hidden */
  94338. _currentSizeGradient: Nullable<FactorGradient>;
  94339. /** @hidden */
  94340. _currentSize1: number;
  94341. /** @hidden */
  94342. _currentSize2: number;
  94343. /** @hidden */
  94344. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  94345. /** @hidden */
  94346. _currentAngularSpeed1: number;
  94347. /** @hidden */
  94348. _currentAngularSpeed2: number;
  94349. /** @hidden */
  94350. _currentVelocityGradient: Nullable<FactorGradient>;
  94351. /** @hidden */
  94352. _currentVelocity1: number;
  94353. /** @hidden */
  94354. _currentVelocity2: number;
  94355. /** @hidden */
  94356. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  94357. /** @hidden */
  94358. _currentLimitVelocity1: number;
  94359. /** @hidden */
  94360. _currentLimitVelocity2: number;
  94361. /** @hidden */
  94362. _currentDragGradient: Nullable<FactorGradient>;
  94363. /** @hidden */
  94364. _currentDrag1: number;
  94365. /** @hidden */
  94366. _currentDrag2: number;
  94367. /** @hidden */
  94368. _randomNoiseCoordinates1: Vector3;
  94369. /** @hidden */
  94370. _randomNoiseCoordinates2: Vector3;
  94371. /** @hidden */
  94372. _localPosition?: Vector3;
  94373. /**
  94374. * Creates a new instance Particle
  94375. * @param particleSystem the particle system the particle belongs to
  94376. */
  94377. constructor(
  94378. /**
  94379. * The particle system the particle belongs to.
  94380. */
  94381. particleSystem: ParticleSystem);
  94382. private updateCellInfoFromSystem;
  94383. /**
  94384. * Defines how the sprite cell index is updated for the particle
  94385. */
  94386. updateCellIndex(): void;
  94387. /** @hidden */
  94388. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  94389. /** @hidden */
  94390. _inheritParticleInfoToSubEmitters(): void;
  94391. /** @hidden */
  94392. _reset(): void;
  94393. /**
  94394. * Copy the properties of particle to another one.
  94395. * @param other the particle to copy the information to.
  94396. */
  94397. copyTo(other: Particle): void;
  94398. }
  94399. }
  94400. declare module BABYLON {
  94401. /**
  94402. * Particle emitter represents a volume emitting particles.
  94403. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  94404. */
  94405. export interface IParticleEmitterType {
  94406. /**
  94407. * Called by the particle System when the direction is computed for the created particle.
  94408. * @param worldMatrix is the world matrix of the particle system
  94409. * @param directionToUpdate is the direction vector to update with the result
  94410. * @param particle is the particle we are computed the direction for
  94411. * @param isLocal defines if the direction should be set in local space
  94412. */
  94413. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94414. /**
  94415. * Called by the particle System when the position is computed for the created particle.
  94416. * @param worldMatrix is the world matrix of the particle system
  94417. * @param positionToUpdate is the position vector to update with the result
  94418. * @param particle is the particle we are computed the position for
  94419. * @param isLocal defines if the position should be set in local space
  94420. */
  94421. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94422. /**
  94423. * Clones the current emitter and returns a copy of it
  94424. * @returns the new emitter
  94425. */
  94426. clone(): IParticleEmitterType;
  94427. /**
  94428. * Called by the GPUParticleSystem to setup the update shader
  94429. * @param effect defines the update shader
  94430. */
  94431. applyToShader(effect: Effect): void;
  94432. /**
  94433. * Returns a string to use to update the GPU particles update shader
  94434. * @returns the effect defines string
  94435. */
  94436. getEffectDefines(): string;
  94437. /**
  94438. * Returns a string representing the class name
  94439. * @returns a string containing the class name
  94440. */
  94441. getClassName(): string;
  94442. /**
  94443. * Serializes the particle system to a JSON object.
  94444. * @returns the JSON object
  94445. */
  94446. serialize(): any;
  94447. /**
  94448. * Parse properties from a JSON object
  94449. * @param serializationObject defines the JSON object
  94450. * @param scene defines the hosting scene
  94451. */
  94452. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94453. }
  94454. }
  94455. declare module BABYLON {
  94456. /**
  94457. * Particle emitter emitting particles from the inside of a box.
  94458. * It emits the particles randomly between 2 given directions.
  94459. */
  94460. export class BoxParticleEmitter implements IParticleEmitterType {
  94461. /**
  94462. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94463. */
  94464. direction1: Vector3;
  94465. /**
  94466. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94467. */
  94468. direction2: Vector3;
  94469. /**
  94470. * 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.
  94471. */
  94472. minEmitBox: Vector3;
  94473. /**
  94474. * 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.
  94475. */
  94476. maxEmitBox: Vector3;
  94477. /**
  94478. * Creates a new instance BoxParticleEmitter
  94479. */
  94480. constructor();
  94481. /**
  94482. * Called by the particle System when the direction is computed for the created particle.
  94483. * @param worldMatrix is the world matrix of the particle system
  94484. * @param directionToUpdate is the direction vector to update with the result
  94485. * @param particle is the particle we are computed the direction for
  94486. * @param isLocal defines if the direction should be set in local space
  94487. */
  94488. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94489. /**
  94490. * Called by the particle System when the position is computed for the created particle.
  94491. * @param worldMatrix is the world matrix of the particle system
  94492. * @param positionToUpdate is the position vector to update with the result
  94493. * @param particle is the particle we are computed the position for
  94494. * @param isLocal defines if the position should be set in local space
  94495. */
  94496. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94497. /**
  94498. * Clones the current emitter and returns a copy of it
  94499. * @returns the new emitter
  94500. */
  94501. clone(): BoxParticleEmitter;
  94502. /**
  94503. * Called by the GPUParticleSystem to setup the update shader
  94504. * @param effect defines the update shader
  94505. */
  94506. applyToShader(effect: Effect): void;
  94507. /**
  94508. * Returns a string to use to update the GPU particles update shader
  94509. * @returns a string containng the defines string
  94510. */
  94511. getEffectDefines(): string;
  94512. /**
  94513. * Returns the string "BoxParticleEmitter"
  94514. * @returns a string containing the class name
  94515. */
  94516. getClassName(): string;
  94517. /**
  94518. * Serializes the particle system to a JSON object.
  94519. * @returns the JSON object
  94520. */
  94521. serialize(): any;
  94522. /**
  94523. * Parse properties from a JSON object
  94524. * @param serializationObject defines the JSON object
  94525. */
  94526. parse(serializationObject: any): void;
  94527. }
  94528. }
  94529. declare module BABYLON {
  94530. /**
  94531. * Particle emitter emitting particles from the inside of a cone.
  94532. * It emits the particles alongside the cone volume from the base to the particle.
  94533. * The emission direction might be randomized.
  94534. */
  94535. export class ConeParticleEmitter implements IParticleEmitterType {
  94536. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94537. directionRandomizer: number;
  94538. private _radius;
  94539. private _angle;
  94540. private _height;
  94541. /**
  94542. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  94543. */
  94544. radiusRange: number;
  94545. /**
  94546. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  94547. */
  94548. heightRange: number;
  94549. /**
  94550. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  94551. */
  94552. emitFromSpawnPointOnly: boolean;
  94553. /**
  94554. * Gets or sets the radius of the emission cone
  94555. */
  94556. get radius(): number;
  94557. set radius(value: number);
  94558. /**
  94559. * Gets or sets the angle of the emission cone
  94560. */
  94561. get angle(): number;
  94562. set angle(value: number);
  94563. private _buildHeight;
  94564. /**
  94565. * Creates a new instance ConeParticleEmitter
  94566. * @param radius the radius of the emission cone (1 by default)
  94567. * @param angle the cone base angle (PI by default)
  94568. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  94569. */
  94570. constructor(radius?: number, angle?: number,
  94571. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  94572. directionRandomizer?: number);
  94573. /**
  94574. * Called by the particle System when the direction is computed for the created particle.
  94575. * @param worldMatrix is the world matrix of the particle system
  94576. * @param directionToUpdate is the direction vector to update with the result
  94577. * @param particle is the particle we are computed the direction for
  94578. * @param isLocal defines if the direction should be set in local space
  94579. */
  94580. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94581. /**
  94582. * Called by the particle System when the position is computed for the created particle.
  94583. * @param worldMatrix is the world matrix of the particle system
  94584. * @param positionToUpdate is the position vector to update with the result
  94585. * @param particle is the particle we are computed the position for
  94586. * @param isLocal defines if the position should be set in local space
  94587. */
  94588. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94589. /**
  94590. * Clones the current emitter and returns a copy of it
  94591. * @returns the new emitter
  94592. */
  94593. clone(): ConeParticleEmitter;
  94594. /**
  94595. * Called by the GPUParticleSystem to setup the update shader
  94596. * @param effect defines the update shader
  94597. */
  94598. applyToShader(effect: Effect): void;
  94599. /**
  94600. * Returns a string to use to update the GPU particles update shader
  94601. * @returns a string containng the defines string
  94602. */
  94603. getEffectDefines(): string;
  94604. /**
  94605. * Returns the string "ConeParticleEmitter"
  94606. * @returns a string containing the class name
  94607. */
  94608. getClassName(): string;
  94609. /**
  94610. * Serializes the particle system to a JSON object.
  94611. * @returns the JSON object
  94612. */
  94613. serialize(): any;
  94614. /**
  94615. * Parse properties from a JSON object
  94616. * @param serializationObject defines the JSON object
  94617. */
  94618. parse(serializationObject: any): void;
  94619. }
  94620. }
  94621. declare module BABYLON {
  94622. /**
  94623. * Particle emitter emitting particles from the inside of a cylinder.
  94624. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  94625. */
  94626. export class CylinderParticleEmitter implements IParticleEmitterType {
  94627. /**
  94628. * The radius of the emission cylinder.
  94629. */
  94630. radius: number;
  94631. /**
  94632. * The height of the emission cylinder.
  94633. */
  94634. height: number;
  94635. /**
  94636. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94637. */
  94638. radiusRange: number;
  94639. /**
  94640. * How much to randomize the particle direction [0-1].
  94641. */
  94642. directionRandomizer: number;
  94643. /**
  94644. * Creates a new instance CylinderParticleEmitter
  94645. * @param radius the radius of the emission cylinder (1 by default)
  94646. * @param height the height of the emission cylinder (1 by default)
  94647. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94648. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94649. */
  94650. constructor(
  94651. /**
  94652. * The radius of the emission cylinder.
  94653. */
  94654. radius?: number,
  94655. /**
  94656. * The height of the emission cylinder.
  94657. */
  94658. height?: number,
  94659. /**
  94660. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94661. */
  94662. radiusRange?: number,
  94663. /**
  94664. * How much to randomize the particle direction [0-1].
  94665. */
  94666. directionRandomizer?: number);
  94667. /**
  94668. * Called by the particle System when the direction is computed for the created particle.
  94669. * @param worldMatrix is the world matrix of the particle system
  94670. * @param directionToUpdate is the direction vector to update with the result
  94671. * @param particle is the particle we are computed the direction for
  94672. * @param isLocal defines if the direction should be set in local space
  94673. */
  94674. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94675. /**
  94676. * Called by the particle System when the position is computed for the created particle.
  94677. * @param worldMatrix is the world matrix of the particle system
  94678. * @param positionToUpdate is the position vector to update with the result
  94679. * @param particle is the particle we are computed the position for
  94680. * @param isLocal defines if the position should be set in local space
  94681. */
  94682. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94683. /**
  94684. * Clones the current emitter and returns a copy of it
  94685. * @returns the new emitter
  94686. */
  94687. clone(): CylinderParticleEmitter;
  94688. /**
  94689. * Called by the GPUParticleSystem to setup the update shader
  94690. * @param effect defines the update shader
  94691. */
  94692. applyToShader(effect: Effect): void;
  94693. /**
  94694. * Returns a string to use to update the GPU particles update shader
  94695. * @returns a string containng the defines string
  94696. */
  94697. getEffectDefines(): string;
  94698. /**
  94699. * Returns the string "CylinderParticleEmitter"
  94700. * @returns a string containing the class name
  94701. */
  94702. getClassName(): string;
  94703. /**
  94704. * Serializes the particle system to a JSON object.
  94705. * @returns the JSON object
  94706. */
  94707. serialize(): any;
  94708. /**
  94709. * Parse properties from a JSON object
  94710. * @param serializationObject defines the JSON object
  94711. */
  94712. parse(serializationObject: any): void;
  94713. }
  94714. /**
  94715. * Particle emitter emitting particles from the inside of a cylinder.
  94716. * It emits the particles randomly between two vectors.
  94717. */
  94718. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94719. /**
  94720. * The min limit of the emission direction.
  94721. */
  94722. direction1: Vector3;
  94723. /**
  94724. * The max limit of the emission direction.
  94725. */
  94726. direction2: Vector3;
  94727. /**
  94728. * Creates a new instance CylinderDirectedParticleEmitter
  94729. * @param radius the radius of the emission cylinder (1 by default)
  94730. * @param height the height of the emission cylinder (1 by default)
  94731. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94732. * @param direction1 the min limit of the emission direction (up vector by default)
  94733. * @param direction2 the max limit of the emission direction (up vector by default)
  94734. */
  94735. constructor(radius?: number, height?: number, radiusRange?: number,
  94736. /**
  94737. * The min limit of the emission direction.
  94738. */
  94739. direction1?: Vector3,
  94740. /**
  94741. * The max limit of the emission direction.
  94742. */
  94743. direction2?: Vector3);
  94744. /**
  94745. * Called by the particle System when the direction is computed for the created particle.
  94746. * @param worldMatrix is the world matrix of the particle system
  94747. * @param directionToUpdate is the direction vector to update with the result
  94748. * @param particle is the particle we are computed the direction for
  94749. */
  94750. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94751. /**
  94752. * Clones the current emitter and returns a copy of it
  94753. * @returns the new emitter
  94754. */
  94755. clone(): CylinderDirectedParticleEmitter;
  94756. /**
  94757. * Called by the GPUParticleSystem to setup the update shader
  94758. * @param effect defines the update shader
  94759. */
  94760. applyToShader(effect: Effect): void;
  94761. /**
  94762. * Returns a string to use to update the GPU particles update shader
  94763. * @returns a string containng the defines string
  94764. */
  94765. getEffectDefines(): string;
  94766. /**
  94767. * Returns the string "CylinderDirectedParticleEmitter"
  94768. * @returns a string containing the class name
  94769. */
  94770. getClassName(): string;
  94771. /**
  94772. * Serializes the particle system to a JSON object.
  94773. * @returns the JSON object
  94774. */
  94775. serialize(): any;
  94776. /**
  94777. * Parse properties from a JSON object
  94778. * @param serializationObject defines the JSON object
  94779. */
  94780. parse(serializationObject: any): void;
  94781. }
  94782. }
  94783. declare module BABYLON {
  94784. /**
  94785. * Particle emitter emitting particles from the inside of a hemisphere.
  94786. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94787. */
  94788. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94789. /**
  94790. * The radius of the emission hemisphere.
  94791. */
  94792. radius: number;
  94793. /**
  94794. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94795. */
  94796. radiusRange: number;
  94797. /**
  94798. * How much to randomize the particle direction [0-1].
  94799. */
  94800. directionRandomizer: number;
  94801. /**
  94802. * Creates a new instance HemisphericParticleEmitter
  94803. * @param radius the radius of the emission hemisphere (1 by default)
  94804. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94805. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94806. */
  94807. constructor(
  94808. /**
  94809. * The radius of the emission hemisphere.
  94810. */
  94811. radius?: number,
  94812. /**
  94813. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94814. */
  94815. radiusRange?: number,
  94816. /**
  94817. * How much to randomize the particle direction [0-1].
  94818. */
  94819. directionRandomizer?: number);
  94820. /**
  94821. * Called by the particle System when the direction is computed for the created particle.
  94822. * @param worldMatrix is the world matrix of the particle system
  94823. * @param directionToUpdate is the direction vector to update with the result
  94824. * @param particle is the particle we are computed the direction for
  94825. * @param isLocal defines if the direction should be set in local space
  94826. */
  94827. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94828. /**
  94829. * Called by the particle System when the position is computed for the created particle.
  94830. * @param worldMatrix is the world matrix of the particle system
  94831. * @param positionToUpdate is the position vector to update with the result
  94832. * @param particle is the particle we are computed the position for
  94833. * @param isLocal defines if the position should be set in local space
  94834. */
  94835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94836. /**
  94837. * Clones the current emitter and returns a copy of it
  94838. * @returns the new emitter
  94839. */
  94840. clone(): HemisphericParticleEmitter;
  94841. /**
  94842. * Called by the GPUParticleSystem to setup the update shader
  94843. * @param effect defines the update shader
  94844. */
  94845. applyToShader(effect: Effect): void;
  94846. /**
  94847. * Returns a string to use to update the GPU particles update shader
  94848. * @returns a string containng the defines string
  94849. */
  94850. getEffectDefines(): string;
  94851. /**
  94852. * Returns the string "HemisphericParticleEmitter"
  94853. * @returns a string containing the class name
  94854. */
  94855. getClassName(): string;
  94856. /**
  94857. * Serializes the particle system to a JSON object.
  94858. * @returns the JSON object
  94859. */
  94860. serialize(): any;
  94861. /**
  94862. * Parse properties from a JSON object
  94863. * @param serializationObject defines the JSON object
  94864. */
  94865. parse(serializationObject: any): void;
  94866. }
  94867. }
  94868. declare module BABYLON {
  94869. /**
  94870. * Particle emitter emitting particles from a point.
  94871. * It emits the particles randomly between 2 given directions.
  94872. */
  94873. export class PointParticleEmitter implements IParticleEmitterType {
  94874. /**
  94875. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94876. */
  94877. direction1: Vector3;
  94878. /**
  94879. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94880. */
  94881. direction2: Vector3;
  94882. /**
  94883. * Creates a new instance PointParticleEmitter
  94884. */
  94885. constructor();
  94886. /**
  94887. * Called by the particle System when the direction is computed for the created particle.
  94888. * @param worldMatrix is the world matrix of the particle system
  94889. * @param directionToUpdate is the direction vector to update with the result
  94890. * @param particle is the particle we are computed the direction for
  94891. * @param isLocal defines if the direction should be set in local space
  94892. */
  94893. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94894. /**
  94895. * Called by the particle System when the position is computed for the created particle.
  94896. * @param worldMatrix is the world matrix of the particle system
  94897. * @param positionToUpdate is the position vector to update with the result
  94898. * @param particle is the particle we are computed the position for
  94899. * @param isLocal defines if the position should be set in local space
  94900. */
  94901. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94902. /**
  94903. * Clones the current emitter and returns a copy of it
  94904. * @returns the new emitter
  94905. */
  94906. clone(): PointParticleEmitter;
  94907. /**
  94908. * Called by the GPUParticleSystem to setup the update shader
  94909. * @param effect defines the update shader
  94910. */
  94911. applyToShader(effect: Effect): void;
  94912. /**
  94913. * Returns a string to use to update the GPU particles update shader
  94914. * @returns a string containng the defines string
  94915. */
  94916. getEffectDefines(): string;
  94917. /**
  94918. * Returns the string "PointParticleEmitter"
  94919. * @returns a string containing the class name
  94920. */
  94921. getClassName(): string;
  94922. /**
  94923. * Serializes the particle system to a JSON object.
  94924. * @returns the JSON object
  94925. */
  94926. serialize(): any;
  94927. /**
  94928. * Parse properties from a JSON object
  94929. * @param serializationObject defines the JSON object
  94930. */
  94931. parse(serializationObject: any): void;
  94932. }
  94933. }
  94934. declare module BABYLON {
  94935. /**
  94936. * Particle emitter emitting particles from the inside of a sphere.
  94937. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94938. */
  94939. export class SphereParticleEmitter implements IParticleEmitterType {
  94940. /**
  94941. * The radius of the emission sphere.
  94942. */
  94943. radius: number;
  94944. /**
  94945. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94946. */
  94947. radiusRange: number;
  94948. /**
  94949. * How much to randomize the particle direction [0-1].
  94950. */
  94951. directionRandomizer: number;
  94952. /**
  94953. * Creates a new instance SphereParticleEmitter
  94954. * @param radius the radius of the emission sphere (1 by default)
  94955. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94956. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94957. */
  94958. constructor(
  94959. /**
  94960. * The radius of the emission sphere.
  94961. */
  94962. radius?: number,
  94963. /**
  94964. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94965. */
  94966. radiusRange?: number,
  94967. /**
  94968. * How much to randomize the particle direction [0-1].
  94969. */
  94970. directionRandomizer?: number);
  94971. /**
  94972. * Called by the particle System when the direction is computed for the created particle.
  94973. * @param worldMatrix is the world matrix of the particle system
  94974. * @param directionToUpdate is the direction vector to update with the result
  94975. * @param particle is the particle we are computed the direction for
  94976. * @param isLocal defines if the direction should be set in local space
  94977. */
  94978. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94979. /**
  94980. * Called by the particle System when the position is computed for the created particle.
  94981. * @param worldMatrix is the world matrix of the particle system
  94982. * @param positionToUpdate is the position vector to update with the result
  94983. * @param particle is the particle we are computed the position for
  94984. * @param isLocal defines if the position should be set in local space
  94985. */
  94986. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94987. /**
  94988. * Clones the current emitter and returns a copy of it
  94989. * @returns the new emitter
  94990. */
  94991. clone(): SphereParticleEmitter;
  94992. /**
  94993. * Called by the GPUParticleSystem to setup the update shader
  94994. * @param effect defines the update shader
  94995. */
  94996. applyToShader(effect: Effect): void;
  94997. /**
  94998. * Returns a string to use to update the GPU particles update shader
  94999. * @returns a string containng the defines string
  95000. */
  95001. getEffectDefines(): string;
  95002. /**
  95003. * Returns the string "SphereParticleEmitter"
  95004. * @returns a string containing the class name
  95005. */
  95006. getClassName(): string;
  95007. /**
  95008. * Serializes the particle system to a JSON object.
  95009. * @returns the JSON object
  95010. */
  95011. serialize(): any;
  95012. /**
  95013. * Parse properties from a JSON object
  95014. * @param serializationObject defines the JSON object
  95015. */
  95016. parse(serializationObject: any): void;
  95017. }
  95018. /**
  95019. * Particle emitter emitting particles from the inside of a sphere.
  95020. * It emits the particles randomly between two vectors.
  95021. */
  95022. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  95023. /**
  95024. * The min limit of the emission direction.
  95025. */
  95026. direction1: Vector3;
  95027. /**
  95028. * The max limit of the emission direction.
  95029. */
  95030. direction2: Vector3;
  95031. /**
  95032. * Creates a new instance SphereDirectedParticleEmitter
  95033. * @param radius the radius of the emission sphere (1 by default)
  95034. * @param direction1 the min limit of the emission direction (up vector by default)
  95035. * @param direction2 the max limit of the emission direction (up vector by default)
  95036. */
  95037. constructor(radius?: number,
  95038. /**
  95039. * The min limit of the emission direction.
  95040. */
  95041. direction1?: Vector3,
  95042. /**
  95043. * The max limit of the emission direction.
  95044. */
  95045. direction2?: Vector3);
  95046. /**
  95047. * Called by the particle System when the direction is computed for the created particle.
  95048. * @param worldMatrix is the world matrix of the particle system
  95049. * @param directionToUpdate is the direction vector to update with the result
  95050. * @param particle is the particle we are computed the direction for
  95051. */
  95052. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  95053. /**
  95054. * Clones the current emitter and returns a copy of it
  95055. * @returns the new emitter
  95056. */
  95057. clone(): SphereDirectedParticleEmitter;
  95058. /**
  95059. * Called by the GPUParticleSystem to setup the update shader
  95060. * @param effect defines the update shader
  95061. */
  95062. applyToShader(effect: Effect): void;
  95063. /**
  95064. * Returns a string to use to update the GPU particles update shader
  95065. * @returns a string containng the defines string
  95066. */
  95067. getEffectDefines(): string;
  95068. /**
  95069. * Returns the string "SphereDirectedParticleEmitter"
  95070. * @returns a string containing the class name
  95071. */
  95072. getClassName(): string;
  95073. /**
  95074. * Serializes the particle system to a JSON object.
  95075. * @returns the JSON object
  95076. */
  95077. serialize(): any;
  95078. /**
  95079. * Parse properties from a JSON object
  95080. * @param serializationObject defines the JSON object
  95081. */
  95082. parse(serializationObject: any): void;
  95083. }
  95084. }
  95085. declare module BABYLON {
  95086. /**
  95087. * Particle emitter emitting particles from a custom list of positions.
  95088. */
  95089. export class CustomParticleEmitter implements IParticleEmitterType {
  95090. /**
  95091. * Gets or sets the position generator that will create the inital position of each particle.
  95092. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  95093. */
  95094. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  95095. /**
  95096. * Gets or sets the destination generator that will create the final destination of each particle.
  95097. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  95098. */
  95099. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  95100. /**
  95101. * Creates a new instance CustomParticleEmitter
  95102. */
  95103. constructor();
  95104. /**
  95105. * Called by the particle System when the direction is computed for the created particle.
  95106. * @param worldMatrix is the world matrix of the particle system
  95107. * @param directionToUpdate is the direction vector to update with the result
  95108. * @param particle is the particle we are computed the direction for
  95109. * @param isLocal defines if the direction should be set in local space
  95110. */
  95111. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95112. /**
  95113. * Called by the particle System when the position is computed for the created particle.
  95114. * @param worldMatrix is the world matrix of the particle system
  95115. * @param positionToUpdate is the position vector to update with the result
  95116. * @param particle is the particle we are computed the position for
  95117. * @param isLocal defines if the position should be set in local space
  95118. */
  95119. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95120. /**
  95121. * Clones the current emitter and returns a copy of it
  95122. * @returns the new emitter
  95123. */
  95124. clone(): CustomParticleEmitter;
  95125. /**
  95126. * Called by the GPUParticleSystem to setup the update shader
  95127. * @param effect defines the update shader
  95128. */
  95129. applyToShader(effect: Effect): void;
  95130. /**
  95131. * Returns a string to use to update the GPU particles update shader
  95132. * @returns a string containng the defines string
  95133. */
  95134. getEffectDefines(): string;
  95135. /**
  95136. * Returns the string "PointParticleEmitter"
  95137. * @returns a string containing the class name
  95138. */
  95139. getClassName(): string;
  95140. /**
  95141. * Serializes the particle system to a JSON object.
  95142. * @returns the JSON object
  95143. */
  95144. serialize(): any;
  95145. /**
  95146. * Parse properties from a JSON object
  95147. * @param serializationObject defines the JSON object
  95148. */
  95149. parse(serializationObject: any): void;
  95150. }
  95151. }
  95152. declare module BABYLON {
  95153. /**
  95154. * Particle emitter emitting particles from the inside of a box.
  95155. * It emits the particles randomly between 2 given directions.
  95156. */
  95157. export class MeshParticleEmitter implements IParticleEmitterType {
  95158. private _indices;
  95159. private _positions;
  95160. private _normals;
  95161. private _storedNormal;
  95162. private _mesh;
  95163. /**
  95164. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  95165. */
  95166. direction1: Vector3;
  95167. /**
  95168. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  95169. */
  95170. direction2: Vector3;
  95171. /**
  95172. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  95173. */
  95174. useMeshNormalsForDirection: boolean;
  95175. /** Defines the mesh to use as source */
  95176. get mesh(): Nullable<AbstractMesh>;
  95177. set mesh(value: Nullable<AbstractMesh>);
  95178. /**
  95179. * Creates a new instance MeshParticleEmitter
  95180. * @param mesh defines the mesh to use as source
  95181. */
  95182. constructor(mesh?: Nullable<AbstractMesh>);
  95183. /**
  95184. * Called by the particle System when the direction is computed for the created particle.
  95185. * @param worldMatrix is the world matrix of the particle system
  95186. * @param directionToUpdate is the direction vector to update with the result
  95187. * @param particle is the particle we are computed the direction for
  95188. * @param isLocal defines if the direction should be set in local space
  95189. */
  95190. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95191. /**
  95192. * Called by the particle System when the position is computed for the created particle.
  95193. * @param worldMatrix is the world matrix of the particle system
  95194. * @param positionToUpdate is the position vector to update with the result
  95195. * @param particle is the particle we are computed the position for
  95196. * @param isLocal defines if the position should be set in local space
  95197. */
  95198. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  95199. /**
  95200. * Clones the current emitter and returns a copy of it
  95201. * @returns the new emitter
  95202. */
  95203. clone(): MeshParticleEmitter;
  95204. /**
  95205. * Called by the GPUParticleSystem to setup the update shader
  95206. * @param effect defines the update shader
  95207. */
  95208. applyToShader(effect: Effect): void;
  95209. /**
  95210. * Returns a string to use to update the GPU particles update shader
  95211. * @returns a string containng the defines string
  95212. */
  95213. getEffectDefines(): string;
  95214. /**
  95215. * Returns the string "BoxParticleEmitter"
  95216. * @returns a string containing the class name
  95217. */
  95218. getClassName(): string;
  95219. /**
  95220. * Serializes the particle system to a JSON object.
  95221. * @returns the JSON object
  95222. */
  95223. serialize(): any;
  95224. /**
  95225. * Parse properties from a JSON object
  95226. * @param serializationObject defines the JSON object
  95227. * @param scene defines the hosting scene
  95228. */
  95229. parse(serializationObject: any, scene: Nullable<Scene>): void;
  95230. }
  95231. }
  95232. declare module BABYLON {
  95233. /**
  95234. * Interface representing a particle system in Babylon.js.
  95235. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  95236. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  95237. */
  95238. export interface IParticleSystem {
  95239. /**
  95240. * List of animations used by the particle system.
  95241. */
  95242. animations: Animation[];
  95243. /**
  95244. * The id of the Particle system.
  95245. */
  95246. id: string;
  95247. /**
  95248. * The name of the Particle system.
  95249. */
  95250. name: string;
  95251. /**
  95252. * The emitter represents the Mesh or position we are attaching the particle system to.
  95253. */
  95254. emitter: Nullable<AbstractMesh | Vector3>;
  95255. /**
  95256. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  95257. */
  95258. isBillboardBased: boolean;
  95259. /**
  95260. * The rendering group used by the Particle system to chose when to render.
  95261. */
  95262. renderingGroupId: number;
  95263. /**
  95264. * The layer mask we are rendering the particles through.
  95265. */
  95266. layerMask: number;
  95267. /**
  95268. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  95269. */
  95270. updateSpeed: number;
  95271. /**
  95272. * The amount of time the particle system is running (depends of the overall update speed).
  95273. */
  95274. targetStopDuration: number;
  95275. /**
  95276. * The texture used to render each particle. (this can be a spritesheet)
  95277. */
  95278. particleTexture: Nullable<BaseTexture>;
  95279. /**
  95280. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  95281. */
  95282. blendMode: number;
  95283. /**
  95284. * Minimum life time of emitting particles.
  95285. */
  95286. minLifeTime: number;
  95287. /**
  95288. * Maximum life time of emitting particles.
  95289. */
  95290. maxLifeTime: number;
  95291. /**
  95292. * Minimum Size of emitting particles.
  95293. */
  95294. minSize: number;
  95295. /**
  95296. * Maximum Size of emitting particles.
  95297. */
  95298. maxSize: number;
  95299. /**
  95300. * Minimum scale of emitting particles on X axis.
  95301. */
  95302. minScaleX: number;
  95303. /**
  95304. * Maximum scale of emitting particles on X axis.
  95305. */
  95306. maxScaleX: number;
  95307. /**
  95308. * Minimum scale of emitting particles on Y axis.
  95309. */
  95310. minScaleY: number;
  95311. /**
  95312. * Maximum scale of emitting particles on Y axis.
  95313. */
  95314. maxScaleY: number;
  95315. /**
  95316. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  95317. */
  95318. color1: Color4;
  95319. /**
  95320. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  95321. */
  95322. color2: Color4;
  95323. /**
  95324. * Color the particle will have at the end of its lifetime.
  95325. */
  95326. colorDead: Color4;
  95327. /**
  95328. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  95329. */
  95330. emitRate: number;
  95331. /**
  95332. * You can use gravity if you want to give an orientation to your particles.
  95333. */
  95334. gravity: Vector3;
  95335. /**
  95336. * Minimum power of emitting particles.
  95337. */
  95338. minEmitPower: number;
  95339. /**
  95340. * Maximum power of emitting particles.
  95341. */
  95342. maxEmitPower: number;
  95343. /**
  95344. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  95345. */
  95346. minAngularSpeed: number;
  95347. /**
  95348. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  95349. */
  95350. maxAngularSpeed: number;
  95351. /**
  95352. * Gets or sets the minimal initial rotation in radians.
  95353. */
  95354. minInitialRotation: number;
  95355. /**
  95356. * Gets or sets the maximal initial rotation in radians.
  95357. */
  95358. maxInitialRotation: number;
  95359. /**
  95360. * The particle emitter type defines the emitter used by the particle system.
  95361. * It can be for example box, sphere, or cone...
  95362. */
  95363. particleEmitterType: Nullable<IParticleEmitterType>;
  95364. /**
  95365. * Defines the delay in milliseconds before starting the system (0 by default)
  95366. */
  95367. startDelay: number;
  95368. /**
  95369. * 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
  95370. */
  95371. preWarmCycles: number;
  95372. /**
  95373. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  95374. */
  95375. preWarmStepOffset: number;
  95376. /**
  95377. * 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)
  95378. */
  95379. spriteCellChangeSpeed: number;
  95380. /**
  95381. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  95382. */
  95383. startSpriteCellID: number;
  95384. /**
  95385. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  95386. */
  95387. endSpriteCellID: number;
  95388. /**
  95389. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  95390. */
  95391. spriteCellWidth: number;
  95392. /**
  95393. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  95394. */
  95395. spriteCellHeight: number;
  95396. /**
  95397. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  95398. */
  95399. spriteRandomStartCell: boolean;
  95400. /**
  95401. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  95402. */
  95403. isAnimationSheetEnabled: boolean;
  95404. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  95405. translationPivot: Vector2;
  95406. /**
  95407. * Gets or sets a texture used to add random noise to particle positions
  95408. */
  95409. noiseTexture: Nullable<BaseTexture>;
  95410. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  95411. noiseStrength: Vector3;
  95412. /**
  95413. * Gets or sets the billboard mode to use when isBillboardBased = true.
  95414. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  95415. */
  95416. billboardMode: number;
  95417. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  95418. limitVelocityDamping: number;
  95419. /**
  95420. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  95421. */
  95422. beginAnimationOnStart: boolean;
  95423. /**
  95424. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  95425. */
  95426. beginAnimationFrom: number;
  95427. /**
  95428. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  95429. */
  95430. beginAnimationTo: number;
  95431. /**
  95432. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  95433. */
  95434. beginAnimationLoop: boolean;
  95435. /**
  95436. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  95437. */
  95438. disposeOnStop: boolean;
  95439. /**
  95440. * Specifies if the particles are updated in emitter local space or world space
  95441. */
  95442. isLocal: boolean;
  95443. /** Snippet ID if the particle system was created from the snippet server */
  95444. snippetId: string;
  95445. /** Gets or sets a matrix to use to compute projection */
  95446. defaultProjectionMatrix: Matrix;
  95447. /**
  95448. * Gets the maximum number of particles active at the same time.
  95449. * @returns The max number of active particles.
  95450. */
  95451. getCapacity(): number;
  95452. /**
  95453. * Gets the number of particles active at the same time.
  95454. * @returns The number of active particles.
  95455. */
  95456. getActiveCount(): number;
  95457. /**
  95458. * Gets if the system has been started. (Note: this will still be true after stop is called)
  95459. * @returns True if it has been started, otherwise false.
  95460. */
  95461. isStarted(): boolean;
  95462. /**
  95463. * Animates the particle system for this frame.
  95464. */
  95465. animate(): void;
  95466. /**
  95467. * Renders the particle system in its current state.
  95468. * @returns the current number of particles
  95469. */
  95470. render(): number;
  95471. /**
  95472. * Dispose the particle system and frees its associated resources.
  95473. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  95474. */
  95475. dispose(disposeTexture?: boolean): void;
  95476. /**
  95477. * An event triggered when the system is disposed
  95478. */
  95479. onDisposeObservable: Observable<IParticleSystem>;
  95480. /**
  95481. * An event triggered when the system is stopped
  95482. */
  95483. onStoppedObservable: Observable<IParticleSystem>;
  95484. /**
  95485. * Clones the particle system.
  95486. * @param name The name of the cloned object
  95487. * @param newEmitter The new emitter to use
  95488. * @returns the cloned particle system
  95489. */
  95490. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  95491. /**
  95492. * Serializes the particle system to a JSON object
  95493. * @param serializeTexture defines if the texture must be serialized as well
  95494. * @returns the JSON object
  95495. */
  95496. serialize(serializeTexture: boolean): any;
  95497. /**
  95498. * Rebuild the particle system
  95499. */
  95500. rebuild(): void;
  95501. /** Force the system to rebuild all gradients that need to be resync */
  95502. forceRefreshGradients(): void;
  95503. /**
  95504. * Starts the particle system and begins to emit
  95505. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  95506. */
  95507. start(delay?: number): void;
  95508. /**
  95509. * Stops the particle system.
  95510. */
  95511. stop(): void;
  95512. /**
  95513. * Remove all active particles
  95514. */
  95515. reset(): void;
  95516. /**
  95517. * Gets a boolean indicating that the system is stopping
  95518. * @returns true if the system is currently stopping
  95519. */
  95520. isStopping(): boolean;
  95521. /**
  95522. * Is this system ready to be used/rendered
  95523. * @return true if the system is ready
  95524. */
  95525. isReady(): boolean;
  95526. /**
  95527. * Returns the string "ParticleSystem"
  95528. * @returns a string containing the class name
  95529. */
  95530. getClassName(): string;
  95531. /**
  95532. * Gets the custom effect used to render the particles
  95533. * @param blendMode Blend mode for which the effect should be retrieved
  95534. * @returns The effect
  95535. */
  95536. getCustomEffect(blendMode: number): Nullable<Effect>;
  95537. /**
  95538. * Sets the custom effect used to render the particles
  95539. * @param effect The effect to set
  95540. * @param blendMode Blend mode for which the effect should be set
  95541. */
  95542. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  95543. /**
  95544. * Fill the defines array according to the current settings of the particle system
  95545. * @param defines Array to be updated
  95546. * @param blendMode blend mode to take into account when updating the array
  95547. */
  95548. fillDefines(defines: Array<string>, blendMode: number): void;
  95549. /**
  95550. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  95551. * @param uniforms Uniforms array to fill
  95552. * @param attributes Attributes array to fill
  95553. * @param samplers Samplers array to fill
  95554. */
  95555. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  95556. /**
  95557. * Observable that will be called just before the particles are drawn
  95558. */
  95559. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  95560. /**
  95561. * Gets the name of the particle vertex shader
  95562. */
  95563. vertexShaderName: string;
  95564. /**
  95565. * Adds a new color gradient
  95566. * @param gradient defines the gradient to use (between 0 and 1)
  95567. * @param color1 defines the color to affect to the specified gradient
  95568. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  95569. * @returns the current particle system
  95570. */
  95571. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  95572. /**
  95573. * Remove a specific color gradient
  95574. * @param gradient defines the gradient to remove
  95575. * @returns the current particle system
  95576. */
  95577. removeColorGradient(gradient: number): IParticleSystem;
  95578. /**
  95579. * Adds a new size gradient
  95580. * @param gradient defines the gradient to use (between 0 and 1)
  95581. * @param factor defines the size factor to affect to the specified gradient
  95582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95583. * @returns the current particle system
  95584. */
  95585. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95586. /**
  95587. * Remove a specific size gradient
  95588. * @param gradient defines the gradient to remove
  95589. * @returns the current particle system
  95590. */
  95591. removeSizeGradient(gradient: number): IParticleSystem;
  95592. /**
  95593. * Gets the current list of color gradients.
  95594. * You must use addColorGradient and removeColorGradient to udpate this list
  95595. * @returns the list of color gradients
  95596. */
  95597. getColorGradients(): Nullable<Array<ColorGradient>>;
  95598. /**
  95599. * Gets the current list of size gradients.
  95600. * You must use addSizeGradient and removeSizeGradient to udpate this list
  95601. * @returns the list of size gradients
  95602. */
  95603. getSizeGradients(): Nullable<Array<FactorGradient>>;
  95604. /**
  95605. * Gets the current list of angular speed gradients.
  95606. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  95607. * @returns the list of angular speed gradients
  95608. */
  95609. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  95610. /**
  95611. * Adds a new angular speed gradient
  95612. * @param gradient defines the gradient to use (between 0 and 1)
  95613. * @param factor defines the angular speed to affect to the specified gradient
  95614. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95615. * @returns the current particle system
  95616. */
  95617. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95618. /**
  95619. * Remove a specific angular speed gradient
  95620. * @param gradient defines the gradient to remove
  95621. * @returns the current particle system
  95622. */
  95623. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  95624. /**
  95625. * Gets the current list of velocity gradients.
  95626. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  95627. * @returns the list of velocity gradients
  95628. */
  95629. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  95630. /**
  95631. * Adds a new velocity gradient
  95632. * @param gradient defines the gradient to use (between 0 and 1)
  95633. * @param factor defines the velocity to affect to the specified gradient
  95634. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95635. * @returns the current particle system
  95636. */
  95637. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95638. /**
  95639. * Remove a specific velocity gradient
  95640. * @param gradient defines the gradient to remove
  95641. * @returns the current particle system
  95642. */
  95643. removeVelocityGradient(gradient: number): IParticleSystem;
  95644. /**
  95645. * Gets the current list of limit velocity gradients.
  95646. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  95647. * @returns the list of limit velocity gradients
  95648. */
  95649. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  95650. /**
  95651. * Adds a new limit velocity gradient
  95652. * @param gradient defines the gradient to use (between 0 and 1)
  95653. * @param factor defines the limit velocity to affect to the specified gradient
  95654. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95655. * @returns the current particle system
  95656. */
  95657. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95658. /**
  95659. * Remove a specific limit velocity gradient
  95660. * @param gradient defines the gradient to remove
  95661. * @returns the current particle system
  95662. */
  95663. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  95664. /**
  95665. * Adds a new drag gradient
  95666. * @param gradient defines the gradient to use (between 0 and 1)
  95667. * @param factor defines the drag to affect to the specified gradient
  95668. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95669. * @returns the current particle system
  95670. */
  95671. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95672. /**
  95673. * Remove a specific drag gradient
  95674. * @param gradient defines the gradient to remove
  95675. * @returns the current particle system
  95676. */
  95677. removeDragGradient(gradient: number): IParticleSystem;
  95678. /**
  95679. * Gets the current list of drag gradients.
  95680. * You must use addDragGradient and removeDragGradient to udpate this list
  95681. * @returns the list of drag gradients
  95682. */
  95683. getDragGradients(): Nullable<Array<FactorGradient>>;
  95684. /**
  95685. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  95686. * @param gradient defines the gradient to use (between 0 and 1)
  95687. * @param factor defines the emit rate to affect to the specified gradient
  95688. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95689. * @returns the current particle system
  95690. */
  95691. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95692. /**
  95693. * Remove a specific emit rate gradient
  95694. * @param gradient defines the gradient to remove
  95695. * @returns the current particle system
  95696. */
  95697. removeEmitRateGradient(gradient: number): IParticleSystem;
  95698. /**
  95699. * Gets the current list of emit rate gradients.
  95700. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  95701. * @returns the list of emit rate gradients
  95702. */
  95703. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  95704. /**
  95705. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  95706. * @param gradient defines the gradient to use (between 0 and 1)
  95707. * @param factor defines the start size to affect to the specified gradient
  95708. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95709. * @returns the current particle system
  95710. */
  95711. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95712. /**
  95713. * Remove a specific start size gradient
  95714. * @param gradient defines the gradient to remove
  95715. * @returns the current particle system
  95716. */
  95717. removeStartSizeGradient(gradient: number): IParticleSystem;
  95718. /**
  95719. * Gets the current list of start size gradients.
  95720. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95721. * @returns the list of start size gradients
  95722. */
  95723. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95724. /**
  95725. * Adds a new life time gradient
  95726. * @param gradient defines the gradient to use (between 0 and 1)
  95727. * @param factor defines the life time factor to affect to the specified gradient
  95728. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95729. * @returns the current particle system
  95730. */
  95731. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95732. /**
  95733. * Remove a specific life time gradient
  95734. * @param gradient defines the gradient to remove
  95735. * @returns the current particle system
  95736. */
  95737. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95738. /**
  95739. * Gets the current list of life time gradients.
  95740. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95741. * @returns the list of life time gradients
  95742. */
  95743. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95744. /**
  95745. * Gets the current list of color gradients.
  95746. * You must use addColorGradient and removeColorGradient to udpate this list
  95747. * @returns the list of color gradients
  95748. */
  95749. getColorGradients(): Nullable<Array<ColorGradient>>;
  95750. /**
  95751. * Adds a new ramp gradient used to remap particle colors
  95752. * @param gradient defines the gradient to use (between 0 and 1)
  95753. * @param color defines the color to affect to the specified gradient
  95754. * @returns the current particle system
  95755. */
  95756. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95757. /**
  95758. * Gets the current list of ramp gradients.
  95759. * You must use addRampGradient and removeRampGradient to udpate this list
  95760. * @returns the list of ramp gradients
  95761. */
  95762. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95763. /** Gets or sets a boolean indicating that ramp gradients must be used
  95764. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95765. */
  95766. useRampGradients: boolean;
  95767. /**
  95768. * Adds a new color remap gradient
  95769. * @param gradient defines the gradient to use (between 0 and 1)
  95770. * @param min defines the color remap minimal range
  95771. * @param max defines the color remap maximal range
  95772. * @returns the current particle system
  95773. */
  95774. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95775. /**
  95776. * Gets the current list of color remap gradients.
  95777. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95778. * @returns the list of color remap gradients
  95779. */
  95780. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95781. /**
  95782. * Adds a new alpha remap gradient
  95783. * @param gradient defines the gradient to use (between 0 and 1)
  95784. * @param min defines the alpha remap minimal range
  95785. * @param max defines the alpha remap maximal range
  95786. * @returns the current particle system
  95787. */
  95788. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95789. /**
  95790. * Gets the current list of alpha remap gradients.
  95791. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95792. * @returns the list of alpha remap gradients
  95793. */
  95794. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95795. /**
  95796. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95797. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95798. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95799. * @returns the emitter
  95800. */
  95801. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95802. /**
  95803. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95804. * @param radius The radius of the hemisphere to emit from
  95805. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95806. * @returns the emitter
  95807. */
  95808. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95809. /**
  95810. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95811. * @param radius The radius of the sphere to emit from
  95812. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95813. * @returns the emitter
  95814. */
  95815. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95816. /**
  95817. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95818. * @param radius The radius of the sphere to emit from
  95819. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95820. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95821. * @returns the emitter
  95822. */
  95823. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95824. /**
  95825. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95826. * @param radius The radius of the emission cylinder
  95827. * @param height The height of the emission cylinder
  95828. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95829. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95830. * @returns the emitter
  95831. */
  95832. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95833. /**
  95834. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95835. * @param radius The radius of the cylinder to emit from
  95836. * @param height The height of the emission cylinder
  95837. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95838. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95839. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95840. * @returns the emitter
  95841. */
  95842. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95843. /**
  95844. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95845. * @param radius The radius of the cone to emit from
  95846. * @param angle The base angle of the cone
  95847. * @returns the emitter
  95848. */
  95849. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95850. /**
  95851. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95852. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95853. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95854. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95855. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95856. * @returns the emitter
  95857. */
  95858. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95859. /**
  95860. * Get hosting scene
  95861. * @returns the scene
  95862. */
  95863. getScene(): Nullable<Scene>;
  95864. }
  95865. }
  95866. declare module BABYLON {
  95867. /**
  95868. * 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.
  95869. * @see https://doc.babylonjs.com/how_to/transformnode
  95870. */
  95871. export class TransformNode extends Node {
  95872. /**
  95873. * Object will not rotate to face the camera
  95874. */
  95875. static BILLBOARDMODE_NONE: number;
  95876. /**
  95877. * Object will rotate to face the camera but only on the x axis
  95878. */
  95879. static BILLBOARDMODE_X: number;
  95880. /**
  95881. * Object will rotate to face the camera but only on the y axis
  95882. */
  95883. static BILLBOARDMODE_Y: number;
  95884. /**
  95885. * Object will rotate to face the camera but only on the z axis
  95886. */
  95887. static BILLBOARDMODE_Z: number;
  95888. /**
  95889. * Object will rotate to face the camera
  95890. */
  95891. static BILLBOARDMODE_ALL: number;
  95892. /**
  95893. * Object will rotate to face the camera's position instead of orientation
  95894. */
  95895. static BILLBOARDMODE_USE_POSITION: number;
  95896. private static _TmpRotation;
  95897. private static _TmpScaling;
  95898. private static _TmpTranslation;
  95899. private _forward;
  95900. private _forwardInverted;
  95901. private _up;
  95902. private _right;
  95903. private _rightInverted;
  95904. private _position;
  95905. private _rotation;
  95906. private _rotationQuaternion;
  95907. protected _scaling: Vector3;
  95908. protected _isDirty: boolean;
  95909. private _transformToBoneReferal;
  95910. private _isAbsoluteSynced;
  95911. private _billboardMode;
  95912. /**
  95913. * Gets or sets the billboard mode. Default is 0.
  95914. *
  95915. * | Value | Type | Description |
  95916. * | --- | --- | --- |
  95917. * | 0 | BILLBOARDMODE_NONE | |
  95918. * | 1 | BILLBOARDMODE_X | |
  95919. * | 2 | BILLBOARDMODE_Y | |
  95920. * | 4 | BILLBOARDMODE_Z | |
  95921. * | 7 | BILLBOARDMODE_ALL | |
  95922. *
  95923. */
  95924. get billboardMode(): number;
  95925. set billboardMode(value: number);
  95926. private _preserveParentRotationForBillboard;
  95927. /**
  95928. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95929. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95930. */
  95931. get preserveParentRotationForBillboard(): boolean;
  95932. set preserveParentRotationForBillboard(value: boolean);
  95933. /**
  95934. * 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
  95935. */
  95936. scalingDeterminant: number;
  95937. private _infiniteDistance;
  95938. /**
  95939. * Gets or sets the distance of the object to max, often used by skybox
  95940. */
  95941. get infiniteDistance(): boolean;
  95942. set infiniteDistance(value: boolean);
  95943. /**
  95944. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95945. * By default the system will update normals to compensate
  95946. */
  95947. ignoreNonUniformScaling: boolean;
  95948. /**
  95949. * 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
  95950. */
  95951. reIntegrateRotationIntoRotationQuaternion: boolean;
  95952. /** @hidden */
  95953. _poseMatrix: Nullable<Matrix>;
  95954. /** @hidden */
  95955. _localMatrix: Matrix;
  95956. private _usePivotMatrix;
  95957. private _absolutePosition;
  95958. private _absoluteScaling;
  95959. private _absoluteRotationQuaternion;
  95960. private _pivotMatrix;
  95961. private _pivotMatrixInverse;
  95962. /** @hidden */
  95963. _postMultiplyPivotMatrix: boolean;
  95964. protected _isWorldMatrixFrozen: boolean;
  95965. /** @hidden */
  95966. _indexInSceneTransformNodesArray: number;
  95967. /**
  95968. * An event triggered after the world matrix is updated
  95969. */
  95970. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95971. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95972. /**
  95973. * Gets a string identifying the name of the class
  95974. * @returns "TransformNode" string
  95975. */
  95976. getClassName(): string;
  95977. /**
  95978. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95979. */
  95980. get position(): Vector3;
  95981. set position(newPosition: Vector3);
  95982. /**
  95983. * 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)).
  95984. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95985. */
  95986. get rotation(): Vector3;
  95987. set rotation(newRotation: Vector3);
  95988. /**
  95989. * 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)).
  95990. */
  95991. get scaling(): Vector3;
  95992. set scaling(newScaling: Vector3);
  95993. /**
  95994. * 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).
  95995. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95996. */
  95997. get rotationQuaternion(): Nullable<Quaternion>;
  95998. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95999. /**
  96000. * The forward direction of that transform in world space.
  96001. */
  96002. get forward(): Vector3;
  96003. /**
  96004. * The up direction of that transform in world space.
  96005. */
  96006. get up(): Vector3;
  96007. /**
  96008. * The right direction of that transform in world space.
  96009. */
  96010. get right(): Vector3;
  96011. /**
  96012. * Copies the parameter passed Matrix into the mesh Pose matrix.
  96013. * @param matrix the matrix to copy the pose from
  96014. * @returns this TransformNode.
  96015. */
  96016. updatePoseMatrix(matrix: Matrix): TransformNode;
  96017. /**
  96018. * Returns the mesh Pose matrix.
  96019. * @returns the pose matrix
  96020. */
  96021. getPoseMatrix(): Matrix;
  96022. /** @hidden */
  96023. _isSynchronized(): boolean;
  96024. /** @hidden */
  96025. _initCache(): void;
  96026. /**
  96027. * Flag the transform node as dirty (Forcing it to update everything)
  96028. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  96029. * @returns this transform node
  96030. */
  96031. markAsDirty(property: string): TransformNode;
  96032. /**
  96033. * Returns the current mesh absolute position.
  96034. * Returns a Vector3.
  96035. */
  96036. get absolutePosition(): Vector3;
  96037. /**
  96038. * Returns the current mesh absolute scaling.
  96039. * Returns a Vector3.
  96040. */
  96041. get absoluteScaling(): Vector3;
  96042. /**
  96043. * Returns the current mesh absolute rotation.
  96044. * Returns a Quaternion.
  96045. */
  96046. get absoluteRotationQuaternion(): Quaternion;
  96047. /**
  96048. * Sets a new matrix to apply before all other transformation
  96049. * @param matrix defines the transform matrix
  96050. * @returns the current TransformNode
  96051. */
  96052. setPreTransformMatrix(matrix: Matrix): TransformNode;
  96053. /**
  96054. * Sets a new pivot matrix to the current node
  96055. * @param matrix defines the new pivot matrix to use
  96056. * @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
  96057. * @returns the current TransformNode
  96058. */
  96059. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  96060. /**
  96061. * Returns the mesh pivot matrix.
  96062. * Default : Identity.
  96063. * @returns the matrix
  96064. */
  96065. getPivotMatrix(): Matrix;
  96066. /**
  96067. * Instantiate (when possible) or clone that node with its hierarchy
  96068. * @param newParent defines the new parent to use for the instance (or clone)
  96069. * @param options defines options to configure how copy is done
  96070. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  96071. * @returns an instance (or a clone) of the current node with its hiearchy
  96072. */
  96073. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  96074. doNotInstantiate: boolean;
  96075. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  96076. /**
  96077. * Prevents the World matrix to be computed any longer
  96078. * @param newWorldMatrix defines an optional matrix to use as world matrix
  96079. * @returns the TransformNode.
  96080. */
  96081. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  96082. /**
  96083. * Allows back the World matrix computation.
  96084. * @returns the TransformNode.
  96085. */
  96086. unfreezeWorldMatrix(): this;
  96087. /**
  96088. * True if the World matrix has been frozen.
  96089. */
  96090. get isWorldMatrixFrozen(): boolean;
  96091. /**
  96092. * Retuns the mesh absolute position in the World.
  96093. * @returns a Vector3.
  96094. */
  96095. getAbsolutePosition(): Vector3;
  96096. /**
  96097. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  96098. * @param absolutePosition the absolute position to set
  96099. * @returns the TransformNode.
  96100. */
  96101. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96102. /**
  96103. * Sets the mesh position in its local space.
  96104. * @param vector3 the position to set in localspace
  96105. * @returns the TransformNode.
  96106. */
  96107. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  96108. /**
  96109. * Returns the mesh position in the local space from the current World matrix values.
  96110. * @returns a new Vector3.
  96111. */
  96112. getPositionExpressedInLocalSpace(): Vector3;
  96113. /**
  96114. * Translates the mesh along the passed Vector3 in its local space.
  96115. * @param vector3 the distance to translate in localspace
  96116. * @returns the TransformNode.
  96117. */
  96118. locallyTranslate(vector3: Vector3): TransformNode;
  96119. private static _lookAtVectorCache;
  96120. /**
  96121. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  96122. * @param targetPoint the position (must be in same space as current mesh) to look at
  96123. * @param yawCor optional yaw (y-axis) correction in radians
  96124. * @param pitchCor optional pitch (x-axis) correction in radians
  96125. * @param rollCor optional roll (z-axis) correction in radians
  96126. * @param space the choosen space of the target
  96127. * @returns the TransformNode.
  96128. */
  96129. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  96130. /**
  96131. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  96132. * This Vector3 is expressed in the World space.
  96133. * @param localAxis axis to rotate
  96134. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  96135. */
  96136. getDirection(localAxis: Vector3): Vector3;
  96137. /**
  96138. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  96139. * localAxis is expressed in the mesh local space.
  96140. * result is computed in the Wordl space from the mesh World matrix.
  96141. * @param localAxis axis to rotate
  96142. * @param result the resulting transformnode
  96143. * @returns this TransformNode.
  96144. */
  96145. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  96146. /**
  96147. * Sets this transform node rotation to the given local axis.
  96148. * @param localAxis the axis in local space
  96149. * @param yawCor optional yaw (y-axis) correction in radians
  96150. * @param pitchCor optional pitch (x-axis) correction in radians
  96151. * @param rollCor optional roll (z-axis) correction in radians
  96152. * @returns this TransformNode
  96153. */
  96154. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  96155. /**
  96156. * Sets a new pivot point to the current node
  96157. * @param point defines the new pivot point to use
  96158. * @param space defines if the point is in world or local space (local by default)
  96159. * @returns the current TransformNode
  96160. */
  96161. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  96162. /**
  96163. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  96164. * @returns the pivot point
  96165. */
  96166. getPivotPoint(): Vector3;
  96167. /**
  96168. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  96169. * @param result the vector3 to store the result
  96170. * @returns this TransformNode.
  96171. */
  96172. getPivotPointToRef(result: Vector3): TransformNode;
  96173. /**
  96174. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  96175. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  96176. */
  96177. getAbsolutePivotPoint(): Vector3;
  96178. /**
  96179. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  96180. * @param result vector3 to store the result
  96181. * @returns this TransformNode.
  96182. */
  96183. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  96184. /**
  96185. * Defines the passed node as the parent of the current node.
  96186. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  96187. * @see https://doc.babylonjs.com/how_to/parenting
  96188. * @param node the node ot set as the parent
  96189. * @returns this TransformNode.
  96190. */
  96191. setParent(node: Nullable<Node>): TransformNode;
  96192. private _nonUniformScaling;
  96193. /**
  96194. * True if the scaling property of this object is non uniform eg. (1,2,1)
  96195. */
  96196. get nonUniformScaling(): boolean;
  96197. /** @hidden */
  96198. _updateNonUniformScalingState(value: boolean): boolean;
  96199. /**
  96200. * Attach the current TransformNode to another TransformNode associated with a bone
  96201. * @param bone Bone affecting the TransformNode
  96202. * @param affectedTransformNode TransformNode associated with the bone
  96203. * @returns this object
  96204. */
  96205. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  96206. /**
  96207. * Detach the transform node if its associated with a bone
  96208. * @returns this object
  96209. */
  96210. detachFromBone(): TransformNode;
  96211. private static _rotationAxisCache;
  96212. /**
  96213. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  96214. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  96215. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  96216. * The passed axis is also normalized.
  96217. * @param axis the axis to rotate around
  96218. * @param amount the amount to rotate in radians
  96219. * @param space Space to rotate in (Default: local)
  96220. * @returns the TransformNode.
  96221. */
  96222. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96223. /**
  96224. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  96225. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  96226. * The passed axis is also normalized. .
  96227. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  96228. * @param point the point to rotate around
  96229. * @param axis the axis to rotate around
  96230. * @param amount the amount to rotate in radians
  96231. * @returns the TransformNode
  96232. */
  96233. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  96234. /**
  96235. * Translates the mesh along the axis vector for the passed distance in the given space.
  96236. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  96237. * @param axis the axis to translate in
  96238. * @param distance the distance to translate
  96239. * @param space Space to rotate in (Default: local)
  96240. * @returns the TransformNode.
  96241. */
  96242. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96243. /**
  96244. * Adds a rotation step to the mesh current rotation.
  96245. * x, y, z are Euler angles expressed in radians.
  96246. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  96247. * This means this rotation is made in the mesh local space only.
  96248. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  96249. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  96250. * ```javascript
  96251. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  96252. * ```
  96253. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  96254. * 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.
  96255. * @param x Rotation to add
  96256. * @param y Rotation to add
  96257. * @param z Rotation to add
  96258. * @returns the TransformNode.
  96259. */
  96260. addRotation(x: number, y: number, z: number): TransformNode;
  96261. /**
  96262. * @hidden
  96263. */
  96264. protected _getEffectiveParent(): Nullable<Node>;
  96265. /**
  96266. * Computes the world matrix of the node
  96267. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  96268. * @returns the world matrix
  96269. */
  96270. computeWorldMatrix(force?: boolean): Matrix;
  96271. /**
  96272. * Resets this nodeTransform's local matrix to Matrix.Identity().
  96273. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  96274. */
  96275. resetLocalMatrix(independentOfChildren?: boolean): void;
  96276. protected _afterComputeWorldMatrix(): void;
  96277. /**
  96278. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  96279. * @param func callback function to add
  96280. *
  96281. * @returns the TransformNode.
  96282. */
  96283. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  96284. /**
  96285. * Removes a registered callback function.
  96286. * @param func callback function to remove
  96287. * @returns the TransformNode.
  96288. */
  96289. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  96290. /**
  96291. * Gets the position of the current mesh in camera space
  96292. * @param camera defines the camera to use
  96293. * @returns a position
  96294. */
  96295. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  96296. /**
  96297. * Returns the distance from the mesh to the active camera
  96298. * @param camera defines the camera to use
  96299. * @returns the distance
  96300. */
  96301. getDistanceToCamera(camera?: Nullable<Camera>): number;
  96302. /**
  96303. * Clone the current transform node
  96304. * @param name Name of the new clone
  96305. * @param newParent New parent for the clone
  96306. * @param doNotCloneChildren Do not clone children hierarchy
  96307. * @returns the new transform node
  96308. */
  96309. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  96310. /**
  96311. * Serializes the objects information.
  96312. * @param currentSerializationObject defines the object to serialize in
  96313. * @returns the serialized object
  96314. */
  96315. serialize(currentSerializationObject?: any): any;
  96316. /**
  96317. * Returns a new TransformNode object parsed from the source provided.
  96318. * @param parsedTransformNode is the source.
  96319. * @param scene the scne the object belongs to
  96320. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  96321. * @returns a new TransformNode object parsed from the source provided.
  96322. */
  96323. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  96324. /**
  96325. * Get all child-transformNodes of this node
  96326. * @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
  96327. * @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
  96328. * @returns an array of TransformNode
  96329. */
  96330. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  96331. /**
  96332. * Releases resources associated with this transform node.
  96333. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96334. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96335. */
  96336. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96337. /**
  96338. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  96339. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  96340. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  96341. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  96342. * @returns the current mesh
  96343. */
  96344. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  96345. private _syncAbsoluteScalingAndRotation;
  96346. }
  96347. }
  96348. declare module BABYLON {
  96349. /**
  96350. * Class used to override all child animations of a given target
  96351. */
  96352. export class AnimationPropertiesOverride {
  96353. /**
  96354. * Gets or sets a value indicating if animation blending must be used
  96355. */
  96356. enableBlending: boolean;
  96357. /**
  96358. * Gets or sets the blending speed to use when enableBlending is true
  96359. */
  96360. blendingSpeed: number;
  96361. /**
  96362. * Gets or sets the default loop mode to use
  96363. */
  96364. loopMode: number;
  96365. }
  96366. }
  96367. declare module BABYLON {
  96368. /**
  96369. * Class used to store bone information
  96370. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96371. */
  96372. export class Bone extends Node {
  96373. /**
  96374. * defines the bone name
  96375. */
  96376. name: string;
  96377. private static _tmpVecs;
  96378. private static _tmpQuat;
  96379. private static _tmpMats;
  96380. /**
  96381. * Gets the list of child bones
  96382. */
  96383. children: Bone[];
  96384. /** Gets the animations associated with this bone */
  96385. animations: Animation[];
  96386. /**
  96387. * Gets or sets bone length
  96388. */
  96389. length: number;
  96390. /**
  96391. * @hidden Internal only
  96392. * Set this value to map this bone to a different index in the transform matrices
  96393. * Set this value to -1 to exclude the bone from the transform matrices
  96394. */
  96395. _index: Nullable<number>;
  96396. private _skeleton;
  96397. private _localMatrix;
  96398. private _restPose;
  96399. private _bindPose;
  96400. private _baseMatrix;
  96401. private _absoluteTransform;
  96402. private _invertedAbsoluteTransform;
  96403. private _parent;
  96404. private _scalingDeterminant;
  96405. private _worldTransform;
  96406. private _localScaling;
  96407. private _localRotation;
  96408. private _localPosition;
  96409. private _needToDecompose;
  96410. private _needToCompose;
  96411. /** @hidden */
  96412. _linkedTransformNode: Nullable<TransformNode>;
  96413. /** @hidden */
  96414. _waitingTransformNodeId: Nullable<string>;
  96415. /** @hidden */
  96416. get _matrix(): Matrix;
  96417. /** @hidden */
  96418. set _matrix(value: Matrix);
  96419. /**
  96420. * Create a new bone
  96421. * @param name defines the bone name
  96422. * @param skeleton defines the parent skeleton
  96423. * @param parentBone defines the parent (can be null if the bone is the root)
  96424. * @param localMatrix defines the local matrix
  96425. * @param restPose defines the rest pose matrix
  96426. * @param baseMatrix defines the base matrix
  96427. * @param index defines index of the bone in the hiearchy
  96428. */
  96429. constructor(
  96430. /**
  96431. * defines the bone name
  96432. */
  96433. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  96434. /**
  96435. * Gets the current object class name.
  96436. * @return the class name
  96437. */
  96438. getClassName(): string;
  96439. /**
  96440. * Gets the parent skeleton
  96441. * @returns a skeleton
  96442. */
  96443. getSkeleton(): Skeleton;
  96444. /**
  96445. * Gets parent bone
  96446. * @returns a bone or null if the bone is the root of the bone hierarchy
  96447. */
  96448. getParent(): Nullable<Bone>;
  96449. /**
  96450. * Returns an array containing the root bones
  96451. * @returns an array containing the root bones
  96452. */
  96453. getChildren(): Array<Bone>;
  96454. /**
  96455. * Gets the node index in matrix array generated for rendering
  96456. * @returns the node index
  96457. */
  96458. getIndex(): number;
  96459. /**
  96460. * Sets the parent bone
  96461. * @param parent defines the parent (can be null if the bone is the root)
  96462. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96463. */
  96464. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  96465. /**
  96466. * Gets the local matrix
  96467. * @returns a matrix
  96468. */
  96469. getLocalMatrix(): Matrix;
  96470. /**
  96471. * Gets the base matrix (initial matrix which remains unchanged)
  96472. * @returns a matrix
  96473. */
  96474. getBaseMatrix(): Matrix;
  96475. /**
  96476. * Gets the rest pose matrix
  96477. * @returns a matrix
  96478. */
  96479. getRestPose(): Matrix;
  96480. /**
  96481. * Sets the rest pose matrix
  96482. * @param matrix the local-space rest pose to set for this bone
  96483. */
  96484. setRestPose(matrix: Matrix): void;
  96485. /**
  96486. * Gets the bind pose matrix
  96487. * @returns the bind pose matrix
  96488. */
  96489. getBindPose(): Matrix;
  96490. /**
  96491. * Sets the bind pose matrix
  96492. * @param matrix the local-space bind pose to set for this bone
  96493. */
  96494. setBindPose(matrix: Matrix): void;
  96495. /**
  96496. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  96497. */
  96498. getWorldMatrix(): Matrix;
  96499. /**
  96500. * Sets the local matrix to rest pose matrix
  96501. */
  96502. returnToRest(): void;
  96503. /**
  96504. * Gets the inverse of the absolute transform matrix.
  96505. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  96506. * @returns a matrix
  96507. */
  96508. getInvertedAbsoluteTransform(): Matrix;
  96509. /**
  96510. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  96511. * @returns a matrix
  96512. */
  96513. getAbsoluteTransform(): Matrix;
  96514. /**
  96515. * Links with the given transform node.
  96516. * The local matrix of this bone is copied from the transform node every frame.
  96517. * @param transformNode defines the transform node to link to
  96518. */
  96519. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  96520. /**
  96521. * Gets the node used to drive the bone's transformation
  96522. * @returns a transform node or null
  96523. */
  96524. getTransformNode(): Nullable<TransformNode>;
  96525. /** Gets or sets current position (in local space) */
  96526. get position(): Vector3;
  96527. set position(newPosition: Vector3);
  96528. /** Gets or sets current rotation (in local space) */
  96529. get rotation(): Vector3;
  96530. set rotation(newRotation: Vector3);
  96531. /** Gets or sets current rotation quaternion (in local space) */
  96532. get rotationQuaternion(): Quaternion;
  96533. set rotationQuaternion(newRotation: Quaternion);
  96534. /** Gets or sets current scaling (in local space) */
  96535. get scaling(): Vector3;
  96536. set scaling(newScaling: Vector3);
  96537. /**
  96538. * Gets the animation properties override
  96539. */
  96540. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96541. private _decompose;
  96542. private _compose;
  96543. /**
  96544. * Update the base and local matrices
  96545. * @param matrix defines the new base or local matrix
  96546. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  96547. * @param updateLocalMatrix defines if the local matrix should be updated
  96548. */
  96549. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  96550. /** @hidden */
  96551. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  96552. /**
  96553. * Flag the bone as dirty (Forcing it to update everything)
  96554. */
  96555. markAsDirty(): void;
  96556. /** @hidden */
  96557. _markAsDirtyAndCompose(): void;
  96558. private _markAsDirtyAndDecompose;
  96559. /**
  96560. * Translate the bone in local or world space
  96561. * @param vec The amount to translate the bone
  96562. * @param space The space that the translation is in
  96563. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96564. */
  96565. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96566. /**
  96567. * Set the postion of the bone in local or world space
  96568. * @param position The position to set the bone
  96569. * @param space The space that the position is in
  96570. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96571. */
  96572. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96573. /**
  96574. * Set the absolute position of the bone (world space)
  96575. * @param position The position to set the bone
  96576. * @param mesh The mesh that this bone is attached to
  96577. */
  96578. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  96579. /**
  96580. * Scale the bone on the x, y and z axes (in local space)
  96581. * @param x The amount to scale the bone on the x axis
  96582. * @param y The amount to scale the bone on the y axis
  96583. * @param z The amount to scale the bone on the z axis
  96584. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  96585. */
  96586. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  96587. /**
  96588. * Set the bone scaling in local space
  96589. * @param scale defines the scaling vector
  96590. */
  96591. setScale(scale: Vector3): void;
  96592. /**
  96593. * Gets the current scaling in local space
  96594. * @returns the current scaling vector
  96595. */
  96596. getScale(): Vector3;
  96597. /**
  96598. * Gets the current scaling in local space and stores it in a target vector
  96599. * @param result defines the target vector
  96600. */
  96601. getScaleToRef(result: Vector3): void;
  96602. /**
  96603. * Set the yaw, pitch, and roll of the bone in local or world space
  96604. * @param yaw The rotation of the bone on the y axis
  96605. * @param pitch The rotation of the bone on the x axis
  96606. * @param roll The rotation of the bone on the z axis
  96607. * @param space The space that the axes of rotation are in
  96608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96609. */
  96610. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  96611. /**
  96612. * Add a rotation to the bone on an axis in local or world space
  96613. * @param axis The axis to rotate the bone on
  96614. * @param amount The amount to rotate the bone
  96615. * @param space The space that the axis is in
  96616. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96617. */
  96618. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  96619. /**
  96620. * Set the rotation of the bone to a particular axis angle in local or world space
  96621. * @param axis The axis to rotate the bone on
  96622. * @param angle The angle that the bone should be rotated to
  96623. * @param space The space that the axis is in
  96624. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96625. */
  96626. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  96627. /**
  96628. * Set the euler rotation of the bone in local or world space
  96629. * @param rotation The euler rotation that the bone should be set to
  96630. * @param space The space that the rotation is in
  96631. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96632. */
  96633. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  96634. /**
  96635. * Set the quaternion rotation of the bone in local or world space
  96636. * @param quat The quaternion rotation that the bone should be set to
  96637. * @param space The space that the rotation is in
  96638. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96639. */
  96640. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  96641. /**
  96642. * Set the rotation matrix of the bone in local or world space
  96643. * @param rotMat The rotation matrix that the bone should be set to
  96644. * @param space The space that the rotation is in
  96645. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96646. */
  96647. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  96648. private _rotateWithMatrix;
  96649. private _getNegativeRotationToRef;
  96650. /**
  96651. * Get the position of the bone in local or world space
  96652. * @param space The space that the returned position is in
  96653. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96654. * @returns The position of the bone
  96655. */
  96656. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96657. /**
  96658. * Copy the position of the bone to a vector3 in local or world space
  96659. * @param space The space that the returned position is in
  96660. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96661. * @param result The vector3 to copy the position to
  96662. */
  96663. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  96664. /**
  96665. * Get the absolute position of the bone (world space)
  96666. * @param mesh The mesh that this bone is attached to
  96667. * @returns The absolute position of the bone
  96668. */
  96669. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  96670. /**
  96671. * Copy the absolute position of the bone (world space) to the result param
  96672. * @param mesh The mesh that this bone is attached to
  96673. * @param result The vector3 to copy the absolute position to
  96674. */
  96675. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  96676. /**
  96677. * Compute the absolute transforms of this bone and its children
  96678. */
  96679. computeAbsoluteTransforms(): void;
  96680. /**
  96681. * Get the world direction from an axis that is in the local space of the bone
  96682. * @param localAxis The local direction that is used to compute the world direction
  96683. * @param mesh The mesh that this bone is attached to
  96684. * @returns The world direction
  96685. */
  96686. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96687. /**
  96688. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  96689. * @param localAxis The local direction that is used to compute the world direction
  96690. * @param mesh The mesh that this bone is attached to
  96691. * @param result The vector3 that the world direction will be copied to
  96692. */
  96693. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96694. /**
  96695. * Get the euler rotation of the bone in local or world space
  96696. * @param space The space that the rotation should be in
  96697. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96698. * @returns The euler rotation
  96699. */
  96700. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  96701. /**
  96702. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  96703. * @param space The space that the rotation should be in
  96704. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96705. * @param result The vector3 that the rotation should be copied to
  96706. */
  96707. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96708. /**
  96709. * Get the quaternion rotation of the bone in either local or world space
  96710. * @param space The space that the rotation should be in
  96711. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96712. * @returns The quaternion rotation
  96713. */
  96714. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96715. /**
  96716. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96717. * @param space The space that the rotation should be in
  96718. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96719. * @param result The quaternion that the rotation should be copied to
  96720. */
  96721. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96722. /**
  96723. * Get the rotation matrix of the bone in local or world space
  96724. * @param space The space that the rotation should be in
  96725. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96726. * @returns The rotation matrix
  96727. */
  96728. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96729. /**
  96730. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96731. * @param space The space that the rotation should be in
  96732. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96733. * @param result The quaternion that the rotation should be copied to
  96734. */
  96735. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96736. /**
  96737. * Get the world position of a point that is in the local space of the bone
  96738. * @param position The local position
  96739. * @param mesh The mesh that this bone is attached to
  96740. * @returns The world position
  96741. */
  96742. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96743. /**
  96744. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96745. * @param position The local position
  96746. * @param mesh The mesh that this bone is attached to
  96747. * @param result The vector3 that the world position should be copied to
  96748. */
  96749. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96750. /**
  96751. * Get the local position of a point that is in world space
  96752. * @param position The world position
  96753. * @param mesh The mesh that this bone is attached to
  96754. * @returns The local position
  96755. */
  96756. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96757. /**
  96758. * Get the local position of a point that is in world space and copy it to the result param
  96759. * @param position The world position
  96760. * @param mesh The mesh that this bone is attached to
  96761. * @param result The vector3 that the local position should be copied to
  96762. */
  96763. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96764. /**
  96765. * Set the current local matrix as the restPose for this bone.
  96766. */
  96767. setCurrentPoseAsRest(): void;
  96768. }
  96769. }
  96770. declare module BABYLON {
  96771. /**
  96772. * Defines a runtime animation
  96773. */
  96774. export class RuntimeAnimation {
  96775. private _events;
  96776. /**
  96777. * The current frame of the runtime animation
  96778. */
  96779. private _currentFrame;
  96780. /**
  96781. * The animation used by the runtime animation
  96782. */
  96783. private _animation;
  96784. /**
  96785. * The target of the runtime animation
  96786. */
  96787. private _target;
  96788. /**
  96789. * The initiating animatable
  96790. */
  96791. private _host;
  96792. /**
  96793. * The original value of the runtime animation
  96794. */
  96795. private _originalValue;
  96796. /**
  96797. * The original blend value of the runtime animation
  96798. */
  96799. private _originalBlendValue;
  96800. /**
  96801. * The offsets cache of the runtime animation
  96802. */
  96803. private _offsetsCache;
  96804. /**
  96805. * The high limits cache of the runtime animation
  96806. */
  96807. private _highLimitsCache;
  96808. /**
  96809. * Specifies if the runtime animation has been stopped
  96810. */
  96811. private _stopped;
  96812. /**
  96813. * The blending factor of the runtime animation
  96814. */
  96815. private _blendingFactor;
  96816. /**
  96817. * The BabylonJS scene
  96818. */
  96819. private _scene;
  96820. /**
  96821. * The current value of the runtime animation
  96822. */
  96823. private _currentValue;
  96824. /** @hidden */
  96825. _animationState: _IAnimationState;
  96826. /**
  96827. * The active target of the runtime animation
  96828. */
  96829. private _activeTargets;
  96830. private _currentActiveTarget;
  96831. private _directTarget;
  96832. /**
  96833. * The target path of the runtime animation
  96834. */
  96835. private _targetPath;
  96836. /**
  96837. * The weight of the runtime animation
  96838. */
  96839. private _weight;
  96840. /**
  96841. * The ratio offset of the runtime animation
  96842. */
  96843. private _ratioOffset;
  96844. /**
  96845. * The previous delay of the runtime animation
  96846. */
  96847. private _previousDelay;
  96848. /**
  96849. * The previous ratio of the runtime animation
  96850. */
  96851. private _previousRatio;
  96852. private _enableBlending;
  96853. private _keys;
  96854. private _minFrame;
  96855. private _maxFrame;
  96856. private _minValue;
  96857. private _maxValue;
  96858. private _targetIsArray;
  96859. /**
  96860. * Gets the current frame of the runtime animation
  96861. */
  96862. get currentFrame(): number;
  96863. /**
  96864. * Gets the weight of the runtime animation
  96865. */
  96866. get weight(): number;
  96867. /**
  96868. * Gets the current value of the runtime animation
  96869. */
  96870. get currentValue(): any;
  96871. /**
  96872. * Gets the target path of the runtime animation
  96873. */
  96874. get targetPath(): string;
  96875. /**
  96876. * Gets the actual target of the runtime animation
  96877. */
  96878. get target(): any;
  96879. /**
  96880. * Gets the additive state of the runtime animation
  96881. */
  96882. get isAdditive(): boolean;
  96883. /** @hidden */
  96884. _onLoop: () => void;
  96885. /**
  96886. * Create a new RuntimeAnimation object
  96887. * @param target defines the target of the animation
  96888. * @param animation defines the source animation object
  96889. * @param scene defines the hosting scene
  96890. * @param host defines the initiating Animatable
  96891. */
  96892. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96893. private _preparePath;
  96894. /**
  96895. * Gets the animation from the runtime animation
  96896. */
  96897. get animation(): Animation;
  96898. /**
  96899. * Resets the runtime animation to the beginning
  96900. * @param restoreOriginal defines whether to restore the target property to the original value
  96901. */
  96902. reset(restoreOriginal?: boolean): void;
  96903. /**
  96904. * Specifies if the runtime animation is stopped
  96905. * @returns Boolean specifying if the runtime animation is stopped
  96906. */
  96907. isStopped(): boolean;
  96908. /**
  96909. * Disposes of the runtime animation
  96910. */
  96911. dispose(): void;
  96912. /**
  96913. * Apply the interpolated value to the target
  96914. * @param currentValue defines the value computed by the animation
  96915. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96916. */
  96917. setValue(currentValue: any, weight: number): void;
  96918. private _getOriginalValues;
  96919. private _setValue;
  96920. /**
  96921. * Gets the loop pmode of the runtime animation
  96922. * @returns Loop Mode
  96923. */
  96924. private _getCorrectLoopMode;
  96925. /**
  96926. * Move the current animation to a given frame
  96927. * @param frame defines the frame to move to
  96928. */
  96929. goToFrame(frame: number): void;
  96930. /**
  96931. * @hidden Internal use only
  96932. */
  96933. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96934. /**
  96935. * Execute the current animation
  96936. * @param delay defines the delay to add to the current frame
  96937. * @param from defines the lower bound of the animation range
  96938. * @param to defines the upper bound of the animation range
  96939. * @param loop defines if the current animation must loop
  96940. * @param speedRatio defines the current speed ratio
  96941. * @param weight defines the weight of the animation (default is -1 so no weight)
  96942. * @param onLoop optional callback called when animation loops
  96943. * @returns a boolean indicating if the animation is running
  96944. */
  96945. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96946. }
  96947. }
  96948. declare module BABYLON {
  96949. /**
  96950. * Class used to store an actual running animation
  96951. */
  96952. export class Animatable {
  96953. /** defines the target object */
  96954. target: any;
  96955. /** defines the starting frame number (default is 0) */
  96956. fromFrame: number;
  96957. /** defines the ending frame number (default is 100) */
  96958. toFrame: number;
  96959. /** defines if the animation must loop (default is false) */
  96960. loopAnimation: boolean;
  96961. /** defines a callback to call when animation ends if it is not looping */
  96962. onAnimationEnd?: (() => void) | null | undefined;
  96963. /** defines a callback to call when animation loops */
  96964. onAnimationLoop?: (() => void) | null | undefined;
  96965. /** defines whether the animation should be evaluated additively */
  96966. isAdditive: boolean;
  96967. private _localDelayOffset;
  96968. private _pausedDelay;
  96969. private _runtimeAnimations;
  96970. private _paused;
  96971. private _scene;
  96972. private _speedRatio;
  96973. private _weight;
  96974. private _syncRoot;
  96975. /**
  96976. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96977. * This will only apply for non looping animation (default is true)
  96978. */
  96979. disposeOnEnd: boolean;
  96980. /**
  96981. * Gets a boolean indicating if the animation has started
  96982. */
  96983. animationStarted: boolean;
  96984. /**
  96985. * Observer raised when the animation ends
  96986. */
  96987. onAnimationEndObservable: Observable<Animatable>;
  96988. /**
  96989. * Observer raised when the animation loops
  96990. */
  96991. onAnimationLoopObservable: Observable<Animatable>;
  96992. /**
  96993. * Gets the root Animatable used to synchronize and normalize animations
  96994. */
  96995. get syncRoot(): Nullable<Animatable>;
  96996. /**
  96997. * Gets the current frame of the first RuntimeAnimation
  96998. * Used to synchronize Animatables
  96999. */
  97000. get masterFrame(): number;
  97001. /**
  97002. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  97003. */
  97004. get weight(): number;
  97005. set weight(value: number);
  97006. /**
  97007. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  97008. */
  97009. get speedRatio(): number;
  97010. set speedRatio(value: number);
  97011. /**
  97012. * Creates a new Animatable
  97013. * @param scene defines the hosting scene
  97014. * @param target defines the target object
  97015. * @param fromFrame defines the starting frame number (default is 0)
  97016. * @param toFrame defines the ending frame number (default is 100)
  97017. * @param loopAnimation defines if the animation must loop (default is false)
  97018. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  97019. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  97020. * @param animations defines a group of animation to add to the new Animatable
  97021. * @param onAnimationLoop defines a callback to call when animation loops
  97022. * @param isAdditive defines whether the animation should be evaluated additively
  97023. */
  97024. constructor(scene: Scene,
  97025. /** defines the target object */
  97026. target: any,
  97027. /** defines the starting frame number (default is 0) */
  97028. fromFrame?: number,
  97029. /** defines the ending frame number (default is 100) */
  97030. toFrame?: number,
  97031. /** defines if the animation must loop (default is false) */
  97032. loopAnimation?: boolean, speedRatio?: number,
  97033. /** defines a callback to call when animation ends if it is not looping */
  97034. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  97035. /** defines a callback to call when animation loops */
  97036. onAnimationLoop?: (() => void) | null | undefined,
  97037. /** defines whether the animation should be evaluated additively */
  97038. isAdditive?: boolean);
  97039. /**
  97040. * Synchronize and normalize current Animatable with a source Animatable
  97041. * This is useful when using animation weights and when animations are not of the same length
  97042. * @param root defines the root Animatable to synchronize with
  97043. * @returns the current Animatable
  97044. */
  97045. syncWith(root: Animatable): Animatable;
  97046. /**
  97047. * Gets the list of runtime animations
  97048. * @returns an array of RuntimeAnimation
  97049. */
  97050. getAnimations(): RuntimeAnimation[];
  97051. /**
  97052. * Adds more animations to the current animatable
  97053. * @param target defines the target of the animations
  97054. * @param animations defines the new animations to add
  97055. */
  97056. appendAnimations(target: any, animations: Animation[]): void;
  97057. /**
  97058. * Gets the source animation for a specific property
  97059. * @param property defines the propertyu to look for
  97060. * @returns null or the source animation for the given property
  97061. */
  97062. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  97063. /**
  97064. * Gets the runtime animation for a specific property
  97065. * @param property defines the propertyu to look for
  97066. * @returns null or the runtime animation for the given property
  97067. */
  97068. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  97069. /**
  97070. * Resets the animatable to its original state
  97071. */
  97072. reset(): void;
  97073. /**
  97074. * Allows the animatable to blend with current running animations
  97075. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97076. * @param blendingSpeed defines the blending speed to use
  97077. */
  97078. enableBlending(blendingSpeed: number): void;
  97079. /**
  97080. * Disable animation blending
  97081. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97082. */
  97083. disableBlending(): void;
  97084. /**
  97085. * Jump directly to a given frame
  97086. * @param frame defines the frame to jump to
  97087. */
  97088. goToFrame(frame: number): void;
  97089. /**
  97090. * Pause the animation
  97091. */
  97092. pause(): void;
  97093. /**
  97094. * Restart the animation
  97095. */
  97096. restart(): void;
  97097. private _raiseOnAnimationEnd;
  97098. /**
  97099. * Stop and delete the current animation
  97100. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  97101. * @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)
  97102. */
  97103. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  97104. /**
  97105. * Wait asynchronously for the animation to end
  97106. * @returns a promise which will be fullfilled when the animation ends
  97107. */
  97108. waitAsync(): Promise<Animatable>;
  97109. /** @hidden */
  97110. _animate(delay: number): boolean;
  97111. }
  97112. interface Scene {
  97113. /** @hidden */
  97114. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  97115. /** @hidden */
  97116. _processLateAnimationBindingsForMatrices(holder: {
  97117. totalWeight: number;
  97118. totalAdditiveWeight: number;
  97119. animations: RuntimeAnimation[];
  97120. additiveAnimations: RuntimeAnimation[];
  97121. originalValue: Matrix;
  97122. }): any;
  97123. /** @hidden */
  97124. _processLateAnimationBindingsForQuaternions(holder: {
  97125. totalWeight: number;
  97126. totalAdditiveWeight: number;
  97127. animations: RuntimeAnimation[];
  97128. additiveAnimations: RuntimeAnimation[];
  97129. originalValue: Quaternion;
  97130. }, refQuaternion: Quaternion): Quaternion;
  97131. /** @hidden */
  97132. _processLateAnimationBindings(): void;
  97133. /**
  97134. * Will start the animation sequence of a given target
  97135. * @param target defines the target
  97136. * @param from defines from which frame should animation start
  97137. * @param to defines until which frame should animation run.
  97138. * @param weight defines the weight to apply to the animation (1.0 by default)
  97139. * @param loop defines if the animation loops
  97140. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  97141. * @param onAnimationEnd defines the function to be executed when the animation ends
  97142. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  97143. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  97144. * @param onAnimationLoop defines the callback to call when an animation loops
  97145. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97146. * @returns the animatable object created for this animation
  97147. */
  97148. 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;
  97149. /**
  97150. * Will start the animation sequence of a given target
  97151. * @param target defines the target
  97152. * @param from defines from which frame should animation start
  97153. * @param to defines until which frame should animation run.
  97154. * @param loop defines if the animation loops
  97155. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  97156. * @param onAnimationEnd defines the function to be executed when the animation ends
  97157. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  97158. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  97159. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  97160. * @param onAnimationLoop defines the callback to call when an animation loops
  97161. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97162. * @returns the animatable object created for this animation
  97163. */
  97164. 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;
  97165. /**
  97166. * Will start the animation sequence of a given target and its hierarchy
  97167. * @param target defines the target
  97168. * @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.
  97169. * @param from defines from which frame should animation start
  97170. * @param to defines until which frame should animation run.
  97171. * @param loop defines if the animation loops
  97172. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  97173. * @param onAnimationEnd defines the function to be executed when the animation ends
  97174. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  97175. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  97176. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  97177. * @param onAnimationLoop defines the callback to call when an animation loops
  97178. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97179. * @returns the list of created animatables
  97180. */
  97181. 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[];
  97182. /**
  97183. * Begin a new animation on a given node
  97184. * @param target defines the target where the animation will take place
  97185. * @param animations defines the list of animations to start
  97186. * @param from defines the initial value
  97187. * @param to defines the final value
  97188. * @param loop defines if you want animation to loop (off by default)
  97189. * @param speedRatio defines the speed ratio to apply to all animations
  97190. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  97191. * @param onAnimationLoop defines the callback to call when an animation loops
  97192. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97193. * @returns the list of created animatables
  97194. */
  97195. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  97196. /**
  97197. * Begin a new animation on a given node and its hierarchy
  97198. * @param target defines the root node where the animation will take place
  97199. * @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.
  97200. * @param animations defines the list of animations to start
  97201. * @param from defines the initial value
  97202. * @param to defines the final value
  97203. * @param loop defines if you want animation to loop (off by default)
  97204. * @param speedRatio defines the speed ratio to apply to all animations
  97205. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  97206. * @param onAnimationLoop defines the callback to call when an animation loops
  97207. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  97208. * @returns the list of animatables created for all nodes
  97209. */
  97210. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  97211. /**
  97212. * Gets the animatable associated with a specific target
  97213. * @param target defines the target of the animatable
  97214. * @returns the required animatable if found
  97215. */
  97216. getAnimatableByTarget(target: any): Nullable<Animatable>;
  97217. /**
  97218. * Gets all animatables associated with a given target
  97219. * @param target defines the target to look animatables for
  97220. * @returns an array of Animatables
  97221. */
  97222. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  97223. /**
  97224. * Stops and removes all animations that have been applied to the scene
  97225. */
  97226. stopAllAnimations(): void;
  97227. /**
  97228. * Gets the current delta time used by animation engine
  97229. */
  97230. deltaTime: number;
  97231. }
  97232. interface Bone {
  97233. /**
  97234. * Copy an animation range from another bone
  97235. * @param source defines the source bone
  97236. * @param rangeName defines the range name to copy
  97237. * @param frameOffset defines the frame offset
  97238. * @param rescaleAsRequired defines if rescaling must be applied if required
  97239. * @param skelDimensionsRatio defines the scaling ratio
  97240. * @returns true if operation was successful
  97241. */
  97242. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  97243. }
  97244. }
  97245. declare module BABYLON {
  97246. /**
  97247. * Class used to handle skinning animations
  97248. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  97249. */
  97250. export class Skeleton implements IAnimatable {
  97251. /** defines the skeleton name */
  97252. name: string;
  97253. /** defines the skeleton Id */
  97254. id: string;
  97255. /**
  97256. * Defines the list of child bones
  97257. */
  97258. bones: Bone[];
  97259. /**
  97260. * Defines an estimate of the dimension of the skeleton at rest
  97261. */
  97262. dimensionsAtRest: Vector3;
  97263. /**
  97264. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  97265. */
  97266. needInitialSkinMatrix: boolean;
  97267. /**
  97268. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  97269. */
  97270. overrideMesh: Nullable<AbstractMesh>;
  97271. /**
  97272. * Gets the list of animations attached to this skeleton
  97273. */
  97274. animations: Array<Animation>;
  97275. private _scene;
  97276. private _isDirty;
  97277. private _transformMatrices;
  97278. private _transformMatrixTexture;
  97279. private _meshesWithPoseMatrix;
  97280. private _animatables;
  97281. private _identity;
  97282. private _synchronizedWithMesh;
  97283. private _ranges;
  97284. private _lastAbsoluteTransformsUpdateId;
  97285. private _canUseTextureForBones;
  97286. private _uniqueId;
  97287. /** @hidden */
  97288. _numBonesWithLinkedTransformNode: number;
  97289. /** @hidden */
  97290. _hasWaitingData: Nullable<boolean>;
  97291. /** @hidden */
  97292. _waitingOverrideMeshId: Nullable<string>;
  97293. /**
  97294. * Specifies if the skeleton should be serialized
  97295. */
  97296. doNotSerialize: boolean;
  97297. private _useTextureToStoreBoneMatrices;
  97298. /**
  97299. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  97300. * Please note that this option is not available if the hardware does not support it
  97301. */
  97302. get useTextureToStoreBoneMatrices(): boolean;
  97303. set useTextureToStoreBoneMatrices(value: boolean);
  97304. private _animationPropertiesOverride;
  97305. /**
  97306. * Gets or sets the animation properties override
  97307. */
  97308. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  97309. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  97310. /**
  97311. * List of inspectable custom properties (used by the Inspector)
  97312. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  97313. */
  97314. inspectableCustomProperties: IInspectable[];
  97315. /**
  97316. * An observable triggered before computing the skeleton's matrices
  97317. */
  97318. onBeforeComputeObservable: Observable<Skeleton>;
  97319. /**
  97320. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  97321. */
  97322. get isUsingTextureForMatrices(): boolean;
  97323. /**
  97324. * Gets the unique ID of this skeleton
  97325. */
  97326. get uniqueId(): number;
  97327. /**
  97328. * Creates a new skeleton
  97329. * @param name defines the skeleton name
  97330. * @param id defines the skeleton Id
  97331. * @param scene defines the hosting scene
  97332. */
  97333. constructor(
  97334. /** defines the skeleton name */
  97335. name: string,
  97336. /** defines the skeleton Id */
  97337. id: string, scene: Scene);
  97338. /**
  97339. * Gets the current object class name.
  97340. * @return the class name
  97341. */
  97342. getClassName(): string;
  97343. /**
  97344. * Returns an array containing the root bones
  97345. * @returns an array containing the root bones
  97346. */
  97347. getChildren(): Array<Bone>;
  97348. /**
  97349. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  97350. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  97351. * @returns a Float32Array containing matrices data
  97352. */
  97353. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  97354. /**
  97355. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  97356. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  97357. * @returns a raw texture containing the data
  97358. */
  97359. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  97360. /**
  97361. * Gets the current hosting scene
  97362. * @returns a scene object
  97363. */
  97364. getScene(): Scene;
  97365. /**
  97366. * Gets a string representing the current skeleton data
  97367. * @param fullDetails defines a boolean indicating if we want a verbose version
  97368. * @returns a string representing the current skeleton data
  97369. */
  97370. toString(fullDetails?: boolean): string;
  97371. /**
  97372. * Get bone's index searching by name
  97373. * @param name defines bone's name to search for
  97374. * @return the indice of the bone. Returns -1 if not found
  97375. */
  97376. getBoneIndexByName(name: string): number;
  97377. /**
  97378. * Creater a new animation range
  97379. * @param name defines the name of the range
  97380. * @param from defines the start key
  97381. * @param to defines the end key
  97382. */
  97383. createAnimationRange(name: string, from: number, to: number): void;
  97384. /**
  97385. * Delete a specific animation range
  97386. * @param name defines the name of the range
  97387. * @param deleteFrames defines if frames must be removed as well
  97388. */
  97389. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  97390. /**
  97391. * Gets a specific animation range
  97392. * @param name defines the name of the range to look for
  97393. * @returns the requested animation range or null if not found
  97394. */
  97395. getAnimationRange(name: string): Nullable<AnimationRange>;
  97396. /**
  97397. * Gets the list of all animation ranges defined on this skeleton
  97398. * @returns an array
  97399. */
  97400. getAnimationRanges(): Nullable<AnimationRange>[];
  97401. /**
  97402. * Copy animation range from a source skeleton.
  97403. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  97404. * @param source defines the source skeleton
  97405. * @param name defines the name of the range to copy
  97406. * @param rescaleAsRequired defines if rescaling must be applied if required
  97407. * @returns true if operation was successful
  97408. */
  97409. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  97410. /**
  97411. * Forces the skeleton to go to rest pose
  97412. */
  97413. returnToRest(): void;
  97414. private _getHighestAnimationFrame;
  97415. /**
  97416. * Begin a specific animation range
  97417. * @param name defines the name of the range to start
  97418. * @param loop defines if looping must be turned on (false by default)
  97419. * @param speedRatio defines the speed ratio to apply (1 by default)
  97420. * @param onAnimationEnd defines a callback which will be called when animation will end
  97421. * @returns a new animatable
  97422. */
  97423. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  97424. /**
  97425. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  97426. * @param skeleton defines the Skeleton containing the animation range to convert
  97427. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  97428. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  97429. * @returns the original skeleton
  97430. */
  97431. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  97432. /** @hidden */
  97433. _markAsDirty(): void;
  97434. /** @hidden */
  97435. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97436. /** @hidden */
  97437. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  97438. private _computeTransformMatrices;
  97439. /**
  97440. * Build all resources required to render a skeleton
  97441. */
  97442. prepare(): void;
  97443. /**
  97444. * Gets the list of animatables currently running for this skeleton
  97445. * @returns an array of animatables
  97446. */
  97447. getAnimatables(): IAnimatable[];
  97448. /**
  97449. * Clone the current skeleton
  97450. * @param name defines the name of the new skeleton
  97451. * @param id defines the id of the new skeleton
  97452. * @returns the new skeleton
  97453. */
  97454. clone(name: string, id?: string): Skeleton;
  97455. /**
  97456. * Enable animation blending for this skeleton
  97457. * @param blendingSpeed defines the blending speed to apply
  97458. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  97459. */
  97460. enableBlending(blendingSpeed?: number): void;
  97461. /**
  97462. * Releases all resources associated with the current skeleton
  97463. */
  97464. dispose(): void;
  97465. /**
  97466. * Serialize the skeleton in a JSON object
  97467. * @returns a JSON object
  97468. */
  97469. serialize(): any;
  97470. /**
  97471. * Creates a new skeleton from serialized data
  97472. * @param parsedSkeleton defines the serialized data
  97473. * @param scene defines the hosting scene
  97474. * @returns a new skeleton
  97475. */
  97476. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  97477. /**
  97478. * Compute all node absolute transforms
  97479. * @param forceUpdate defines if computation must be done even if cache is up to date
  97480. */
  97481. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  97482. /**
  97483. * Gets the root pose matrix
  97484. * @returns a matrix
  97485. */
  97486. getPoseMatrix(): Nullable<Matrix>;
  97487. /**
  97488. * Sorts bones per internal index
  97489. */
  97490. sortBones(): void;
  97491. private _sortBones;
  97492. /**
  97493. * Set the current local matrix as the restPose for all bones in the skeleton.
  97494. */
  97495. setCurrentPoseAsRest(): void;
  97496. }
  97497. }
  97498. declare module BABYLON {
  97499. /**
  97500. * Creates an instance based on a source mesh.
  97501. */
  97502. export class InstancedMesh extends AbstractMesh {
  97503. private _sourceMesh;
  97504. private _currentLOD;
  97505. /** @hidden */
  97506. _indexInSourceMeshInstanceArray: number;
  97507. constructor(name: string, source: Mesh);
  97508. /**
  97509. * Returns the string "InstancedMesh".
  97510. */
  97511. getClassName(): string;
  97512. /** Gets the list of lights affecting that mesh */
  97513. get lightSources(): Light[];
  97514. _resyncLightSources(): void;
  97515. _resyncLightSource(light: Light): void;
  97516. _removeLightSource(light: Light, dispose: boolean): void;
  97517. /**
  97518. * If the source mesh receives shadows
  97519. */
  97520. get receiveShadows(): boolean;
  97521. /**
  97522. * The material of the source mesh
  97523. */
  97524. get material(): Nullable<Material>;
  97525. /**
  97526. * Visibility of the source mesh
  97527. */
  97528. get visibility(): number;
  97529. /**
  97530. * Skeleton of the source mesh
  97531. */
  97532. get skeleton(): Nullable<Skeleton>;
  97533. /**
  97534. * Rendering ground id of the source mesh
  97535. */
  97536. get renderingGroupId(): number;
  97537. set renderingGroupId(value: number);
  97538. /**
  97539. * Returns the total number of vertices (integer).
  97540. */
  97541. getTotalVertices(): number;
  97542. /**
  97543. * Returns a positive integer : the total number of indices in this mesh geometry.
  97544. * @returns the numner of indices or zero if the mesh has no geometry.
  97545. */
  97546. getTotalIndices(): number;
  97547. /**
  97548. * The source mesh of the instance
  97549. */
  97550. get sourceMesh(): Mesh;
  97551. /**
  97552. * Creates a new InstancedMesh object from the mesh model.
  97553. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97554. * @param name defines the name of the new instance
  97555. * @returns a new InstancedMesh
  97556. */
  97557. createInstance(name: string): InstancedMesh;
  97558. /**
  97559. * Is this node ready to be used/rendered
  97560. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97561. * @return {boolean} is it ready
  97562. */
  97563. isReady(completeCheck?: boolean): boolean;
  97564. /**
  97565. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97566. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  97567. * @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.
  97568. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  97569. */
  97570. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  97571. /**
  97572. * Sets the vertex data of the mesh geometry for the requested `kind`.
  97573. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  97574. * The `data` are either a numeric array either a Float32Array.
  97575. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  97576. * 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).
  97577. * Note that a new underlying VertexBuffer object is created each call.
  97578. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  97579. *
  97580. * Possible `kind` values :
  97581. * - VertexBuffer.PositionKind
  97582. * - VertexBuffer.UVKind
  97583. * - VertexBuffer.UV2Kind
  97584. * - VertexBuffer.UV3Kind
  97585. * - VertexBuffer.UV4Kind
  97586. * - VertexBuffer.UV5Kind
  97587. * - VertexBuffer.UV6Kind
  97588. * - VertexBuffer.ColorKind
  97589. * - VertexBuffer.MatricesIndicesKind
  97590. * - VertexBuffer.MatricesIndicesExtraKind
  97591. * - VertexBuffer.MatricesWeightsKind
  97592. * - VertexBuffer.MatricesWeightsExtraKind
  97593. *
  97594. * Returns the Mesh.
  97595. */
  97596. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97597. /**
  97598. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  97599. * If the mesh has no geometry, it is simply returned as it is.
  97600. * The `data` are either a numeric array either a Float32Array.
  97601. * No new underlying VertexBuffer object is created.
  97602. * 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.
  97603. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  97604. *
  97605. * Possible `kind` values :
  97606. * - VertexBuffer.PositionKind
  97607. * - VertexBuffer.UVKind
  97608. * - VertexBuffer.UV2Kind
  97609. * - VertexBuffer.UV3Kind
  97610. * - VertexBuffer.UV4Kind
  97611. * - VertexBuffer.UV5Kind
  97612. * - VertexBuffer.UV6Kind
  97613. * - VertexBuffer.ColorKind
  97614. * - VertexBuffer.MatricesIndicesKind
  97615. * - VertexBuffer.MatricesIndicesExtraKind
  97616. * - VertexBuffer.MatricesWeightsKind
  97617. * - VertexBuffer.MatricesWeightsExtraKind
  97618. *
  97619. * Returns the Mesh.
  97620. */
  97621. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  97622. /**
  97623. * Sets the mesh indices.
  97624. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  97625. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  97626. * This method creates a new index buffer each call.
  97627. * Returns the Mesh.
  97628. */
  97629. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  97630. /**
  97631. * Boolean : True if the mesh owns the requested kind of data.
  97632. */
  97633. isVerticesDataPresent(kind: string): boolean;
  97634. /**
  97635. * Returns an array of indices (IndicesArray).
  97636. */
  97637. getIndices(): Nullable<IndicesArray>;
  97638. get _positions(): Nullable<Vector3[]>;
  97639. /**
  97640. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97641. * This means the mesh underlying bounding box and sphere are recomputed.
  97642. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97643. * @returns the current mesh
  97644. */
  97645. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  97646. /** @hidden */
  97647. _preActivate(): InstancedMesh;
  97648. /** @hidden */
  97649. _activate(renderId: number, intermediateRendering: boolean): boolean;
  97650. /** @hidden */
  97651. _postActivate(): void;
  97652. getWorldMatrix(): Matrix;
  97653. get isAnInstance(): boolean;
  97654. /**
  97655. * Returns the current associated LOD AbstractMesh.
  97656. */
  97657. getLOD(camera: Camera): AbstractMesh;
  97658. /** @hidden */
  97659. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97660. /** @hidden */
  97661. _syncSubMeshes(): InstancedMesh;
  97662. /** @hidden */
  97663. _generatePointsArray(): boolean;
  97664. /** @hidden */
  97665. _updateBoundingInfo(): AbstractMesh;
  97666. /**
  97667. * Creates a new InstancedMesh from the current mesh.
  97668. * - name (string) : the cloned mesh name
  97669. * - newParent (optional Node) : the optional Node to parent the clone to.
  97670. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  97671. *
  97672. * Returns the clone.
  97673. */
  97674. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  97675. /**
  97676. * Disposes the InstancedMesh.
  97677. * Returns nothing.
  97678. */
  97679. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  97680. }
  97681. interface Mesh {
  97682. /**
  97683. * Register a custom buffer that will be instanced
  97684. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97685. * @param kind defines the buffer kind
  97686. * @param stride defines the stride in floats
  97687. */
  97688. registerInstancedBuffer(kind: string, stride: number): void;
  97689. /**
  97690. * true to use the edge renderer for all instances of this mesh
  97691. */
  97692. edgesShareWithInstances: boolean;
  97693. /** @hidden */
  97694. _userInstancedBuffersStorage: {
  97695. data: {
  97696. [key: string]: Float32Array;
  97697. };
  97698. sizes: {
  97699. [key: string]: number;
  97700. };
  97701. vertexBuffers: {
  97702. [key: string]: Nullable<VertexBuffer>;
  97703. };
  97704. strides: {
  97705. [key: string]: number;
  97706. };
  97707. };
  97708. }
  97709. interface AbstractMesh {
  97710. /**
  97711. * Object used to store instanced buffers defined by user
  97712. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97713. */
  97714. instancedBuffers: {
  97715. [key: string]: any;
  97716. };
  97717. }
  97718. }
  97719. declare module BABYLON {
  97720. /**
  97721. * Defines the options associated with the creation of a shader material.
  97722. */
  97723. export interface IShaderMaterialOptions {
  97724. /**
  97725. * Does the material work in alpha blend mode
  97726. */
  97727. needAlphaBlending: boolean;
  97728. /**
  97729. * Does the material work in alpha test mode
  97730. */
  97731. needAlphaTesting: boolean;
  97732. /**
  97733. * The list of attribute names used in the shader
  97734. */
  97735. attributes: string[];
  97736. /**
  97737. * The list of unifrom names used in the shader
  97738. */
  97739. uniforms: string[];
  97740. /**
  97741. * The list of UBO names used in the shader
  97742. */
  97743. uniformBuffers: string[];
  97744. /**
  97745. * The list of sampler names used in the shader
  97746. */
  97747. samplers: string[];
  97748. /**
  97749. * The list of defines used in the shader
  97750. */
  97751. defines: string[];
  97752. }
  97753. /**
  97754. * 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.
  97755. *
  97756. * This returned material effects how the mesh will look based on the code in the shaders.
  97757. *
  97758. * @see https://doc.babylonjs.com/how_to/shader_material
  97759. */
  97760. export class ShaderMaterial extends Material {
  97761. private _shaderPath;
  97762. private _options;
  97763. private _textures;
  97764. private _textureArrays;
  97765. private _floats;
  97766. private _ints;
  97767. private _floatsArrays;
  97768. private _colors3;
  97769. private _colors3Arrays;
  97770. private _colors4;
  97771. private _colors4Arrays;
  97772. private _vectors2;
  97773. private _vectors3;
  97774. private _vectors4;
  97775. private _matrices;
  97776. private _matrixArrays;
  97777. private _matrices3x3;
  97778. private _matrices2x2;
  97779. private _vectors2Arrays;
  97780. private _vectors3Arrays;
  97781. private _vectors4Arrays;
  97782. private _cachedWorldViewMatrix;
  97783. private _cachedWorldViewProjectionMatrix;
  97784. private _renderId;
  97785. private _multiview;
  97786. private _cachedDefines;
  97787. /** Define the Url to load snippets */
  97788. static SnippetUrl: string;
  97789. /** Snippet ID if the material was created from the snippet server */
  97790. snippetId: string;
  97791. /**
  97792. * Instantiate a new shader material.
  97793. * 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.
  97794. * This returned material effects how the mesh will look based on the code in the shaders.
  97795. * @see https://doc.babylonjs.com/how_to/shader_material
  97796. * @param name Define the name of the material in the scene
  97797. * @param scene Define the scene the material belongs to
  97798. * @param shaderPath Defines the route to the shader code in one of three ways:
  97799. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97800. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97801. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97802. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97803. * @param options Define the options used to create the shader
  97804. */
  97805. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97806. /**
  97807. * Gets the shader path used to define the shader code
  97808. * It can be modified to trigger a new compilation
  97809. */
  97810. get shaderPath(): any;
  97811. /**
  97812. * Sets the shader path used to define the shader code
  97813. * It can be modified to trigger a new compilation
  97814. */
  97815. set shaderPath(shaderPath: any);
  97816. /**
  97817. * Gets the options used to compile the shader.
  97818. * They can be modified to trigger a new compilation
  97819. */
  97820. get options(): IShaderMaterialOptions;
  97821. /**
  97822. * Gets the current class name of the material e.g. "ShaderMaterial"
  97823. * Mainly use in serialization.
  97824. * @returns the class name
  97825. */
  97826. getClassName(): string;
  97827. /**
  97828. * Specifies if the material will require alpha blending
  97829. * @returns a boolean specifying if alpha blending is needed
  97830. */
  97831. needAlphaBlending(): boolean;
  97832. /**
  97833. * Specifies if this material should be rendered in alpha test mode
  97834. * @returns a boolean specifying if an alpha test is needed.
  97835. */
  97836. needAlphaTesting(): boolean;
  97837. private _checkUniform;
  97838. /**
  97839. * Set a texture in the shader.
  97840. * @param name Define the name of the uniform samplers as defined in the shader
  97841. * @param texture Define the texture to bind to this sampler
  97842. * @return the material itself allowing "fluent" like uniform updates
  97843. */
  97844. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97845. /**
  97846. * Set a texture array in the shader.
  97847. * @param name Define the name of the uniform sampler array as defined in the shader
  97848. * @param textures Define the list of textures to bind to this sampler
  97849. * @return the material itself allowing "fluent" like uniform updates
  97850. */
  97851. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97852. /**
  97853. * Set a float in the shader.
  97854. * @param name Define the name of the uniform as defined in the shader
  97855. * @param value Define the value to give to the uniform
  97856. * @return the material itself allowing "fluent" like uniform updates
  97857. */
  97858. setFloat(name: string, value: number): ShaderMaterial;
  97859. /**
  97860. * Set a int in the shader.
  97861. * @param name Define the name of the uniform as defined in the shader
  97862. * @param value Define the value to give to the uniform
  97863. * @return the material itself allowing "fluent" like uniform updates
  97864. */
  97865. setInt(name: string, value: number): ShaderMaterial;
  97866. /**
  97867. * Set an array of floats in the shader.
  97868. * @param name Define the name of the uniform as defined in the shader
  97869. * @param value Define the value to give to the uniform
  97870. * @return the material itself allowing "fluent" like uniform updates
  97871. */
  97872. setFloats(name: string, value: number[]): ShaderMaterial;
  97873. /**
  97874. * Set a vec3 in the shader from a Color3.
  97875. * @param name Define the name of the uniform as defined in the shader
  97876. * @param value Define the value to give to the uniform
  97877. * @return the material itself allowing "fluent" like uniform updates
  97878. */
  97879. setColor3(name: string, value: Color3): ShaderMaterial;
  97880. /**
  97881. * Set a vec3 array in the shader from a Color3 array.
  97882. * @param name Define the name of the uniform as defined in the shader
  97883. * @param value Define the value to give to the uniform
  97884. * @return the material itself allowing "fluent" like uniform updates
  97885. */
  97886. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97887. /**
  97888. * Set a vec4 in the shader from a Color4.
  97889. * @param name Define the name of the uniform as defined in the shader
  97890. * @param value Define the value to give to the uniform
  97891. * @return the material itself allowing "fluent" like uniform updates
  97892. */
  97893. setColor4(name: string, value: Color4): ShaderMaterial;
  97894. /**
  97895. * Set a vec4 array in the shader from a Color4 array.
  97896. * @param name Define the name of the uniform as defined in the shader
  97897. * @param value Define the value to give to the uniform
  97898. * @return the material itself allowing "fluent" like uniform updates
  97899. */
  97900. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97901. /**
  97902. * Set a vec2 in the shader from a Vector2.
  97903. * @param name Define the name of the uniform as defined in the shader
  97904. * @param value Define the value to give to the uniform
  97905. * @return the material itself allowing "fluent" like uniform updates
  97906. */
  97907. setVector2(name: string, value: Vector2): ShaderMaterial;
  97908. /**
  97909. * Set a vec3 in the shader from a Vector3.
  97910. * @param name Define the name of the uniform as defined in the shader
  97911. * @param value Define the value to give to the uniform
  97912. * @return the material itself allowing "fluent" like uniform updates
  97913. */
  97914. setVector3(name: string, value: Vector3): ShaderMaterial;
  97915. /**
  97916. * Set a vec4 in the shader from a Vector4.
  97917. * @param name Define the name of the uniform as defined in the shader
  97918. * @param value Define the value to give to the uniform
  97919. * @return the material itself allowing "fluent" like uniform updates
  97920. */
  97921. setVector4(name: string, value: Vector4): ShaderMaterial;
  97922. /**
  97923. * Set a mat4 in the shader from a Matrix.
  97924. * @param name Define the name of the uniform as defined in the shader
  97925. * @param value Define the value to give to the uniform
  97926. * @return the material itself allowing "fluent" like uniform updates
  97927. */
  97928. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97929. /**
  97930. * Set a float32Array in the shader from a matrix array.
  97931. * @param name Define the name of the uniform as defined in the shader
  97932. * @param value Define the value to give to the uniform
  97933. * @return the material itself allowing "fluent" like uniform updates
  97934. */
  97935. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97936. /**
  97937. * Set a mat3 in the shader from a Float32Array.
  97938. * @param name Define the name of the uniform as defined in the shader
  97939. * @param value Define the value to give to the uniform
  97940. * @return the material itself allowing "fluent" like uniform updates
  97941. */
  97942. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97943. /**
  97944. * Set a mat2 in the shader from a Float32Array.
  97945. * @param name Define the name of the uniform as defined in the shader
  97946. * @param value Define the value to give to the uniform
  97947. * @return the material itself allowing "fluent" like uniform updates
  97948. */
  97949. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97950. /**
  97951. * Set a vec2 array in the shader from a number array.
  97952. * @param name Define the name of the uniform as defined in the shader
  97953. * @param value Define the value to give to the uniform
  97954. * @return the material itself allowing "fluent" like uniform updates
  97955. */
  97956. setArray2(name: string, value: number[]): ShaderMaterial;
  97957. /**
  97958. * Set a vec3 array in the shader from a number array.
  97959. * @param name Define the name of the uniform as defined in the shader
  97960. * @param value Define the value to give to the uniform
  97961. * @return the material itself allowing "fluent" like uniform updates
  97962. */
  97963. setArray3(name: string, value: number[]): ShaderMaterial;
  97964. /**
  97965. * Set a vec4 array in the shader from a number array.
  97966. * @param name Define the name of the uniform as defined in the shader
  97967. * @param value Define the value to give to the uniform
  97968. * @return the material itself allowing "fluent" like uniform updates
  97969. */
  97970. setArray4(name: string, value: number[]): ShaderMaterial;
  97971. private _checkCache;
  97972. /**
  97973. * Specifies that the submesh is ready to be used
  97974. * @param mesh defines the mesh to check
  97975. * @param subMesh defines which submesh to check
  97976. * @param useInstances specifies that instances should be used
  97977. * @returns a boolean indicating that the submesh is ready or not
  97978. */
  97979. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97980. /**
  97981. * Checks if the material is ready to render the requested mesh
  97982. * @param mesh Define the mesh to render
  97983. * @param useInstances Define whether or not the material is used with instances
  97984. * @returns true if ready, otherwise false
  97985. */
  97986. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97987. /**
  97988. * Binds the world matrix to the material
  97989. * @param world defines the world transformation matrix
  97990. * @param effectOverride - If provided, use this effect instead of internal effect
  97991. */
  97992. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97993. /**
  97994. * Binds the submesh to this material by preparing the effect and shader to draw
  97995. * @param world defines the world transformation matrix
  97996. * @param mesh defines the mesh containing the submesh
  97997. * @param subMesh defines the submesh to bind the material to
  97998. */
  97999. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98000. /**
  98001. * Binds the material to the mesh
  98002. * @param world defines the world transformation matrix
  98003. * @param mesh defines the mesh to bind the material to
  98004. * @param effectOverride - If provided, use this effect instead of internal effect
  98005. */
  98006. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  98007. protected _afterBind(mesh?: Mesh): void;
  98008. /**
  98009. * Gets the active textures from the material
  98010. * @returns an array of textures
  98011. */
  98012. getActiveTextures(): BaseTexture[];
  98013. /**
  98014. * Specifies if the material uses a texture
  98015. * @param texture defines the texture to check against the material
  98016. * @returns a boolean specifying if the material uses the texture
  98017. */
  98018. hasTexture(texture: BaseTexture): boolean;
  98019. /**
  98020. * Makes a duplicate of the material, and gives it a new name
  98021. * @param name defines the new name for the duplicated material
  98022. * @returns the cloned material
  98023. */
  98024. clone(name: string): ShaderMaterial;
  98025. /**
  98026. * Disposes the material
  98027. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98028. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98029. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  98030. */
  98031. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  98032. /**
  98033. * Serializes this material in a JSON representation
  98034. * @returns the serialized material object
  98035. */
  98036. serialize(): any;
  98037. /**
  98038. * Creates a shader material from parsed shader material data
  98039. * @param source defines the JSON represnetation of the material
  98040. * @param scene defines the hosting scene
  98041. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98042. * @returns a new material
  98043. */
  98044. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  98045. /**
  98046. * Creates a new ShaderMaterial from a snippet saved in a remote file
  98047. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  98048. * @param url defines the url to load from
  98049. * @param scene defines the hosting scene
  98050. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98051. * @returns a promise that will resolve to the new ShaderMaterial
  98052. */
  98053. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  98054. /**
  98055. * Creates a ShaderMaterial from a snippet saved by the Inspector
  98056. * @param snippetId defines the snippet to load
  98057. * @param scene defines the hosting scene
  98058. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98059. * @returns a promise that will resolve to the new ShaderMaterial
  98060. */
  98061. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  98062. }
  98063. }
  98064. declare module BABYLON {
  98065. /** @hidden */
  98066. export var colorPixelShader: {
  98067. name: string;
  98068. shader: string;
  98069. };
  98070. }
  98071. declare module BABYLON {
  98072. /** @hidden */
  98073. export var colorVertexShader: {
  98074. name: string;
  98075. shader: string;
  98076. };
  98077. }
  98078. declare module BABYLON {
  98079. /**
  98080. * Line mesh
  98081. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  98082. */
  98083. export class LinesMesh extends Mesh {
  98084. /**
  98085. * If vertex color should be applied to the mesh
  98086. */
  98087. readonly useVertexColor?: boolean | undefined;
  98088. /**
  98089. * If vertex alpha should be applied to the mesh
  98090. */
  98091. readonly useVertexAlpha?: boolean | undefined;
  98092. /**
  98093. * Color of the line (Default: White)
  98094. */
  98095. color: Color3;
  98096. /**
  98097. * Alpha of the line (Default: 1)
  98098. */
  98099. alpha: number;
  98100. /**
  98101. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  98102. * This margin is expressed in world space coordinates, so its value may vary.
  98103. * Default value is 0.1
  98104. */
  98105. intersectionThreshold: number;
  98106. private _colorShader;
  98107. private color4;
  98108. /**
  98109. * Creates a new LinesMesh
  98110. * @param name defines the name
  98111. * @param scene defines the hosting scene
  98112. * @param parent defines the parent mesh if any
  98113. * @param source defines the optional source LinesMesh used to clone data from
  98114. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  98115. * When false, achieved by calling a clone(), also passing False.
  98116. * This will make creation of children, recursive.
  98117. * @param useVertexColor defines if this LinesMesh supports vertex color
  98118. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  98119. */
  98120. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  98121. /**
  98122. * If vertex color should be applied to the mesh
  98123. */
  98124. useVertexColor?: boolean | undefined,
  98125. /**
  98126. * If vertex alpha should be applied to the mesh
  98127. */
  98128. useVertexAlpha?: boolean | undefined);
  98129. private _addClipPlaneDefine;
  98130. private _removeClipPlaneDefine;
  98131. isReady(): boolean;
  98132. /**
  98133. * Returns the string "LineMesh"
  98134. */
  98135. getClassName(): string;
  98136. /**
  98137. * @hidden
  98138. */
  98139. get material(): Material;
  98140. /**
  98141. * @hidden
  98142. */
  98143. set material(value: Material);
  98144. /**
  98145. * @hidden
  98146. */
  98147. get checkCollisions(): boolean;
  98148. /** @hidden */
  98149. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98150. /** @hidden */
  98151. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98152. /**
  98153. * Disposes of the line mesh
  98154. * @param doNotRecurse If children should be disposed
  98155. */
  98156. dispose(doNotRecurse?: boolean): void;
  98157. /**
  98158. * Returns a new LineMesh object cloned from the current one.
  98159. */
  98160. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  98161. /**
  98162. * Creates a new InstancedLinesMesh object from the mesh model.
  98163. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  98164. * @param name defines the name of the new instance
  98165. * @returns a new InstancedLinesMesh
  98166. */
  98167. createInstance(name: string): InstancedLinesMesh;
  98168. }
  98169. /**
  98170. * Creates an instance based on a source LinesMesh
  98171. */
  98172. export class InstancedLinesMesh extends InstancedMesh {
  98173. /**
  98174. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  98175. * This margin is expressed in world space coordinates, so its value may vary.
  98176. * Initilized with the intersectionThreshold value of the source LinesMesh
  98177. */
  98178. intersectionThreshold: number;
  98179. constructor(name: string, source: LinesMesh);
  98180. /**
  98181. * Returns the string "InstancedLinesMesh".
  98182. */
  98183. getClassName(): string;
  98184. }
  98185. }
  98186. declare module BABYLON {
  98187. /** @hidden */
  98188. export var linePixelShader: {
  98189. name: string;
  98190. shader: string;
  98191. };
  98192. }
  98193. declare module BABYLON {
  98194. /** @hidden */
  98195. export var lineVertexShader: {
  98196. name: string;
  98197. shader: string;
  98198. };
  98199. }
  98200. declare module BABYLON {
  98201. interface Scene {
  98202. /** @hidden */
  98203. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  98204. }
  98205. interface AbstractMesh {
  98206. /**
  98207. * Gets the edgesRenderer associated with the mesh
  98208. */
  98209. edgesRenderer: Nullable<EdgesRenderer>;
  98210. }
  98211. interface LinesMesh {
  98212. /**
  98213. * Enables the edge rendering mode on the mesh.
  98214. * This mode makes the mesh edges visible
  98215. * @param epsilon defines the maximal distance between two angles to detect a face
  98216. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  98217. * @returns the currentAbstractMesh
  98218. * @see https://www.babylonjs-playground.com/#19O9TU#0
  98219. */
  98220. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  98221. }
  98222. interface InstancedLinesMesh {
  98223. /**
  98224. * Enables the edge rendering mode on the mesh.
  98225. * This mode makes the mesh edges visible
  98226. * @param epsilon defines the maximal distance between two angles to detect a face
  98227. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  98228. * @returns the current InstancedLinesMesh
  98229. * @see https://www.babylonjs-playground.com/#19O9TU#0
  98230. */
  98231. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  98232. }
  98233. /**
  98234. * Defines the minimum contract an Edges renderer should follow.
  98235. */
  98236. export interface IEdgesRenderer extends IDisposable {
  98237. /**
  98238. * Gets or sets a boolean indicating if the edgesRenderer is active
  98239. */
  98240. isEnabled: boolean;
  98241. /**
  98242. * Renders the edges of the attached mesh,
  98243. */
  98244. render(): void;
  98245. /**
  98246. * Checks wether or not the edges renderer is ready to render.
  98247. * @return true if ready, otherwise false.
  98248. */
  98249. isReady(): boolean;
  98250. /**
  98251. * List of instances to render in case the source mesh has instances
  98252. */
  98253. customInstances: SmartArray<Matrix>;
  98254. }
  98255. /**
  98256. * Defines the additional options of the edges renderer
  98257. */
  98258. export interface IEdgesRendererOptions {
  98259. /**
  98260. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  98261. * If not defined, the default value is true
  98262. */
  98263. useAlternateEdgeFinder?: boolean;
  98264. /**
  98265. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  98266. * If not defined, the default value is true.
  98267. * 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)
  98268. * This option is used only if useAlternateEdgeFinder = true
  98269. */
  98270. useFastVertexMerger?: boolean;
  98271. /**
  98272. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  98273. * The default value is 1e-6
  98274. * This option is used only if useAlternateEdgeFinder = true
  98275. */
  98276. epsilonVertexMerge?: number;
  98277. /**
  98278. * 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
  98279. * 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.
  98280. * This option is used only if useAlternateEdgeFinder = true
  98281. */
  98282. applyTessellation?: boolean;
  98283. /**
  98284. * 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
  98285. * The default value is 1e-6
  98286. * This option is used only if useAlternateEdgeFinder = true
  98287. */
  98288. epsilonVertexAligned?: number;
  98289. }
  98290. /**
  98291. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  98292. */
  98293. export class EdgesRenderer implements IEdgesRenderer {
  98294. /**
  98295. * Define the size of the edges with an orthographic camera
  98296. */
  98297. edgesWidthScalerForOrthographic: number;
  98298. /**
  98299. * Define the size of the edges with a perspective camera
  98300. */
  98301. edgesWidthScalerForPerspective: number;
  98302. protected _source: AbstractMesh;
  98303. protected _linesPositions: number[];
  98304. protected _linesNormals: number[];
  98305. protected _linesIndices: number[];
  98306. protected _epsilon: number;
  98307. protected _indicesCount: number;
  98308. protected _lineShader: ShaderMaterial;
  98309. protected _ib: DataBuffer;
  98310. protected _buffers: {
  98311. [key: string]: Nullable<VertexBuffer>;
  98312. };
  98313. protected _buffersForInstances: {
  98314. [key: string]: Nullable<VertexBuffer>;
  98315. };
  98316. protected _checkVerticesInsteadOfIndices: boolean;
  98317. protected _options: Nullable<IEdgesRendererOptions>;
  98318. private _meshRebuildObserver;
  98319. private _meshDisposeObserver;
  98320. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  98321. isEnabled: boolean;
  98322. /**
  98323. * List of instances to render in case the source mesh has instances
  98324. */
  98325. customInstances: SmartArray<Matrix>;
  98326. private static GetShader;
  98327. /**
  98328. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  98329. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  98330. * @param source Mesh used to create edges
  98331. * @param epsilon sum of angles in adjacency to check for edge
  98332. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  98333. * @param generateEdgesLines - should generate Lines or only prepare resources.
  98334. * @param options The options to apply when generating the edges
  98335. */
  98336. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  98337. protected _prepareRessources(): void;
  98338. /** @hidden */
  98339. _rebuild(): void;
  98340. /**
  98341. * Releases the required resources for the edges renderer
  98342. */
  98343. dispose(): void;
  98344. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  98345. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  98346. /**
  98347. * Checks if the pair of p0 and p1 is en edge
  98348. * @param faceIndex
  98349. * @param edge
  98350. * @param faceNormals
  98351. * @param p0
  98352. * @param p1
  98353. * @private
  98354. */
  98355. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  98356. /**
  98357. * push line into the position, normal and index buffer
  98358. * @protected
  98359. */
  98360. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  98361. /**
  98362. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  98363. */
  98364. private _tessellateTriangle;
  98365. private _generateEdgesLinesAlternate;
  98366. /**
  98367. * Generates lines edges from adjacencjes
  98368. * @private
  98369. */
  98370. _generateEdgesLines(): void;
  98371. /**
  98372. * Checks wether or not the edges renderer is ready to render.
  98373. * @return true if ready, otherwise false.
  98374. */
  98375. isReady(): boolean;
  98376. /**
  98377. * Renders the edges of the attached mesh,
  98378. */
  98379. render(): void;
  98380. }
  98381. /**
  98382. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  98383. */
  98384. export class LineEdgesRenderer extends EdgesRenderer {
  98385. /**
  98386. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  98387. * @param source LineMesh used to generate edges
  98388. * @param epsilon not important (specified angle for edge detection)
  98389. * @param checkVerticesInsteadOfIndices not important for LineMesh
  98390. */
  98391. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  98392. /**
  98393. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  98394. */
  98395. _generateEdgesLines(): void;
  98396. }
  98397. }
  98398. declare module BABYLON {
  98399. /**
  98400. * This represents the object necessary to create a rendering group.
  98401. * This is exclusively used and created by the rendering manager.
  98402. * To modify the behavior, you use the available helpers in your scene or meshes.
  98403. * @hidden
  98404. */
  98405. export class RenderingGroup {
  98406. index: number;
  98407. private static _zeroVector;
  98408. private _scene;
  98409. private _opaqueSubMeshes;
  98410. private _transparentSubMeshes;
  98411. private _alphaTestSubMeshes;
  98412. private _depthOnlySubMeshes;
  98413. private _particleSystems;
  98414. private _spriteManagers;
  98415. private _opaqueSortCompareFn;
  98416. private _alphaTestSortCompareFn;
  98417. private _transparentSortCompareFn;
  98418. private _renderOpaque;
  98419. private _renderAlphaTest;
  98420. private _renderTransparent;
  98421. /** @hidden */
  98422. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  98423. onBeforeTransparentRendering: () => void;
  98424. /**
  98425. * Set the opaque sort comparison function.
  98426. * If null the sub meshes will be render in the order they were created
  98427. */
  98428. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98429. /**
  98430. * Set the alpha test sort comparison function.
  98431. * If null the sub meshes will be render in the order they were created
  98432. */
  98433. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98434. /**
  98435. * Set the transparent sort comparison function.
  98436. * If null the sub meshes will be render in the order they were created
  98437. */
  98438. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  98439. /**
  98440. * Creates a new rendering group.
  98441. * @param index The rendering group index
  98442. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  98443. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  98444. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  98445. */
  98446. 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>);
  98447. /**
  98448. * Render all the sub meshes contained in the group.
  98449. * @param customRenderFunction Used to override the default render behaviour of the group.
  98450. * @returns true if rendered some submeshes.
  98451. */
  98452. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  98453. /**
  98454. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  98455. * @param subMeshes The submeshes to render
  98456. */
  98457. private renderOpaqueSorted;
  98458. /**
  98459. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  98460. * @param subMeshes The submeshes to render
  98461. */
  98462. private renderAlphaTestSorted;
  98463. /**
  98464. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  98465. * @param subMeshes The submeshes to render
  98466. */
  98467. private renderTransparentSorted;
  98468. /**
  98469. * Renders the submeshes in a specified order.
  98470. * @param subMeshes The submeshes to sort before render
  98471. * @param sortCompareFn The comparison function use to sort
  98472. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  98473. * @param transparent Specifies to activate blending if true
  98474. */
  98475. private static renderSorted;
  98476. /**
  98477. * Renders the submeshes in the order they were dispatched (no sort applied).
  98478. * @param subMeshes The submeshes to render
  98479. */
  98480. private static renderUnsorted;
  98481. /**
  98482. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98483. * are rendered back to front if in the same alpha index.
  98484. *
  98485. * @param a The first submesh
  98486. * @param b The second submesh
  98487. * @returns The result of the comparison
  98488. */
  98489. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  98490. /**
  98491. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98492. * are rendered back to front.
  98493. *
  98494. * @param a The first submesh
  98495. * @param b The second submesh
  98496. * @returns The result of the comparison
  98497. */
  98498. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  98499. /**
  98500. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  98501. * are rendered front to back (prevent overdraw).
  98502. *
  98503. * @param a The first submesh
  98504. * @param b The second submesh
  98505. * @returns The result of the comparison
  98506. */
  98507. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  98508. /**
  98509. * Resets the different lists of submeshes to prepare a new frame.
  98510. */
  98511. prepare(): void;
  98512. dispose(): void;
  98513. /**
  98514. * Inserts the submesh in its correct queue depending on its material.
  98515. * @param subMesh The submesh to dispatch
  98516. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98517. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98518. */
  98519. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98520. dispatchSprites(spriteManager: ISpriteManager): void;
  98521. dispatchParticles(particleSystem: IParticleSystem): void;
  98522. private _renderParticles;
  98523. private _renderSprites;
  98524. }
  98525. }
  98526. declare module BABYLON {
  98527. /**
  98528. * Interface describing the different options available in the rendering manager
  98529. * regarding Auto Clear between groups.
  98530. */
  98531. export interface IRenderingManagerAutoClearSetup {
  98532. /**
  98533. * Defines whether or not autoclear is enable.
  98534. */
  98535. autoClear: boolean;
  98536. /**
  98537. * Defines whether or not to autoclear the depth buffer.
  98538. */
  98539. depth: boolean;
  98540. /**
  98541. * Defines whether or not to autoclear the stencil buffer.
  98542. */
  98543. stencil: boolean;
  98544. }
  98545. /**
  98546. * This class is used by the onRenderingGroupObservable
  98547. */
  98548. export class RenderingGroupInfo {
  98549. /**
  98550. * The Scene that being rendered
  98551. */
  98552. scene: Scene;
  98553. /**
  98554. * The camera currently used for the rendering pass
  98555. */
  98556. camera: Nullable<Camera>;
  98557. /**
  98558. * The ID of the renderingGroup being processed
  98559. */
  98560. renderingGroupId: number;
  98561. }
  98562. /**
  98563. * This is the manager responsible of all the rendering for meshes sprites and particles.
  98564. * It is enable to manage the different groups as well as the different necessary sort functions.
  98565. * This should not be used directly aside of the few static configurations
  98566. */
  98567. export class RenderingManager {
  98568. /**
  98569. * The max id used for rendering groups (not included)
  98570. */
  98571. static MAX_RENDERINGGROUPS: number;
  98572. /**
  98573. * The min id used for rendering groups (included)
  98574. */
  98575. static MIN_RENDERINGGROUPS: number;
  98576. /**
  98577. * Used to globally prevent autoclearing scenes.
  98578. */
  98579. static AUTOCLEAR: boolean;
  98580. /**
  98581. * @hidden
  98582. */
  98583. _useSceneAutoClearSetup: boolean;
  98584. private _scene;
  98585. private _renderingGroups;
  98586. private _depthStencilBufferAlreadyCleaned;
  98587. private _autoClearDepthStencil;
  98588. private _customOpaqueSortCompareFn;
  98589. private _customAlphaTestSortCompareFn;
  98590. private _customTransparentSortCompareFn;
  98591. private _renderingGroupInfo;
  98592. /**
  98593. * Instantiates a new rendering group for a particular scene
  98594. * @param scene Defines the scene the groups belongs to
  98595. */
  98596. constructor(scene: Scene);
  98597. private _clearDepthStencilBuffer;
  98598. /**
  98599. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  98600. * @hidden
  98601. */
  98602. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  98603. /**
  98604. * Resets the different information of the group to prepare a new frame
  98605. * @hidden
  98606. */
  98607. reset(): void;
  98608. /**
  98609. * Dispose and release the group and its associated resources.
  98610. * @hidden
  98611. */
  98612. dispose(): void;
  98613. /**
  98614. * Clear the info related to rendering groups preventing retention points during dispose.
  98615. */
  98616. freeRenderingGroups(): void;
  98617. private _prepareRenderingGroup;
  98618. /**
  98619. * Add a sprite manager to the rendering manager in order to render it this frame.
  98620. * @param spriteManager Define the sprite manager to render
  98621. */
  98622. dispatchSprites(spriteManager: ISpriteManager): void;
  98623. /**
  98624. * Add a particle system to the rendering manager in order to render it this frame.
  98625. * @param particleSystem Define the particle system to render
  98626. */
  98627. dispatchParticles(particleSystem: IParticleSystem): void;
  98628. /**
  98629. * Add a submesh to the manager in order to render it this frame
  98630. * @param subMesh The submesh to dispatch
  98631. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  98632. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  98633. */
  98634. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  98635. /**
  98636. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  98637. * This allowed control for front to back rendering or reversly depending of the special needs.
  98638. *
  98639. * @param renderingGroupId The rendering group id corresponding to its index
  98640. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  98641. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  98642. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  98643. */
  98644. 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;
  98645. /**
  98646. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  98647. *
  98648. * @param renderingGroupId The rendering group id corresponding to its index
  98649. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  98650. * @param depth Automatically clears depth between groups if true and autoClear is true.
  98651. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  98652. */
  98653. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  98654. /**
  98655. * Gets the current auto clear configuration for one rendering group of the rendering
  98656. * manager.
  98657. * @param index the rendering group index to get the information for
  98658. * @returns The auto clear setup for the requested rendering group
  98659. */
  98660. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  98661. }
  98662. }
  98663. declare module BABYLON {
  98664. /**
  98665. * Defines the options associated with the creation of a custom shader for a shadow generator.
  98666. */
  98667. export interface ICustomShaderOptions {
  98668. /**
  98669. * Gets or sets the custom shader name to use
  98670. */
  98671. shaderName: string;
  98672. /**
  98673. * The list of attribute names used in the shader
  98674. */
  98675. attributes?: string[];
  98676. /**
  98677. * The list of unifrom names used in the shader
  98678. */
  98679. uniforms?: string[];
  98680. /**
  98681. * The list of sampler names used in the shader
  98682. */
  98683. samplers?: string[];
  98684. /**
  98685. * The list of defines used in the shader
  98686. */
  98687. defines?: string[];
  98688. }
  98689. /**
  98690. * Interface to implement to create a shadow generator compatible with BJS.
  98691. */
  98692. export interface IShadowGenerator {
  98693. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98694. id: string;
  98695. /**
  98696. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98697. * @returns The render target texture if present otherwise, null
  98698. */
  98699. getShadowMap(): Nullable<RenderTargetTexture>;
  98700. /**
  98701. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98702. * @param subMesh The submesh we want to render in the shadow map
  98703. * @param useInstances Defines wether will draw in the map using instances
  98704. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98705. * @returns true if ready otherwise, false
  98706. */
  98707. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98708. /**
  98709. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98710. * @param defines Defines of the material we want to update
  98711. * @param lightIndex Index of the light in the enabled light list of the material
  98712. */
  98713. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98714. /**
  98715. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98716. * defined in the generator but impacting the effect).
  98717. * It implies the unifroms available on the materials are the standard BJS ones.
  98718. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98719. * @param effect The effect we are binfing the information for
  98720. */
  98721. bindShadowLight(lightIndex: string, effect: Effect): void;
  98722. /**
  98723. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98724. * (eq to shadow prjection matrix * light transform matrix)
  98725. * @returns The transform matrix used to create the shadow map
  98726. */
  98727. getTransformMatrix(): Matrix;
  98728. /**
  98729. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98730. * Cube and 2D textures for instance.
  98731. */
  98732. recreateShadowMap(): void;
  98733. /**
  98734. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98735. * @param onCompiled Callback triggered at the and of the effects compilation
  98736. * @param options Sets of optional options forcing the compilation with different modes
  98737. */
  98738. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98739. useInstances: boolean;
  98740. }>): void;
  98741. /**
  98742. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98743. * @param options Sets of optional options forcing the compilation with different modes
  98744. * @returns A promise that resolves when the compilation completes
  98745. */
  98746. forceCompilationAsync(options?: Partial<{
  98747. useInstances: boolean;
  98748. }>): Promise<void>;
  98749. /**
  98750. * Serializes the shadow generator setup to a json object.
  98751. * @returns The serialized JSON object
  98752. */
  98753. serialize(): any;
  98754. /**
  98755. * Disposes the Shadow map and related Textures and effects.
  98756. */
  98757. dispose(): void;
  98758. }
  98759. /**
  98760. * Default implementation IShadowGenerator.
  98761. * This is the main object responsible of generating shadows in the framework.
  98762. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98763. */
  98764. export class ShadowGenerator implements IShadowGenerator {
  98765. /**
  98766. * Name of the shadow generator class
  98767. */
  98768. static CLASSNAME: string;
  98769. /**
  98770. * Shadow generator mode None: no filtering applied.
  98771. */
  98772. static readonly FILTER_NONE: number;
  98773. /**
  98774. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98775. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98776. */
  98777. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98778. /**
  98779. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98780. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98781. */
  98782. static readonly FILTER_POISSONSAMPLING: number;
  98783. /**
  98784. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98785. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98786. */
  98787. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98788. /**
  98789. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98790. * edge artifacts on steep falloff.
  98791. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98792. */
  98793. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98794. /**
  98795. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98796. * edge artifacts on steep falloff.
  98797. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98798. */
  98799. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98800. /**
  98801. * Shadow generator mode PCF: Percentage Closer Filtering
  98802. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98803. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98804. */
  98805. static readonly FILTER_PCF: number;
  98806. /**
  98807. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98808. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98809. * Contact Hardening
  98810. */
  98811. static readonly FILTER_PCSS: number;
  98812. /**
  98813. * Reserved for PCF and PCSS
  98814. * Highest Quality.
  98815. *
  98816. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98817. *
  98818. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98819. */
  98820. static readonly QUALITY_HIGH: number;
  98821. /**
  98822. * Reserved for PCF and PCSS
  98823. * Good tradeoff for quality/perf cross devices
  98824. *
  98825. * Execute PCF on a 3*3 kernel.
  98826. *
  98827. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98828. */
  98829. static readonly QUALITY_MEDIUM: number;
  98830. /**
  98831. * Reserved for PCF and PCSS
  98832. * The lowest quality but the fastest.
  98833. *
  98834. * Execute PCF on a 1*1 kernel.
  98835. *
  98836. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98837. */
  98838. static readonly QUALITY_LOW: number;
  98839. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98840. id: string;
  98841. /** Gets or sets the custom shader name to use */
  98842. customShaderOptions: ICustomShaderOptions;
  98843. /**
  98844. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98845. */
  98846. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98847. /**
  98848. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98849. */
  98850. onAfterShadowMapRenderObservable: Observable<Effect>;
  98851. /**
  98852. * Observable triggered before a mesh is rendered in the shadow map.
  98853. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98854. */
  98855. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98856. /**
  98857. * Observable triggered after a mesh is rendered in the shadow map.
  98858. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98859. */
  98860. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98861. protected _bias: number;
  98862. /**
  98863. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98864. */
  98865. get bias(): number;
  98866. /**
  98867. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98868. */
  98869. set bias(bias: number);
  98870. protected _normalBias: number;
  98871. /**
  98872. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98873. */
  98874. get normalBias(): number;
  98875. /**
  98876. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98877. */
  98878. set normalBias(normalBias: number);
  98879. protected _blurBoxOffset: number;
  98880. /**
  98881. * Gets the blur box offset: offset applied during the blur pass.
  98882. * Only useful if useKernelBlur = false
  98883. */
  98884. get blurBoxOffset(): number;
  98885. /**
  98886. * Sets the blur box offset: offset applied during the blur pass.
  98887. * Only useful if useKernelBlur = false
  98888. */
  98889. set blurBoxOffset(value: number);
  98890. protected _blurScale: number;
  98891. /**
  98892. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98893. * 2 means half of the size.
  98894. */
  98895. get blurScale(): number;
  98896. /**
  98897. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98898. * 2 means half of the size.
  98899. */
  98900. set blurScale(value: number);
  98901. protected _blurKernel: number;
  98902. /**
  98903. * Gets the blur kernel: kernel size of the blur pass.
  98904. * Only useful if useKernelBlur = true
  98905. */
  98906. get blurKernel(): number;
  98907. /**
  98908. * Sets the blur kernel: kernel size of the blur pass.
  98909. * Only useful if useKernelBlur = true
  98910. */
  98911. set blurKernel(value: number);
  98912. protected _useKernelBlur: boolean;
  98913. /**
  98914. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98915. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98916. */
  98917. get useKernelBlur(): boolean;
  98918. /**
  98919. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98920. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98921. */
  98922. set useKernelBlur(value: boolean);
  98923. protected _depthScale: number;
  98924. /**
  98925. * Gets the depth scale used in ESM mode.
  98926. */
  98927. get depthScale(): number;
  98928. /**
  98929. * Sets the depth scale used in ESM mode.
  98930. * This can override the scale stored on the light.
  98931. */
  98932. set depthScale(value: number);
  98933. protected _validateFilter(filter: number): number;
  98934. protected _filter: number;
  98935. /**
  98936. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98937. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98938. */
  98939. get filter(): number;
  98940. /**
  98941. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98942. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98943. */
  98944. set filter(value: number);
  98945. /**
  98946. * Gets if the current filter is set to Poisson Sampling.
  98947. */
  98948. get usePoissonSampling(): boolean;
  98949. /**
  98950. * Sets the current filter to Poisson Sampling.
  98951. */
  98952. set usePoissonSampling(value: boolean);
  98953. /**
  98954. * Gets if the current filter is set to ESM.
  98955. */
  98956. get useExponentialShadowMap(): boolean;
  98957. /**
  98958. * Sets the current filter is to ESM.
  98959. */
  98960. set useExponentialShadowMap(value: boolean);
  98961. /**
  98962. * Gets if the current filter is set to filtered ESM.
  98963. */
  98964. get useBlurExponentialShadowMap(): boolean;
  98965. /**
  98966. * Gets if the current filter is set to filtered ESM.
  98967. */
  98968. set useBlurExponentialShadowMap(value: boolean);
  98969. /**
  98970. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98971. * exponential to prevent steep falloff artifacts).
  98972. */
  98973. get useCloseExponentialShadowMap(): boolean;
  98974. /**
  98975. * Sets the current filter to "close ESM" (using the inverse of the
  98976. * exponential to prevent steep falloff artifacts).
  98977. */
  98978. set useCloseExponentialShadowMap(value: boolean);
  98979. /**
  98980. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98981. * exponential to prevent steep falloff artifacts).
  98982. */
  98983. get useBlurCloseExponentialShadowMap(): boolean;
  98984. /**
  98985. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98986. * exponential to prevent steep falloff artifacts).
  98987. */
  98988. set useBlurCloseExponentialShadowMap(value: boolean);
  98989. /**
  98990. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98991. */
  98992. get usePercentageCloserFiltering(): boolean;
  98993. /**
  98994. * Sets the current filter to "PCF" (percentage closer filtering).
  98995. */
  98996. set usePercentageCloserFiltering(value: boolean);
  98997. protected _filteringQuality: number;
  98998. /**
  98999. * Gets the PCF or PCSS Quality.
  99000. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  99001. */
  99002. get filteringQuality(): number;
  99003. /**
  99004. * Sets the PCF or PCSS Quality.
  99005. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  99006. */
  99007. set filteringQuality(filteringQuality: number);
  99008. /**
  99009. * Gets if the current filter is set to "PCSS" (contact hardening).
  99010. */
  99011. get useContactHardeningShadow(): boolean;
  99012. /**
  99013. * Sets the current filter to "PCSS" (contact hardening).
  99014. */
  99015. set useContactHardeningShadow(value: boolean);
  99016. protected _contactHardeningLightSizeUVRatio: number;
  99017. /**
  99018. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  99019. * Using a ratio helps keeping shape stability independently of the map size.
  99020. *
  99021. * It does not account for the light projection as it was having too much
  99022. * instability during the light setup or during light position changes.
  99023. *
  99024. * Only valid if useContactHardeningShadow is true.
  99025. */
  99026. get contactHardeningLightSizeUVRatio(): number;
  99027. /**
  99028. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  99029. * Using a ratio helps keeping shape stability independently of the map size.
  99030. *
  99031. * It does not account for the light projection as it was having too much
  99032. * instability during the light setup or during light position changes.
  99033. *
  99034. * Only valid if useContactHardeningShadow is true.
  99035. */
  99036. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  99037. protected _darkness: number;
  99038. /** Gets or sets the actual darkness of a shadow */
  99039. get darkness(): number;
  99040. set darkness(value: number);
  99041. /**
  99042. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  99043. * 0 means strongest and 1 would means no shadow.
  99044. * @returns the darkness.
  99045. */
  99046. getDarkness(): number;
  99047. /**
  99048. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  99049. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  99050. * @returns the shadow generator allowing fluent coding.
  99051. */
  99052. setDarkness(darkness: number): ShadowGenerator;
  99053. protected _transparencyShadow: boolean;
  99054. /** Gets or sets the ability to have transparent shadow */
  99055. get transparencyShadow(): boolean;
  99056. set transparencyShadow(value: boolean);
  99057. /**
  99058. * Sets the ability to have transparent shadow (boolean).
  99059. * @param transparent True if transparent else False
  99060. * @returns the shadow generator allowing fluent coding
  99061. */
  99062. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  99063. /**
  99064. * Enables or disables shadows with varying strength based on the transparency
  99065. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  99066. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  99067. * mesh.visibility * alphaTexture.a
  99068. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  99069. */
  99070. enableSoftTransparentShadow: boolean;
  99071. protected _shadowMap: Nullable<RenderTargetTexture>;
  99072. protected _shadowMap2: Nullable<RenderTargetTexture>;
  99073. /**
  99074. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  99075. * @returns The render target texture if present otherwise, null
  99076. */
  99077. getShadowMap(): Nullable<RenderTargetTexture>;
  99078. /**
  99079. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  99080. * @returns The render target texture if the shadow map is present otherwise, null
  99081. */
  99082. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  99083. /**
  99084. * Gets the class name of that object
  99085. * @returns "ShadowGenerator"
  99086. */
  99087. getClassName(): string;
  99088. /**
  99089. * Helper function to add a mesh and its descendants to the list of shadow casters.
  99090. * @param mesh Mesh to add
  99091. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  99092. * @returns the Shadow Generator itself
  99093. */
  99094. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  99095. /**
  99096. * Helper function to remove a mesh and its descendants from the list of shadow casters
  99097. * @param mesh Mesh to remove
  99098. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  99099. * @returns the Shadow Generator itself
  99100. */
  99101. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  99102. /**
  99103. * Controls the extent to which the shadows fade out at the edge of the frustum
  99104. */
  99105. frustumEdgeFalloff: number;
  99106. protected _light: IShadowLight;
  99107. /**
  99108. * Returns the associated light object.
  99109. * @returns the light generating the shadow
  99110. */
  99111. getLight(): IShadowLight;
  99112. /**
  99113. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  99114. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  99115. * It might on the other hand introduce peter panning.
  99116. */
  99117. forceBackFacesOnly: boolean;
  99118. protected _scene: Scene;
  99119. protected _lightDirection: Vector3;
  99120. protected _effect: Effect;
  99121. protected _viewMatrix: Matrix;
  99122. protected _projectionMatrix: Matrix;
  99123. protected _transformMatrix: Matrix;
  99124. protected _cachedPosition: Vector3;
  99125. protected _cachedDirection: Vector3;
  99126. protected _cachedDefines: string;
  99127. protected _currentRenderID: number;
  99128. protected _boxBlurPostprocess: Nullable<PostProcess>;
  99129. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  99130. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  99131. protected _blurPostProcesses: PostProcess[];
  99132. protected _mapSize: number;
  99133. protected _currentFaceIndex: number;
  99134. protected _currentFaceIndexCache: number;
  99135. protected _textureType: number;
  99136. protected _defaultTextureMatrix: Matrix;
  99137. protected _storedUniqueId: Nullable<number>;
  99138. /** @hidden */
  99139. static _SceneComponentInitialization: (scene: Scene) => void;
  99140. /**
  99141. * Gets or sets the size of the texture what stores the shadows
  99142. */
  99143. get mapSize(): number;
  99144. set mapSize(size: number);
  99145. /**
  99146. * Creates a ShadowGenerator object.
  99147. * A ShadowGenerator is the required tool to use the shadows.
  99148. * Each light casting shadows needs to use its own ShadowGenerator.
  99149. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  99150. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  99151. * @param light The light object generating the shadows.
  99152. * @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.
  99153. */
  99154. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  99155. protected _initializeGenerator(): void;
  99156. protected _createTargetRenderTexture(): void;
  99157. protected _initializeShadowMap(): void;
  99158. protected _initializeBlurRTTAndPostProcesses(): void;
  99159. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  99160. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  99161. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  99162. protected _applyFilterValues(): void;
  99163. /**
  99164. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  99165. * @param onCompiled Callback triggered at the and of the effects compilation
  99166. * @param options Sets of optional options forcing the compilation with different modes
  99167. */
  99168. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  99169. useInstances: boolean;
  99170. }>): void;
  99171. /**
  99172. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  99173. * @param options Sets of optional options forcing the compilation with different modes
  99174. * @returns A promise that resolves when the compilation completes
  99175. */
  99176. forceCompilationAsync(options?: Partial<{
  99177. useInstances: boolean;
  99178. }>): Promise<void>;
  99179. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  99180. private _prepareShadowDefines;
  99181. /**
  99182. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  99183. * @param subMesh The submesh we want to render in the shadow map
  99184. * @param useInstances Defines wether will draw in the map using instances
  99185. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  99186. * @returns true if ready otherwise, false
  99187. */
  99188. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  99189. /**
  99190. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  99191. * @param defines Defines of the material we want to update
  99192. * @param lightIndex Index of the light in the enabled light list of the material
  99193. */
  99194. prepareDefines(defines: any, lightIndex: number): void;
  99195. /**
  99196. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  99197. * defined in the generator but impacting the effect).
  99198. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  99199. * @param effect The effect we are binfing the information for
  99200. */
  99201. bindShadowLight(lightIndex: string, effect: Effect): void;
  99202. /**
  99203. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  99204. * (eq to shadow prjection matrix * light transform matrix)
  99205. * @returns The transform matrix used to create the shadow map
  99206. */
  99207. getTransformMatrix(): Matrix;
  99208. /**
  99209. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  99210. * Cube and 2D textures for instance.
  99211. */
  99212. recreateShadowMap(): void;
  99213. protected _disposeBlurPostProcesses(): void;
  99214. protected _disposeRTTandPostProcesses(): void;
  99215. /**
  99216. * Disposes the ShadowGenerator.
  99217. * Returns nothing.
  99218. */
  99219. dispose(): void;
  99220. /**
  99221. * Serializes the shadow generator setup to a json object.
  99222. * @returns The serialized JSON object
  99223. */
  99224. serialize(): any;
  99225. /**
  99226. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  99227. * @param parsedShadowGenerator The JSON object to parse
  99228. * @param scene The scene to create the shadow map for
  99229. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  99230. * @returns The parsed shadow generator
  99231. */
  99232. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  99233. }
  99234. }
  99235. declare module BABYLON {
  99236. /**
  99237. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  99238. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  99239. * 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.
  99240. */
  99241. export abstract class Light extends Node {
  99242. /**
  99243. * Falloff Default: light is falling off following the material specification:
  99244. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  99245. */
  99246. static readonly FALLOFF_DEFAULT: number;
  99247. /**
  99248. * Falloff Physical: light is falling off following the inverse squared distance law.
  99249. */
  99250. static readonly FALLOFF_PHYSICAL: number;
  99251. /**
  99252. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  99253. * to enhance interoperability with other engines.
  99254. */
  99255. static readonly FALLOFF_GLTF: number;
  99256. /**
  99257. * Falloff Standard: light is falling off like in the standard material
  99258. * to enhance interoperability with other materials.
  99259. */
  99260. static readonly FALLOFF_STANDARD: number;
  99261. /**
  99262. * If every light affecting the material is in this lightmapMode,
  99263. * material.lightmapTexture adds or multiplies
  99264. * (depends on material.useLightmapAsShadowmap)
  99265. * after every other light calculations.
  99266. */
  99267. static readonly LIGHTMAP_DEFAULT: number;
  99268. /**
  99269. * material.lightmapTexture as only diffuse lighting from this light
  99270. * adds only specular lighting from this light
  99271. * adds dynamic shadows
  99272. */
  99273. static readonly LIGHTMAP_SPECULAR: number;
  99274. /**
  99275. * material.lightmapTexture as only lighting
  99276. * no light calculation from this light
  99277. * only adds dynamic shadows from this light
  99278. */
  99279. static readonly LIGHTMAP_SHADOWSONLY: number;
  99280. /**
  99281. * Each light type uses the default quantity according to its type:
  99282. * point/spot lights use luminous intensity
  99283. * directional lights use illuminance
  99284. */
  99285. static readonly INTENSITYMODE_AUTOMATIC: number;
  99286. /**
  99287. * lumen (lm)
  99288. */
  99289. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  99290. /**
  99291. * candela (lm/sr)
  99292. */
  99293. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  99294. /**
  99295. * lux (lm/m^2)
  99296. */
  99297. static readonly INTENSITYMODE_ILLUMINANCE: number;
  99298. /**
  99299. * nit (cd/m^2)
  99300. */
  99301. static readonly INTENSITYMODE_LUMINANCE: number;
  99302. /**
  99303. * Light type const id of the point light.
  99304. */
  99305. static readonly LIGHTTYPEID_POINTLIGHT: number;
  99306. /**
  99307. * Light type const id of the directional light.
  99308. */
  99309. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  99310. /**
  99311. * Light type const id of the spot light.
  99312. */
  99313. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  99314. /**
  99315. * Light type const id of the hemispheric light.
  99316. */
  99317. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  99318. /**
  99319. * Diffuse gives the basic color to an object.
  99320. */
  99321. diffuse: Color3;
  99322. /**
  99323. * Specular produces a highlight color on an object.
  99324. * Note: This is note affecting PBR materials.
  99325. */
  99326. specular: Color3;
  99327. /**
  99328. * Defines the falloff type for this light. This lets overrriding how punctual light are
  99329. * falling off base on range or angle.
  99330. * This can be set to any values in Light.FALLOFF_x.
  99331. *
  99332. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  99333. * other types of materials.
  99334. */
  99335. falloffType: number;
  99336. /**
  99337. * Strength of the light.
  99338. * Note: By default it is define in the framework own unit.
  99339. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  99340. */
  99341. intensity: number;
  99342. private _range;
  99343. protected _inverseSquaredRange: number;
  99344. /**
  99345. * Defines how far from the source the light is impacting in scene units.
  99346. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  99347. */
  99348. get range(): number;
  99349. /**
  99350. * Defines how far from the source the light is impacting in scene units.
  99351. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  99352. */
  99353. set range(value: number);
  99354. /**
  99355. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  99356. * of light.
  99357. */
  99358. private _photometricScale;
  99359. private _intensityMode;
  99360. /**
  99361. * Gets the photometric scale used to interpret the intensity.
  99362. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  99363. */
  99364. get intensityMode(): number;
  99365. /**
  99366. * Sets the photometric scale used to interpret the intensity.
  99367. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  99368. */
  99369. set intensityMode(value: number);
  99370. private _radius;
  99371. /**
  99372. * Gets the light radius used by PBR Materials to simulate soft area lights.
  99373. */
  99374. get radius(): number;
  99375. /**
  99376. * sets the light radius used by PBR Materials to simulate soft area lights.
  99377. */
  99378. set radius(value: number);
  99379. private _renderPriority;
  99380. /**
  99381. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  99382. * exceeding the number allowed of the materials.
  99383. */
  99384. renderPriority: number;
  99385. private _shadowEnabled;
  99386. /**
  99387. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99388. * the current shadow generator.
  99389. */
  99390. get shadowEnabled(): boolean;
  99391. /**
  99392. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  99393. * the current shadow generator.
  99394. */
  99395. set shadowEnabled(value: boolean);
  99396. private _includedOnlyMeshes;
  99397. /**
  99398. * Gets the only meshes impacted by this light.
  99399. */
  99400. get includedOnlyMeshes(): AbstractMesh[];
  99401. /**
  99402. * Sets the only meshes impacted by this light.
  99403. */
  99404. set includedOnlyMeshes(value: AbstractMesh[]);
  99405. private _excludedMeshes;
  99406. /**
  99407. * Gets the meshes not impacted by this light.
  99408. */
  99409. get excludedMeshes(): AbstractMesh[];
  99410. /**
  99411. * Sets the meshes not impacted by this light.
  99412. */
  99413. set excludedMeshes(value: AbstractMesh[]);
  99414. private _excludeWithLayerMask;
  99415. /**
  99416. * Gets the layer id use to find what meshes are not impacted by the light.
  99417. * Inactive if 0
  99418. */
  99419. get excludeWithLayerMask(): number;
  99420. /**
  99421. * Sets the layer id use to find what meshes are not impacted by the light.
  99422. * Inactive if 0
  99423. */
  99424. set excludeWithLayerMask(value: number);
  99425. private _includeOnlyWithLayerMask;
  99426. /**
  99427. * Gets the layer id use to find what meshes are impacted by the light.
  99428. * Inactive if 0
  99429. */
  99430. get includeOnlyWithLayerMask(): number;
  99431. /**
  99432. * Sets the layer id use to find what meshes are impacted by the light.
  99433. * Inactive if 0
  99434. */
  99435. set includeOnlyWithLayerMask(value: number);
  99436. private _lightmapMode;
  99437. /**
  99438. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99439. */
  99440. get lightmapMode(): number;
  99441. /**
  99442. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  99443. */
  99444. set lightmapMode(value: number);
  99445. /**
  99446. * Shadow generator associted to the light.
  99447. * @hidden Internal use only.
  99448. */
  99449. _shadowGenerator: Nullable<IShadowGenerator>;
  99450. /**
  99451. * @hidden Internal use only.
  99452. */
  99453. _excludedMeshesIds: string[];
  99454. /**
  99455. * @hidden Internal use only.
  99456. */
  99457. _includedOnlyMeshesIds: string[];
  99458. /**
  99459. * The current light unifom buffer.
  99460. * @hidden Internal use only.
  99461. */
  99462. _uniformBuffer: UniformBuffer;
  99463. /** @hidden */
  99464. _renderId: number;
  99465. /**
  99466. * Creates a Light object in the scene.
  99467. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99468. * @param name The firendly name of the light
  99469. * @param scene The scene the light belongs too
  99470. */
  99471. constructor(name: string, scene: Scene);
  99472. protected abstract _buildUniformLayout(): void;
  99473. /**
  99474. * Sets the passed Effect "effect" with the Light information.
  99475. * @param effect The effect to update
  99476. * @param lightIndex The index of the light in the effect to update
  99477. * @returns The light
  99478. */
  99479. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  99480. /**
  99481. * Sets the passed Effect "effect" with the Light textures.
  99482. * @param effect The effect to update
  99483. * @param lightIndex The index of the light in the effect to update
  99484. * @returns The light
  99485. */
  99486. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  99487. /**
  99488. * Binds the lights information from the scene to the effect for the given mesh.
  99489. * @param lightIndex Light index
  99490. * @param scene The scene where the light belongs to
  99491. * @param effect The effect we are binding the data to
  99492. * @param useSpecular Defines if specular is supported
  99493. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  99494. */
  99495. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  99496. /**
  99497. * Sets the passed Effect "effect" with the Light information.
  99498. * @param effect The effect to update
  99499. * @param lightDataUniformName The uniform used to store light data (position or direction)
  99500. * @returns The light
  99501. */
  99502. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  99503. /**
  99504. * Returns the string "Light".
  99505. * @returns the class name
  99506. */
  99507. getClassName(): string;
  99508. /** @hidden */
  99509. readonly _isLight: boolean;
  99510. /**
  99511. * Converts the light information to a readable string for debug purpose.
  99512. * @param fullDetails Supports for multiple levels of logging within scene loading
  99513. * @returns the human readable light info
  99514. */
  99515. toString(fullDetails?: boolean): string;
  99516. /** @hidden */
  99517. protected _syncParentEnabledState(): void;
  99518. /**
  99519. * Set the enabled state of this node.
  99520. * @param value - the new enabled state
  99521. */
  99522. setEnabled(value: boolean): void;
  99523. /**
  99524. * Returns the Light associated shadow generator if any.
  99525. * @return the associated shadow generator.
  99526. */
  99527. getShadowGenerator(): Nullable<IShadowGenerator>;
  99528. /**
  99529. * Returns a Vector3, the absolute light position in the World.
  99530. * @returns the world space position of the light
  99531. */
  99532. getAbsolutePosition(): Vector3;
  99533. /**
  99534. * Specifies if the light will affect the passed mesh.
  99535. * @param mesh The mesh to test against the light
  99536. * @return true the mesh is affected otherwise, false.
  99537. */
  99538. canAffectMesh(mesh: AbstractMesh): boolean;
  99539. /**
  99540. * Sort function to order lights for rendering.
  99541. * @param a First Light object to compare to second.
  99542. * @param b Second Light object to compare first.
  99543. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  99544. */
  99545. static CompareLightsPriority(a: Light, b: Light): number;
  99546. /**
  99547. * Releases resources associated with this node.
  99548. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99549. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99550. */
  99551. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99552. /**
  99553. * Returns the light type ID (integer).
  99554. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99555. */
  99556. getTypeID(): number;
  99557. /**
  99558. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  99559. * @returns the scaled intensity in intensity mode unit
  99560. */
  99561. getScaledIntensity(): number;
  99562. /**
  99563. * Returns a new Light object, named "name", from the current one.
  99564. * @param name The name of the cloned light
  99565. * @param newParent The parent of this light, if it has one
  99566. * @returns the new created light
  99567. */
  99568. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  99569. /**
  99570. * Serializes the current light into a Serialization object.
  99571. * @returns the serialized object.
  99572. */
  99573. serialize(): any;
  99574. /**
  99575. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  99576. * This new light is named "name" and added to the passed scene.
  99577. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  99578. * @param name The friendly name of the light
  99579. * @param scene The scene the new light will belong to
  99580. * @returns the constructor function
  99581. */
  99582. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  99583. /**
  99584. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  99585. * @param parsedLight The JSON representation of the light
  99586. * @param scene The scene to create the parsed light in
  99587. * @returns the created light after parsing
  99588. */
  99589. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  99590. private _hookArrayForExcluded;
  99591. private _hookArrayForIncludedOnly;
  99592. private _resyncMeshes;
  99593. /**
  99594. * Forces the meshes to update their light related information in their rendering used effects
  99595. * @hidden Internal Use Only
  99596. */
  99597. _markMeshesAsLightDirty(): void;
  99598. /**
  99599. * Recomputes the cached photometric scale if needed.
  99600. */
  99601. private _computePhotometricScale;
  99602. /**
  99603. * Returns the Photometric Scale according to the light type and intensity mode.
  99604. */
  99605. private _getPhotometricScale;
  99606. /**
  99607. * Reorder the light in the scene according to their defined priority.
  99608. * @hidden Internal Use Only
  99609. */
  99610. _reorderLightsInScene(): void;
  99611. /**
  99612. * Prepares the list of defines specific to the light type.
  99613. * @param defines the list of defines
  99614. * @param lightIndex defines the index of the light for the effect
  99615. */
  99616. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99617. }
  99618. }
  99619. declare module BABYLON {
  99620. /**
  99621. * Configuration needed for prepass-capable materials
  99622. */
  99623. export class PrePassConfiguration {
  99624. /**
  99625. * Previous world matrices of meshes carrying this material
  99626. * Used for computing velocity
  99627. */
  99628. previousWorldMatrices: {
  99629. [index: number]: Matrix;
  99630. };
  99631. /**
  99632. * Previous view project matrix
  99633. * Used for computing velocity
  99634. */
  99635. previousViewProjection: Matrix;
  99636. /**
  99637. * Previous bones of meshes carrying this material
  99638. * Used for computing velocity
  99639. */
  99640. previousBones: {
  99641. [index: number]: Float32Array;
  99642. };
  99643. /**
  99644. * Add the required uniforms to the current list.
  99645. * @param uniforms defines the current uniform list.
  99646. */
  99647. static AddUniforms(uniforms: string[]): void;
  99648. /**
  99649. * Add the required samplers to the current list.
  99650. * @param samplers defines the current sampler list.
  99651. */
  99652. static AddSamplers(samplers: string[]): void;
  99653. /**
  99654. * Binds the material data.
  99655. * @param effect defines the effect to update
  99656. * @param scene defines the scene the material belongs to.
  99657. * @param mesh The mesh
  99658. * @param world World matrix of this mesh
  99659. * @param isFrozen Is the material frozen
  99660. */
  99661. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  99662. }
  99663. }
  99664. declare module BABYLON {
  99665. /**
  99666. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  99667. * This is the base of the follow, arc rotate cameras and Free camera
  99668. * @see https://doc.babylonjs.com/features/cameras
  99669. */
  99670. export class TargetCamera extends Camera {
  99671. private static _RigCamTransformMatrix;
  99672. private static _TargetTransformMatrix;
  99673. private static _TargetFocalPoint;
  99674. private _tmpUpVector;
  99675. private _tmpTargetVector;
  99676. /**
  99677. * Define the current direction the camera is moving to
  99678. */
  99679. cameraDirection: Vector3;
  99680. /**
  99681. * Define the current rotation the camera is rotating to
  99682. */
  99683. cameraRotation: Vector2;
  99684. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  99685. ignoreParentScaling: boolean;
  99686. /**
  99687. * When set, the up vector of the camera will be updated by the rotation of the camera
  99688. */
  99689. updateUpVectorFromRotation: boolean;
  99690. private _tmpQuaternion;
  99691. /**
  99692. * Define the current rotation of the camera
  99693. */
  99694. rotation: Vector3;
  99695. /**
  99696. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  99697. */
  99698. rotationQuaternion: Quaternion;
  99699. /**
  99700. * Define the current speed of the camera
  99701. */
  99702. speed: number;
  99703. /**
  99704. * Add constraint to the camera to prevent it to move freely in all directions and
  99705. * around all axis.
  99706. */
  99707. noRotationConstraint: boolean;
  99708. /**
  99709. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  99710. * panning
  99711. */
  99712. invertRotation: boolean;
  99713. /**
  99714. * Speed multiplier for inverse camera panning
  99715. */
  99716. inverseRotationSpeed: number;
  99717. /**
  99718. * Define the current target of the camera as an object or a position.
  99719. */
  99720. lockedTarget: any;
  99721. /** @hidden */
  99722. _currentTarget: Vector3;
  99723. /** @hidden */
  99724. _initialFocalDistance: number;
  99725. /** @hidden */
  99726. _viewMatrix: Matrix;
  99727. /** @hidden */
  99728. _camMatrix: Matrix;
  99729. /** @hidden */
  99730. _cameraTransformMatrix: Matrix;
  99731. /** @hidden */
  99732. _cameraRotationMatrix: Matrix;
  99733. /** @hidden */
  99734. _referencePoint: Vector3;
  99735. /** @hidden */
  99736. _transformedReferencePoint: Vector3;
  99737. /** @hidden */
  99738. _reset: () => void;
  99739. private _defaultUp;
  99740. /**
  99741. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99742. * This is the base of the follow, arc rotate cameras and Free camera
  99743. * @see https://doc.babylonjs.com/features/cameras
  99744. * @param name Defines the name of the camera in the scene
  99745. * @param position Defines the start position of the camera in the scene
  99746. * @param scene Defines the scene the camera belongs to
  99747. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99748. */
  99749. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99750. /**
  99751. * Gets the position in front of the camera at a given distance.
  99752. * @param distance The distance from the camera we want the position to be
  99753. * @returns the position
  99754. */
  99755. getFrontPosition(distance: number): Vector3;
  99756. /** @hidden */
  99757. _getLockedTargetPosition(): Nullable<Vector3>;
  99758. private _storedPosition;
  99759. private _storedRotation;
  99760. private _storedRotationQuaternion;
  99761. /**
  99762. * Store current camera state of the camera (fov, position, rotation, etc..)
  99763. * @returns the camera
  99764. */
  99765. storeState(): Camera;
  99766. /**
  99767. * Restored camera state. You must call storeState() first
  99768. * @returns whether it was successful or not
  99769. * @hidden
  99770. */
  99771. _restoreStateValues(): boolean;
  99772. /** @hidden */
  99773. _initCache(): void;
  99774. /** @hidden */
  99775. _updateCache(ignoreParentClass?: boolean): void;
  99776. /** @hidden */
  99777. _isSynchronizedViewMatrix(): boolean;
  99778. /** @hidden */
  99779. _computeLocalCameraSpeed(): number;
  99780. /**
  99781. * Defines the target the camera should look at.
  99782. * @param target Defines the new target as a Vector or a mesh
  99783. */
  99784. setTarget(target: Vector3): void;
  99785. /**
  99786. * Defines the target point of the camera.
  99787. * The camera looks towards it form the radius distance.
  99788. */
  99789. get target(): Vector3;
  99790. set target(value: Vector3);
  99791. /**
  99792. * Return the current target position of the camera. This value is expressed in local space.
  99793. * @returns the target position
  99794. */
  99795. getTarget(): Vector3;
  99796. /** @hidden */
  99797. _decideIfNeedsToMove(): boolean;
  99798. /** @hidden */
  99799. _updatePosition(): void;
  99800. /** @hidden */
  99801. _checkInputs(): void;
  99802. protected _updateCameraRotationMatrix(): void;
  99803. /**
  99804. * 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)
  99805. * @returns the current camera
  99806. */
  99807. private _rotateUpVectorWithCameraRotationMatrix;
  99808. private _cachedRotationZ;
  99809. private _cachedQuaternionRotationZ;
  99810. /** @hidden */
  99811. _getViewMatrix(): Matrix;
  99812. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99813. /**
  99814. * @hidden
  99815. */
  99816. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99817. /**
  99818. * @hidden
  99819. */
  99820. _updateRigCameras(): void;
  99821. private _getRigCamPositionAndTarget;
  99822. /**
  99823. * Gets the current object class name.
  99824. * @return the class name
  99825. */
  99826. getClassName(): string;
  99827. }
  99828. }
  99829. declare module BABYLON {
  99830. /**
  99831. * Gather the list of keyboard event types as constants.
  99832. */
  99833. export class KeyboardEventTypes {
  99834. /**
  99835. * The keydown event is fired when a key becomes active (pressed).
  99836. */
  99837. static readonly KEYDOWN: number;
  99838. /**
  99839. * The keyup event is fired when a key has been released.
  99840. */
  99841. static readonly KEYUP: number;
  99842. }
  99843. /**
  99844. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99845. */
  99846. export class KeyboardInfo {
  99847. /**
  99848. * Defines the type of event (KeyboardEventTypes)
  99849. */
  99850. type: number;
  99851. /**
  99852. * Defines the related dom event
  99853. */
  99854. event: KeyboardEvent;
  99855. /**
  99856. * Instantiates a new keyboard info.
  99857. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99858. * @param type Defines the type of event (KeyboardEventTypes)
  99859. * @param event Defines the related dom event
  99860. */
  99861. constructor(
  99862. /**
  99863. * Defines the type of event (KeyboardEventTypes)
  99864. */
  99865. type: number,
  99866. /**
  99867. * Defines the related dom event
  99868. */
  99869. event: KeyboardEvent);
  99870. }
  99871. /**
  99872. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99873. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99874. */
  99875. export class KeyboardInfoPre extends KeyboardInfo {
  99876. /**
  99877. * Defines the type of event (KeyboardEventTypes)
  99878. */
  99879. type: number;
  99880. /**
  99881. * Defines the related dom event
  99882. */
  99883. event: KeyboardEvent;
  99884. /**
  99885. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99886. */
  99887. skipOnPointerObservable: boolean;
  99888. /**
  99889. * Instantiates a new keyboard pre info.
  99890. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99891. * @param type Defines the type of event (KeyboardEventTypes)
  99892. * @param event Defines the related dom event
  99893. */
  99894. constructor(
  99895. /**
  99896. * Defines the type of event (KeyboardEventTypes)
  99897. */
  99898. type: number,
  99899. /**
  99900. * Defines the related dom event
  99901. */
  99902. event: KeyboardEvent);
  99903. }
  99904. }
  99905. declare module BABYLON {
  99906. /**
  99907. * Manage the keyboard inputs to control the movement of a free camera.
  99908. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99909. */
  99910. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  99911. /**
  99912. * Defines the camera the input is attached to.
  99913. */
  99914. camera: FreeCamera;
  99915. /**
  99916. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99917. */
  99918. keysUp: number[];
  99919. /**
  99920. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99921. */
  99922. keysUpward: number[];
  99923. /**
  99924. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99925. */
  99926. keysDown: number[];
  99927. /**
  99928. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99929. */
  99930. keysDownward: number[];
  99931. /**
  99932. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99933. */
  99934. keysLeft: number[];
  99935. /**
  99936. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99937. */
  99938. keysRight: number[];
  99939. private _keys;
  99940. private _onCanvasBlurObserver;
  99941. private _onKeyboardObserver;
  99942. private _engine;
  99943. private _scene;
  99944. /**
  99945. * Attach the input controls to a specific dom element to get the input from.
  99946. * @param element Defines the element the controls should be listened from
  99947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99948. */
  99949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99950. /**
  99951. * Detach the current controls from the specified dom element.
  99952. * @param element Defines the element to stop listening the inputs from
  99953. */
  99954. detachControl(element: Nullable<HTMLElement>): void;
  99955. /**
  99956. * Update the current camera state depending on the inputs that have been used this frame.
  99957. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99958. */
  99959. checkInputs(): void;
  99960. /**
  99961. * Gets the class name of the current intput.
  99962. * @returns the class name
  99963. */
  99964. getClassName(): string;
  99965. /** @hidden */
  99966. _onLostFocus(): void;
  99967. /**
  99968. * Get the friendly name associated with the input class.
  99969. * @returns the input friendly name
  99970. */
  99971. getSimpleName(): string;
  99972. }
  99973. }
  99974. declare module BABYLON {
  99975. /**
  99976. * Gather the list of pointer event types as constants.
  99977. */
  99978. export class PointerEventTypes {
  99979. /**
  99980. * 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.
  99981. */
  99982. static readonly POINTERDOWN: number;
  99983. /**
  99984. * The pointerup event is fired when a pointer is no longer active.
  99985. */
  99986. static readonly POINTERUP: number;
  99987. /**
  99988. * The pointermove event is fired when a pointer changes coordinates.
  99989. */
  99990. static readonly POINTERMOVE: number;
  99991. /**
  99992. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99993. */
  99994. static readonly POINTERWHEEL: number;
  99995. /**
  99996. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99997. */
  99998. static readonly POINTERPICK: number;
  99999. /**
  100000. * The pointertap event is fired when a the object has been touched and released without drag.
  100001. */
  100002. static readonly POINTERTAP: number;
  100003. /**
  100004. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  100005. */
  100006. static readonly POINTERDOUBLETAP: number;
  100007. }
  100008. /**
  100009. * Base class of pointer info types.
  100010. */
  100011. export class PointerInfoBase {
  100012. /**
  100013. * Defines the type of event (PointerEventTypes)
  100014. */
  100015. type: number;
  100016. /**
  100017. * Defines the related dom event
  100018. */
  100019. event: PointerEvent | MouseWheelEvent;
  100020. /**
  100021. * Instantiates the base class of pointers info.
  100022. * @param type Defines the type of event (PointerEventTypes)
  100023. * @param event Defines the related dom event
  100024. */
  100025. constructor(
  100026. /**
  100027. * Defines the type of event (PointerEventTypes)
  100028. */
  100029. type: number,
  100030. /**
  100031. * Defines the related dom event
  100032. */
  100033. event: PointerEvent | MouseWheelEvent);
  100034. }
  100035. /**
  100036. * This class is used to store pointer related info for the onPrePointerObservable event.
  100037. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  100038. */
  100039. export class PointerInfoPre extends PointerInfoBase {
  100040. /**
  100041. * Ray from a pointer if availible (eg. 6dof controller)
  100042. */
  100043. ray: Nullable<Ray>;
  100044. /**
  100045. * Defines the local position of the pointer on the canvas.
  100046. */
  100047. localPosition: Vector2;
  100048. /**
  100049. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  100050. */
  100051. skipOnPointerObservable: boolean;
  100052. /**
  100053. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  100054. * @param type Defines the type of event (PointerEventTypes)
  100055. * @param event Defines the related dom event
  100056. * @param localX Defines the local x coordinates of the pointer when the event occured
  100057. * @param localY Defines the local y coordinates of the pointer when the event occured
  100058. */
  100059. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  100060. }
  100061. /**
  100062. * This type contains all the data related to a pointer event in Babylon.js.
  100063. * 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.
  100064. */
  100065. export class PointerInfo extends PointerInfoBase {
  100066. /**
  100067. * Defines the picking info associated to the info (if any)\
  100068. */
  100069. pickInfo: Nullable<PickingInfo>;
  100070. /**
  100071. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  100072. * @param type Defines the type of event (PointerEventTypes)
  100073. * @param event Defines the related dom event
  100074. * @param pickInfo Defines the picking info associated to the info (if any)\
  100075. */
  100076. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  100077. /**
  100078. * Defines the picking info associated to the info (if any)\
  100079. */
  100080. pickInfo: Nullable<PickingInfo>);
  100081. }
  100082. /**
  100083. * Data relating to a touch event on the screen.
  100084. */
  100085. export interface PointerTouch {
  100086. /**
  100087. * X coordinate of touch.
  100088. */
  100089. x: number;
  100090. /**
  100091. * Y coordinate of touch.
  100092. */
  100093. y: number;
  100094. /**
  100095. * Id of touch. Unique for each finger.
  100096. */
  100097. pointerId: number;
  100098. /**
  100099. * Event type passed from DOM.
  100100. */
  100101. type: any;
  100102. }
  100103. }
  100104. declare module BABYLON {
  100105. /**
  100106. * Manage the mouse inputs to control the movement of a free camera.
  100107. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100108. */
  100109. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  100110. /**
  100111. * Define if touch is enabled in the mouse input
  100112. */
  100113. touchEnabled: boolean;
  100114. /**
  100115. * Defines the camera the input is attached to.
  100116. */
  100117. camera: FreeCamera;
  100118. /**
  100119. * Defines the buttons associated with the input to handle camera move.
  100120. */
  100121. buttons: number[];
  100122. /**
  100123. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  100124. */
  100125. angularSensibility: number;
  100126. private _pointerInput;
  100127. private _onMouseMove;
  100128. private _observer;
  100129. private previousPosition;
  100130. /**
  100131. * Observable for when a pointer move event occurs containing the move offset
  100132. */
  100133. onPointerMovedObservable: Observable<{
  100134. offsetX: number;
  100135. offsetY: number;
  100136. }>;
  100137. /**
  100138. * @hidden
  100139. * If the camera should be rotated automatically based on pointer movement
  100140. */
  100141. _allowCameraRotation: boolean;
  100142. /**
  100143. * Manage the mouse inputs to control the movement of a free camera.
  100144. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100145. * @param touchEnabled Defines if touch is enabled or not
  100146. */
  100147. constructor(
  100148. /**
  100149. * Define if touch is enabled in the mouse input
  100150. */
  100151. touchEnabled?: boolean);
  100152. /**
  100153. * Attach the input controls to a specific dom element to get the input from.
  100154. * @param element Defines the element the controls should be listened from
  100155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100156. */
  100157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100158. /**
  100159. * Called on JS contextmenu event.
  100160. * Override this method to provide functionality.
  100161. */
  100162. protected onContextMenu(evt: PointerEvent): void;
  100163. /**
  100164. * Detach the current controls from the specified dom element.
  100165. * @param element Defines the element to stop listening the inputs from
  100166. */
  100167. detachControl(element: Nullable<HTMLElement>): void;
  100168. /**
  100169. * Gets the class name of the current intput.
  100170. * @returns the class name
  100171. */
  100172. getClassName(): string;
  100173. /**
  100174. * Get the friendly name associated with the input class.
  100175. * @returns the input friendly name
  100176. */
  100177. getSimpleName(): string;
  100178. }
  100179. }
  100180. declare module BABYLON {
  100181. /**
  100182. * Base class for mouse wheel input..
  100183. * See FollowCameraMouseWheelInput in src/Cameras/Inputs/freeCameraMouseWheelInput.ts
  100184. * for example usage.
  100185. */
  100186. export abstract class BaseCameraMouseWheelInput implements ICameraInput<Camera> {
  100187. /**
  100188. * Defines the camera the input is attached to.
  100189. */
  100190. abstract camera: Camera;
  100191. /**
  100192. * How fast is the camera moves in relation to X axis mouseWheel events.
  100193. * Use negative value to reverse direction.
  100194. */
  100195. wheelPrecisionX: number;
  100196. /**
  100197. * How fast is the camera moves in relation to Y axis mouseWheel events.
  100198. * Use negative value to reverse direction.
  100199. */
  100200. wheelPrecisionY: number;
  100201. /**
  100202. * How fast is the camera moves in relation to Z axis mouseWheel events.
  100203. * Use negative value to reverse direction.
  100204. */
  100205. wheelPrecisionZ: number;
  100206. /**
  100207. * Observable for when a mouse wheel move event occurs.
  100208. */
  100209. onChangedObservable: Observable<{
  100210. wheelDeltaX: number;
  100211. wheelDeltaY: number;
  100212. wheelDeltaZ: number;
  100213. }>;
  100214. private _wheel;
  100215. private _observer;
  100216. /**
  100217. * Attach the input controls to a specific dom element to get the input from.
  100218. * @param element Defines the element the controls should be listened from
  100219. * @param noPreventDefault Defines whether event caught by the controls
  100220. * should call preventdefault().
  100221. * (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100222. */
  100223. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100224. /**
  100225. * Detach the current controls from the specified dom element.
  100226. * @param element Defines the element to stop listening the inputs from
  100227. */
  100228. detachControl(element: Nullable<HTMLElement>): void;
  100229. /**
  100230. * Called for each rendered frame.
  100231. */
  100232. checkInputs(): void;
  100233. /**
  100234. * Gets the class name of the current intput.
  100235. * @returns the class name
  100236. */
  100237. getClassName(): string;
  100238. /**
  100239. * Get the friendly name associated with the input class.
  100240. * @returns the input friendly name
  100241. */
  100242. getSimpleName(): string;
  100243. /**
  100244. * Incremental value of multiple mouse wheel movements of the X axis.
  100245. * Should be zero-ed when read.
  100246. */
  100247. protected _wheelDeltaX: number;
  100248. /**
  100249. * Incremental value of multiple mouse wheel movements of the Y axis.
  100250. * Should be zero-ed when read.
  100251. */
  100252. protected _wheelDeltaY: number;
  100253. /**
  100254. * Incremental value of multiple mouse wheel movements of the Z axis.
  100255. * Should be zero-ed when read.
  100256. */
  100257. protected _wheelDeltaZ: number;
  100258. /**
  100259. * Firefox uses a different scheme to report scroll distances to other
  100260. * browsers. Rather than use complicated methods to calculate the exact
  100261. * multiple we need to apply, let's just cheat and use a constant.
  100262. * https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent/deltaMode
  100263. * https://stackoverflow.com/questions/20110224/what-is-the-height-of-a-line-in-a-wheel-event-deltamode-dom-delta-line
  100264. */
  100265. private readonly _ffMultiplier;
  100266. /**
  100267. * Different event attributes for wheel data fall into a few set ranges.
  100268. * Some relevant but dated date here:
  100269. * https://stackoverflow.com/questions/5527601/normalizing-mousewheel-speed-across-browsers
  100270. */
  100271. private readonly _normalize;
  100272. }
  100273. }
  100274. declare module BABYLON {
  100275. /**
  100276. * Manage the mouse wheel inputs to control a free camera.
  100277. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100278. */
  100279. export class FreeCameraMouseWheelInput extends BaseCameraMouseWheelInput {
  100280. /**
  100281. * Defines the camera the input is attached to.
  100282. */
  100283. camera: FreeCamera;
  100284. /**
  100285. * Gets the class name of the current input.
  100286. * @returns the class name
  100287. */
  100288. getClassName(): string;
  100289. /**
  100290. * Set which movement axis (relative to camera's orientation) the mouse
  100291. * wheel's X axis controls.
  100292. * @param axis The axis to be moved. Set null to clear.
  100293. */
  100294. set wheelXMoveRelative(axis: Nullable<Coordinate>);
  100295. /**
  100296. * Get the configured movement axis (relative to camera's orientation) the
  100297. * mouse wheel's X axis controls.
  100298. * @returns The configured axis or null if none.
  100299. */
  100300. get wheelXMoveRelative(): Nullable<Coordinate>;
  100301. /**
  100302. * Set which movement axis (relative to camera's orientation) the mouse
  100303. * wheel's Y axis controls.
  100304. * @param axis The axis to be moved. Set null to clear.
  100305. */
  100306. set wheelYMoveRelative(axis: Nullable<Coordinate>);
  100307. /**
  100308. * Get the configured movement axis (relative to camera's orientation) the
  100309. * mouse wheel's Y axis controls.
  100310. * @returns The configured axis or null if none.
  100311. */
  100312. get wheelYMoveRelative(): Nullable<Coordinate>;
  100313. /**
  100314. * Set which movement axis (relative to camera's orientation) the mouse
  100315. * wheel's Z axis controls.
  100316. * @param axis The axis to be moved. Set null to clear.
  100317. */
  100318. set wheelZMoveRelative(axis: Nullable<Coordinate>);
  100319. /**
  100320. * Get the configured movement axis (relative to camera's orientation) the
  100321. * mouse wheel's Z axis controls.
  100322. * @returns The configured axis or null if none.
  100323. */
  100324. get wheelZMoveRelative(): Nullable<Coordinate>;
  100325. /**
  100326. * Set which rotation axis (relative to camera's orientation) the mouse
  100327. * wheel's X axis controls.
  100328. * @param axis The axis to be moved. Set null to clear.
  100329. */
  100330. set wheelXRotateRelative(axis: Nullable<Coordinate>);
  100331. /**
  100332. * Get the configured rotation axis (relative to camera's orientation) the
  100333. * mouse wheel's X axis controls.
  100334. * @returns The configured axis or null if none.
  100335. */
  100336. get wheelXRotateRelative(): Nullable<Coordinate>;
  100337. /**
  100338. * Set which rotation axis (relative to camera's orientation) the mouse
  100339. * wheel's Y axis controls.
  100340. * @param axis The axis to be moved. Set null to clear.
  100341. */
  100342. set wheelYRotateRelative(axis: Nullable<Coordinate>);
  100343. /**
  100344. * Get the configured rotation axis (relative to camera's orientation) the
  100345. * mouse wheel's Y axis controls.
  100346. * @returns The configured axis or null if none.
  100347. */
  100348. get wheelYRotateRelative(): Nullable<Coordinate>;
  100349. /**
  100350. * Set which rotation axis (relative to camera's orientation) the mouse
  100351. * wheel's Z axis controls.
  100352. * @param axis The axis to be moved. Set null to clear.
  100353. */
  100354. set wheelZRotateRelative(axis: Nullable<Coordinate>);
  100355. /**
  100356. * Get the configured rotation axis (relative to camera's orientation) the
  100357. * mouse wheel's Z axis controls.
  100358. * @returns The configured axis or null if none.
  100359. */
  100360. get wheelZRotateRelative(): Nullable<Coordinate>;
  100361. /**
  100362. * Set which movement axis (relative to the scene) the mouse wheel's X axis
  100363. * controls.
  100364. * @param axis The axis to be moved. Set null to clear.
  100365. */
  100366. set wheelXMoveScene(axis: Nullable<Coordinate>);
  100367. /**
  100368. * Get the configured movement axis (relative to the scene) the mouse wheel's
  100369. * X axis controls.
  100370. * @returns The configured axis or null if none.
  100371. */
  100372. get wheelXMoveScene(): Nullable<Coordinate>;
  100373. /**
  100374. * Set which movement axis (relative to the scene) the mouse wheel's Y axis
  100375. * controls.
  100376. * @param axis The axis to be moved. Set null to clear.
  100377. */
  100378. set wheelYMoveScene(axis: Nullable<Coordinate>);
  100379. /**
  100380. * Get the configured movement axis (relative to the scene) the mouse wheel's
  100381. * Y axis controls.
  100382. * @returns The configured axis or null if none.
  100383. */
  100384. get wheelYMoveScene(): Nullable<Coordinate>;
  100385. /**
  100386. * Set which movement axis (relative to the scene) the mouse wheel's Z axis
  100387. * controls.
  100388. * @param axis The axis to be moved. Set null to clear.
  100389. */
  100390. set wheelZMoveScene(axis: Nullable<Coordinate>);
  100391. /**
  100392. * Get the configured movement axis (relative to the scene) the mouse wheel's
  100393. * Z axis controls.
  100394. * @returns The configured axis or null if none.
  100395. */
  100396. get wheelZMoveScene(): Nullable<Coordinate>;
  100397. /**
  100398. * Called for each rendered frame.
  100399. */
  100400. checkInputs(): void;
  100401. private _moveRelative;
  100402. private _rotateRelative;
  100403. private _moveScene;
  100404. /**
  100405. * These are set to the desired default behaviour.
  100406. */
  100407. private _wheelXAction;
  100408. private _wheelXActionCoordinate;
  100409. private _wheelYAction;
  100410. private _wheelYActionCoordinate;
  100411. private _wheelZAction;
  100412. private _wheelZActionCoordinate;
  100413. /**
  100414. * Update the camera according to any configured properties for the 3
  100415. * mouse-wheel axis.
  100416. */
  100417. private _updateCamera;
  100418. }
  100419. }
  100420. declare module BABYLON {
  100421. /**
  100422. * Manage the touch inputs to control the movement of a free camera.
  100423. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100424. */
  100425. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  100426. /**
  100427. * Define if mouse events can be treated as touch events
  100428. */
  100429. allowMouse: boolean;
  100430. /**
  100431. * Defines the camera the input is attached to.
  100432. */
  100433. camera: FreeCamera;
  100434. /**
  100435. * Defines the touch sensibility for rotation.
  100436. * The higher the faster.
  100437. */
  100438. touchAngularSensibility: number;
  100439. /**
  100440. * Defines the touch sensibility for move.
  100441. * The higher the faster.
  100442. */
  100443. touchMoveSensibility: number;
  100444. private _offsetX;
  100445. private _offsetY;
  100446. private _pointerPressed;
  100447. private _pointerInput;
  100448. private _observer;
  100449. private _onLostFocus;
  100450. /**
  100451. * Manage the touch inputs to control the movement of a free camera.
  100452. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100453. * @param allowMouse Defines if mouse events can be treated as touch events
  100454. */
  100455. constructor(
  100456. /**
  100457. * Define if mouse events can be treated as touch events
  100458. */
  100459. allowMouse?: boolean);
  100460. /**
  100461. * Attach the input controls to a specific dom element to get the input from.
  100462. * @param element Defines the element the controls should be listened from
  100463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100464. */
  100465. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100466. /**
  100467. * Detach the current controls from the specified dom element.
  100468. * @param element Defines the element to stop listening the inputs from
  100469. */
  100470. detachControl(element: Nullable<HTMLElement>): void;
  100471. /**
  100472. * Update the current camera state depending on the inputs that have been used this frame.
  100473. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  100474. */
  100475. checkInputs(): void;
  100476. /**
  100477. * Gets the class name of the current intput.
  100478. * @returns the class name
  100479. */
  100480. getClassName(): string;
  100481. /**
  100482. * Get the friendly name associated with the input class.
  100483. * @returns the input friendly name
  100484. */
  100485. getSimpleName(): string;
  100486. }
  100487. }
  100488. declare module BABYLON {
  100489. /**
  100490. * Default Inputs manager for the FreeCamera.
  100491. * It groups all the default supported inputs for ease of use.
  100492. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  100493. */
  100494. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  100495. /**
  100496. * @hidden
  100497. */
  100498. _mouseInput: Nullable<FreeCameraMouseInput>;
  100499. /**
  100500. * @hidden
  100501. */
  100502. _mouseWheelInput: Nullable<FreeCameraMouseWheelInput>;
  100503. /**
  100504. * Instantiates a new FreeCameraInputsManager.
  100505. * @param camera Defines the camera the inputs belong to
  100506. */
  100507. constructor(camera: FreeCamera);
  100508. /**
  100509. * Add keyboard input support to the input manager.
  100510. * @returns the current input manager
  100511. */
  100512. addKeyboard(): FreeCameraInputsManager;
  100513. /**
  100514. * Add mouse input support to the input manager.
  100515. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  100516. * @returns the current input manager
  100517. */
  100518. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  100519. /**
  100520. * Removes the mouse input support from the manager
  100521. * @returns the current input manager
  100522. */
  100523. removeMouse(): FreeCameraInputsManager;
  100524. /**
  100525. * Add mouse wheel input support to the input manager.
  100526. * @returns the current input manager
  100527. */
  100528. addMouseWheel(): FreeCameraInputsManager;
  100529. /**
  100530. * Removes the mouse wheel input support from the manager
  100531. * @returns the current input manager
  100532. */
  100533. removeMouseWheel(): FreeCameraInputsManager;
  100534. /**
  100535. * Add touch input support to the input manager.
  100536. * @returns the current input manager
  100537. */
  100538. addTouch(): FreeCameraInputsManager;
  100539. /**
  100540. * Remove all attached input methods from a camera
  100541. */
  100542. clear(): void;
  100543. }
  100544. }
  100545. declare module BABYLON {
  100546. /**
  100547. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100548. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  100549. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  100550. */
  100551. export class FreeCamera extends TargetCamera {
  100552. /**
  100553. * Define the collision ellipsoid of the camera.
  100554. * This is helpful to simulate a camera body like the player body around the camera
  100555. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  100556. */
  100557. ellipsoid: Vector3;
  100558. /**
  100559. * Define an offset for the position of the ellipsoid around the camera.
  100560. * This can be helpful to determine the center of the body near the gravity center of the body
  100561. * instead of its head.
  100562. */
  100563. ellipsoidOffset: Vector3;
  100564. /**
  100565. * Enable or disable collisions of the camera with the rest of the scene objects.
  100566. */
  100567. checkCollisions: boolean;
  100568. /**
  100569. * Enable or disable gravity on the camera.
  100570. */
  100571. applyGravity: boolean;
  100572. /**
  100573. * Define the input manager associated to the camera.
  100574. */
  100575. inputs: FreeCameraInputsManager;
  100576. /**
  100577. * Gets the input sensibility for a mouse input. (default is 2000.0)
  100578. * Higher values reduce sensitivity.
  100579. */
  100580. get angularSensibility(): number;
  100581. /**
  100582. * Sets the input sensibility for a mouse input. (default is 2000.0)
  100583. * Higher values reduce sensitivity.
  100584. */
  100585. set angularSensibility(value: number);
  100586. /**
  100587. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  100588. */
  100589. get keysUp(): number[];
  100590. set keysUp(value: number[]);
  100591. /**
  100592. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  100593. */
  100594. get keysUpward(): number[];
  100595. set keysUpward(value: number[]);
  100596. /**
  100597. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  100598. */
  100599. get keysDown(): number[];
  100600. set keysDown(value: number[]);
  100601. /**
  100602. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  100603. */
  100604. get keysDownward(): number[];
  100605. set keysDownward(value: number[]);
  100606. /**
  100607. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  100608. */
  100609. get keysLeft(): number[];
  100610. set keysLeft(value: number[]);
  100611. /**
  100612. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  100613. */
  100614. get keysRight(): number[];
  100615. set keysRight(value: number[]);
  100616. /**
  100617. * Event raised when the camera collide with a mesh in the scene.
  100618. */
  100619. onCollide: (collidedMesh: AbstractMesh) => void;
  100620. private _collider;
  100621. private _needMoveForGravity;
  100622. private _oldPosition;
  100623. private _diffPosition;
  100624. private _newPosition;
  100625. /** @hidden */
  100626. _localDirection: Vector3;
  100627. /** @hidden */
  100628. _transformedDirection: Vector3;
  100629. /**
  100630. * Instantiates a Free Camera.
  100631. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100632. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  100633. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  100634. * @param name Define the name of the camera in the scene
  100635. * @param position Define the start position of the camera in the scene
  100636. * @param scene Define the scene the camera belongs to
  100637. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  100638. */
  100639. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100640. /**
  100641. * Attached controls to the current camera.
  100642. * @param element Defines the element the controls should be listened from
  100643. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100644. */
  100645. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100646. /**
  100647. * Detach the current controls from the camera.
  100648. * The camera will stop reacting to inputs.
  100649. * @param element Defines the element to stop listening the inputs from
  100650. */
  100651. detachControl(element: HTMLElement): void;
  100652. private _collisionMask;
  100653. /**
  100654. * Define a collision mask to limit the list of object the camera can collide with
  100655. */
  100656. get collisionMask(): number;
  100657. set collisionMask(mask: number);
  100658. /** @hidden */
  100659. _collideWithWorld(displacement: Vector3): void;
  100660. private _onCollisionPositionChange;
  100661. /** @hidden */
  100662. _checkInputs(): void;
  100663. /** @hidden */
  100664. _decideIfNeedsToMove(): boolean;
  100665. /** @hidden */
  100666. _updatePosition(): void;
  100667. /**
  100668. * Destroy the camera and release the current resources hold by it.
  100669. */
  100670. dispose(): void;
  100671. /**
  100672. * Gets the current object class name.
  100673. * @return the class name
  100674. */
  100675. getClassName(): string;
  100676. }
  100677. }
  100678. declare module BABYLON {
  100679. /**
  100680. * Represents a gamepad control stick position
  100681. */
  100682. export class StickValues {
  100683. /**
  100684. * The x component of the control stick
  100685. */
  100686. x: number;
  100687. /**
  100688. * The y component of the control stick
  100689. */
  100690. y: number;
  100691. /**
  100692. * Initializes the gamepad x and y control stick values
  100693. * @param x The x component of the gamepad control stick value
  100694. * @param y The y component of the gamepad control stick value
  100695. */
  100696. constructor(
  100697. /**
  100698. * The x component of the control stick
  100699. */
  100700. x: number,
  100701. /**
  100702. * The y component of the control stick
  100703. */
  100704. y: number);
  100705. }
  100706. /**
  100707. * An interface which manages callbacks for gamepad button changes
  100708. */
  100709. export interface GamepadButtonChanges {
  100710. /**
  100711. * Called when a gamepad has been changed
  100712. */
  100713. changed: boolean;
  100714. /**
  100715. * Called when a gamepad press event has been triggered
  100716. */
  100717. pressChanged: boolean;
  100718. /**
  100719. * Called when a touch event has been triggered
  100720. */
  100721. touchChanged: boolean;
  100722. /**
  100723. * Called when a value has changed
  100724. */
  100725. valueChanged: boolean;
  100726. }
  100727. /**
  100728. * Represents a gamepad
  100729. */
  100730. export class Gamepad {
  100731. /**
  100732. * The id of the gamepad
  100733. */
  100734. id: string;
  100735. /**
  100736. * The index of the gamepad
  100737. */
  100738. index: number;
  100739. /**
  100740. * The browser gamepad
  100741. */
  100742. browserGamepad: any;
  100743. /**
  100744. * Specifies what type of gamepad this represents
  100745. */
  100746. type: number;
  100747. private _leftStick;
  100748. private _rightStick;
  100749. /** @hidden */
  100750. _isConnected: boolean;
  100751. private _leftStickAxisX;
  100752. private _leftStickAxisY;
  100753. private _rightStickAxisX;
  100754. private _rightStickAxisY;
  100755. /**
  100756. * Triggered when the left control stick has been changed
  100757. */
  100758. private _onleftstickchanged;
  100759. /**
  100760. * Triggered when the right control stick has been changed
  100761. */
  100762. private _onrightstickchanged;
  100763. /**
  100764. * Represents a gamepad controller
  100765. */
  100766. static GAMEPAD: number;
  100767. /**
  100768. * Represents a generic controller
  100769. */
  100770. static GENERIC: number;
  100771. /**
  100772. * Represents an XBox controller
  100773. */
  100774. static XBOX: number;
  100775. /**
  100776. * Represents a pose-enabled controller
  100777. */
  100778. static POSE_ENABLED: number;
  100779. /**
  100780. * Represents an Dual Shock controller
  100781. */
  100782. static DUALSHOCK: number;
  100783. /**
  100784. * Specifies whether the left control stick should be Y-inverted
  100785. */
  100786. protected _invertLeftStickY: boolean;
  100787. /**
  100788. * Specifies if the gamepad has been connected
  100789. */
  100790. get isConnected(): boolean;
  100791. /**
  100792. * Initializes the gamepad
  100793. * @param id The id of the gamepad
  100794. * @param index The index of the gamepad
  100795. * @param browserGamepad The browser gamepad
  100796. * @param leftStickX The x component of the left joystick
  100797. * @param leftStickY The y component of the left joystick
  100798. * @param rightStickX The x component of the right joystick
  100799. * @param rightStickY The y component of the right joystick
  100800. */
  100801. constructor(
  100802. /**
  100803. * The id of the gamepad
  100804. */
  100805. id: string,
  100806. /**
  100807. * The index of the gamepad
  100808. */
  100809. index: number,
  100810. /**
  100811. * The browser gamepad
  100812. */
  100813. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  100814. /**
  100815. * Callback triggered when the left joystick has changed
  100816. * @param callback
  100817. */
  100818. onleftstickchanged(callback: (values: StickValues) => void): void;
  100819. /**
  100820. * Callback triggered when the right joystick has changed
  100821. * @param callback
  100822. */
  100823. onrightstickchanged(callback: (values: StickValues) => void): void;
  100824. /**
  100825. * Gets the left joystick
  100826. */
  100827. get leftStick(): StickValues;
  100828. /**
  100829. * Sets the left joystick values
  100830. */
  100831. set leftStick(newValues: StickValues);
  100832. /**
  100833. * Gets the right joystick
  100834. */
  100835. get rightStick(): StickValues;
  100836. /**
  100837. * Sets the right joystick value
  100838. */
  100839. set rightStick(newValues: StickValues);
  100840. /**
  100841. * Updates the gamepad joystick positions
  100842. */
  100843. update(): void;
  100844. /**
  100845. * Disposes the gamepad
  100846. */
  100847. dispose(): void;
  100848. }
  100849. /**
  100850. * Represents a generic gamepad
  100851. */
  100852. export class GenericPad extends Gamepad {
  100853. private _buttons;
  100854. private _onbuttondown;
  100855. private _onbuttonup;
  100856. /**
  100857. * Observable triggered when a button has been pressed
  100858. */
  100859. onButtonDownObservable: Observable<number>;
  100860. /**
  100861. * Observable triggered when a button has been released
  100862. */
  100863. onButtonUpObservable: Observable<number>;
  100864. /**
  100865. * Callback triggered when a button has been pressed
  100866. * @param callback Called when a button has been pressed
  100867. */
  100868. onbuttondown(callback: (buttonPressed: number) => void): void;
  100869. /**
  100870. * Callback triggered when a button has been released
  100871. * @param callback Called when a button has been released
  100872. */
  100873. onbuttonup(callback: (buttonReleased: number) => void): void;
  100874. /**
  100875. * Initializes the generic gamepad
  100876. * @param id The id of the generic gamepad
  100877. * @param index The index of the generic gamepad
  100878. * @param browserGamepad The browser gamepad
  100879. */
  100880. constructor(id: string, index: number, browserGamepad: any);
  100881. private _setButtonValue;
  100882. /**
  100883. * Updates the generic gamepad
  100884. */
  100885. update(): void;
  100886. /**
  100887. * Disposes the generic gamepad
  100888. */
  100889. dispose(): void;
  100890. }
  100891. }
  100892. declare module BABYLON {
  100893. /**
  100894. * Defines the types of pose enabled controllers that are supported
  100895. */
  100896. export enum PoseEnabledControllerType {
  100897. /**
  100898. * HTC Vive
  100899. */
  100900. VIVE = 0,
  100901. /**
  100902. * Oculus Rift
  100903. */
  100904. OCULUS = 1,
  100905. /**
  100906. * Windows mixed reality
  100907. */
  100908. WINDOWS = 2,
  100909. /**
  100910. * Samsung gear VR
  100911. */
  100912. GEAR_VR = 3,
  100913. /**
  100914. * Google Daydream
  100915. */
  100916. DAYDREAM = 4,
  100917. /**
  100918. * Generic
  100919. */
  100920. GENERIC = 5
  100921. }
  100922. /**
  100923. * Defines the MutableGamepadButton interface for the state of a gamepad button
  100924. */
  100925. export interface MutableGamepadButton {
  100926. /**
  100927. * Value of the button/trigger
  100928. */
  100929. value: number;
  100930. /**
  100931. * If the button/trigger is currently touched
  100932. */
  100933. touched: boolean;
  100934. /**
  100935. * If the button/trigger is currently pressed
  100936. */
  100937. pressed: boolean;
  100938. }
  100939. /**
  100940. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  100941. * @hidden
  100942. */
  100943. export interface ExtendedGamepadButton extends GamepadButton {
  100944. /**
  100945. * If the button/trigger is currently pressed
  100946. */
  100947. readonly pressed: boolean;
  100948. /**
  100949. * If the button/trigger is currently touched
  100950. */
  100951. readonly touched: boolean;
  100952. /**
  100953. * Value of the button/trigger
  100954. */
  100955. readonly value: number;
  100956. }
  100957. /** @hidden */
  100958. export interface _GamePadFactory {
  100959. /**
  100960. * Returns whether or not the current gamepad can be created for this type of controller.
  100961. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100962. * @returns true if it can be created, otherwise false
  100963. */
  100964. canCreate(gamepadInfo: any): boolean;
  100965. /**
  100966. * Creates a new instance of the Gamepad.
  100967. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100968. * @returns the new gamepad instance
  100969. */
  100970. create(gamepadInfo: any): Gamepad;
  100971. }
  100972. /**
  100973. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100974. */
  100975. export class PoseEnabledControllerHelper {
  100976. /** @hidden */
  100977. static _ControllerFactories: _GamePadFactory[];
  100978. /** @hidden */
  100979. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  100980. /**
  100981. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100982. * @param vrGamepad the gamepad to initialized
  100983. * @returns a vr controller of the type the gamepad identified as
  100984. */
  100985. static InitiateController(vrGamepad: any): Gamepad;
  100986. }
  100987. /**
  100988. * Defines the PoseEnabledController object that contains state of a vr capable controller
  100989. */
  100990. export class PoseEnabledController extends Gamepad implements PoseControlled {
  100991. /**
  100992. * If the controller is used in a webXR session
  100993. */
  100994. isXR: boolean;
  100995. private _deviceRoomPosition;
  100996. private _deviceRoomRotationQuaternion;
  100997. /**
  100998. * The device position in babylon space
  100999. */
  101000. devicePosition: Vector3;
  101001. /**
  101002. * The device rotation in babylon space
  101003. */
  101004. deviceRotationQuaternion: Quaternion;
  101005. /**
  101006. * The scale factor of the device in babylon space
  101007. */
  101008. deviceScaleFactor: number;
  101009. /**
  101010. * (Likely devicePosition should be used instead) The device position in its room space
  101011. */
  101012. position: Vector3;
  101013. /**
  101014. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  101015. */
  101016. rotationQuaternion: Quaternion;
  101017. /**
  101018. * The type of controller (Eg. Windows mixed reality)
  101019. */
  101020. controllerType: PoseEnabledControllerType;
  101021. protected _calculatedPosition: Vector3;
  101022. private _calculatedRotation;
  101023. /**
  101024. * The raw pose from the device
  101025. */
  101026. rawPose: DevicePose;
  101027. private _trackPosition;
  101028. private _maxRotationDistFromHeadset;
  101029. private _draggedRoomRotation;
  101030. /**
  101031. * @hidden
  101032. */
  101033. _disableTrackPosition(fixedPosition: Vector3): void;
  101034. /**
  101035. * Internal, the mesh attached to the controller
  101036. * @hidden
  101037. */
  101038. _mesh: Nullable<AbstractMesh>;
  101039. private _poseControlledCamera;
  101040. private _leftHandSystemQuaternion;
  101041. /**
  101042. * Internal, matrix used to convert room space to babylon space
  101043. * @hidden
  101044. */
  101045. _deviceToWorld: Matrix;
  101046. /**
  101047. * Node to be used when casting a ray from the controller
  101048. * @hidden
  101049. */
  101050. _pointingPoseNode: Nullable<TransformNode>;
  101051. /**
  101052. * Name of the child mesh that can be used to cast a ray from the controller
  101053. */
  101054. static readonly POINTING_POSE: string;
  101055. /**
  101056. * Creates a new PoseEnabledController from a gamepad
  101057. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  101058. */
  101059. constructor(browserGamepad: any);
  101060. private _workingMatrix;
  101061. /**
  101062. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  101063. */
  101064. update(): void;
  101065. /**
  101066. * Updates only the pose device and mesh without doing any button event checking
  101067. */
  101068. protected _updatePoseAndMesh(): void;
  101069. /**
  101070. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  101071. * @param poseData raw pose fromthe device
  101072. */
  101073. updateFromDevice(poseData: DevicePose): void;
  101074. /**
  101075. * @hidden
  101076. */
  101077. _meshAttachedObservable: Observable<AbstractMesh>;
  101078. /**
  101079. * Attaches a mesh to the controller
  101080. * @param mesh the mesh to be attached
  101081. */
  101082. attachToMesh(mesh: AbstractMesh): void;
  101083. /**
  101084. * Attaches the controllers mesh to a camera
  101085. * @param camera the camera the mesh should be attached to
  101086. */
  101087. attachToPoseControlledCamera(camera: TargetCamera): void;
  101088. /**
  101089. * Disposes of the controller
  101090. */
  101091. dispose(): void;
  101092. /**
  101093. * The mesh that is attached to the controller
  101094. */
  101095. get mesh(): Nullable<AbstractMesh>;
  101096. /**
  101097. * Gets the ray of the controller in the direction the controller is pointing
  101098. * @param length the length the resulting ray should be
  101099. * @returns a ray in the direction the controller is pointing
  101100. */
  101101. getForwardRay(length?: number): Ray;
  101102. }
  101103. }
  101104. declare module BABYLON {
  101105. /**
  101106. * Defines the WebVRController object that represents controllers tracked in 3D space
  101107. */
  101108. export abstract class WebVRController extends PoseEnabledController {
  101109. /**
  101110. * Internal, the default controller model for the controller
  101111. */
  101112. protected _defaultModel: Nullable<AbstractMesh>;
  101113. /**
  101114. * Fired when the trigger state has changed
  101115. */
  101116. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  101117. /**
  101118. * Fired when the main button state has changed
  101119. */
  101120. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101121. /**
  101122. * Fired when the secondary button state has changed
  101123. */
  101124. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101125. /**
  101126. * Fired when the pad state has changed
  101127. */
  101128. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  101129. /**
  101130. * Fired when controllers stick values have changed
  101131. */
  101132. onPadValuesChangedObservable: Observable<StickValues>;
  101133. /**
  101134. * Array of button availible on the controller
  101135. */
  101136. protected _buttons: Array<MutableGamepadButton>;
  101137. private _onButtonStateChange;
  101138. /**
  101139. * Fired when a controller button's state has changed
  101140. * @param callback the callback containing the button that was modified
  101141. */
  101142. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  101143. /**
  101144. * X and Y axis corresponding to the controllers joystick
  101145. */
  101146. pad: StickValues;
  101147. /**
  101148. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  101149. */
  101150. hand: string;
  101151. /**
  101152. * The default controller model for the controller
  101153. */
  101154. get defaultModel(): Nullable<AbstractMesh>;
  101155. /**
  101156. * Creates a new WebVRController from a gamepad
  101157. * @param vrGamepad the gamepad that the WebVRController should be created from
  101158. */
  101159. constructor(vrGamepad: any);
  101160. /**
  101161. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  101162. */
  101163. update(): void;
  101164. /**
  101165. * Function to be called when a button is modified
  101166. */
  101167. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101168. /**
  101169. * Loads a mesh and attaches it to the controller
  101170. * @param scene the scene the mesh should be added to
  101171. * @param meshLoaded callback for when the mesh has been loaded
  101172. */
  101173. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101174. private _setButtonValue;
  101175. private _changes;
  101176. private _checkChanges;
  101177. /**
  101178. * Disposes of th webVRCOntroller
  101179. */
  101180. dispose(): void;
  101181. }
  101182. }
  101183. declare module BABYLON {
  101184. /**
  101185. * The HemisphericLight simulates the ambient environment light,
  101186. * so the passed direction is the light reflection direction, not the incoming direction.
  101187. */
  101188. export class HemisphericLight extends Light {
  101189. /**
  101190. * The groundColor is the light in the opposite direction to the one specified during creation.
  101191. * 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.
  101192. */
  101193. groundColor: Color3;
  101194. /**
  101195. * The light reflection direction, not the incoming direction.
  101196. */
  101197. direction: Vector3;
  101198. /**
  101199. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  101200. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  101201. * The HemisphericLight can't cast shadows.
  101202. * Documentation : https://doc.babylonjs.com/babylon101/lights
  101203. * @param name The friendly name of the light
  101204. * @param direction The direction of the light reflection
  101205. * @param scene The scene the light belongs to
  101206. */
  101207. constructor(name: string, direction: Vector3, scene: Scene);
  101208. protected _buildUniformLayout(): void;
  101209. /**
  101210. * Returns the string "HemisphericLight".
  101211. * @return The class name
  101212. */
  101213. getClassName(): string;
  101214. /**
  101215. * Sets the HemisphericLight direction towards the passed target (Vector3).
  101216. * Returns the updated direction.
  101217. * @param target The target the direction should point to
  101218. * @return The computed direction
  101219. */
  101220. setDirectionToTarget(target: Vector3): Vector3;
  101221. /**
  101222. * Returns the shadow generator associated to the light.
  101223. * @returns Always null for hemispheric lights because it does not support shadows.
  101224. */
  101225. getShadowGenerator(): Nullable<IShadowGenerator>;
  101226. /**
  101227. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  101228. * @param effect The effect to update
  101229. * @param lightIndex The index of the light in the effect to update
  101230. * @returns The hemispheric light
  101231. */
  101232. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  101233. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  101234. /**
  101235. * Computes the world matrix of the node
  101236. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  101237. * @param useWasUpdatedFlag defines a reserved property
  101238. * @returns the world matrix
  101239. */
  101240. computeWorldMatrix(): Matrix;
  101241. /**
  101242. * Returns the integer 3.
  101243. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  101244. */
  101245. getTypeID(): number;
  101246. /**
  101247. * Prepares the list of defines specific to the light type.
  101248. * @param defines the list of defines
  101249. * @param lightIndex defines the index of the light for the effect
  101250. */
  101251. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  101252. }
  101253. }
  101254. declare module BABYLON {
  101255. /** @hidden */
  101256. export var vrMultiviewToSingleviewPixelShader: {
  101257. name: string;
  101258. shader: string;
  101259. };
  101260. }
  101261. declare module BABYLON {
  101262. /**
  101263. * Renders to multiple views with a single draw call
  101264. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  101265. */
  101266. export class MultiviewRenderTarget extends RenderTargetTexture {
  101267. /**
  101268. * Creates a multiview render target
  101269. * @param scene scene used with the render target
  101270. * @param size the size of the render target (used for each view)
  101271. */
  101272. constructor(scene: Scene, size?: number | {
  101273. width: number;
  101274. height: number;
  101275. } | {
  101276. ratio: number;
  101277. });
  101278. /**
  101279. * @hidden
  101280. * @param faceIndex the face index, if its a cube texture
  101281. */
  101282. _bindFrameBuffer(faceIndex?: number): void;
  101283. /**
  101284. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101285. * @returns the view count
  101286. */
  101287. getViewCount(): number;
  101288. }
  101289. }
  101290. declare module BABYLON {
  101291. interface Engine {
  101292. /**
  101293. * Creates a new multiview render target
  101294. * @param width defines the width of the texture
  101295. * @param height defines the height of the texture
  101296. * @returns the created multiview texture
  101297. */
  101298. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  101299. /**
  101300. * Binds a multiview framebuffer to be drawn to
  101301. * @param multiviewTexture texture to bind
  101302. */
  101303. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  101304. }
  101305. interface Camera {
  101306. /**
  101307. * @hidden
  101308. * 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)
  101309. */
  101310. _useMultiviewToSingleView: boolean;
  101311. /**
  101312. * @hidden
  101313. * 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)
  101314. */
  101315. _multiviewTexture: Nullable<RenderTargetTexture>;
  101316. /**
  101317. * @hidden
  101318. * ensures the multiview texture of the camera exists and has the specified width/height
  101319. * @param width height to set on the multiview texture
  101320. * @param height width to set on the multiview texture
  101321. */
  101322. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  101323. }
  101324. interface Scene {
  101325. /** @hidden */
  101326. _transformMatrixR: Matrix;
  101327. /** @hidden */
  101328. _multiviewSceneUbo: Nullable<UniformBuffer>;
  101329. /** @hidden */
  101330. _createMultiviewUbo(): void;
  101331. /** @hidden */
  101332. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  101333. /** @hidden */
  101334. _renderMultiviewToSingleView(camera: Camera): void;
  101335. }
  101336. }
  101337. declare module BABYLON {
  101338. /**
  101339. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  101340. * This will not be used for webXR as it supports displaying texture arrays directly
  101341. */
  101342. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  101343. /**
  101344. * Gets a string identifying the name of the class
  101345. * @returns "VRMultiviewToSingleviewPostProcess" string
  101346. */
  101347. getClassName(): string;
  101348. /**
  101349. * Initializes a VRMultiviewToSingleview
  101350. * @param name name of the post process
  101351. * @param camera camera to be applied to
  101352. * @param scaleFactor scaling factor to the size of the output texture
  101353. */
  101354. constructor(name: string, camera: Camera, scaleFactor: number);
  101355. }
  101356. }
  101357. declare module BABYLON {
  101358. /**
  101359. * Interface used to define additional presentation attributes
  101360. */
  101361. export interface IVRPresentationAttributes {
  101362. /**
  101363. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  101364. */
  101365. highRefreshRate: boolean;
  101366. /**
  101367. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  101368. */
  101369. foveationLevel: number;
  101370. }
  101371. interface Engine {
  101372. /** @hidden */
  101373. _vrDisplay: any;
  101374. /** @hidden */
  101375. _vrSupported: boolean;
  101376. /** @hidden */
  101377. _oldSize: Size;
  101378. /** @hidden */
  101379. _oldHardwareScaleFactor: number;
  101380. /** @hidden */
  101381. _vrExclusivePointerMode: boolean;
  101382. /** @hidden */
  101383. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  101384. /** @hidden */
  101385. _onVRDisplayPointerRestricted: () => void;
  101386. /** @hidden */
  101387. _onVRDisplayPointerUnrestricted: () => void;
  101388. /** @hidden */
  101389. _onVrDisplayConnect: Nullable<(display: any) => void>;
  101390. /** @hidden */
  101391. _onVrDisplayDisconnect: Nullable<() => void>;
  101392. /** @hidden */
  101393. _onVrDisplayPresentChange: Nullable<() => void>;
  101394. /**
  101395. * Observable signaled when VR display mode changes
  101396. */
  101397. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  101398. /**
  101399. * Observable signaled when VR request present is complete
  101400. */
  101401. onVRRequestPresentComplete: Observable<boolean>;
  101402. /**
  101403. * Observable signaled when VR request present starts
  101404. */
  101405. onVRRequestPresentStart: Observable<Engine>;
  101406. /**
  101407. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  101408. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  101409. */
  101410. isInVRExclusivePointerMode: boolean;
  101411. /**
  101412. * Gets a boolean indicating if a webVR device was detected
  101413. * @returns true if a webVR device was detected
  101414. */
  101415. isVRDevicePresent(): boolean;
  101416. /**
  101417. * Gets the current webVR device
  101418. * @returns the current webVR device (or null)
  101419. */
  101420. getVRDevice(): any;
  101421. /**
  101422. * Initializes a webVR display and starts listening to display change events
  101423. * The onVRDisplayChangedObservable will be notified upon these changes
  101424. * @returns A promise containing a VRDisplay and if vr is supported
  101425. */
  101426. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  101427. /** @hidden */
  101428. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  101429. /**
  101430. * Gets or sets the presentation attributes used to configure VR rendering
  101431. */
  101432. vrPresentationAttributes?: IVRPresentationAttributes;
  101433. /**
  101434. * Call this function to switch to webVR mode
  101435. * Will do nothing if webVR is not supported or if there is no webVR device
  101436. * @param options the webvr options provided to the camera. mainly used for multiview
  101437. * @see https://doc.babylonjs.com/how_to/webvr_camera
  101438. */
  101439. enableVR(options: WebVROptions): void;
  101440. /** @hidden */
  101441. _onVRFullScreenTriggered(): void;
  101442. }
  101443. }
  101444. declare module BABYLON {
  101445. /**
  101446. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  101447. * IMPORTANT!! The data is right-hand data.
  101448. * @export
  101449. * @interface DevicePose
  101450. */
  101451. export interface DevicePose {
  101452. /**
  101453. * The position of the device, values in array are [x,y,z].
  101454. */
  101455. readonly position: Nullable<Float32Array>;
  101456. /**
  101457. * The linearVelocity of the device, values in array are [x,y,z].
  101458. */
  101459. readonly linearVelocity: Nullable<Float32Array>;
  101460. /**
  101461. * The linearAcceleration of the device, values in array are [x,y,z].
  101462. */
  101463. readonly linearAcceleration: Nullable<Float32Array>;
  101464. /**
  101465. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  101466. */
  101467. readonly orientation: Nullable<Float32Array>;
  101468. /**
  101469. * The angularVelocity of the device, values in array are [x,y,z].
  101470. */
  101471. readonly angularVelocity: Nullable<Float32Array>;
  101472. /**
  101473. * The angularAcceleration of the device, values in array are [x,y,z].
  101474. */
  101475. readonly angularAcceleration: Nullable<Float32Array>;
  101476. }
  101477. /**
  101478. * Interface representing a pose controlled object in Babylon.
  101479. * A pose controlled object has both regular pose values as well as pose values
  101480. * from an external device such as a VR head mounted display
  101481. */
  101482. export interface PoseControlled {
  101483. /**
  101484. * The position of the object in babylon space.
  101485. */
  101486. position: Vector3;
  101487. /**
  101488. * The rotation quaternion of the object in babylon space.
  101489. */
  101490. rotationQuaternion: Quaternion;
  101491. /**
  101492. * The position of the device in babylon space.
  101493. */
  101494. devicePosition?: Vector3;
  101495. /**
  101496. * The rotation quaternion of the device in babylon space.
  101497. */
  101498. deviceRotationQuaternion: Quaternion;
  101499. /**
  101500. * The raw pose coming from the device.
  101501. */
  101502. rawPose: Nullable<DevicePose>;
  101503. /**
  101504. * The scale of the device to be used when translating from device space to babylon space.
  101505. */
  101506. deviceScaleFactor: number;
  101507. /**
  101508. * Updates the poseControlled values based on the input device pose.
  101509. * @param poseData the pose data to update the object with
  101510. */
  101511. updateFromDevice(poseData: DevicePose): void;
  101512. }
  101513. /**
  101514. * Set of options to customize the webVRCamera
  101515. */
  101516. export interface WebVROptions {
  101517. /**
  101518. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  101519. */
  101520. trackPosition?: boolean;
  101521. /**
  101522. * Sets the scale of the vrDevice in babylon space. (default: 1)
  101523. */
  101524. positionScale?: number;
  101525. /**
  101526. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  101527. */
  101528. displayName?: string;
  101529. /**
  101530. * Should the native controller meshes be initialized. (default: true)
  101531. */
  101532. controllerMeshes?: boolean;
  101533. /**
  101534. * Creating a default HemiLight only on controllers. (default: true)
  101535. */
  101536. defaultLightingOnControllers?: boolean;
  101537. /**
  101538. * If you don't want to use the default VR button of the helper. (default: false)
  101539. */
  101540. useCustomVRButton?: boolean;
  101541. /**
  101542. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  101543. */
  101544. customVRButton?: HTMLButtonElement;
  101545. /**
  101546. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  101547. */
  101548. rayLength?: number;
  101549. /**
  101550. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  101551. */
  101552. defaultHeight?: number;
  101553. /**
  101554. * If multiview should be used if availible (default: false)
  101555. */
  101556. useMultiview?: boolean;
  101557. }
  101558. /**
  101559. * This represents a WebVR camera.
  101560. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  101561. * @example https://doc.babylonjs.com/how_to/webvr_camera
  101562. */
  101563. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  101564. private webVROptions;
  101565. /**
  101566. * @hidden
  101567. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  101568. */
  101569. _vrDevice: any;
  101570. /**
  101571. * The rawPose of the vrDevice.
  101572. */
  101573. rawPose: Nullable<DevicePose>;
  101574. private _onVREnabled;
  101575. private _specsVersion;
  101576. private _attached;
  101577. private _frameData;
  101578. protected _descendants: Array<Node>;
  101579. private _deviceRoomPosition;
  101580. /** @hidden */
  101581. _deviceRoomRotationQuaternion: Quaternion;
  101582. private _standingMatrix;
  101583. /**
  101584. * Represents device position in babylon space.
  101585. */
  101586. devicePosition: Vector3;
  101587. /**
  101588. * Represents device rotation in babylon space.
  101589. */
  101590. deviceRotationQuaternion: Quaternion;
  101591. /**
  101592. * The scale of the device to be used when translating from device space to babylon space.
  101593. */
  101594. deviceScaleFactor: number;
  101595. private _deviceToWorld;
  101596. private _worldToDevice;
  101597. /**
  101598. * References to the webVR controllers for the vrDevice.
  101599. */
  101600. controllers: Array<WebVRController>;
  101601. /**
  101602. * Emits an event when a controller is attached.
  101603. */
  101604. onControllersAttachedObservable: Observable<WebVRController[]>;
  101605. /**
  101606. * Emits an event when a controller's mesh has been loaded;
  101607. */
  101608. onControllerMeshLoadedObservable: Observable<WebVRController>;
  101609. /**
  101610. * Emits an event when the HMD's pose has been updated.
  101611. */
  101612. onPoseUpdatedFromDeviceObservable: Observable<any>;
  101613. private _poseSet;
  101614. /**
  101615. * If the rig cameras be used as parent instead of this camera.
  101616. */
  101617. rigParenting: boolean;
  101618. private _lightOnControllers;
  101619. private _defaultHeight?;
  101620. /**
  101621. * Instantiates a WebVRFreeCamera.
  101622. * @param name The name of the WebVRFreeCamera
  101623. * @param position The starting anchor position for the camera
  101624. * @param scene The scene the camera belongs to
  101625. * @param webVROptions a set of customizable options for the webVRCamera
  101626. */
  101627. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  101628. /**
  101629. * Gets the device distance from the ground in meters.
  101630. * @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.
  101631. */
  101632. deviceDistanceToRoomGround(): number;
  101633. /**
  101634. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  101635. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  101636. */
  101637. useStandingMatrix(callback?: (bool: boolean) => void): void;
  101638. /**
  101639. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  101640. * @returns A promise with a boolean set to if the standing matrix is supported.
  101641. */
  101642. useStandingMatrixAsync(): Promise<boolean>;
  101643. /**
  101644. * Disposes the camera
  101645. */
  101646. dispose(): void;
  101647. /**
  101648. * Gets a vrController by name.
  101649. * @param name The name of the controller to retreive
  101650. * @returns the controller matching the name specified or null if not found
  101651. */
  101652. getControllerByName(name: string): Nullable<WebVRController>;
  101653. private _leftController;
  101654. /**
  101655. * The controller corresponding to the users left hand.
  101656. */
  101657. get leftController(): Nullable<WebVRController>;
  101658. private _rightController;
  101659. /**
  101660. * The controller corresponding to the users right hand.
  101661. */
  101662. get rightController(): Nullable<WebVRController>;
  101663. /**
  101664. * Casts a ray forward from the vrCamera's gaze.
  101665. * @param length Length of the ray (default: 100)
  101666. * @returns the ray corresponding to the gaze
  101667. */
  101668. getForwardRay(length?: number): Ray;
  101669. /**
  101670. * @hidden
  101671. * Updates the camera based on device's frame data
  101672. */
  101673. _checkInputs(): void;
  101674. /**
  101675. * Updates the poseControlled values based on the input device pose.
  101676. * @param poseData Pose coming from the device
  101677. */
  101678. updateFromDevice(poseData: DevicePose): void;
  101679. private _htmlElementAttached;
  101680. private _detachIfAttached;
  101681. /**
  101682. * WebVR's attach control will start broadcasting frames to the device.
  101683. * Note that in certain browsers (chrome for example) this function must be called
  101684. * within a user-interaction callback. Example:
  101685. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  101686. *
  101687. * @param element html element to attach the vrDevice to
  101688. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  101689. */
  101690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  101691. /**
  101692. * Detaches the camera from the html element and disables VR
  101693. *
  101694. * @param element html element to detach from
  101695. */
  101696. detachControl(element: HTMLElement): void;
  101697. /**
  101698. * @returns the name of this class
  101699. */
  101700. getClassName(): string;
  101701. /**
  101702. * Calls resetPose on the vrDisplay
  101703. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  101704. */
  101705. resetToCurrentRotation(): void;
  101706. /**
  101707. * @hidden
  101708. * Updates the rig cameras (left and right eye)
  101709. */
  101710. _updateRigCameras(): void;
  101711. private _workingVector;
  101712. private _oneVector;
  101713. private _workingMatrix;
  101714. private updateCacheCalled;
  101715. private _correctPositionIfNotTrackPosition;
  101716. /**
  101717. * @hidden
  101718. * Updates the cached values of the camera
  101719. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  101720. */
  101721. _updateCache(ignoreParentClass?: boolean): void;
  101722. /**
  101723. * @hidden
  101724. * Get current device position in babylon world
  101725. */
  101726. _computeDevicePosition(): void;
  101727. /**
  101728. * Updates the current device position and rotation in the babylon world
  101729. */
  101730. update(): void;
  101731. /**
  101732. * @hidden
  101733. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  101734. * @returns an identity matrix
  101735. */
  101736. _getViewMatrix(): Matrix;
  101737. private _tmpMatrix;
  101738. /**
  101739. * This function is called by the two RIG cameras.
  101740. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  101741. * @hidden
  101742. */
  101743. _getWebVRViewMatrix(): Matrix;
  101744. /** @hidden */
  101745. _getWebVRProjectionMatrix(): Matrix;
  101746. private _onGamepadConnectedObserver;
  101747. private _onGamepadDisconnectedObserver;
  101748. private _updateCacheWhenTrackingDisabledObserver;
  101749. /**
  101750. * Initializes the controllers and their meshes
  101751. */
  101752. initControllers(): void;
  101753. }
  101754. }
  101755. declare module BABYLON {
  101756. /**
  101757. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  101758. *
  101759. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  101760. *
  101761. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  101762. */
  101763. export class MaterialHelper {
  101764. /**
  101765. * Bind the current view position to an effect.
  101766. * @param effect The effect to be bound
  101767. * @param scene The scene the eyes position is used from
  101768. * @param variableName name of the shader variable that will hold the eye position
  101769. */
  101770. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  101771. /**
  101772. * Helps preparing the defines values about the UVs in used in the effect.
  101773. * UVs are shared as much as we can accross channels in the shaders.
  101774. * @param texture The texture we are preparing the UVs for
  101775. * @param defines The defines to update
  101776. * @param key The channel key "diffuse", "specular"... used in the shader
  101777. */
  101778. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  101779. /**
  101780. * Binds a texture matrix value to its corrsponding uniform
  101781. * @param texture The texture to bind the matrix for
  101782. * @param uniformBuffer The uniform buffer receivin the data
  101783. * @param key The channel key "diffuse", "specular"... used in the shader
  101784. */
  101785. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  101786. /**
  101787. * Gets the current status of the fog (should it be enabled?)
  101788. * @param mesh defines the mesh to evaluate for fog support
  101789. * @param scene defines the hosting scene
  101790. * @returns true if fog must be enabled
  101791. */
  101792. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  101793. /**
  101794. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  101795. * @param mesh defines the current mesh
  101796. * @param scene defines the current scene
  101797. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  101798. * @param pointsCloud defines if point cloud rendering has to be turned on
  101799. * @param fogEnabled defines if fog has to be turned on
  101800. * @param alphaTest defines if alpha testing has to be turned on
  101801. * @param defines defines the current list of defines
  101802. */
  101803. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  101804. /**
  101805. * Helper used to prepare the list of defines associated with frame values for shader compilation
  101806. * @param scene defines the current scene
  101807. * @param engine defines the current engine
  101808. * @param defines specifies the list of active defines
  101809. * @param useInstances defines if instances have to be turned on
  101810. * @param useClipPlane defines if clip plane have to be turned on
  101811. * @param useInstances defines if instances have to be turned on
  101812. * @param useThinInstances defines if thin instances have to be turned on
  101813. */
  101814. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  101815. /**
  101816. * Prepares the defines for bones
  101817. * @param mesh The mesh containing the geometry data we will draw
  101818. * @param defines The defines to update
  101819. */
  101820. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  101821. /**
  101822. * Prepares the defines for morph targets
  101823. * @param mesh The mesh containing the geometry data we will draw
  101824. * @param defines The defines to update
  101825. */
  101826. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  101827. /**
  101828. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  101829. * @param mesh The mesh containing the geometry data we will draw
  101830. * @param defines The defines to update
  101831. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  101832. * @param useBones Precise whether bones should be used or not (override mesh info)
  101833. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  101834. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  101835. * @returns false if defines are considered not dirty and have not been checked
  101836. */
  101837. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  101838. /**
  101839. * Prepares the defines related to multiview
  101840. * @param scene The scene we are intending to draw
  101841. * @param defines The defines to update
  101842. */
  101843. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  101844. /**
  101845. * Prepares the defines related to the prepass
  101846. * @param scene The scene we are intending to draw
  101847. * @param defines The defines to update
  101848. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  101849. */
  101850. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  101851. /**
  101852. * Prepares the defines related to the light information passed in parameter
  101853. * @param scene The scene we are intending to draw
  101854. * @param mesh The mesh the effect is compiling for
  101855. * @param light The light the effect is compiling for
  101856. * @param lightIndex The index of the light
  101857. * @param defines The defines to update
  101858. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101859. * @param state Defines the current state regarding what is needed (normals, etc...)
  101860. */
  101861. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  101862. needNormals: boolean;
  101863. needRebuild: boolean;
  101864. shadowEnabled: boolean;
  101865. specularEnabled: boolean;
  101866. lightmapMode: boolean;
  101867. }): void;
  101868. /**
  101869. * Prepares the defines related to the light information passed in parameter
  101870. * @param scene The scene we are intending to draw
  101871. * @param mesh The mesh the effect is compiling for
  101872. * @param defines The defines to update
  101873. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  101874. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  101875. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  101876. * @returns true if normals will be required for the rest of the effect
  101877. */
  101878. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  101879. /**
  101880. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  101881. * @param lightIndex defines the light index
  101882. * @param uniformsList The uniform list
  101883. * @param samplersList The sampler list
  101884. * @param projectedLightTexture defines if projected texture must be used
  101885. * @param uniformBuffersList defines an optional list of uniform buffers
  101886. */
  101887. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  101888. /**
  101889. * Prepares the uniforms and samplers list to be used in the effect
  101890. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  101891. * @param samplersList The sampler list
  101892. * @param defines The defines helping in the list generation
  101893. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  101894. */
  101895. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  101896. /**
  101897. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  101898. * @param defines The defines to update while falling back
  101899. * @param fallbacks The authorized effect fallbacks
  101900. * @param maxSimultaneousLights The maximum number of lights allowed
  101901. * @param rank the current rank of the Effect
  101902. * @returns The newly affected rank
  101903. */
  101904. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  101905. private static _TmpMorphInfluencers;
  101906. /**
  101907. * Prepares the list of attributes required for morph targets according to the effect defines.
  101908. * @param attribs The current list of supported attribs
  101909. * @param mesh The mesh to prepare the morph targets attributes for
  101910. * @param influencers The number of influencers
  101911. */
  101912. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  101913. /**
  101914. * Prepares the list of attributes required for morph targets according to the effect defines.
  101915. * @param attribs The current list of supported attribs
  101916. * @param mesh The mesh to prepare the morph targets attributes for
  101917. * @param defines The current Defines of the effect
  101918. */
  101919. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  101920. /**
  101921. * Prepares the list of attributes required for bones according to the effect defines.
  101922. * @param attribs The current list of supported attribs
  101923. * @param mesh The mesh to prepare the bones attributes for
  101924. * @param defines The current Defines of the effect
  101925. * @param fallbacks The current efffect fallback strategy
  101926. */
  101927. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  101928. /**
  101929. * Check and prepare the list of attributes required for instances according to the effect defines.
  101930. * @param attribs The current list of supported attribs
  101931. * @param defines The current MaterialDefines of the effect
  101932. */
  101933. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  101934. /**
  101935. * Add the list of attributes required for instances to the attribs array.
  101936. * @param attribs The current list of supported attribs
  101937. */
  101938. static PushAttributesForInstances(attribs: string[]): void;
  101939. /**
  101940. * Binds the light information to the effect.
  101941. * @param light The light containing the generator
  101942. * @param effect The effect we are binding the data to
  101943. * @param lightIndex The light index in the effect used to render
  101944. */
  101945. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  101946. /**
  101947. * Binds the lights information from the scene to the effect for the given mesh.
  101948. * @param light Light to bind
  101949. * @param lightIndex Light index
  101950. * @param scene The scene where the light belongs to
  101951. * @param effect The effect we are binding the data to
  101952. * @param useSpecular Defines if specular is supported
  101953. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101954. */
  101955. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  101956. /**
  101957. * Binds the lights information from the scene to the effect for the given mesh.
  101958. * @param scene The scene the lights belongs to
  101959. * @param mesh The mesh we are binding the information to render
  101960. * @param effect The effect we are binding the data to
  101961. * @param defines The generated defines for the effect
  101962. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  101963. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  101964. */
  101965. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  101966. private static _tempFogColor;
  101967. /**
  101968. * Binds the fog information from the scene to the effect for the given mesh.
  101969. * @param scene The scene the lights belongs to
  101970. * @param mesh The mesh we are binding the information to render
  101971. * @param effect The effect we are binding the data to
  101972. * @param linearSpace Defines if the fog effect is applied in linear space
  101973. */
  101974. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  101975. /**
  101976. * Binds the bones information from the mesh to the effect.
  101977. * @param mesh The mesh we are binding the information to render
  101978. * @param effect The effect we are binding the data to
  101979. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  101980. */
  101981. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  101982. private static _CopyBonesTransformationMatrices;
  101983. /**
  101984. * Binds the morph targets information from the mesh to the effect.
  101985. * @param abstractMesh The mesh we are binding the information to render
  101986. * @param effect The effect we are binding the data to
  101987. */
  101988. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  101989. /**
  101990. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  101991. * @param defines The generated defines used in the effect
  101992. * @param effect The effect we are binding the data to
  101993. * @param scene The scene we are willing to render with logarithmic scale for
  101994. */
  101995. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  101996. /**
  101997. * Binds the clip plane information from the scene to the effect.
  101998. * @param scene The scene the clip plane information are extracted from
  101999. * @param effect The effect we are binding the data to
  102000. */
  102001. static BindClipPlane(effect: Effect, scene: Scene): void;
  102002. }
  102003. }
  102004. declare module BABYLON {
  102005. /**
  102006. * Block used to expose an input value
  102007. */
  102008. export class InputBlock extends NodeMaterialBlock {
  102009. private _mode;
  102010. private _associatedVariableName;
  102011. private _storedValue;
  102012. private _valueCallback;
  102013. private _type;
  102014. private _animationType;
  102015. /** Gets or set a value used to limit the range of float values */
  102016. min: number;
  102017. /** Gets or set a value used to limit the range of float values */
  102018. max: number;
  102019. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  102020. isBoolean: boolean;
  102021. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  102022. matrixMode: number;
  102023. /** @hidden */
  102024. _systemValue: Nullable<NodeMaterialSystemValues>;
  102025. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  102026. isConstant: boolean;
  102027. /** Gets or sets the group to use to display this block in the Inspector */
  102028. groupInInspector: string;
  102029. /** Gets an observable raised when the value is changed */
  102030. onValueChangedObservable: Observable<InputBlock>;
  102031. /**
  102032. * Gets or sets the connection point type (default is float)
  102033. */
  102034. get type(): NodeMaterialBlockConnectionPointTypes;
  102035. /**
  102036. * Creates a new InputBlock
  102037. * @param name defines the block name
  102038. * @param target defines the target of that block (Vertex by default)
  102039. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  102040. */
  102041. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  102042. /**
  102043. * Validates if a name is a reserve word.
  102044. * @param newName the new name to be given to the node.
  102045. * @returns false if the name is a reserve word, else true.
  102046. */
  102047. validateBlockName(newName: string): boolean;
  102048. /**
  102049. * Gets the output component
  102050. */
  102051. get output(): NodeMaterialConnectionPoint;
  102052. /**
  102053. * Set the source of this connection point to a vertex attribute
  102054. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  102055. * @returns the current connection point
  102056. */
  102057. setAsAttribute(attributeName?: string): InputBlock;
  102058. /**
  102059. * Set the source of this connection point to a system value
  102060. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  102061. * @returns the current connection point
  102062. */
  102063. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  102064. /**
  102065. * Gets or sets the value of that point.
  102066. * Please note that this value will be ignored if valueCallback is defined
  102067. */
  102068. get value(): any;
  102069. set value(value: any);
  102070. /**
  102071. * Gets or sets a callback used to get the value of that point.
  102072. * Please note that setting this value will force the connection point to ignore the value property
  102073. */
  102074. get valueCallback(): () => any;
  102075. set valueCallback(value: () => any);
  102076. /**
  102077. * Gets or sets the associated variable name in the shader
  102078. */
  102079. get associatedVariableName(): string;
  102080. set associatedVariableName(value: string);
  102081. /** Gets or sets the type of animation applied to the input */
  102082. get animationType(): AnimatedInputBlockTypes;
  102083. set animationType(value: AnimatedInputBlockTypes);
  102084. /**
  102085. * Gets a boolean indicating that this connection point not defined yet
  102086. */
  102087. get isUndefined(): boolean;
  102088. /**
  102089. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  102090. * In this case the connection point name must be the name of the uniform to use.
  102091. * Can only be set on inputs
  102092. */
  102093. get isUniform(): boolean;
  102094. set isUniform(value: boolean);
  102095. /**
  102096. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  102097. * In this case the connection point name must be the name of the attribute to use
  102098. * Can only be set on inputs
  102099. */
  102100. get isAttribute(): boolean;
  102101. set isAttribute(value: boolean);
  102102. /**
  102103. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  102104. * Can only be set on exit points
  102105. */
  102106. get isVarying(): boolean;
  102107. set isVarying(value: boolean);
  102108. /**
  102109. * Gets a boolean indicating that the current connection point is a system value
  102110. */
  102111. get isSystemValue(): boolean;
  102112. /**
  102113. * Gets or sets the current well known value or null if not defined as a system value
  102114. */
  102115. get systemValue(): Nullable<NodeMaterialSystemValues>;
  102116. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  102117. /**
  102118. * Gets the current class name
  102119. * @returns the class name
  102120. */
  102121. getClassName(): string;
  102122. /**
  102123. * Animate the input if animationType !== None
  102124. * @param scene defines the rendering scene
  102125. */
  102126. animate(scene: Scene): void;
  102127. private _emitDefine;
  102128. initialize(state: NodeMaterialBuildState): void;
  102129. /**
  102130. * Set the input block to its default value (based on its type)
  102131. */
  102132. setDefaultValue(): void;
  102133. private _emitConstant;
  102134. /** @hidden */
  102135. get _noContextSwitch(): boolean;
  102136. private _emit;
  102137. /** @hidden */
  102138. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  102139. /** @hidden */
  102140. _transmit(effect: Effect, scene: Scene): void;
  102141. protected _buildBlock(state: NodeMaterialBuildState): void;
  102142. protected _dumpPropertiesCode(): string;
  102143. dispose(): void;
  102144. serialize(): any;
  102145. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102146. }
  102147. }
  102148. declare module BABYLON {
  102149. /**
  102150. * Enum used to define the compatibility state between two connection points
  102151. */
  102152. export enum NodeMaterialConnectionPointCompatibilityStates {
  102153. /** Points are compatibles */
  102154. Compatible = 0,
  102155. /** Points are incompatible because of their types */
  102156. TypeIncompatible = 1,
  102157. /** Points are incompatible because of their targets (vertex vs fragment) */
  102158. TargetIncompatible = 2
  102159. }
  102160. /**
  102161. * Defines the direction of a connection point
  102162. */
  102163. export enum NodeMaterialConnectionPointDirection {
  102164. /** Input */
  102165. Input = 0,
  102166. /** Output */
  102167. Output = 1
  102168. }
  102169. /**
  102170. * Defines a connection point for a block
  102171. */
  102172. export class NodeMaterialConnectionPoint {
  102173. /** @hidden */
  102174. _ownerBlock: NodeMaterialBlock;
  102175. /** @hidden */
  102176. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  102177. private _endpoints;
  102178. private _associatedVariableName;
  102179. private _direction;
  102180. /** @hidden */
  102181. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  102182. /** @hidden */
  102183. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  102184. private _type;
  102185. /** @hidden */
  102186. _enforceAssociatedVariableName: boolean;
  102187. /** Gets the direction of the point */
  102188. get direction(): NodeMaterialConnectionPointDirection;
  102189. /** Indicates that this connection point needs dual validation before being connected to another point */
  102190. needDualDirectionValidation: boolean;
  102191. /**
  102192. * Gets or sets the additional types supported by this connection point
  102193. */
  102194. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  102195. /**
  102196. * Gets or sets the additional types excluded by this connection point
  102197. */
  102198. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  102199. /**
  102200. * Observable triggered when this point is connected
  102201. */
  102202. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  102203. /**
  102204. * Gets or sets the associated variable name in the shader
  102205. */
  102206. get associatedVariableName(): string;
  102207. set associatedVariableName(value: string);
  102208. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  102209. get innerType(): NodeMaterialBlockConnectionPointTypes;
  102210. /**
  102211. * Gets or sets the connection point type (default is float)
  102212. */
  102213. get type(): NodeMaterialBlockConnectionPointTypes;
  102214. set type(value: NodeMaterialBlockConnectionPointTypes);
  102215. /**
  102216. * Gets or sets the connection point name
  102217. */
  102218. name: string;
  102219. /**
  102220. * Gets or sets the connection point name
  102221. */
  102222. displayName: string;
  102223. /**
  102224. * Gets or sets a boolean indicating that this connection point can be omitted
  102225. */
  102226. isOptional: boolean;
  102227. /**
  102228. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  102229. */
  102230. isExposedOnFrame: boolean;
  102231. /**
  102232. * Gets or sets number indicating the position that the port is exposed to on a frame
  102233. */
  102234. exposedPortPosition: number;
  102235. /**
  102236. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  102237. */
  102238. define: string;
  102239. /** @hidden */
  102240. _prioritizeVertex: boolean;
  102241. private _target;
  102242. /** Gets or sets the target of that connection point */
  102243. get target(): NodeMaterialBlockTargets;
  102244. set target(value: NodeMaterialBlockTargets);
  102245. /**
  102246. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  102247. */
  102248. get isConnected(): boolean;
  102249. /**
  102250. * Gets a boolean indicating that the current point is connected to an input block
  102251. */
  102252. get isConnectedToInputBlock(): boolean;
  102253. /**
  102254. * Gets a the connected input block (if any)
  102255. */
  102256. get connectInputBlock(): Nullable<InputBlock>;
  102257. /** Get the other side of the connection (if any) */
  102258. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  102259. /** Get the block that owns this connection point */
  102260. get ownerBlock(): NodeMaterialBlock;
  102261. /** Get the block connected on the other side of this connection (if any) */
  102262. get sourceBlock(): Nullable<NodeMaterialBlock>;
  102263. /** Get the block connected on the endpoints of this connection (if any) */
  102264. get connectedBlocks(): Array<NodeMaterialBlock>;
  102265. /** Gets the list of connected endpoints */
  102266. get endpoints(): NodeMaterialConnectionPoint[];
  102267. /** Gets a boolean indicating if that output point is connected to at least one input */
  102268. get hasEndpoints(): boolean;
  102269. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  102270. get isConnectedInVertexShader(): boolean;
  102271. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  102272. get isConnectedInFragmentShader(): boolean;
  102273. /**
  102274. * Creates a block suitable to be used as an input for this input point.
  102275. * If null is returned, a block based on the point type will be created.
  102276. * @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
  102277. */
  102278. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  102279. /**
  102280. * Creates a new connection point
  102281. * @param name defines the connection point name
  102282. * @param ownerBlock defines the block hosting this connection point
  102283. * @param direction defines the direction of the connection point
  102284. */
  102285. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  102286. /**
  102287. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  102288. * @returns the class name
  102289. */
  102290. getClassName(): string;
  102291. /**
  102292. * Gets a boolean indicating if the current point can be connected to another point
  102293. * @param connectionPoint defines the other connection point
  102294. * @returns a boolean
  102295. */
  102296. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  102297. /**
  102298. * Gets a number indicating if the current point can be connected to another point
  102299. * @param connectionPoint defines the other connection point
  102300. * @returns a number defining the compatibility state
  102301. */
  102302. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  102303. /**
  102304. * Connect this point to another connection point
  102305. * @param connectionPoint defines the other connection point
  102306. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  102307. * @returns the current connection point
  102308. */
  102309. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  102310. /**
  102311. * Disconnect this point from one of his endpoint
  102312. * @param endpoint defines the other connection point
  102313. * @returns the current connection point
  102314. */
  102315. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  102316. /**
  102317. * Serializes this point in a JSON representation
  102318. * @param isInput defines if the connection point is an input (default is true)
  102319. * @returns the serialized point object
  102320. */
  102321. serialize(isInput?: boolean): any;
  102322. /**
  102323. * Release resources
  102324. */
  102325. dispose(): void;
  102326. }
  102327. }
  102328. declare module BABYLON {
  102329. /**
  102330. * Enum used to define the material modes
  102331. */
  102332. export enum NodeMaterialModes {
  102333. /** Regular material */
  102334. Material = 0,
  102335. /** For post process */
  102336. PostProcess = 1,
  102337. /** For particle system */
  102338. Particle = 2,
  102339. /** For procedural texture */
  102340. ProceduralTexture = 3
  102341. }
  102342. }
  102343. declare module BABYLON {
  102344. /**
  102345. * Block used to read a texture from a sampler
  102346. */
  102347. export class TextureBlock extends NodeMaterialBlock {
  102348. private _defineName;
  102349. private _linearDefineName;
  102350. private _gammaDefineName;
  102351. private _tempTextureRead;
  102352. private _samplerName;
  102353. private _transformedUVName;
  102354. private _textureTransformName;
  102355. private _textureInfoName;
  102356. private _mainUVName;
  102357. private _mainUVDefineName;
  102358. private _fragmentOnly;
  102359. /**
  102360. * Gets or sets the texture associated with the node
  102361. */
  102362. texture: Nullable<Texture>;
  102363. /**
  102364. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102365. */
  102366. convertToGammaSpace: boolean;
  102367. /**
  102368. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102369. */
  102370. convertToLinearSpace: boolean;
  102371. /**
  102372. * Create a new TextureBlock
  102373. * @param name defines the block name
  102374. */
  102375. constructor(name: string, fragmentOnly?: boolean);
  102376. /**
  102377. * Gets the current class name
  102378. * @returns the class name
  102379. */
  102380. getClassName(): string;
  102381. /**
  102382. * Gets the uv input component
  102383. */
  102384. get uv(): NodeMaterialConnectionPoint;
  102385. /**
  102386. * Gets the rgba output component
  102387. */
  102388. get rgba(): NodeMaterialConnectionPoint;
  102389. /**
  102390. * Gets the rgb output component
  102391. */
  102392. get rgb(): NodeMaterialConnectionPoint;
  102393. /**
  102394. * Gets the r output component
  102395. */
  102396. get r(): NodeMaterialConnectionPoint;
  102397. /**
  102398. * Gets the g output component
  102399. */
  102400. get g(): NodeMaterialConnectionPoint;
  102401. /**
  102402. * Gets the b output component
  102403. */
  102404. get b(): NodeMaterialConnectionPoint;
  102405. /**
  102406. * Gets the a output component
  102407. */
  102408. get a(): NodeMaterialConnectionPoint;
  102409. get target(): NodeMaterialBlockTargets;
  102410. autoConfigure(material: NodeMaterial): void;
  102411. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102412. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102413. isReady(): boolean;
  102414. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  102415. private get _isMixed();
  102416. private _injectVertexCode;
  102417. private _writeTextureRead;
  102418. private _writeOutput;
  102419. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102420. protected _dumpPropertiesCode(): string;
  102421. serialize(): any;
  102422. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102423. }
  102424. }
  102425. declare module BABYLON {
  102426. /** @hidden */
  102427. export var reflectionFunction: {
  102428. name: string;
  102429. shader: string;
  102430. };
  102431. }
  102432. declare module BABYLON {
  102433. /**
  102434. * Base block used to read a reflection texture from a sampler
  102435. */
  102436. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  102437. /** @hidden */
  102438. _define3DName: string;
  102439. /** @hidden */
  102440. _defineCubicName: string;
  102441. /** @hidden */
  102442. _defineExplicitName: string;
  102443. /** @hidden */
  102444. _defineProjectionName: string;
  102445. /** @hidden */
  102446. _defineLocalCubicName: string;
  102447. /** @hidden */
  102448. _defineSphericalName: string;
  102449. /** @hidden */
  102450. _definePlanarName: string;
  102451. /** @hidden */
  102452. _defineEquirectangularName: string;
  102453. /** @hidden */
  102454. _defineMirroredEquirectangularFixedName: string;
  102455. /** @hidden */
  102456. _defineEquirectangularFixedName: string;
  102457. /** @hidden */
  102458. _defineSkyboxName: string;
  102459. /** @hidden */
  102460. _defineOppositeZ: string;
  102461. /** @hidden */
  102462. _cubeSamplerName: string;
  102463. /** @hidden */
  102464. _2DSamplerName: string;
  102465. protected _positionUVWName: string;
  102466. protected _directionWName: string;
  102467. protected _reflectionVectorName: string;
  102468. /** @hidden */
  102469. _reflectionCoordsName: string;
  102470. /** @hidden */
  102471. _reflectionMatrixName: string;
  102472. protected _reflectionColorName: string;
  102473. /**
  102474. * Gets or sets the texture associated with the node
  102475. */
  102476. texture: Nullable<BaseTexture>;
  102477. /**
  102478. * Create a new ReflectionTextureBaseBlock
  102479. * @param name defines the block name
  102480. */
  102481. constructor(name: string);
  102482. /**
  102483. * Gets the current class name
  102484. * @returns the class name
  102485. */
  102486. getClassName(): string;
  102487. /**
  102488. * Gets the world position input component
  102489. */
  102490. abstract get position(): NodeMaterialConnectionPoint;
  102491. /**
  102492. * Gets the world position input component
  102493. */
  102494. abstract get worldPosition(): NodeMaterialConnectionPoint;
  102495. /**
  102496. * Gets the world normal input component
  102497. */
  102498. abstract get worldNormal(): NodeMaterialConnectionPoint;
  102499. /**
  102500. * Gets the world input component
  102501. */
  102502. abstract get world(): NodeMaterialConnectionPoint;
  102503. /**
  102504. * Gets the camera (or eye) position component
  102505. */
  102506. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  102507. /**
  102508. * Gets the view input component
  102509. */
  102510. abstract get view(): NodeMaterialConnectionPoint;
  102511. protected _getTexture(): Nullable<BaseTexture>;
  102512. autoConfigure(material: NodeMaterial): void;
  102513. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102514. isReady(): boolean;
  102515. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  102516. /**
  102517. * Gets the code to inject in the vertex shader
  102518. * @param state current state of the node material building
  102519. * @returns the shader code
  102520. */
  102521. handleVertexSide(state: NodeMaterialBuildState): string;
  102522. /**
  102523. * Handles the inits for the fragment code path
  102524. * @param state node material build state
  102525. */
  102526. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  102527. /**
  102528. * Generates the reflection coords code for the fragment code path
  102529. * @param worldNormalVarName name of the world normal variable
  102530. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  102531. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  102532. * @returns the shader code
  102533. */
  102534. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  102535. /**
  102536. * Generates the reflection color code for the fragment code path
  102537. * @param lodVarName name of the lod variable
  102538. * @param swizzleLookupTexture swizzle to use for the final color variable
  102539. * @returns the shader code
  102540. */
  102541. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  102542. /**
  102543. * Generates the code corresponding to the connected output points
  102544. * @param state node material build state
  102545. * @param varName name of the variable to output
  102546. * @returns the shader code
  102547. */
  102548. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  102549. protected _buildBlock(state: NodeMaterialBuildState): this;
  102550. protected _dumpPropertiesCode(): string;
  102551. serialize(): any;
  102552. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102553. }
  102554. }
  102555. declare module BABYLON {
  102556. /**
  102557. * Defines a connection point to be used for points with a custom object type
  102558. */
  102559. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  102560. private _blockType;
  102561. private _blockName;
  102562. private _nameForCheking?;
  102563. /**
  102564. * Creates a new connection point
  102565. * @param name defines the connection point name
  102566. * @param ownerBlock defines the block hosting this connection point
  102567. * @param direction defines the direction of the connection point
  102568. */
  102569. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  102570. /**
  102571. * Gets a number indicating if the current point can be connected to another point
  102572. * @param connectionPoint defines the other connection point
  102573. * @returns a number defining the compatibility state
  102574. */
  102575. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  102576. /**
  102577. * Creates a block suitable to be used as an input for this input point.
  102578. * If null is returned, a block based on the point type will be created.
  102579. * @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
  102580. */
  102581. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  102582. }
  102583. }
  102584. declare module BABYLON {
  102585. /**
  102586. * Enum defining the type of properties that can be edited in the property pages in the NME
  102587. */
  102588. export enum PropertyTypeForEdition {
  102589. /** property is a boolean */
  102590. Boolean = 0,
  102591. /** property is a float */
  102592. Float = 1,
  102593. /** property is a Vector2 */
  102594. Vector2 = 2,
  102595. /** property is a list of values */
  102596. List = 3
  102597. }
  102598. /**
  102599. * Interface that defines an option in a variable of type list
  102600. */
  102601. export interface IEditablePropertyListOption {
  102602. /** label of the option */
  102603. "label": string;
  102604. /** value of the option */
  102605. "value": number;
  102606. }
  102607. /**
  102608. * Interface that defines the options available for an editable property
  102609. */
  102610. export interface IEditablePropertyOption {
  102611. /** min value */
  102612. "min"?: number;
  102613. /** max value */
  102614. "max"?: number;
  102615. /** notifiers: indicates which actions to take when the property is changed */
  102616. "notifiers"?: {
  102617. /** the material should be rebuilt */
  102618. "rebuild"?: boolean;
  102619. /** the preview should be updated */
  102620. "update"?: boolean;
  102621. };
  102622. /** list of the options for a variable of type list */
  102623. "options"?: IEditablePropertyListOption[];
  102624. }
  102625. /**
  102626. * Interface that describes an editable property
  102627. */
  102628. export interface IPropertyDescriptionForEdition {
  102629. /** name of the property */
  102630. "propertyName": string;
  102631. /** display name of the property */
  102632. "displayName": string;
  102633. /** type of the property */
  102634. "type": PropertyTypeForEdition;
  102635. /** group of the property - all properties with the same group value will be displayed in a specific section */
  102636. "groupName": string;
  102637. /** options for the property */
  102638. "options": IEditablePropertyOption;
  102639. }
  102640. /**
  102641. * Decorator that flags a property in a node material block as being editable
  102642. */
  102643. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  102644. }
  102645. declare module BABYLON {
  102646. /**
  102647. * Block used to implement the refraction part of the sub surface module of the PBR material
  102648. */
  102649. export class RefractionBlock extends NodeMaterialBlock {
  102650. /** @hidden */
  102651. _define3DName: string;
  102652. /** @hidden */
  102653. _refractionMatrixName: string;
  102654. /** @hidden */
  102655. _defineLODRefractionAlpha: string;
  102656. /** @hidden */
  102657. _defineLinearSpecularRefraction: string;
  102658. /** @hidden */
  102659. _defineOppositeZ: string;
  102660. /** @hidden */
  102661. _cubeSamplerName: string;
  102662. /** @hidden */
  102663. _2DSamplerName: string;
  102664. /** @hidden */
  102665. _vRefractionMicrosurfaceInfosName: string;
  102666. /** @hidden */
  102667. _vRefractionInfosName: string;
  102668. private _scene;
  102669. /**
  102670. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  102671. * Materials half opaque for instance using refraction could benefit from this control.
  102672. */
  102673. linkRefractionWithTransparency: boolean;
  102674. /**
  102675. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  102676. */
  102677. invertRefractionY: boolean;
  102678. /**
  102679. * Gets or sets the texture associated with the node
  102680. */
  102681. texture: Nullable<BaseTexture>;
  102682. /**
  102683. * Create a new RefractionBlock
  102684. * @param name defines the block name
  102685. */
  102686. constructor(name: string);
  102687. /**
  102688. * Gets the current class name
  102689. * @returns the class name
  102690. */
  102691. getClassName(): string;
  102692. /**
  102693. * Gets the intensity input component
  102694. */
  102695. get intensity(): NodeMaterialConnectionPoint;
  102696. /**
  102697. * Gets the index of refraction input component
  102698. */
  102699. get indexOfRefraction(): NodeMaterialConnectionPoint;
  102700. /**
  102701. * Gets the tint at distance input component
  102702. */
  102703. get tintAtDistance(): NodeMaterialConnectionPoint;
  102704. /**
  102705. * Gets the view input component
  102706. */
  102707. get view(): NodeMaterialConnectionPoint;
  102708. /**
  102709. * Gets the refraction object output component
  102710. */
  102711. get refraction(): NodeMaterialConnectionPoint;
  102712. /**
  102713. * Returns true if the block has a texture
  102714. */
  102715. get hasTexture(): boolean;
  102716. protected _getTexture(): Nullable<BaseTexture>;
  102717. autoConfigure(material: NodeMaterial): void;
  102718. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102719. isReady(): boolean;
  102720. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102721. /**
  102722. * Gets the main code of the block (fragment side)
  102723. * @param state current state of the node material building
  102724. * @returns the shader code
  102725. */
  102726. getCode(state: NodeMaterialBuildState): string;
  102727. protected _buildBlock(state: NodeMaterialBuildState): this;
  102728. protected _dumpPropertiesCode(): string;
  102729. serialize(): any;
  102730. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102731. }
  102732. }
  102733. declare module BABYLON {
  102734. /**
  102735. * Base block used as input for post process
  102736. */
  102737. export class CurrentScreenBlock extends NodeMaterialBlock {
  102738. private _samplerName;
  102739. private _linearDefineName;
  102740. private _gammaDefineName;
  102741. private _mainUVName;
  102742. private _tempTextureRead;
  102743. /**
  102744. * Gets or sets the texture associated with the node
  102745. */
  102746. texture: Nullable<BaseTexture>;
  102747. /**
  102748. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102749. */
  102750. convertToGammaSpace: boolean;
  102751. /**
  102752. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102753. */
  102754. convertToLinearSpace: boolean;
  102755. /**
  102756. * Create a new CurrentScreenBlock
  102757. * @param name defines the block name
  102758. */
  102759. constructor(name: string);
  102760. /**
  102761. * Gets the current class name
  102762. * @returns the class name
  102763. */
  102764. getClassName(): string;
  102765. /**
  102766. * Gets the uv input component
  102767. */
  102768. get uv(): NodeMaterialConnectionPoint;
  102769. /**
  102770. * Gets the rgba output component
  102771. */
  102772. get rgba(): NodeMaterialConnectionPoint;
  102773. /**
  102774. * Gets the rgb output component
  102775. */
  102776. get rgb(): NodeMaterialConnectionPoint;
  102777. /**
  102778. * Gets the r output component
  102779. */
  102780. get r(): NodeMaterialConnectionPoint;
  102781. /**
  102782. * Gets the g output component
  102783. */
  102784. get g(): NodeMaterialConnectionPoint;
  102785. /**
  102786. * Gets the b output component
  102787. */
  102788. get b(): NodeMaterialConnectionPoint;
  102789. /**
  102790. * Gets the a output component
  102791. */
  102792. get a(): NodeMaterialConnectionPoint;
  102793. /**
  102794. * Initialize the block and prepare the context for build
  102795. * @param state defines the state that will be used for the build
  102796. */
  102797. initialize(state: NodeMaterialBuildState): void;
  102798. get target(): NodeMaterialBlockTargets;
  102799. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102800. isReady(): boolean;
  102801. private _injectVertexCode;
  102802. private _writeTextureRead;
  102803. private _writeOutput;
  102804. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102805. serialize(): any;
  102806. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102807. }
  102808. }
  102809. declare module BABYLON {
  102810. /**
  102811. * Base block used for the particle texture
  102812. */
  102813. export class ParticleTextureBlock extends NodeMaterialBlock {
  102814. private _samplerName;
  102815. private _linearDefineName;
  102816. private _gammaDefineName;
  102817. private _tempTextureRead;
  102818. /**
  102819. * Gets or sets the texture associated with the node
  102820. */
  102821. texture: Nullable<BaseTexture>;
  102822. /**
  102823. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  102824. */
  102825. convertToGammaSpace: boolean;
  102826. /**
  102827. * Gets or sets a boolean indicating if content needs to be converted to linear space
  102828. */
  102829. convertToLinearSpace: boolean;
  102830. /**
  102831. * Create a new ParticleTextureBlock
  102832. * @param name defines the block name
  102833. */
  102834. constructor(name: string);
  102835. /**
  102836. * Gets the current class name
  102837. * @returns the class name
  102838. */
  102839. getClassName(): string;
  102840. /**
  102841. * Gets the uv input component
  102842. */
  102843. get uv(): NodeMaterialConnectionPoint;
  102844. /**
  102845. * Gets the rgba output component
  102846. */
  102847. get rgba(): NodeMaterialConnectionPoint;
  102848. /**
  102849. * Gets the rgb output component
  102850. */
  102851. get rgb(): NodeMaterialConnectionPoint;
  102852. /**
  102853. * Gets the r output component
  102854. */
  102855. get r(): NodeMaterialConnectionPoint;
  102856. /**
  102857. * Gets the g output component
  102858. */
  102859. get g(): NodeMaterialConnectionPoint;
  102860. /**
  102861. * Gets the b output component
  102862. */
  102863. get b(): NodeMaterialConnectionPoint;
  102864. /**
  102865. * Gets the a output component
  102866. */
  102867. get a(): NodeMaterialConnectionPoint;
  102868. /**
  102869. * Initialize the block and prepare the context for build
  102870. * @param state defines the state that will be used for the build
  102871. */
  102872. initialize(state: NodeMaterialBuildState): void;
  102873. autoConfigure(material: NodeMaterial): void;
  102874. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  102875. isReady(): boolean;
  102876. private _writeOutput;
  102877. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102878. serialize(): any;
  102879. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102880. }
  102881. }
  102882. declare module BABYLON {
  102883. /**
  102884. * Class used to store shared data between 2 NodeMaterialBuildState
  102885. */
  102886. export class NodeMaterialBuildStateSharedData {
  102887. /**
  102888. * Gets the list of emitted varyings
  102889. */
  102890. temps: string[];
  102891. /**
  102892. * Gets the list of emitted varyings
  102893. */
  102894. varyings: string[];
  102895. /**
  102896. * Gets the varying declaration string
  102897. */
  102898. varyingDeclaration: string;
  102899. /**
  102900. * Input blocks
  102901. */
  102902. inputBlocks: InputBlock[];
  102903. /**
  102904. * Input blocks
  102905. */
  102906. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102907. /**
  102908. * Bindable blocks (Blocks that need to set data to the effect)
  102909. */
  102910. bindableBlocks: NodeMaterialBlock[];
  102911. /**
  102912. * List of blocks that can provide a compilation fallback
  102913. */
  102914. blocksWithFallbacks: NodeMaterialBlock[];
  102915. /**
  102916. * List of blocks that can provide a define update
  102917. */
  102918. blocksWithDefines: NodeMaterialBlock[];
  102919. /**
  102920. * List of blocks that can provide a repeatable content
  102921. */
  102922. repeatableContentBlocks: NodeMaterialBlock[];
  102923. /**
  102924. * List of blocks that can provide a dynamic list of uniforms
  102925. */
  102926. dynamicUniformBlocks: NodeMaterialBlock[];
  102927. /**
  102928. * List of blocks that can block the isReady function for the material
  102929. */
  102930. blockingBlocks: NodeMaterialBlock[];
  102931. /**
  102932. * Gets the list of animated inputs
  102933. */
  102934. animatedInputs: InputBlock[];
  102935. /**
  102936. * Build Id used to avoid multiple recompilations
  102937. */
  102938. buildId: number;
  102939. /** List of emitted variables */
  102940. variableNames: {
  102941. [key: string]: number;
  102942. };
  102943. /** List of emitted defines */
  102944. defineNames: {
  102945. [key: string]: number;
  102946. };
  102947. /** Should emit comments? */
  102948. emitComments: boolean;
  102949. /** Emit build activity */
  102950. verbose: boolean;
  102951. /** Gets or sets the hosting scene */
  102952. scene: Scene;
  102953. /**
  102954. * Gets the compilation hints emitted at compilation time
  102955. */
  102956. hints: {
  102957. needWorldViewMatrix: boolean;
  102958. needWorldViewProjectionMatrix: boolean;
  102959. needAlphaBlending: boolean;
  102960. needAlphaTesting: boolean;
  102961. };
  102962. /**
  102963. * List of compilation checks
  102964. */
  102965. checks: {
  102966. emitVertex: boolean;
  102967. emitFragment: boolean;
  102968. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  102969. };
  102970. /**
  102971. * Is vertex program allowed to be empty?
  102972. */
  102973. allowEmptyVertexProgram: boolean;
  102974. /** Creates a new shared data */
  102975. constructor();
  102976. /**
  102977. * Emits console errors and exceptions if there is a failing check
  102978. */
  102979. emitErrors(): void;
  102980. }
  102981. }
  102982. declare module BABYLON {
  102983. /**
  102984. * Class used to store node based material build state
  102985. */
  102986. export class NodeMaterialBuildState {
  102987. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  102988. supportUniformBuffers: boolean;
  102989. /**
  102990. * Gets the list of emitted attributes
  102991. */
  102992. attributes: string[];
  102993. /**
  102994. * Gets the list of emitted uniforms
  102995. */
  102996. uniforms: string[];
  102997. /**
  102998. * Gets the list of emitted constants
  102999. */
  103000. constants: string[];
  103001. /**
  103002. * Gets the list of emitted samplers
  103003. */
  103004. samplers: string[];
  103005. /**
  103006. * Gets the list of emitted functions
  103007. */
  103008. functions: {
  103009. [key: string]: string;
  103010. };
  103011. /**
  103012. * Gets the list of emitted extensions
  103013. */
  103014. extensions: {
  103015. [key: string]: string;
  103016. };
  103017. /**
  103018. * Gets the target of the compilation state
  103019. */
  103020. target: NodeMaterialBlockTargets;
  103021. /**
  103022. * Gets the list of emitted counters
  103023. */
  103024. counters: {
  103025. [key: string]: number;
  103026. };
  103027. /**
  103028. * Shared data between multiple NodeMaterialBuildState instances
  103029. */
  103030. sharedData: NodeMaterialBuildStateSharedData;
  103031. /** @hidden */
  103032. _vertexState: NodeMaterialBuildState;
  103033. /** @hidden */
  103034. _attributeDeclaration: string;
  103035. /** @hidden */
  103036. _uniformDeclaration: string;
  103037. /** @hidden */
  103038. _constantDeclaration: string;
  103039. /** @hidden */
  103040. _samplerDeclaration: string;
  103041. /** @hidden */
  103042. _varyingTransfer: string;
  103043. /** @hidden */
  103044. _injectAtEnd: string;
  103045. private _repeatableContentAnchorIndex;
  103046. /** @hidden */
  103047. _builtCompilationString: string;
  103048. /**
  103049. * Gets the emitted compilation strings
  103050. */
  103051. compilationString: string;
  103052. /**
  103053. * Finalize the compilation strings
  103054. * @param state defines the current compilation state
  103055. */
  103056. finalize(state: NodeMaterialBuildState): void;
  103057. /** @hidden */
  103058. get _repeatableContentAnchor(): string;
  103059. /** @hidden */
  103060. _getFreeVariableName(prefix: string): string;
  103061. /** @hidden */
  103062. _getFreeDefineName(prefix: string): string;
  103063. /** @hidden */
  103064. _excludeVariableName(name: string): void;
  103065. /** @hidden */
  103066. _emit2DSampler(name: string): void;
  103067. /** @hidden */
  103068. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  103069. /** @hidden */
  103070. _emitExtension(name: string, extension: string, define?: string): void;
  103071. /** @hidden */
  103072. _emitFunction(name: string, code: string, comments: string): void;
  103073. /** @hidden */
  103074. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  103075. replaceStrings?: {
  103076. search: RegExp;
  103077. replace: string;
  103078. }[];
  103079. repeatKey?: string;
  103080. }): string;
  103081. /** @hidden */
  103082. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  103083. repeatKey?: string;
  103084. removeAttributes?: boolean;
  103085. removeUniforms?: boolean;
  103086. removeVaryings?: boolean;
  103087. removeIfDef?: boolean;
  103088. replaceStrings?: {
  103089. search: RegExp;
  103090. replace: string;
  103091. }[];
  103092. }, storeKey?: string): void;
  103093. /** @hidden */
  103094. _registerTempVariable(name: string): boolean;
  103095. /** @hidden */
  103096. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  103097. /** @hidden */
  103098. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  103099. /** @hidden */
  103100. _emitFloat(value: number): string;
  103101. }
  103102. }
  103103. declare module BABYLON {
  103104. /**
  103105. * Helper class used to generate session unique ID
  103106. */
  103107. export class UniqueIdGenerator {
  103108. private static _UniqueIdCounter;
  103109. /**
  103110. * Gets an unique (relatively to the current scene) Id
  103111. */
  103112. static get UniqueId(): number;
  103113. }
  103114. }
  103115. declare module BABYLON {
  103116. /**
  103117. * Defines a block that can be used inside a node based material
  103118. */
  103119. export class NodeMaterialBlock {
  103120. private _buildId;
  103121. private _buildTarget;
  103122. private _target;
  103123. private _isFinalMerger;
  103124. private _isInput;
  103125. private _name;
  103126. protected _isUnique: boolean;
  103127. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  103128. inputsAreExclusive: boolean;
  103129. /** @hidden */
  103130. _codeVariableName: string;
  103131. /** @hidden */
  103132. _inputs: NodeMaterialConnectionPoint[];
  103133. /** @hidden */
  103134. _outputs: NodeMaterialConnectionPoint[];
  103135. /** @hidden */
  103136. _preparationId: number;
  103137. /**
  103138. * Gets the name of the block
  103139. */
  103140. get name(): string;
  103141. /**
  103142. * Sets the name of the block. Will check if the name is valid.
  103143. */
  103144. set name(newName: string);
  103145. /**
  103146. * Gets or sets the unique id of the node
  103147. */
  103148. uniqueId: number;
  103149. /**
  103150. * Gets or sets the comments associated with this block
  103151. */
  103152. comments: string;
  103153. /**
  103154. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  103155. */
  103156. get isUnique(): boolean;
  103157. /**
  103158. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  103159. */
  103160. get isFinalMerger(): boolean;
  103161. /**
  103162. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  103163. */
  103164. get isInput(): boolean;
  103165. /**
  103166. * Gets or sets the build Id
  103167. */
  103168. get buildId(): number;
  103169. set buildId(value: number);
  103170. /**
  103171. * Gets or sets the target of the block
  103172. */
  103173. get target(): NodeMaterialBlockTargets;
  103174. set target(value: NodeMaterialBlockTargets);
  103175. /**
  103176. * Gets the list of input points
  103177. */
  103178. get inputs(): NodeMaterialConnectionPoint[];
  103179. /** Gets the list of output points */
  103180. get outputs(): NodeMaterialConnectionPoint[];
  103181. /**
  103182. * Find an input by its name
  103183. * @param name defines the name of the input to look for
  103184. * @returns the input or null if not found
  103185. */
  103186. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  103187. /**
  103188. * Find an output by its name
  103189. * @param name defines the name of the outputto look for
  103190. * @returns the output or null if not found
  103191. */
  103192. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  103193. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  103194. visibleInInspector: boolean;
  103195. /**
  103196. * Creates a new NodeMaterialBlock
  103197. * @param name defines the block name
  103198. * @param target defines the target of that block (Vertex by default)
  103199. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  103200. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  103201. */
  103202. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  103203. /**
  103204. * Initialize the block and prepare the context for build
  103205. * @param state defines the state that will be used for the build
  103206. */
  103207. initialize(state: NodeMaterialBuildState): void;
  103208. /**
  103209. * Bind data to effect. Will only be called for blocks with isBindable === true
  103210. * @param effect defines the effect to bind data to
  103211. * @param nodeMaterial defines the hosting NodeMaterial
  103212. * @param mesh defines the mesh that will be rendered
  103213. * @param subMesh defines the submesh that will be rendered
  103214. */
  103215. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  103216. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  103217. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  103218. protected _writeFloat(value: number): string;
  103219. /**
  103220. * Gets the current class name e.g. "NodeMaterialBlock"
  103221. * @returns the class name
  103222. */
  103223. getClassName(): string;
  103224. /**
  103225. * Register a new input. Must be called inside a block constructor
  103226. * @param name defines the connection point name
  103227. * @param type defines the connection point type
  103228. * @param isOptional defines a boolean indicating that this input can be omitted
  103229. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  103230. * @param point an already created connection point. If not provided, create a new one
  103231. * @returns the current block
  103232. */
  103233. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  103234. /**
  103235. * Register a new output. Must be called inside a block constructor
  103236. * @param name defines the connection point name
  103237. * @param type defines the connection point type
  103238. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  103239. * @param point an already created connection point. If not provided, create a new one
  103240. * @returns the current block
  103241. */
  103242. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  103243. /**
  103244. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  103245. * @param forOutput defines an optional connection point to check compatibility with
  103246. * @returns the first available input or null
  103247. */
  103248. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  103249. /**
  103250. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  103251. * @param forBlock defines an optional block to check compatibility with
  103252. * @returns the first available input or null
  103253. */
  103254. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  103255. /**
  103256. * Gets the sibling of the given output
  103257. * @param current defines the current output
  103258. * @returns the next output in the list or null
  103259. */
  103260. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  103261. /**
  103262. * Connect current block with another block
  103263. * @param other defines the block to connect with
  103264. * @param options define the various options to help pick the right connections
  103265. * @returns the current block
  103266. */
  103267. connectTo(other: NodeMaterialBlock, options?: {
  103268. input?: string;
  103269. output?: string;
  103270. outputSwizzle?: string;
  103271. }): this | undefined;
  103272. protected _buildBlock(state: NodeMaterialBuildState): void;
  103273. /**
  103274. * Add uniforms, samplers and uniform buffers at compilation time
  103275. * @param state defines the state to update
  103276. * @param nodeMaterial defines the node material requesting the update
  103277. * @param defines defines the material defines to update
  103278. * @param uniformBuffers defines the list of uniform buffer names
  103279. */
  103280. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  103281. /**
  103282. * Add potential fallbacks if shader compilation fails
  103283. * @param mesh defines the mesh to be rendered
  103284. * @param fallbacks defines the current prioritized list of fallbacks
  103285. */
  103286. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  103287. /**
  103288. * Initialize defines for shader compilation
  103289. * @param mesh defines the mesh to be rendered
  103290. * @param nodeMaterial defines the node material requesting the update
  103291. * @param defines defines the material defines to update
  103292. * @param useInstances specifies that instances should be used
  103293. */
  103294. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  103295. /**
  103296. * Update defines for shader compilation
  103297. * @param mesh defines the mesh to be rendered
  103298. * @param nodeMaterial defines the node material requesting the update
  103299. * @param defines defines the material defines to update
  103300. * @param useInstances specifies that instances should be used
  103301. * @param subMesh defines which submesh to render
  103302. */
  103303. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  103304. /**
  103305. * Lets the block try to connect some inputs automatically
  103306. * @param material defines the hosting NodeMaterial
  103307. */
  103308. autoConfigure(material: NodeMaterial): void;
  103309. /**
  103310. * Function called when a block is declared as repeatable content generator
  103311. * @param vertexShaderState defines the current compilation state for the vertex shader
  103312. * @param fragmentShaderState defines the current compilation state for the fragment shader
  103313. * @param mesh defines the mesh to be rendered
  103314. * @param defines defines the material defines to update
  103315. */
  103316. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  103317. /**
  103318. * Checks if the block is ready
  103319. * @param mesh defines the mesh to be rendered
  103320. * @param nodeMaterial defines the node material requesting the update
  103321. * @param defines defines the material defines to update
  103322. * @param useInstances specifies that instances should be used
  103323. * @returns true if the block is ready
  103324. */
  103325. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  103326. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  103327. private _processBuild;
  103328. /**
  103329. * Validates the new name for the block node.
  103330. * @param newName the new name to be given to the node.
  103331. * @returns false if the name is a reserve word, else true.
  103332. */
  103333. validateBlockName(newName: string): boolean;
  103334. /**
  103335. * Compile the current node and generate the shader code
  103336. * @param state defines the current compilation state (uniforms, samplers, current string)
  103337. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  103338. * @returns true if already built
  103339. */
  103340. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  103341. protected _inputRename(name: string): string;
  103342. protected _outputRename(name: string): string;
  103343. protected _dumpPropertiesCode(): string;
  103344. /** @hidden */
  103345. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  103346. /** @hidden */
  103347. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  103348. /**
  103349. * Clone the current block to a new identical block
  103350. * @param scene defines the hosting scene
  103351. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103352. * @returns a copy of the current block
  103353. */
  103354. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  103355. /**
  103356. * Serializes this block in a JSON representation
  103357. * @returns the serialized block object
  103358. */
  103359. serialize(): any;
  103360. /** @hidden */
  103361. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103362. private _deserializePortDisplayNamesAndExposedOnFrame;
  103363. /**
  103364. * Release resources
  103365. */
  103366. dispose(): void;
  103367. }
  103368. }
  103369. declare module BABYLON {
  103370. /**
  103371. * Base class of materials working in push mode in babylon JS
  103372. * @hidden
  103373. */
  103374. export class PushMaterial extends Material {
  103375. protected _activeEffect: Effect;
  103376. protected _normalMatrix: Matrix;
  103377. constructor(name: string, scene: Scene);
  103378. getEffect(): Effect;
  103379. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  103380. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  103381. /**
  103382. * Binds the given world matrix to the active effect
  103383. *
  103384. * @param world the matrix to bind
  103385. */
  103386. bindOnlyWorldMatrix(world: Matrix): void;
  103387. /**
  103388. * Binds the given normal matrix to the active effect
  103389. *
  103390. * @param normalMatrix the matrix to bind
  103391. */
  103392. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  103393. bind(world: Matrix, mesh?: Mesh): void;
  103394. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  103395. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  103396. }
  103397. }
  103398. declare module BABYLON {
  103399. /**
  103400. * Root class for all node material optimizers
  103401. */
  103402. export class NodeMaterialOptimizer {
  103403. /**
  103404. * Function used to optimize a NodeMaterial graph
  103405. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  103406. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  103407. */
  103408. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  103409. }
  103410. }
  103411. declare module BABYLON {
  103412. /**
  103413. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  103414. */
  103415. export class TransformBlock extends NodeMaterialBlock {
  103416. /**
  103417. * Defines the value to use to complement W value to transform it to a Vector4
  103418. */
  103419. complementW: number;
  103420. /**
  103421. * Defines the value to use to complement z value to transform it to a Vector4
  103422. */
  103423. complementZ: number;
  103424. /**
  103425. * Creates a new TransformBlock
  103426. * @param name defines the block name
  103427. */
  103428. constructor(name: string);
  103429. /**
  103430. * Gets the current class name
  103431. * @returns the class name
  103432. */
  103433. getClassName(): string;
  103434. /**
  103435. * Gets the vector input
  103436. */
  103437. get vector(): NodeMaterialConnectionPoint;
  103438. /**
  103439. * Gets the output component
  103440. */
  103441. get output(): NodeMaterialConnectionPoint;
  103442. /**
  103443. * Gets the xyz output component
  103444. */
  103445. get xyz(): NodeMaterialConnectionPoint;
  103446. /**
  103447. * Gets the matrix transform input
  103448. */
  103449. get transform(): NodeMaterialConnectionPoint;
  103450. protected _buildBlock(state: NodeMaterialBuildState): this;
  103451. /**
  103452. * Update defines for shader compilation
  103453. * @param mesh defines the mesh to be rendered
  103454. * @param nodeMaterial defines the node material requesting the update
  103455. * @param defines defines the material defines to update
  103456. * @param useInstances specifies that instances should be used
  103457. * @param subMesh defines which submesh to render
  103458. */
  103459. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  103460. serialize(): any;
  103461. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103462. protected _dumpPropertiesCode(): string;
  103463. }
  103464. }
  103465. declare module BABYLON {
  103466. /**
  103467. * Block used to output the vertex position
  103468. */
  103469. export class VertexOutputBlock extends NodeMaterialBlock {
  103470. /**
  103471. * Creates a new VertexOutputBlock
  103472. * @param name defines the block name
  103473. */
  103474. constructor(name: string);
  103475. /**
  103476. * Gets the current class name
  103477. * @returns the class name
  103478. */
  103479. getClassName(): string;
  103480. /**
  103481. * Gets the vector input component
  103482. */
  103483. get vector(): NodeMaterialConnectionPoint;
  103484. protected _buildBlock(state: NodeMaterialBuildState): this;
  103485. }
  103486. }
  103487. declare module BABYLON {
  103488. /**
  103489. * Block used to output the final color
  103490. */
  103491. export class FragmentOutputBlock extends NodeMaterialBlock {
  103492. /**
  103493. * Create a new FragmentOutputBlock
  103494. * @param name defines the block name
  103495. */
  103496. constructor(name: string);
  103497. /**
  103498. * Gets the current class name
  103499. * @returns the class name
  103500. */
  103501. getClassName(): string;
  103502. /**
  103503. * Gets the rgba input component
  103504. */
  103505. get rgba(): NodeMaterialConnectionPoint;
  103506. /**
  103507. * Gets the rgb input component
  103508. */
  103509. get rgb(): NodeMaterialConnectionPoint;
  103510. /**
  103511. * Gets the a input component
  103512. */
  103513. get a(): NodeMaterialConnectionPoint;
  103514. protected _buildBlock(state: NodeMaterialBuildState): this;
  103515. }
  103516. }
  103517. declare module BABYLON {
  103518. /**
  103519. * Block used for the particle ramp gradient section
  103520. */
  103521. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  103522. /**
  103523. * Create a new ParticleRampGradientBlock
  103524. * @param name defines the block name
  103525. */
  103526. constructor(name: string);
  103527. /**
  103528. * Gets the current class name
  103529. * @returns the class name
  103530. */
  103531. getClassName(): string;
  103532. /**
  103533. * Gets the color input component
  103534. */
  103535. get color(): NodeMaterialConnectionPoint;
  103536. /**
  103537. * Gets the rampColor output component
  103538. */
  103539. get rampColor(): NodeMaterialConnectionPoint;
  103540. /**
  103541. * Initialize the block and prepare the context for build
  103542. * @param state defines the state that will be used for the build
  103543. */
  103544. initialize(state: NodeMaterialBuildState): void;
  103545. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103546. }
  103547. }
  103548. declare module BABYLON {
  103549. /**
  103550. * Block used for the particle blend multiply section
  103551. */
  103552. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  103553. /**
  103554. * Create a new ParticleBlendMultiplyBlock
  103555. * @param name defines the block name
  103556. */
  103557. constructor(name: string);
  103558. /**
  103559. * Gets the current class name
  103560. * @returns the class name
  103561. */
  103562. getClassName(): string;
  103563. /**
  103564. * Gets the color input component
  103565. */
  103566. get color(): NodeMaterialConnectionPoint;
  103567. /**
  103568. * Gets the alphaTexture input component
  103569. */
  103570. get alphaTexture(): NodeMaterialConnectionPoint;
  103571. /**
  103572. * Gets the alphaColor input component
  103573. */
  103574. get alphaColor(): NodeMaterialConnectionPoint;
  103575. /**
  103576. * Gets the blendColor output component
  103577. */
  103578. get blendColor(): NodeMaterialConnectionPoint;
  103579. /**
  103580. * Initialize the block and prepare the context for build
  103581. * @param state defines the state that will be used for the build
  103582. */
  103583. initialize(state: NodeMaterialBuildState): void;
  103584. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103585. }
  103586. }
  103587. declare module BABYLON {
  103588. /**
  103589. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  103590. */
  103591. export class VectorMergerBlock extends NodeMaterialBlock {
  103592. /**
  103593. * Create a new VectorMergerBlock
  103594. * @param name defines the block name
  103595. */
  103596. constructor(name: string);
  103597. /**
  103598. * Gets the current class name
  103599. * @returns the class name
  103600. */
  103601. getClassName(): string;
  103602. /**
  103603. * Gets the xyz component (input)
  103604. */
  103605. get xyzIn(): NodeMaterialConnectionPoint;
  103606. /**
  103607. * Gets the xy component (input)
  103608. */
  103609. get xyIn(): NodeMaterialConnectionPoint;
  103610. /**
  103611. * Gets the x component (input)
  103612. */
  103613. get x(): NodeMaterialConnectionPoint;
  103614. /**
  103615. * Gets the y component (input)
  103616. */
  103617. get y(): NodeMaterialConnectionPoint;
  103618. /**
  103619. * Gets the z component (input)
  103620. */
  103621. get z(): NodeMaterialConnectionPoint;
  103622. /**
  103623. * Gets the w component (input)
  103624. */
  103625. get w(): NodeMaterialConnectionPoint;
  103626. /**
  103627. * Gets the xyzw component (output)
  103628. */
  103629. get xyzw(): NodeMaterialConnectionPoint;
  103630. /**
  103631. * Gets the xyz component (output)
  103632. */
  103633. get xyzOut(): NodeMaterialConnectionPoint;
  103634. /**
  103635. * Gets the xy component (output)
  103636. */
  103637. get xyOut(): NodeMaterialConnectionPoint;
  103638. /**
  103639. * Gets the xy component (output)
  103640. * @deprecated Please use xyOut instead.
  103641. */
  103642. get xy(): NodeMaterialConnectionPoint;
  103643. /**
  103644. * Gets the xyz component (output)
  103645. * @deprecated Please use xyzOut instead.
  103646. */
  103647. get xyz(): NodeMaterialConnectionPoint;
  103648. protected _buildBlock(state: NodeMaterialBuildState): this;
  103649. }
  103650. }
  103651. declare module BABYLON {
  103652. /**
  103653. * Block used to remap a float from a range to a new one
  103654. */
  103655. export class RemapBlock extends NodeMaterialBlock {
  103656. /**
  103657. * Gets or sets the source range
  103658. */
  103659. sourceRange: Vector2;
  103660. /**
  103661. * Gets or sets the target range
  103662. */
  103663. targetRange: Vector2;
  103664. /**
  103665. * Creates a new RemapBlock
  103666. * @param name defines the block name
  103667. */
  103668. constructor(name: string);
  103669. /**
  103670. * Gets the current class name
  103671. * @returns the class name
  103672. */
  103673. getClassName(): string;
  103674. /**
  103675. * Gets the input component
  103676. */
  103677. get input(): NodeMaterialConnectionPoint;
  103678. /**
  103679. * Gets the source min input component
  103680. */
  103681. get sourceMin(): NodeMaterialConnectionPoint;
  103682. /**
  103683. * Gets the source max input component
  103684. */
  103685. get sourceMax(): NodeMaterialConnectionPoint;
  103686. /**
  103687. * Gets the target min input component
  103688. */
  103689. get targetMin(): NodeMaterialConnectionPoint;
  103690. /**
  103691. * Gets the target max input component
  103692. */
  103693. get targetMax(): NodeMaterialConnectionPoint;
  103694. /**
  103695. * Gets the output component
  103696. */
  103697. get output(): NodeMaterialConnectionPoint;
  103698. protected _buildBlock(state: NodeMaterialBuildState): this;
  103699. protected _dumpPropertiesCode(): string;
  103700. serialize(): any;
  103701. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103702. }
  103703. }
  103704. declare module BABYLON {
  103705. /**
  103706. * Block used to multiply 2 values
  103707. */
  103708. export class MultiplyBlock extends NodeMaterialBlock {
  103709. /**
  103710. * Creates a new MultiplyBlock
  103711. * @param name defines the block name
  103712. */
  103713. constructor(name: string);
  103714. /**
  103715. * Gets the current class name
  103716. * @returns the class name
  103717. */
  103718. getClassName(): string;
  103719. /**
  103720. * Gets the left operand input component
  103721. */
  103722. get left(): NodeMaterialConnectionPoint;
  103723. /**
  103724. * Gets the right operand input component
  103725. */
  103726. get right(): NodeMaterialConnectionPoint;
  103727. /**
  103728. * Gets the output component
  103729. */
  103730. get output(): NodeMaterialConnectionPoint;
  103731. protected _buildBlock(state: NodeMaterialBuildState): this;
  103732. }
  103733. }
  103734. declare module BABYLON {
  103735. /**
  103736. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  103737. */
  103738. export class ColorSplitterBlock extends NodeMaterialBlock {
  103739. /**
  103740. * Create a new ColorSplitterBlock
  103741. * @param name defines the block name
  103742. */
  103743. constructor(name: string);
  103744. /**
  103745. * Gets the current class name
  103746. * @returns the class name
  103747. */
  103748. getClassName(): string;
  103749. /**
  103750. * Gets the rgba component (input)
  103751. */
  103752. get rgba(): NodeMaterialConnectionPoint;
  103753. /**
  103754. * Gets the rgb component (input)
  103755. */
  103756. get rgbIn(): NodeMaterialConnectionPoint;
  103757. /**
  103758. * Gets the rgb component (output)
  103759. */
  103760. get rgbOut(): NodeMaterialConnectionPoint;
  103761. /**
  103762. * Gets the r component (output)
  103763. */
  103764. get r(): NodeMaterialConnectionPoint;
  103765. /**
  103766. * Gets the g component (output)
  103767. */
  103768. get g(): NodeMaterialConnectionPoint;
  103769. /**
  103770. * Gets the b component (output)
  103771. */
  103772. get b(): NodeMaterialConnectionPoint;
  103773. /**
  103774. * Gets the a component (output)
  103775. */
  103776. get a(): NodeMaterialConnectionPoint;
  103777. protected _inputRename(name: string): string;
  103778. protected _outputRename(name: string): string;
  103779. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  103780. }
  103781. }
  103782. declare module BABYLON {
  103783. /**
  103784. * Operations supported by the Trigonometry block
  103785. */
  103786. export enum TrigonometryBlockOperations {
  103787. /** Cos */
  103788. Cos = 0,
  103789. /** Sin */
  103790. Sin = 1,
  103791. /** Abs */
  103792. Abs = 2,
  103793. /** Exp */
  103794. Exp = 3,
  103795. /** Exp2 */
  103796. Exp2 = 4,
  103797. /** Round */
  103798. Round = 5,
  103799. /** Floor */
  103800. Floor = 6,
  103801. /** Ceiling */
  103802. Ceiling = 7,
  103803. /** Square root */
  103804. Sqrt = 8,
  103805. /** Log */
  103806. Log = 9,
  103807. /** Tangent */
  103808. Tan = 10,
  103809. /** Arc tangent */
  103810. ArcTan = 11,
  103811. /** Arc cosinus */
  103812. ArcCos = 12,
  103813. /** Arc sinus */
  103814. ArcSin = 13,
  103815. /** Fraction */
  103816. Fract = 14,
  103817. /** Sign */
  103818. Sign = 15,
  103819. /** To radians (from degrees) */
  103820. Radians = 16,
  103821. /** To degrees (from radians) */
  103822. Degrees = 17
  103823. }
  103824. /**
  103825. * Block used to apply trigonometry operation to floats
  103826. */
  103827. export class TrigonometryBlock extends NodeMaterialBlock {
  103828. /**
  103829. * Gets or sets the operation applied by the block
  103830. */
  103831. operation: TrigonometryBlockOperations;
  103832. /**
  103833. * Creates a new TrigonometryBlock
  103834. * @param name defines the block name
  103835. */
  103836. constructor(name: string);
  103837. /**
  103838. * Gets the current class name
  103839. * @returns the class name
  103840. */
  103841. getClassName(): string;
  103842. /**
  103843. * Gets the input component
  103844. */
  103845. get input(): NodeMaterialConnectionPoint;
  103846. /**
  103847. * Gets the output component
  103848. */
  103849. get output(): NodeMaterialConnectionPoint;
  103850. protected _buildBlock(state: NodeMaterialBuildState): this;
  103851. serialize(): any;
  103852. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  103853. protected _dumpPropertiesCode(): string;
  103854. }
  103855. }
  103856. declare module BABYLON {
  103857. /**
  103858. * Interface used to configure the node material editor
  103859. */
  103860. export interface INodeMaterialEditorOptions {
  103861. /** Define the URl to load node editor script */
  103862. editorURL?: string;
  103863. }
  103864. /** @hidden */
  103865. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  103866. NORMAL: boolean;
  103867. TANGENT: boolean;
  103868. UV1: boolean;
  103869. /** BONES */
  103870. NUM_BONE_INFLUENCERS: number;
  103871. BonesPerMesh: number;
  103872. BONETEXTURE: boolean;
  103873. /** MORPH TARGETS */
  103874. MORPHTARGETS: boolean;
  103875. MORPHTARGETS_NORMAL: boolean;
  103876. MORPHTARGETS_TANGENT: boolean;
  103877. MORPHTARGETS_UV: boolean;
  103878. NUM_MORPH_INFLUENCERS: number;
  103879. /** IMAGE PROCESSING */
  103880. IMAGEPROCESSING: boolean;
  103881. VIGNETTE: boolean;
  103882. VIGNETTEBLENDMODEMULTIPLY: boolean;
  103883. VIGNETTEBLENDMODEOPAQUE: boolean;
  103884. TONEMAPPING: boolean;
  103885. TONEMAPPING_ACES: boolean;
  103886. CONTRAST: boolean;
  103887. EXPOSURE: boolean;
  103888. COLORCURVES: boolean;
  103889. COLORGRADING: boolean;
  103890. COLORGRADING3D: boolean;
  103891. SAMPLER3DGREENDEPTH: boolean;
  103892. SAMPLER3DBGRMAP: boolean;
  103893. IMAGEPROCESSINGPOSTPROCESS: boolean;
  103894. /** MISC. */
  103895. BUMPDIRECTUV: number;
  103896. constructor();
  103897. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  103898. }
  103899. /**
  103900. * Class used to configure NodeMaterial
  103901. */
  103902. export interface INodeMaterialOptions {
  103903. /**
  103904. * Defines if blocks should emit comments
  103905. */
  103906. emitComments: boolean;
  103907. }
  103908. /**
  103909. * Class used to create a node based material built by assembling shader blocks
  103910. */
  103911. export class NodeMaterial extends PushMaterial {
  103912. private static _BuildIdGenerator;
  103913. private _options;
  103914. private _vertexCompilationState;
  103915. private _fragmentCompilationState;
  103916. private _sharedData;
  103917. private _buildId;
  103918. private _buildWasSuccessful;
  103919. private _cachedWorldViewMatrix;
  103920. private _cachedWorldViewProjectionMatrix;
  103921. private _optimizers;
  103922. private _animationFrame;
  103923. /** Define the Url to load node editor script */
  103924. static EditorURL: string;
  103925. /** Define the Url to load snippets */
  103926. static SnippetUrl: string;
  103927. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  103928. static IgnoreTexturesAtLoadTime: boolean;
  103929. private BJSNODEMATERIALEDITOR;
  103930. /** Get the inspector from bundle or global */
  103931. private _getGlobalNodeMaterialEditor;
  103932. /**
  103933. * Snippet ID if the material was created from the snippet server
  103934. */
  103935. snippetId: string;
  103936. /**
  103937. * Gets or sets data used by visual editor
  103938. * @see https://nme.babylonjs.com
  103939. */
  103940. editorData: any;
  103941. /**
  103942. * 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)
  103943. */
  103944. ignoreAlpha: boolean;
  103945. /**
  103946. * Defines the maximum number of lights that can be used in the material
  103947. */
  103948. maxSimultaneousLights: number;
  103949. /**
  103950. * Observable raised when the material is built
  103951. */
  103952. onBuildObservable: Observable<NodeMaterial>;
  103953. /**
  103954. * Gets or sets the root nodes of the material vertex shader
  103955. */
  103956. _vertexOutputNodes: NodeMaterialBlock[];
  103957. /**
  103958. * Gets or sets the root nodes of the material fragment (pixel) shader
  103959. */
  103960. _fragmentOutputNodes: NodeMaterialBlock[];
  103961. /** Gets or sets options to control the node material overall behavior */
  103962. get options(): INodeMaterialOptions;
  103963. set options(options: INodeMaterialOptions);
  103964. /**
  103965. * Default configuration related to image processing available in the standard Material.
  103966. */
  103967. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103968. /**
  103969. * Gets the image processing configuration used either in this material.
  103970. */
  103971. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103972. /**
  103973. * Sets the Default image processing configuration used either in the this material.
  103974. *
  103975. * If sets to null, the scene one is in use.
  103976. */
  103977. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103978. /**
  103979. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  103980. */
  103981. attachedBlocks: NodeMaterialBlock[];
  103982. /**
  103983. * Specifies the mode of the node material
  103984. * @hidden
  103985. */
  103986. _mode: NodeMaterialModes;
  103987. /**
  103988. * Gets the mode property
  103989. */
  103990. get mode(): NodeMaterialModes;
  103991. /**
  103992. * A free comment about the material
  103993. */
  103994. comment: string;
  103995. /**
  103996. * Create a new node based material
  103997. * @param name defines the material name
  103998. * @param scene defines the hosting scene
  103999. * @param options defines creation option
  104000. */
  104001. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  104002. /**
  104003. * Gets the current class name of the material e.g. "NodeMaterial"
  104004. * @returns the class name
  104005. */
  104006. getClassName(): string;
  104007. /**
  104008. * Keep track of the image processing observer to allow dispose and replace.
  104009. */
  104010. private _imageProcessingObserver;
  104011. /**
  104012. * Attaches a new image processing configuration to the Standard Material.
  104013. * @param configuration
  104014. */
  104015. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104016. /**
  104017. * Get a block by its name
  104018. * @param name defines the name of the block to retrieve
  104019. * @returns the required block or null if not found
  104020. */
  104021. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  104022. /**
  104023. * Get a block by its name
  104024. * @param predicate defines the predicate used to find the good candidate
  104025. * @returns the required block or null if not found
  104026. */
  104027. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  104028. /**
  104029. * Get an input block by its name
  104030. * @param predicate defines the predicate used to find the good candidate
  104031. * @returns the required input block or null if not found
  104032. */
  104033. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  104034. /**
  104035. * Gets the list of input blocks attached to this material
  104036. * @returns an array of InputBlocks
  104037. */
  104038. getInputBlocks(): InputBlock[];
  104039. /**
  104040. * Adds a new optimizer to the list of optimizers
  104041. * @param optimizer defines the optimizers to add
  104042. * @returns the current material
  104043. */
  104044. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  104045. /**
  104046. * Remove an optimizer from the list of optimizers
  104047. * @param optimizer defines the optimizers to remove
  104048. * @returns the current material
  104049. */
  104050. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  104051. /**
  104052. * Add a new block to the list of output nodes
  104053. * @param node defines the node to add
  104054. * @returns the current material
  104055. */
  104056. addOutputNode(node: NodeMaterialBlock): this;
  104057. /**
  104058. * Remove a block from the list of root nodes
  104059. * @param node defines the node to remove
  104060. * @returns the current material
  104061. */
  104062. removeOutputNode(node: NodeMaterialBlock): this;
  104063. private _addVertexOutputNode;
  104064. private _removeVertexOutputNode;
  104065. private _addFragmentOutputNode;
  104066. private _removeFragmentOutputNode;
  104067. /**
  104068. * Specifies if the material will require alpha blending
  104069. * @returns a boolean specifying if alpha blending is needed
  104070. */
  104071. needAlphaBlending(): boolean;
  104072. /**
  104073. * Specifies if this material should be rendered in alpha test mode
  104074. * @returns a boolean specifying if an alpha test is needed.
  104075. */
  104076. needAlphaTesting(): boolean;
  104077. private _initializeBlock;
  104078. private _resetDualBlocks;
  104079. /**
  104080. * Remove a block from the current node material
  104081. * @param block defines the block to remove
  104082. */
  104083. removeBlock(block: NodeMaterialBlock): void;
  104084. /**
  104085. * Build the material and generates the inner effect
  104086. * @param verbose defines if the build should log activity
  104087. */
  104088. build(verbose?: boolean): void;
  104089. /**
  104090. * Runs an otpimization phase to try to improve the shader code
  104091. */
  104092. optimize(): void;
  104093. private _prepareDefinesForAttributes;
  104094. /**
  104095. * Create a post process from the material
  104096. * @param camera The camera to apply the render pass to.
  104097. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104099. * @param engine The engine which the post process will be applied. (default: current engine)
  104100. * @param reusable If the post process can be reused on the same frame. (default: false)
  104101. * @param textureType Type of textures used when performing the post process. (default: 0)
  104102. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  104103. * @returns the post process created
  104104. */
  104105. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  104106. /**
  104107. * Create the post process effect from the material
  104108. * @param postProcess The post process to create the effect for
  104109. */
  104110. createEffectForPostProcess(postProcess: PostProcess): void;
  104111. private _createEffectForPostProcess;
  104112. /**
  104113. * Create a new procedural texture based on this node material
  104114. * @param size defines the size of the texture
  104115. * @param scene defines the hosting scene
  104116. * @returns the new procedural texture attached to this node material
  104117. */
  104118. createProceduralTexture(size: number | {
  104119. width: number;
  104120. height: number;
  104121. layers?: number;
  104122. }, scene: Scene): Nullable<ProceduralTexture>;
  104123. private _createEffectForParticles;
  104124. private _checkInternals;
  104125. /**
  104126. * Create the effect to be used as the custom effect for a particle system
  104127. * @param particleSystem Particle system to create the effect for
  104128. * @param onCompiled defines a function to call when the effect creation is successful
  104129. * @param onError defines a function to call when the effect creation has failed
  104130. */
  104131. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104132. private _processDefines;
  104133. /**
  104134. * Get if the submesh is ready to be used and all its information available.
  104135. * Child classes can use it to update shaders
  104136. * @param mesh defines the mesh to check
  104137. * @param subMesh defines which submesh to check
  104138. * @param useInstances specifies that instances should be used
  104139. * @returns a boolean indicating that the submesh is ready or not
  104140. */
  104141. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104142. /**
  104143. * Get a string representing the shaders built by the current node graph
  104144. */
  104145. get compiledShaders(): string;
  104146. /**
  104147. * Binds the world matrix to the material
  104148. * @param world defines the world transformation matrix
  104149. */
  104150. bindOnlyWorldMatrix(world: Matrix): void;
  104151. /**
  104152. * Binds the submesh to this material by preparing the effect and shader to draw
  104153. * @param world defines the world transformation matrix
  104154. * @param mesh defines the mesh containing the submesh
  104155. * @param subMesh defines the submesh to bind the material to
  104156. */
  104157. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104158. /**
  104159. * Gets the active textures from the material
  104160. * @returns an array of textures
  104161. */
  104162. getActiveTextures(): BaseTexture[];
  104163. /**
  104164. * Gets the list of texture blocks
  104165. * @returns an array of texture blocks
  104166. */
  104167. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  104168. /**
  104169. * Specifies if the material uses a texture
  104170. * @param texture defines the texture to check against the material
  104171. * @returns a boolean specifying if the material uses the texture
  104172. */
  104173. hasTexture(texture: BaseTexture): boolean;
  104174. /**
  104175. * Disposes the material
  104176. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  104177. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  104178. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  104179. */
  104180. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  104181. /** Creates the node editor window. */
  104182. private _createNodeEditor;
  104183. /**
  104184. * Launch the node material editor
  104185. * @param config Define the configuration of the editor
  104186. * @return a promise fulfilled when the node editor is visible
  104187. */
  104188. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  104189. /**
  104190. * Clear the current material
  104191. */
  104192. clear(): void;
  104193. /**
  104194. * Clear the current material and set it to a default state
  104195. */
  104196. setToDefault(): void;
  104197. /**
  104198. * Clear the current material and set it to a default state for post process
  104199. */
  104200. setToDefaultPostProcess(): void;
  104201. /**
  104202. * Clear the current material and set it to a default state for procedural texture
  104203. */
  104204. setToDefaultProceduralTexture(): void;
  104205. /**
  104206. * Clear the current material and set it to a default state for particle
  104207. */
  104208. setToDefaultParticle(): void;
  104209. /**
  104210. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  104211. * @param url defines the url to load from
  104212. * @returns a promise that will fullfil when the material is fully loaded
  104213. */
  104214. loadAsync(url: string): Promise<void>;
  104215. private _gatherBlocks;
  104216. /**
  104217. * Generate a string containing the code declaration required to create an equivalent of this material
  104218. * @returns a string
  104219. */
  104220. generateCode(): string;
  104221. /**
  104222. * Serializes this material in a JSON representation
  104223. * @returns the serialized material object
  104224. */
  104225. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  104226. private _restoreConnections;
  104227. /**
  104228. * Clear the current graph and load a new one from a serialization object
  104229. * @param source defines the JSON representation of the material
  104230. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104231. * @param merge defines whether or not the source must be merged or replace the current content
  104232. */
  104233. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  104234. /**
  104235. * Makes a duplicate of the current material.
  104236. * @param name - name to use for the new material.
  104237. */
  104238. clone(name: string): NodeMaterial;
  104239. /**
  104240. * Creates a node material from parsed material data
  104241. * @param source defines the JSON representation of the material
  104242. * @param scene defines the hosting scene
  104243. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104244. * @returns a new node material
  104245. */
  104246. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  104247. /**
  104248. * Creates a node material from a snippet saved in a remote file
  104249. * @param name defines the name of the material to create
  104250. * @param url defines the url to load from
  104251. * @param scene defines the hosting scene
  104252. * @returns a promise that will resolve to the new node material
  104253. */
  104254. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  104255. /**
  104256. * Creates a node material from a snippet saved by the node material editor
  104257. * @param snippetId defines the snippet to load
  104258. * @param scene defines the hosting scene
  104259. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  104260. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  104261. * @returns a promise that will resolve to the new node material
  104262. */
  104263. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  104264. /**
  104265. * Creates a new node material set to default basic configuration
  104266. * @param name defines the name of the material
  104267. * @param scene defines the hosting scene
  104268. * @returns a new NodeMaterial
  104269. */
  104270. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  104271. }
  104272. }
  104273. declare module BABYLON {
  104274. interface ThinEngine {
  104275. /**
  104276. * Unbind a list of render target textures from the webGL context
  104277. * This is used only when drawBuffer extension or webGL2 are active
  104278. * @param textures defines the render target textures to unbind
  104279. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104280. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104281. */
  104282. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104283. /**
  104284. * Create a multi render target texture
  104285. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  104286. * @param size defines the size of the texture
  104287. * @param options defines the creation options
  104288. * @returns the cube texture as an InternalTexture
  104289. */
  104290. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104291. /**
  104292. * Update the sample count for a given multiple render target texture
  104293. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104294. * @param textures defines the textures to update
  104295. * @param samples defines the sample count to set
  104296. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104297. */
  104298. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104299. /**
  104300. * Select a subsets of attachments to draw to.
  104301. * @param attachments gl attachments
  104302. */
  104303. bindAttachments(attachments: number[]): void;
  104304. /**
  104305. * Creates a layout object to draw/clear on specific textures in a MRT
  104306. * @param textureStatus textureStatus[i] indicates if the i-th is active
  104307. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  104308. */
  104309. buildTextureLayout(textureStatus: boolean[]): number[];
  104310. /**
  104311. * Restores the webgl state to only draw on the main color attachment
  104312. */
  104313. restoreSingleAttachment(): void;
  104314. }
  104315. }
  104316. declare module BABYLON {
  104317. /**
  104318. * Creation options of the multi render target texture.
  104319. */
  104320. export interface IMultiRenderTargetOptions {
  104321. /**
  104322. * Define if the texture needs to create mip maps after render.
  104323. */
  104324. generateMipMaps?: boolean;
  104325. /**
  104326. * Define the types of all the draw buffers we want to create
  104327. */
  104328. types?: number[];
  104329. /**
  104330. * Define the sampling modes of all the draw buffers we want to create
  104331. */
  104332. samplingModes?: number[];
  104333. /**
  104334. * Define if a depth buffer is required
  104335. */
  104336. generateDepthBuffer?: boolean;
  104337. /**
  104338. * Define if a stencil buffer is required
  104339. */
  104340. generateStencilBuffer?: boolean;
  104341. /**
  104342. * Define if a depth texture is required instead of a depth buffer
  104343. */
  104344. generateDepthTexture?: boolean;
  104345. /**
  104346. * Define the number of desired draw buffers
  104347. */
  104348. textureCount?: number;
  104349. /**
  104350. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104351. */
  104352. doNotChangeAspectRatio?: boolean;
  104353. /**
  104354. * Define the default type of the buffers we are creating
  104355. */
  104356. defaultType?: number;
  104357. }
  104358. /**
  104359. * A multi render target, like a render target provides the ability to render to a texture.
  104360. * Unlike the render target, it can render to several draw buffers in one draw.
  104361. * This is specially interesting in deferred rendering or for any effects requiring more than
  104362. * just one color from a single pass.
  104363. */
  104364. export class MultiRenderTarget extends RenderTargetTexture {
  104365. private _internalTextures;
  104366. private _textures;
  104367. private _multiRenderTargetOptions;
  104368. private _count;
  104369. /**
  104370. * Get if draw buffers are currently supported by the used hardware and browser.
  104371. */
  104372. get isSupported(): boolean;
  104373. /**
  104374. * Get the list of textures generated by the multi render target.
  104375. */
  104376. get textures(): Texture[];
  104377. /**
  104378. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  104379. */
  104380. get count(): number;
  104381. /**
  104382. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104383. */
  104384. get depthTexture(): Texture;
  104385. /**
  104386. * Set the wrapping mode on U of all the textures we are rendering to.
  104387. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104388. */
  104389. set wrapU(wrap: number);
  104390. /**
  104391. * Set the wrapping mode on V of all the textures we are rendering to.
  104392. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104393. */
  104394. set wrapV(wrap: number);
  104395. /**
  104396. * Instantiate a new multi render target texture.
  104397. * A multi render target, like a render target provides the ability to render to a texture.
  104398. * Unlike the render target, it can render to several draw buffers in one draw.
  104399. * This is specially interesting in deferred rendering or for any effects requiring more than
  104400. * just one color from a single pass.
  104401. * @param name Define the name of the texture
  104402. * @param size Define the size of the buffers to render to
  104403. * @param count Define the number of target we are rendering into
  104404. * @param scene Define the scene the texture belongs to
  104405. * @param options Define the options used to create the multi render target
  104406. */
  104407. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104408. private _initTypes;
  104409. /** @hidden */
  104410. _rebuild(forceFullRebuild?: boolean): void;
  104411. private _createInternalTextures;
  104412. private _createTextures;
  104413. /**
  104414. * Replaces a texture within the MRT.
  104415. * @param texture The new texture to insert in the MRT
  104416. * @param index The index of the texture to replace
  104417. */
  104418. replaceTexture(texture: Texture, index: number): void;
  104419. /**
  104420. * Define the number of samples used if MSAA is enabled.
  104421. */
  104422. get samples(): number;
  104423. set samples(value: number);
  104424. /**
  104425. * Resize all the textures in the multi render target.
  104426. * Be careful as it will recreate all the data in the new texture.
  104427. * @param size Define the new size
  104428. */
  104429. resize(size: any): void;
  104430. /**
  104431. * Changes the number of render targets in this MRT
  104432. * Be careful as it will recreate all the data in the new texture.
  104433. * @param count new texture count
  104434. * @param options Specifies texture types and sampling modes for new textures
  104435. */
  104436. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  104437. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104438. /**
  104439. * Dispose the render targets and their associated resources
  104440. */
  104441. dispose(): void;
  104442. /**
  104443. * Release all the underlying texture used as draw buffers.
  104444. */
  104445. releaseInternalTextures(): void;
  104446. }
  104447. }
  104448. declare module BABYLON {
  104449. /** @hidden */
  104450. export var imageProcessingPixelShader: {
  104451. name: string;
  104452. shader: string;
  104453. };
  104454. }
  104455. declare module BABYLON {
  104456. /**
  104457. * ImageProcessingPostProcess
  104458. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104459. */
  104460. export class ImageProcessingPostProcess extends PostProcess {
  104461. /**
  104462. * Default configuration related to image processing available in the PBR Material.
  104463. */
  104464. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104465. /**
  104466. * Gets the image processing configuration used either in this material.
  104467. */
  104468. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104469. /**
  104470. * Sets the Default image processing configuration used either in the this material.
  104471. *
  104472. * If sets to null, the scene one is in use.
  104473. */
  104474. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104475. /**
  104476. * Keep track of the image processing observer to allow dispose and replace.
  104477. */
  104478. private _imageProcessingObserver;
  104479. /**
  104480. * Attaches a new image processing configuration to the PBR Material.
  104481. * @param configuration
  104482. */
  104483. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104484. /**
  104485. * If the post process is supported.
  104486. */
  104487. get isSupported(): boolean;
  104488. /**
  104489. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104490. */
  104491. get colorCurves(): Nullable<ColorCurves>;
  104492. /**
  104493. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104494. */
  104495. set colorCurves(value: Nullable<ColorCurves>);
  104496. /**
  104497. * Gets wether the color curves effect is enabled.
  104498. */
  104499. get colorCurvesEnabled(): boolean;
  104500. /**
  104501. * Sets wether the color curves effect is enabled.
  104502. */
  104503. set colorCurvesEnabled(value: boolean);
  104504. /**
  104505. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104506. */
  104507. get colorGradingTexture(): Nullable<BaseTexture>;
  104508. /**
  104509. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104510. */
  104511. set colorGradingTexture(value: Nullable<BaseTexture>);
  104512. /**
  104513. * Gets wether the color grading effect is enabled.
  104514. */
  104515. get colorGradingEnabled(): boolean;
  104516. /**
  104517. * Gets wether the color grading effect is enabled.
  104518. */
  104519. set colorGradingEnabled(value: boolean);
  104520. /**
  104521. * Gets exposure used in the effect.
  104522. */
  104523. get exposure(): number;
  104524. /**
  104525. * Sets exposure used in the effect.
  104526. */
  104527. set exposure(value: number);
  104528. /**
  104529. * Gets wether tonemapping is enabled or not.
  104530. */
  104531. get toneMappingEnabled(): boolean;
  104532. /**
  104533. * Sets wether tonemapping is enabled or not
  104534. */
  104535. set toneMappingEnabled(value: boolean);
  104536. /**
  104537. * Gets the type of tone mapping effect.
  104538. */
  104539. get toneMappingType(): number;
  104540. /**
  104541. * Sets the type of tone mapping effect.
  104542. */
  104543. set toneMappingType(value: number);
  104544. /**
  104545. * Gets contrast used in the effect.
  104546. */
  104547. get contrast(): number;
  104548. /**
  104549. * Sets contrast used in the effect.
  104550. */
  104551. set contrast(value: number);
  104552. /**
  104553. * Gets Vignette stretch size.
  104554. */
  104555. get vignetteStretch(): number;
  104556. /**
  104557. * Sets Vignette stretch size.
  104558. */
  104559. set vignetteStretch(value: number);
  104560. /**
  104561. * Gets Vignette centre X Offset.
  104562. */
  104563. get vignetteCentreX(): number;
  104564. /**
  104565. * Sets Vignette centre X Offset.
  104566. */
  104567. set vignetteCentreX(value: number);
  104568. /**
  104569. * Gets Vignette centre Y Offset.
  104570. */
  104571. get vignetteCentreY(): number;
  104572. /**
  104573. * Sets Vignette centre Y Offset.
  104574. */
  104575. set vignetteCentreY(value: number);
  104576. /**
  104577. * Gets Vignette weight or intensity of the vignette effect.
  104578. */
  104579. get vignetteWeight(): number;
  104580. /**
  104581. * Sets Vignette weight or intensity of the vignette effect.
  104582. */
  104583. set vignetteWeight(value: number);
  104584. /**
  104585. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104586. * if vignetteEnabled is set to true.
  104587. */
  104588. get vignetteColor(): Color4;
  104589. /**
  104590. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104591. * if vignetteEnabled is set to true.
  104592. */
  104593. set vignetteColor(value: Color4);
  104594. /**
  104595. * Gets Camera field of view used by the Vignette effect.
  104596. */
  104597. get vignetteCameraFov(): number;
  104598. /**
  104599. * Sets Camera field of view used by the Vignette effect.
  104600. */
  104601. set vignetteCameraFov(value: number);
  104602. /**
  104603. * Gets the vignette blend mode allowing different kind of effect.
  104604. */
  104605. get vignetteBlendMode(): number;
  104606. /**
  104607. * Sets the vignette blend mode allowing different kind of effect.
  104608. */
  104609. set vignetteBlendMode(value: number);
  104610. /**
  104611. * Gets wether the vignette effect is enabled.
  104612. */
  104613. get vignetteEnabled(): boolean;
  104614. /**
  104615. * Sets wether the vignette effect is enabled.
  104616. */
  104617. set vignetteEnabled(value: boolean);
  104618. private _fromLinearSpace;
  104619. /**
  104620. * Gets wether the input of the processing is in Gamma or Linear Space.
  104621. */
  104622. get fromLinearSpace(): boolean;
  104623. /**
  104624. * Sets wether the input of the processing is in Gamma or Linear Space.
  104625. */
  104626. set fromLinearSpace(value: boolean);
  104627. /**
  104628. * Defines cache preventing GC.
  104629. */
  104630. private _defines;
  104631. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104632. /**
  104633. * "ImageProcessingPostProcess"
  104634. * @returns "ImageProcessingPostProcess"
  104635. */
  104636. getClassName(): string;
  104637. /**
  104638. * @hidden
  104639. */
  104640. _updateParameters(): void;
  104641. dispose(camera?: Camera): void;
  104642. }
  104643. }
  104644. declare module BABYLON {
  104645. /**
  104646. * Interface for defining prepass effects in the prepass post-process pipeline
  104647. */
  104648. export interface PrePassEffectConfiguration {
  104649. /**
  104650. * Name of the effect
  104651. */
  104652. name: string;
  104653. /**
  104654. * Post process to attach for this effect
  104655. */
  104656. postProcess?: PostProcess;
  104657. /**
  104658. * Textures required in the MRT
  104659. */
  104660. texturesRequired: number[];
  104661. /**
  104662. * Is the effect enabled
  104663. */
  104664. enabled: boolean;
  104665. /**
  104666. * Disposes the effect configuration
  104667. */
  104668. dispose?: () => void;
  104669. /**
  104670. * Creates the associated post process
  104671. */
  104672. createPostProcess?: () => PostProcess;
  104673. }
  104674. }
  104675. declare module BABYLON {
  104676. /**
  104677. * Options to be used when creating a FresnelParameters.
  104678. */
  104679. export type IFresnelParametersCreationOptions = {
  104680. /**
  104681. * Define the color used on edges (grazing angle)
  104682. */
  104683. leftColor?: Color3;
  104684. /**
  104685. * Define the color used on center
  104686. */
  104687. rightColor?: Color3;
  104688. /**
  104689. * Define bias applied to computed fresnel term
  104690. */
  104691. bias?: number;
  104692. /**
  104693. * Defined the power exponent applied to fresnel term
  104694. */
  104695. power?: number;
  104696. /**
  104697. * Define if the fresnel effect is enable or not.
  104698. */
  104699. isEnabled?: boolean;
  104700. };
  104701. /**
  104702. * Serialized format for FresnelParameters.
  104703. */
  104704. export type IFresnelParametersSerialized = {
  104705. /**
  104706. * Define the color used on edges (grazing angle) [as an array]
  104707. */
  104708. leftColor: number[];
  104709. /**
  104710. * Define the color used on center [as an array]
  104711. */
  104712. rightColor: number[];
  104713. /**
  104714. * Define bias applied to computed fresnel term
  104715. */
  104716. bias: number;
  104717. /**
  104718. * Defined the power exponent applied to fresnel term
  104719. */
  104720. power?: number;
  104721. /**
  104722. * Define if the fresnel effect is enable or not.
  104723. */
  104724. isEnabled: boolean;
  104725. };
  104726. /**
  104727. * This represents all the required information to add a fresnel effect on a material:
  104728. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  104729. */
  104730. export class FresnelParameters {
  104731. private _isEnabled;
  104732. /**
  104733. * Define if the fresnel effect is enable or not.
  104734. */
  104735. get isEnabled(): boolean;
  104736. set isEnabled(value: boolean);
  104737. /**
  104738. * Define the color used on edges (grazing angle)
  104739. */
  104740. leftColor: Color3;
  104741. /**
  104742. * Define the color used on center
  104743. */
  104744. rightColor: Color3;
  104745. /**
  104746. * Define bias applied to computed fresnel term
  104747. */
  104748. bias: number;
  104749. /**
  104750. * Defined the power exponent applied to fresnel term
  104751. */
  104752. power: number;
  104753. /**
  104754. * Creates a new FresnelParameters object.
  104755. *
  104756. * @param options provide your own settings to optionally to override defaults
  104757. */
  104758. constructor(options?: IFresnelParametersCreationOptions);
  104759. /**
  104760. * Clones the current fresnel and its valuues
  104761. * @returns a clone fresnel configuration
  104762. */
  104763. clone(): FresnelParameters;
  104764. /**
  104765. * Determines equality between FresnelParameters objects
  104766. * @param otherFresnelParameters defines the second operand
  104767. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  104768. */
  104769. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  104770. /**
  104771. * Serializes the current fresnel parameters to a JSON representation.
  104772. * @return the JSON serialization
  104773. */
  104774. serialize(): IFresnelParametersSerialized;
  104775. /**
  104776. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  104777. * @param parsedFresnelParameters Define the JSON representation
  104778. * @returns the parsed parameters
  104779. */
  104780. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  104781. }
  104782. }
  104783. declare module BABYLON {
  104784. /**
  104785. * This groups all the flags used to control the materials channel.
  104786. */
  104787. export class MaterialFlags {
  104788. private static _DiffuseTextureEnabled;
  104789. /**
  104790. * Are diffuse textures enabled in the application.
  104791. */
  104792. static get DiffuseTextureEnabled(): boolean;
  104793. static set DiffuseTextureEnabled(value: boolean);
  104794. private static _DetailTextureEnabled;
  104795. /**
  104796. * Are detail textures enabled in the application.
  104797. */
  104798. static get DetailTextureEnabled(): boolean;
  104799. static set DetailTextureEnabled(value: boolean);
  104800. private static _AmbientTextureEnabled;
  104801. /**
  104802. * Are ambient textures enabled in the application.
  104803. */
  104804. static get AmbientTextureEnabled(): boolean;
  104805. static set AmbientTextureEnabled(value: boolean);
  104806. private static _OpacityTextureEnabled;
  104807. /**
  104808. * Are opacity textures enabled in the application.
  104809. */
  104810. static get OpacityTextureEnabled(): boolean;
  104811. static set OpacityTextureEnabled(value: boolean);
  104812. private static _ReflectionTextureEnabled;
  104813. /**
  104814. * Are reflection textures enabled in the application.
  104815. */
  104816. static get ReflectionTextureEnabled(): boolean;
  104817. static set ReflectionTextureEnabled(value: boolean);
  104818. private static _EmissiveTextureEnabled;
  104819. /**
  104820. * Are emissive textures enabled in the application.
  104821. */
  104822. static get EmissiveTextureEnabled(): boolean;
  104823. static set EmissiveTextureEnabled(value: boolean);
  104824. private static _SpecularTextureEnabled;
  104825. /**
  104826. * Are specular textures enabled in the application.
  104827. */
  104828. static get SpecularTextureEnabled(): boolean;
  104829. static set SpecularTextureEnabled(value: boolean);
  104830. private static _BumpTextureEnabled;
  104831. /**
  104832. * Are bump textures enabled in the application.
  104833. */
  104834. static get BumpTextureEnabled(): boolean;
  104835. static set BumpTextureEnabled(value: boolean);
  104836. private static _LightmapTextureEnabled;
  104837. /**
  104838. * Are lightmap textures enabled in the application.
  104839. */
  104840. static get LightmapTextureEnabled(): boolean;
  104841. static set LightmapTextureEnabled(value: boolean);
  104842. private static _RefractionTextureEnabled;
  104843. /**
  104844. * Are refraction textures enabled in the application.
  104845. */
  104846. static get RefractionTextureEnabled(): boolean;
  104847. static set RefractionTextureEnabled(value: boolean);
  104848. private static _ColorGradingTextureEnabled;
  104849. /**
  104850. * Are color grading textures enabled in the application.
  104851. */
  104852. static get ColorGradingTextureEnabled(): boolean;
  104853. static set ColorGradingTextureEnabled(value: boolean);
  104854. private static _FresnelEnabled;
  104855. /**
  104856. * Are fresnels enabled in the application.
  104857. */
  104858. static get FresnelEnabled(): boolean;
  104859. static set FresnelEnabled(value: boolean);
  104860. private static _ClearCoatTextureEnabled;
  104861. /**
  104862. * Are clear coat textures enabled in the application.
  104863. */
  104864. static get ClearCoatTextureEnabled(): boolean;
  104865. static set ClearCoatTextureEnabled(value: boolean);
  104866. private static _ClearCoatBumpTextureEnabled;
  104867. /**
  104868. * Are clear coat bump textures enabled in the application.
  104869. */
  104870. static get ClearCoatBumpTextureEnabled(): boolean;
  104871. static set ClearCoatBumpTextureEnabled(value: boolean);
  104872. private static _ClearCoatTintTextureEnabled;
  104873. /**
  104874. * Are clear coat tint textures enabled in the application.
  104875. */
  104876. static get ClearCoatTintTextureEnabled(): boolean;
  104877. static set ClearCoatTintTextureEnabled(value: boolean);
  104878. private static _SheenTextureEnabled;
  104879. /**
  104880. * Are sheen textures enabled in the application.
  104881. */
  104882. static get SheenTextureEnabled(): boolean;
  104883. static set SheenTextureEnabled(value: boolean);
  104884. private static _AnisotropicTextureEnabled;
  104885. /**
  104886. * Are anisotropic textures enabled in the application.
  104887. */
  104888. static get AnisotropicTextureEnabled(): boolean;
  104889. static set AnisotropicTextureEnabled(value: boolean);
  104890. private static _ThicknessTextureEnabled;
  104891. /**
  104892. * Are thickness textures enabled in the application.
  104893. */
  104894. static get ThicknessTextureEnabled(): boolean;
  104895. static set ThicknessTextureEnabled(value: boolean);
  104896. }
  104897. }
  104898. declare module BABYLON {
  104899. /** @hidden */
  104900. export var defaultFragmentDeclaration: {
  104901. name: string;
  104902. shader: string;
  104903. };
  104904. }
  104905. declare module BABYLON {
  104906. /** @hidden */
  104907. export var defaultUboDeclaration: {
  104908. name: string;
  104909. shader: string;
  104910. };
  104911. }
  104912. declare module BABYLON {
  104913. /** @hidden */
  104914. export var prePassDeclaration: {
  104915. name: string;
  104916. shader: string;
  104917. };
  104918. }
  104919. declare module BABYLON {
  104920. /** @hidden */
  104921. export var lightFragmentDeclaration: {
  104922. name: string;
  104923. shader: string;
  104924. };
  104925. }
  104926. declare module BABYLON {
  104927. /** @hidden */
  104928. export var lightUboDeclaration: {
  104929. name: string;
  104930. shader: string;
  104931. };
  104932. }
  104933. declare module BABYLON {
  104934. /** @hidden */
  104935. export var lightsFragmentFunctions: {
  104936. name: string;
  104937. shader: string;
  104938. };
  104939. }
  104940. declare module BABYLON {
  104941. /** @hidden */
  104942. export var shadowsFragmentFunctions: {
  104943. name: string;
  104944. shader: string;
  104945. };
  104946. }
  104947. declare module BABYLON {
  104948. /** @hidden */
  104949. export var fresnelFunction: {
  104950. name: string;
  104951. shader: string;
  104952. };
  104953. }
  104954. declare module BABYLON {
  104955. /** @hidden */
  104956. export var bumpFragmentMainFunctions: {
  104957. name: string;
  104958. shader: string;
  104959. };
  104960. }
  104961. declare module BABYLON {
  104962. /** @hidden */
  104963. export var bumpFragmentFunctions: {
  104964. name: string;
  104965. shader: string;
  104966. };
  104967. }
  104968. declare module BABYLON {
  104969. /** @hidden */
  104970. export var logDepthDeclaration: {
  104971. name: string;
  104972. shader: string;
  104973. };
  104974. }
  104975. declare module BABYLON {
  104976. /** @hidden */
  104977. export var bumpFragment: {
  104978. name: string;
  104979. shader: string;
  104980. };
  104981. }
  104982. declare module BABYLON {
  104983. /** @hidden */
  104984. export var depthPrePass: {
  104985. name: string;
  104986. shader: string;
  104987. };
  104988. }
  104989. declare module BABYLON {
  104990. /** @hidden */
  104991. export var lightFragment: {
  104992. name: string;
  104993. shader: string;
  104994. };
  104995. }
  104996. declare module BABYLON {
  104997. /** @hidden */
  104998. export var logDepthFragment: {
  104999. name: string;
  105000. shader: string;
  105001. };
  105002. }
  105003. declare module BABYLON {
  105004. /** @hidden */
  105005. export var defaultPixelShader: {
  105006. name: string;
  105007. shader: string;
  105008. };
  105009. }
  105010. declare module BABYLON {
  105011. /** @hidden */
  105012. export var defaultVertexDeclaration: {
  105013. name: string;
  105014. shader: string;
  105015. };
  105016. }
  105017. declare module BABYLON {
  105018. /** @hidden */
  105019. export var prePassVertexDeclaration: {
  105020. name: string;
  105021. shader: string;
  105022. };
  105023. }
  105024. declare module BABYLON {
  105025. /** @hidden */
  105026. export var bumpVertexDeclaration: {
  105027. name: string;
  105028. shader: string;
  105029. };
  105030. }
  105031. declare module BABYLON {
  105032. /** @hidden */
  105033. export var prePassVertex: {
  105034. name: string;
  105035. shader: string;
  105036. };
  105037. }
  105038. declare module BABYLON {
  105039. /** @hidden */
  105040. export var bumpVertex: {
  105041. name: string;
  105042. shader: string;
  105043. };
  105044. }
  105045. declare module BABYLON {
  105046. /** @hidden */
  105047. export var fogVertex: {
  105048. name: string;
  105049. shader: string;
  105050. };
  105051. }
  105052. declare module BABYLON {
  105053. /** @hidden */
  105054. export var shadowsVertex: {
  105055. name: string;
  105056. shader: string;
  105057. };
  105058. }
  105059. declare module BABYLON {
  105060. /** @hidden */
  105061. export var pointCloudVertex: {
  105062. name: string;
  105063. shader: string;
  105064. };
  105065. }
  105066. declare module BABYLON {
  105067. /** @hidden */
  105068. export var logDepthVertex: {
  105069. name: string;
  105070. shader: string;
  105071. };
  105072. }
  105073. declare module BABYLON {
  105074. /** @hidden */
  105075. export var defaultVertexShader: {
  105076. name: string;
  105077. shader: string;
  105078. };
  105079. }
  105080. declare module BABYLON {
  105081. /**
  105082. * @hidden
  105083. */
  105084. export interface IMaterialDetailMapDefines {
  105085. DETAIL: boolean;
  105086. DETAILDIRECTUV: number;
  105087. DETAIL_NORMALBLENDMETHOD: number;
  105088. /** @hidden */
  105089. _areTexturesDirty: boolean;
  105090. }
  105091. /**
  105092. * Define the code related to the detail map parameters of a material
  105093. *
  105094. * Inspired from:
  105095. * 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
  105096. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  105097. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  105098. */
  105099. export class DetailMapConfiguration {
  105100. private _texture;
  105101. /**
  105102. * The detail texture of the material.
  105103. */
  105104. texture: Nullable<BaseTexture>;
  105105. /**
  105106. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  105107. * Bigger values mean stronger blending
  105108. */
  105109. diffuseBlendLevel: number;
  105110. /**
  105111. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  105112. * Bigger values mean stronger blending. Only used with PBR materials
  105113. */
  105114. roughnessBlendLevel: number;
  105115. /**
  105116. * Defines how strong the bump effect from the detail map is
  105117. * Bigger values mean stronger effect
  105118. */
  105119. bumpLevel: number;
  105120. private _normalBlendMethod;
  105121. /**
  105122. * The method used to blend the bump and detail normals together
  105123. */
  105124. normalBlendMethod: number;
  105125. private _isEnabled;
  105126. /**
  105127. * Enable or disable the detail map on this material
  105128. */
  105129. isEnabled: boolean;
  105130. /** @hidden */
  105131. private _internalMarkAllSubMeshesAsTexturesDirty;
  105132. /** @hidden */
  105133. _markAllSubMeshesAsTexturesDirty(): void;
  105134. /**
  105135. * Instantiate a new detail map
  105136. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  105137. */
  105138. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  105139. /**
  105140. * Gets whether the submesh is ready to be used or not.
  105141. * @param defines the list of "defines" to update.
  105142. * @param scene defines the scene the material belongs to.
  105143. * @returns - boolean indicating that the submesh is ready or not.
  105144. */
  105145. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  105146. /**
  105147. * Update the defines for detail map usage
  105148. * @param defines the list of "defines" to update.
  105149. * @param scene defines the scene the material belongs to.
  105150. */
  105151. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  105152. /**
  105153. * Binds the material data.
  105154. * @param uniformBuffer defines the Uniform buffer to fill in.
  105155. * @param scene defines the scene the material belongs to.
  105156. * @param isFrozen defines whether the material is frozen or not.
  105157. */
  105158. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  105159. /**
  105160. * Checks to see if a texture is used in the material.
  105161. * @param texture - Base texture to use.
  105162. * @returns - Boolean specifying if a texture is used in the material.
  105163. */
  105164. hasTexture(texture: BaseTexture): boolean;
  105165. /**
  105166. * Returns an array of the actively used textures.
  105167. * @param activeTextures Array of BaseTextures
  105168. */
  105169. getActiveTextures(activeTextures: BaseTexture[]): void;
  105170. /**
  105171. * Returns the animatable textures.
  105172. * @param animatables Array of animatable textures.
  105173. */
  105174. getAnimatables(animatables: IAnimatable[]): void;
  105175. /**
  105176. * Disposes the resources of the material.
  105177. * @param forceDisposeTextures - Forces the disposal of all textures.
  105178. */
  105179. dispose(forceDisposeTextures?: boolean): void;
  105180. /**
  105181. * Get the current class name useful for serialization or dynamic coding.
  105182. * @returns "DetailMap"
  105183. */
  105184. getClassName(): string;
  105185. /**
  105186. * Add the required uniforms to the current list.
  105187. * @param uniforms defines the current uniform list.
  105188. */
  105189. static AddUniforms(uniforms: string[]): void;
  105190. /**
  105191. * Add the required samplers to the current list.
  105192. * @param samplers defines the current sampler list.
  105193. */
  105194. static AddSamplers(samplers: string[]): void;
  105195. /**
  105196. * Add the required uniforms to the current buffer.
  105197. * @param uniformBuffer defines the current uniform buffer.
  105198. */
  105199. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  105200. /**
  105201. * Makes a duplicate of the current instance into another one.
  105202. * @param detailMap define the instance where to copy the info
  105203. */
  105204. copyTo(detailMap: DetailMapConfiguration): void;
  105205. /**
  105206. * Serializes this detail map instance
  105207. * @returns - An object with the serialized instance.
  105208. */
  105209. serialize(): any;
  105210. /**
  105211. * Parses a detail map setting from a serialized object.
  105212. * @param source - Serialized object.
  105213. * @param scene Defines the scene we are parsing for
  105214. * @param rootUrl Defines the rootUrl to load from
  105215. */
  105216. parse(source: any, scene: Scene, rootUrl: string): void;
  105217. }
  105218. }
  105219. declare module BABYLON {
  105220. /** @hidden */
  105221. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  105222. MAINUV1: boolean;
  105223. MAINUV2: boolean;
  105224. DIFFUSE: boolean;
  105225. DIFFUSEDIRECTUV: number;
  105226. DETAIL: boolean;
  105227. DETAILDIRECTUV: number;
  105228. DETAIL_NORMALBLENDMETHOD: number;
  105229. AMBIENT: boolean;
  105230. AMBIENTDIRECTUV: number;
  105231. OPACITY: boolean;
  105232. OPACITYDIRECTUV: number;
  105233. OPACITYRGB: boolean;
  105234. REFLECTION: boolean;
  105235. EMISSIVE: boolean;
  105236. EMISSIVEDIRECTUV: number;
  105237. SPECULAR: boolean;
  105238. SPECULARDIRECTUV: number;
  105239. BUMP: boolean;
  105240. BUMPDIRECTUV: number;
  105241. PARALLAX: boolean;
  105242. PARALLAXOCCLUSION: boolean;
  105243. SPECULAROVERALPHA: boolean;
  105244. CLIPPLANE: boolean;
  105245. CLIPPLANE2: boolean;
  105246. CLIPPLANE3: boolean;
  105247. CLIPPLANE4: boolean;
  105248. CLIPPLANE5: boolean;
  105249. CLIPPLANE6: boolean;
  105250. ALPHATEST: boolean;
  105251. DEPTHPREPASS: boolean;
  105252. ALPHAFROMDIFFUSE: boolean;
  105253. POINTSIZE: boolean;
  105254. FOG: boolean;
  105255. SPECULARTERM: boolean;
  105256. DIFFUSEFRESNEL: boolean;
  105257. OPACITYFRESNEL: boolean;
  105258. REFLECTIONFRESNEL: boolean;
  105259. REFRACTIONFRESNEL: boolean;
  105260. EMISSIVEFRESNEL: boolean;
  105261. FRESNEL: boolean;
  105262. NORMAL: boolean;
  105263. UV1: boolean;
  105264. UV2: boolean;
  105265. VERTEXCOLOR: boolean;
  105266. VERTEXALPHA: boolean;
  105267. NUM_BONE_INFLUENCERS: number;
  105268. BonesPerMesh: number;
  105269. BONETEXTURE: boolean;
  105270. BONES_VELOCITY_ENABLED: boolean;
  105271. INSTANCES: boolean;
  105272. THIN_INSTANCES: boolean;
  105273. GLOSSINESS: boolean;
  105274. ROUGHNESS: boolean;
  105275. EMISSIVEASILLUMINATION: boolean;
  105276. LINKEMISSIVEWITHDIFFUSE: boolean;
  105277. REFLECTIONFRESNELFROMSPECULAR: boolean;
  105278. LIGHTMAP: boolean;
  105279. LIGHTMAPDIRECTUV: number;
  105280. OBJECTSPACE_NORMALMAP: boolean;
  105281. USELIGHTMAPASSHADOWMAP: boolean;
  105282. REFLECTIONMAP_3D: boolean;
  105283. REFLECTIONMAP_SPHERICAL: boolean;
  105284. REFLECTIONMAP_PLANAR: boolean;
  105285. REFLECTIONMAP_CUBIC: boolean;
  105286. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  105287. REFLECTIONMAP_PROJECTION: boolean;
  105288. REFLECTIONMAP_SKYBOX: boolean;
  105289. REFLECTIONMAP_EXPLICIT: boolean;
  105290. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  105291. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  105292. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  105293. INVERTCUBICMAP: boolean;
  105294. LOGARITHMICDEPTH: boolean;
  105295. REFRACTION: boolean;
  105296. REFRACTIONMAP_3D: boolean;
  105297. REFLECTIONOVERALPHA: boolean;
  105298. TWOSIDEDLIGHTING: boolean;
  105299. SHADOWFLOAT: boolean;
  105300. MORPHTARGETS: boolean;
  105301. MORPHTARGETS_NORMAL: boolean;
  105302. MORPHTARGETS_TANGENT: boolean;
  105303. MORPHTARGETS_UV: boolean;
  105304. NUM_MORPH_INFLUENCERS: number;
  105305. NONUNIFORMSCALING: boolean;
  105306. PREMULTIPLYALPHA: boolean;
  105307. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  105308. ALPHABLEND: boolean;
  105309. PREPASS: boolean;
  105310. PREPASS_IRRADIANCE: boolean;
  105311. PREPASS_IRRADIANCE_INDEX: number;
  105312. PREPASS_ALBEDO: boolean;
  105313. PREPASS_ALBEDO_INDEX: number;
  105314. PREPASS_DEPTHNORMAL: boolean;
  105315. PREPASS_DEPTHNORMAL_INDEX: number;
  105316. PREPASS_POSITION: boolean;
  105317. PREPASS_POSITION_INDEX: number;
  105318. PREPASS_VELOCITY: boolean;
  105319. PREPASS_VELOCITY_INDEX: number;
  105320. PREPASS_REFLECTIVITY: boolean;
  105321. PREPASS_REFLECTIVITY_INDEX: number;
  105322. SCENE_MRT_COUNT: number;
  105323. RGBDLIGHTMAP: boolean;
  105324. RGBDREFLECTION: boolean;
  105325. RGBDREFRACTION: boolean;
  105326. IMAGEPROCESSING: boolean;
  105327. VIGNETTE: boolean;
  105328. VIGNETTEBLENDMODEMULTIPLY: boolean;
  105329. VIGNETTEBLENDMODEOPAQUE: boolean;
  105330. TONEMAPPING: boolean;
  105331. TONEMAPPING_ACES: boolean;
  105332. CONTRAST: boolean;
  105333. COLORCURVES: boolean;
  105334. COLORGRADING: boolean;
  105335. COLORGRADING3D: boolean;
  105336. SAMPLER3DGREENDEPTH: boolean;
  105337. SAMPLER3DBGRMAP: boolean;
  105338. IMAGEPROCESSINGPOSTPROCESS: boolean;
  105339. MULTIVIEW: boolean;
  105340. /**
  105341. * If the reflection texture on this material is in linear color space
  105342. * @hidden
  105343. */
  105344. IS_REFLECTION_LINEAR: boolean;
  105345. /**
  105346. * If the refraction texture on this material is in linear color space
  105347. * @hidden
  105348. */
  105349. IS_REFRACTION_LINEAR: boolean;
  105350. EXPOSURE: boolean;
  105351. constructor();
  105352. setReflectionMode(modeToEnable: string): void;
  105353. }
  105354. /**
  105355. * This is the default material used in Babylon. It is the best trade off between quality
  105356. * and performances.
  105357. * @see https://doc.babylonjs.com/babylon101/materials
  105358. */
  105359. export class StandardMaterial extends PushMaterial {
  105360. private _diffuseTexture;
  105361. /**
  105362. * The basic texture of the material as viewed under a light.
  105363. */
  105364. diffuseTexture: Nullable<BaseTexture>;
  105365. private _ambientTexture;
  105366. /**
  105367. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  105368. */
  105369. ambientTexture: Nullable<BaseTexture>;
  105370. private _opacityTexture;
  105371. /**
  105372. * Define the transparency of the material from a texture.
  105373. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  105374. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  105375. */
  105376. opacityTexture: Nullable<BaseTexture>;
  105377. private _reflectionTexture;
  105378. /**
  105379. * Define the texture used to display the reflection.
  105380. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105381. */
  105382. reflectionTexture: Nullable<BaseTexture>;
  105383. private _emissiveTexture;
  105384. /**
  105385. * Define texture of the material as if self lit.
  105386. * This will be mixed in the final result even in the absence of light.
  105387. */
  105388. emissiveTexture: Nullable<BaseTexture>;
  105389. private _specularTexture;
  105390. /**
  105391. * Define how the color and intensity of the highlight given by the light in the material.
  105392. */
  105393. specularTexture: Nullable<BaseTexture>;
  105394. private _bumpTexture;
  105395. /**
  105396. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  105397. * 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.
  105398. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  105399. */
  105400. bumpTexture: Nullable<BaseTexture>;
  105401. private _lightmapTexture;
  105402. /**
  105403. * Complex lighting can be computationally expensive to compute at runtime.
  105404. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  105405. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  105406. */
  105407. lightmapTexture: Nullable<BaseTexture>;
  105408. private _refractionTexture;
  105409. /**
  105410. * Define the texture used to display the refraction.
  105411. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105412. */
  105413. refractionTexture: Nullable<BaseTexture>;
  105414. /**
  105415. * The color of the material lit by the environmental background lighting.
  105416. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  105417. */
  105418. ambientColor: Color3;
  105419. /**
  105420. * The basic color of the material as viewed under a light.
  105421. */
  105422. diffuseColor: Color3;
  105423. /**
  105424. * Define how the color and intensity of the highlight given by the light in the material.
  105425. */
  105426. specularColor: Color3;
  105427. /**
  105428. * Define the color of the material as if self lit.
  105429. * This will be mixed in the final result even in the absence of light.
  105430. */
  105431. emissiveColor: Color3;
  105432. /**
  105433. * Defines how sharp are the highlights in the material.
  105434. * The bigger the value the sharper giving a more glossy feeling to the result.
  105435. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  105436. */
  105437. specularPower: number;
  105438. private _useAlphaFromDiffuseTexture;
  105439. /**
  105440. * Does the transparency come from the diffuse texture alpha channel.
  105441. */
  105442. useAlphaFromDiffuseTexture: boolean;
  105443. private _useEmissiveAsIllumination;
  105444. /**
  105445. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  105446. */
  105447. useEmissiveAsIllumination: boolean;
  105448. private _linkEmissiveWithDiffuse;
  105449. /**
  105450. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  105451. * the emissive level when the final color is close to one.
  105452. */
  105453. linkEmissiveWithDiffuse: boolean;
  105454. private _useSpecularOverAlpha;
  105455. /**
  105456. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  105457. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  105458. */
  105459. useSpecularOverAlpha: boolean;
  105460. private _useReflectionOverAlpha;
  105461. /**
  105462. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105463. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105464. */
  105465. useReflectionOverAlpha: boolean;
  105466. private _disableLighting;
  105467. /**
  105468. * Does lights from the scene impacts this material.
  105469. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  105470. */
  105471. disableLighting: boolean;
  105472. private _useObjectSpaceNormalMap;
  105473. /**
  105474. * Allows using an object space normal map (instead of tangent space).
  105475. */
  105476. useObjectSpaceNormalMap: boolean;
  105477. private _useParallax;
  105478. /**
  105479. * Is parallax enabled or not.
  105480. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  105481. */
  105482. useParallax: boolean;
  105483. private _useParallaxOcclusion;
  105484. /**
  105485. * Is parallax occlusion enabled or not.
  105486. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  105487. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  105488. */
  105489. useParallaxOcclusion: boolean;
  105490. /**
  105491. * 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.
  105492. */
  105493. parallaxScaleBias: number;
  105494. private _roughness;
  105495. /**
  105496. * Helps to define how blurry the reflections should appears in the material.
  105497. */
  105498. roughness: number;
  105499. /**
  105500. * In case of refraction, define the value of the index of refraction.
  105501. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105502. */
  105503. indexOfRefraction: number;
  105504. /**
  105505. * Invert the refraction texture alongside the y axis.
  105506. * It can be useful with procedural textures or probe for instance.
  105507. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  105508. */
  105509. invertRefractionY: boolean;
  105510. /**
  105511. * Defines the alpha limits in alpha test mode.
  105512. */
  105513. alphaCutOff: number;
  105514. private _useLightmapAsShadowmap;
  105515. /**
  105516. * In case of light mapping, define whether the map contains light or shadow informations.
  105517. */
  105518. useLightmapAsShadowmap: boolean;
  105519. private _diffuseFresnelParameters;
  105520. /**
  105521. * Define the diffuse fresnel parameters of the material.
  105522. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105523. */
  105524. diffuseFresnelParameters: FresnelParameters;
  105525. private _opacityFresnelParameters;
  105526. /**
  105527. * Define the opacity fresnel parameters of the material.
  105528. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105529. */
  105530. opacityFresnelParameters: FresnelParameters;
  105531. private _reflectionFresnelParameters;
  105532. /**
  105533. * Define the reflection fresnel parameters of the material.
  105534. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105535. */
  105536. reflectionFresnelParameters: FresnelParameters;
  105537. private _refractionFresnelParameters;
  105538. /**
  105539. * Define the refraction fresnel parameters of the material.
  105540. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105541. */
  105542. refractionFresnelParameters: FresnelParameters;
  105543. private _emissiveFresnelParameters;
  105544. /**
  105545. * Define the emissive fresnel parameters of the material.
  105546. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105547. */
  105548. emissiveFresnelParameters: FresnelParameters;
  105549. private _useReflectionFresnelFromSpecular;
  105550. /**
  105551. * If true automatically deducts the fresnels values from the material specularity.
  105552. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  105553. */
  105554. useReflectionFresnelFromSpecular: boolean;
  105555. private _useGlossinessFromSpecularMapAlpha;
  105556. /**
  105557. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  105558. */
  105559. useGlossinessFromSpecularMapAlpha: boolean;
  105560. private _maxSimultaneousLights;
  105561. /**
  105562. * Defines the maximum number of lights that can be used in the material
  105563. */
  105564. maxSimultaneousLights: number;
  105565. private _invertNormalMapX;
  105566. /**
  105567. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105568. */
  105569. invertNormalMapX: boolean;
  105570. private _invertNormalMapY;
  105571. /**
  105572. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105573. */
  105574. invertNormalMapY: boolean;
  105575. private _twoSidedLighting;
  105576. /**
  105577. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105578. */
  105579. twoSidedLighting: boolean;
  105580. /**
  105581. * Default configuration related to image processing available in the standard Material.
  105582. */
  105583. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105584. /**
  105585. * Gets the image processing configuration used either in this material.
  105586. */
  105587. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  105588. /**
  105589. * Sets the Default image processing configuration used either in the this material.
  105590. *
  105591. * If sets to null, the scene one is in use.
  105592. */
  105593. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  105594. /**
  105595. * Keep track of the image processing observer to allow dispose and replace.
  105596. */
  105597. private _imageProcessingObserver;
  105598. /**
  105599. * Attaches a new image processing configuration to the Standard Material.
  105600. * @param configuration
  105601. */
  105602. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105603. /**
  105604. * Defines additionnal PrePass parameters for the material.
  105605. */
  105606. readonly prePassConfiguration: PrePassConfiguration;
  105607. /**
  105608. * Gets wether the color curves effect is enabled.
  105609. */
  105610. get cameraColorCurvesEnabled(): boolean;
  105611. /**
  105612. * Sets wether the color curves effect is enabled.
  105613. */
  105614. set cameraColorCurvesEnabled(value: boolean);
  105615. /**
  105616. * Gets wether the color grading effect is enabled.
  105617. */
  105618. get cameraColorGradingEnabled(): boolean;
  105619. /**
  105620. * Gets wether the color grading effect is enabled.
  105621. */
  105622. set cameraColorGradingEnabled(value: boolean);
  105623. /**
  105624. * Gets wether tonemapping is enabled or not.
  105625. */
  105626. get cameraToneMappingEnabled(): boolean;
  105627. /**
  105628. * Sets wether tonemapping is enabled or not
  105629. */
  105630. set cameraToneMappingEnabled(value: boolean);
  105631. /**
  105632. * The camera exposure used on this material.
  105633. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105634. * This corresponds to a photographic exposure.
  105635. */
  105636. get cameraExposure(): number;
  105637. /**
  105638. * The camera exposure used on this material.
  105639. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105640. * This corresponds to a photographic exposure.
  105641. */
  105642. set cameraExposure(value: number);
  105643. /**
  105644. * Gets The camera contrast used on this material.
  105645. */
  105646. get cameraContrast(): number;
  105647. /**
  105648. * Sets The camera contrast used on this material.
  105649. */
  105650. set cameraContrast(value: number);
  105651. /**
  105652. * Gets the Color Grading 2D Lookup Texture.
  105653. */
  105654. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  105655. /**
  105656. * Sets the Color Grading 2D Lookup Texture.
  105657. */
  105658. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  105659. /**
  105660. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105661. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105662. * 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;
  105663. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105664. */
  105665. get cameraColorCurves(): Nullable<ColorCurves>;
  105666. /**
  105667. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105668. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105669. * 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;
  105670. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105671. */
  105672. set cameraColorCurves(value: Nullable<ColorCurves>);
  105673. /**
  105674. * Can this material render to several textures at once
  105675. */
  105676. get canRenderToMRT(): boolean;
  105677. /**
  105678. * Defines the detail map parameters for the material.
  105679. */
  105680. readonly detailMap: DetailMapConfiguration;
  105681. protected _renderTargets: SmartArray<RenderTargetTexture>;
  105682. protected _worldViewProjectionMatrix: Matrix;
  105683. protected _globalAmbientColor: Color3;
  105684. protected _useLogarithmicDepth: boolean;
  105685. protected _rebuildInParallel: boolean;
  105686. /**
  105687. * Instantiates a new standard material.
  105688. * This is the default material used in Babylon. It is the best trade off between quality
  105689. * and performances.
  105690. * @see https://doc.babylonjs.com/babylon101/materials
  105691. * @param name Define the name of the material in the scene
  105692. * @param scene Define the scene the material belong to
  105693. */
  105694. constructor(name: string, scene: Scene);
  105695. /**
  105696. * Gets a boolean indicating that current material needs to register RTT
  105697. */
  105698. get hasRenderTargetTextures(): boolean;
  105699. /**
  105700. * Gets the current class name of the material e.g. "StandardMaterial"
  105701. * Mainly use in serialization.
  105702. * @returns the class name
  105703. */
  105704. getClassName(): string;
  105705. /**
  105706. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  105707. * You can try switching to logarithmic depth.
  105708. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  105709. */
  105710. get useLogarithmicDepth(): boolean;
  105711. set useLogarithmicDepth(value: boolean);
  105712. /**
  105713. * Specifies if the material will require alpha blending
  105714. * @returns a boolean specifying if alpha blending is needed
  105715. */
  105716. needAlphaBlending(): boolean;
  105717. /**
  105718. * Specifies if this material should be rendered in alpha test mode
  105719. * @returns a boolean specifying if an alpha test is needed.
  105720. */
  105721. needAlphaTesting(): boolean;
  105722. /**
  105723. * Specifies whether or not the alpha value of the diffuse texture should be used for alpha blending.
  105724. */
  105725. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  105726. /**
  105727. * Specifies whether or not there is a usable alpha channel for transparency.
  105728. */
  105729. protected _hasAlphaChannel(): boolean;
  105730. /**
  105731. * Get the texture used for alpha test purpose.
  105732. * @returns the diffuse texture in case of the standard material.
  105733. */
  105734. getAlphaTestTexture(): Nullable<BaseTexture>;
  105735. /**
  105736. * Get if the submesh is ready to be used and all its information available.
  105737. * Child classes can use it to update shaders
  105738. * @param mesh defines the mesh to check
  105739. * @param subMesh defines which submesh to check
  105740. * @param useInstances specifies that instances should be used
  105741. * @returns a boolean indicating that the submesh is ready or not
  105742. */
  105743. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105744. /**
  105745. * Builds the material UBO layouts.
  105746. * Used internally during the effect preparation.
  105747. */
  105748. buildUniformLayout(): void;
  105749. /**
  105750. * Unbinds the material from the mesh
  105751. */
  105752. unbind(): void;
  105753. /**
  105754. * Binds the submesh to this material by preparing the effect and shader to draw
  105755. * @param world defines the world transformation matrix
  105756. * @param mesh defines the mesh containing the submesh
  105757. * @param subMesh defines the submesh to bind the material to
  105758. */
  105759. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105760. /**
  105761. * Get the list of animatables in the material.
  105762. * @returns the list of animatables object used in the material
  105763. */
  105764. getAnimatables(): IAnimatable[];
  105765. /**
  105766. * Gets the active textures from the material
  105767. * @returns an array of textures
  105768. */
  105769. getActiveTextures(): BaseTexture[];
  105770. /**
  105771. * Specifies if the material uses a texture
  105772. * @param texture defines the texture to check against the material
  105773. * @returns a boolean specifying if the material uses the texture
  105774. */
  105775. hasTexture(texture: BaseTexture): boolean;
  105776. /**
  105777. * Disposes the material
  105778. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105779. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105780. */
  105781. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105782. /**
  105783. * Makes a duplicate of the material, and gives it a new name
  105784. * @param name defines the new name for the duplicated material
  105785. * @returns the cloned material
  105786. */
  105787. clone(name: string): StandardMaterial;
  105788. /**
  105789. * Serializes this material in a JSON representation
  105790. * @returns the serialized material object
  105791. */
  105792. serialize(): any;
  105793. /**
  105794. * Creates a standard material from parsed material data
  105795. * @param source defines the JSON representation of the material
  105796. * @param scene defines the hosting scene
  105797. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  105798. * @returns a new standard material
  105799. */
  105800. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  105801. /**
  105802. * Are diffuse textures enabled in the application.
  105803. */
  105804. static get DiffuseTextureEnabled(): boolean;
  105805. static set DiffuseTextureEnabled(value: boolean);
  105806. /**
  105807. * Are detail textures enabled in the application.
  105808. */
  105809. static get DetailTextureEnabled(): boolean;
  105810. static set DetailTextureEnabled(value: boolean);
  105811. /**
  105812. * Are ambient textures enabled in the application.
  105813. */
  105814. static get AmbientTextureEnabled(): boolean;
  105815. static set AmbientTextureEnabled(value: boolean);
  105816. /**
  105817. * Are opacity textures enabled in the application.
  105818. */
  105819. static get OpacityTextureEnabled(): boolean;
  105820. static set OpacityTextureEnabled(value: boolean);
  105821. /**
  105822. * Are reflection textures enabled in the application.
  105823. */
  105824. static get ReflectionTextureEnabled(): boolean;
  105825. static set ReflectionTextureEnabled(value: boolean);
  105826. /**
  105827. * Are emissive textures enabled in the application.
  105828. */
  105829. static get EmissiveTextureEnabled(): boolean;
  105830. static set EmissiveTextureEnabled(value: boolean);
  105831. /**
  105832. * Are specular textures enabled in the application.
  105833. */
  105834. static get SpecularTextureEnabled(): boolean;
  105835. static set SpecularTextureEnabled(value: boolean);
  105836. /**
  105837. * Are bump textures enabled in the application.
  105838. */
  105839. static get BumpTextureEnabled(): boolean;
  105840. static set BumpTextureEnabled(value: boolean);
  105841. /**
  105842. * Are lightmap textures enabled in the application.
  105843. */
  105844. static get LightmapTextureEnabled(): boolean;
  105845. static set LightmapTextureEnabled(value: boolean);
  105846. /**
  105847. * Are refraction textures enabled in the application.
  105848. */
  105849. static get RefractionTextureEnabled(): boolean;
  105850. static set RefractionTextureEnabled(value: boolean);
  105851. /**
  105852. * Are color grading textures enabled in the application.
  105853. */
  105854. static get ColorGradingTextureEnabled(): boolean;
  105855. static set ColorGradingTextureEnabled(value: boolean);
  105856. /**
  105857. * Are fresnels enabled in the application.
  105858. */
  105859. static get FresnelEnabled(): boolean;
  105860. static set FresnelEnabled(value: boolean);
  105861. }
  105862. }
  105863. declare module BABYLON {
  105864. /** @hidden */
  105865. export var rgbdDecodePixelShader: {
  105866. name: string;
  105867. shader: string;
  105868. };
  105869. }
  105870. declare module BABYLON {
  105871. /**
  105872. * Class used to host RGBD texture specific utilities
  105873. */
  105874. export class RGBDTextureTools {
  105875. /**
  105876. * Expand the RGBD Texture from RGBD to Half Float if possible.
  105877. * @param texture the texture to expand.
  105878. */
  105879. static ExpandRGBDTexture(texture: Texture): void;
  105880. }
  105881. }
  105882. declare module BABYLON {
  105883. /**
  105884. * Class used to host texture specific utilities
  105885. */
  105886. export class BRDFTextureTools {
  105887. /**
  105888. * Prevents texture cache collision
  105889. */
  105890. private static _instanceNumber;
  105891. /**
  105892. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  105893. * @param scene defines the hosting scene
  105894. * @returns the environment BRDF texture
  105895. */
  105896. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  105897. private static _environmentBRDFBase64Texture;
  105898. }
  105899. }
  105900. declare module BABYLON {
  105901. /**
  105902. * @hidden
  105903. */
  105904. export interface IMaterialClearCoatDefines {
  105905. CLEARCOAT: boolean;
  105906. CLEARCOAT_DEFAULTIOR: boolean;
  105907. CLEARCOAT_TEXTURE: boolean;
  105908. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  105909. CLEARCOAT_TEXTUREDIRECTUV: number;
  105910. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  105911. CLEARCOAT_BUMP: boolean;
  105912. CLEARCOAT_BUMPDIRECTUV: number;
  105913. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  105914. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  105915. CLEARCOAT_REMAP_F0: boolean;
  105916. CLEARCOAT_TINT: boolean;
  105917. CLEARCOAT_TINT_TEXTURE: boolean;
  105918. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  105919. /** @hidden */
  105920. _areTexturesDirty: boolean;
  105921. }
  105922. /**
  105923. * Define the code related to the clear coat parameters of the pbr material.
  105924. */
  105925. export class PBRClearCoatConfiguration {
  105926. /**
  105927. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105928. * The default fits with a polyurethane material.
  105929. */
  105930. private static readonly _DefaultIndexOfRefraction;
  105931. private _isEnabled;
  105932. /**
  105933. * Defines if the clear coat is enabled in the material.
  105934. */
  105935. isEnabled: boolean;
  105936. /**
  105937. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  105938. */
  105939. intensity: number;
  105940. /**
  105941. * Defines the clear coat layer roughness.
  105942. */
  105943. roughness: number;
  105944. private _indexOfRefraction;
  105945. /**
  105946. * Defines the index of refraction of the clear coat.
  105947. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  105948. * The default fits with a polyurethane material.
  105949. * Changing the default value is more performance intensive.
  105950. */
  105951. indexOfRefraction: number;
  105952. private _texture;
  105953. /**
  105954. * Stores the clear coat values in a texture (red channel is intensity and green channel is roughness)
  105955. * If useRoughnessFromMainTexture is false, the green channel of texture is not used and the green channel of textureRoughness is used instead
  105956. * if textureRoughness is not empty, else no texture roughness is used
  105957. */
  105958. texture: Nullable<BaseTexture>;
  105959. private _useRoughnessFromMainTexture;
  105960. /**
  105961. * Indicates that the green channel of the texture property will be used for roughness (default: true)
  105962. * If false, the green channel from textureRoughness is used for roughness
  105963. */
  105964. useRoughnessFromMainTexture: boolean;
  105965. private _textureRoughness;
  105966. /**
  105967. * Stores the clear coat roughness in a texture (green channel)
  105968. * Not used if useRoughnessFromMainTexture is true
  105969. */
  105970. textureRoughness: Nullable<BaseTexture>;
  105971. private _remapF0OnInterfaceChange;
  105972. /**
  105973. * Defines if the F0 value should be remapped to account for the interface change in the material.
  105974. */
  105975. remapF0OnInterfaceChange: boolean;
  105976. private _bumpTexture;
  105977. /**
  105978. * Define the clear coat specific bump texture.
  105979. */
  105980. bumpTexture: Nullable<BaseTexture>;
  105981. private _isTintEnabled;
  105982. /**
  105983. * Defines if the clear coat tint is enabled in the material.
  105984. */
  105985. isTintEnabled: boolean;
  105986. /**
  105987. * Defines the clear coat tint of the material.
  105988. * This is only use if tint is enabled
  105989. */
  105990. tintColor: Color3;
  105991. /**
  105992. * Defines the distance at which the tint color should be found in the
  105993. * clear coat media.
  105994. * This is only use if tint is enabled
  105995. */
  105996. tintColorAtDistance: number;
  105997. /**
  105998. * Defines the clear coat layer thickness.
  105999. * This is only use if tint is enabled
  106000. */
  106001. tintThickness: number;
  106002. private _tintTexture;
  106003. /**
  106004. * Stores the clear tint values in a texture.
  106005. * rgb is tint
  106006. * a is a thickness factor
  106007. */
  106008. tintTexture: Nullable<BaseTexture>;
  106009. /** @hidden */
  106010. private _internalMarkAllSubMeshesAsTexturesDirty;
  106011. /** @hidden */
  106012. _markAllSubMeshesAsTexturesDirty(): void;
  106013. /**
  106014. * Instantiate a new istance of clear coat configuration.
  106015. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106016. */
  106017. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106018. /**
  106019. * Gets wehter the submesh is ready to be used or not.
  106020. * @param defines the list of "defines" to update.
  106021. * @param scene defines the scene the material belongs to.
  106022. * @param engine defines the engine the material belongs to.
  106023. * @param disableBumpMap defines wether the material disables bump or not.
  106024. * @returns - boolean indicating that the submesh is ready or not.
  106025. */
  106026. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  106027. /**
  106028. * Checks to see if a texture is used in the material.
  106029. * @param defines the list of "defines" to update.
  106030. * @param scene defines the scene to the material belongs to.
  106031. */
  106032. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  106033. /**
  106034. * Binds the material data.
  106035. * @param uniformBuffer defines the Uniform buffer to fill in.
  106036. * @param scene defines the scene the material belongs to.
  106037. * @param engine defines the engine the material belongs to.
  106038. * @param disableBumpMap defines wether the material disables bump or not.
  106039. * @param isFrozen defines wether the material is frozen or not.
  106040. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  106041. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  106042. * @param subMesh the submesh to bind data for
  106043. */
  106044. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean, subMesh?: SubMesh): void;
  106045. /**
  106046. * Checks to see if a texture is used in the material.
  106047. * @param texture - Base texture to use.
  106048. * @returns - Boolean specifying if a texture is used in the material.
  106049. */
  106050. hasTexture(texture: BaseTexture): boolean;
  106051. /**
  106052. * Returns an array of the actively used textures.
  106053. * @param activeTextures Array of BaseTextures
  106054. */
  106055. getActiveTextures(activeTextures: BaseTexture[]): void;
  106056. /**
  106057. * Returns the animatable textures.
  106058. * @param animatables Array of animatable textures.
  106059. */
  106060. getAnimatables(animatables: IAnimatable[]): void;
  106061. /**
  106062. * Disposes the resources of the material.
  106063. * @param forceDisposeTextures - Forces the disposal of all textures.
  106064. */
  106065. dispose(forceDisposeTextures?: boolean): void;
  106066. /**
  106067. * Get the current class name of the texture useful for serialization or dynamic coding.
  106068. * @returns "PBRClearCoatConfiguration"
  106069. */
  106070. getClassName(): string;
  106071. /**
  106072. * Add fallbacks to the effect fallbacks list.
  106073. * @param defines defines the Base texture to use.
  106074. * @param fallbacks defines the current fallback list.
  106075. * @param currentRank defines the current fallback rank.
  106076. * @returns the new fallback rank.
  106077. */
  106078. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106079. /**
  106080. * Add the required uniforms to the current list.
  106081. * @param uniforms defines the current uniform list.
  106082. */
  106083. static AddUniforms(uniforms: string[]): void;
  106084. /**
  106085. * Add the required samplers to the current list.
  106086. * @param samplers defines the current sampler list.
  106087. */
  106088. static AddSamplers(samplers: string[]): void;
  106089. /**
  106090. * Add the required uniforms to the current buffer.
  106091. * @param uniformBuffer defines the current uniform buffer.
  106092. */
  106093. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106094. /**
  106095. * Makes a duplicate of the current configuration into another one.
  106096. * @param clearCoatConfiguration define the config where to copy the info
  106097. */
  106098. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  106099. /**
  106100. * Serializes this clear coat configuration.
  106101. * @returns - An object with the serialized config.
  106102. */
  106103. serialize(): any;
  106104. /**
  106105. * Parses a anisotropy Configuration from a serialized object.
  106106. * @param source - Serialized object.
  106107. * @param scene Defines the scene we are parsing for
  106108. * @param rootUrl Defines the rootUrl to load from
  106109. */
  106110. parse(source: any, scene: Scene, rootUrl: string): void;
  106111. }
  106112. }
  106113. declare module BABYLON {
  106114. /**
  106115. * @hidden
  106116. */
  106117. export interface IMaterialAnisotropicDefines {
  106118. ANISOTROPIC: boolean;
  106119. ANISOTROPIC_TEXTURE: boolean;
  106120. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106121. MAINUV1: boolean;
  106122. _areTexturesDirty: boolean;
  106123. _needUVs: boolean;
  106124. }
  106125. /**
  106126. * Define the code related to the anisotropic parameters of the pbr material.
  106127. */
  106128. export class PBRAnisotropicConfiguration {
  106129. private _isEnabled;
  106130. /**
  106131. * Defines if the anisotropy is enabled in the material.
  106132. */
  106133. isEnabled: boolean;
  106134. /**
  106135. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  106136. */
  106137. intensity: number;
  106138. /**
  106139. * Defines if the effect is along the tangents, bitangents or in between.
  106140. * By default, the effect is "strectching" the highlights along the tangents.
  106141. */
  106142. direction: Vector2;
  106143. private _texture;
  106144. /**
  106145. * Stores the anisotropy values in a texture.
  106146. * rg is direction (like normal from -1 to 1)
  106147. * b is a intensity
  106148. */
  106149. texture: Nullable<BaseTexture>;
  106150. /** @hidden */
  106151. private _internalMarkAllSubMeshesAsTexturesDirty;
  106152. /** @hidden */
  106153. _markAllSubMeshesAsTexturesDirty(): void;
  106154. /**
  106155. * Instantiate a new istance of anisotropy configuration.
  106156. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106157. */
  106158. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106159. /**
  106160. * Specifies that the submesh is ready to be used.
  106161. * @param defines the list of "defines" to update.
  106162. * @param scene defines the scene the material belongs to.
  106163. * @returns - boolean indicating that the submesh is ready or not.
  106164. */
  106165. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  106166. /**
  106167. * Checks to see if a texture is used in the material.
  106168. * @param defines the list of "defines" to update.
  106169. * @param mesh the mesh we are preparing the defines for.
  106170. * @param scene defines the scene the material belongs to.
  106171. */
  106172. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  106173. /**
  106174. * Binds the material data.
  106175. * @param uniformBuffer defines the Uniform buffer to fill in.
  106176. * @param scene defines the scene the material belongs to.
  106177. * @param isFrozen defines wether the material is frozen or not.
  106178. */
  106179. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  106180. /**
  106181. * Checks to see if a texture is used in the material.
  106182. * @param texture - Base texture to use.
  106183. * @returns - Boolean specifying if a texture is used in the material.
  106184. */
  106185. hasTexture(texture: BaseTexture): boolean;
  106186. /**
  106187. * Returns an array of the actively used textures.
  106188. * @param activeTextures Array of BaseTextures
  106189. */
  106190. getActiveTextures(activeTextures: BaseTexture[]): void;
  106191. /**
  106192. * Returns the animatable textures.
  106193. * @param animatables Array of animatable textures.
  106194. */
  106195. getAnimatables(animatables: IAnimatable[]): void;
  106196. /**
  106197. * Disposes the resources of the material.
  106198. * @param forceDisposeTextures - Forces the disposal of all textures.
  106199. */
  106200. dispose(forceDisposeTextures?: boolean): void;
  106201. /**
  106202. * Get the current class name of the texture useful for serialization or dynamic coding.
  106203. * @returns "PBRAnisotropicConfiguration"
  106204. */
  106205. getClassName(): string;
  106206. /**
  106207. * Add fallbacks to the effect fallbacks list.
  106208. * @param defines defines the Base texture to use.
  106209. * @param fallbacks defines the current fallback list.
  106210. * @param currentRank defines the current fallback rank.
  106211. * @returns the new fallback rank.
  106212. */
  106213. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106214. /**
  106215. * Add the required uniforms to the current list.
  106216. * @param uniforms defines the current uniform list.
  106217. */
  106218. static AddUniforms(uniforms: string[]): void;
  106219. /**
  106220. * Add the required uniforms to the current buffer.
  106221. * @param uniformBuffer defines the current uniform buffer.
  106222. */
  106223. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106224. /**
  106225. * Add the required samplers to the current list.
  106226. * @param samplers defines the current sampler list.
  106227. */
  106228. static AddSamplers(samplers: string[]): void;
  106229. /**
  106230. * Makes a duplicate of the current configuration into another one.
  106231. * @param anisotropicConfiguration define the config where to copy the info
  106232. */
  106233. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  106234. /**
  106235. * Serializes this anisotropy configuration.
  106236. * @returns - An object with the serialized config.
  106237. */
  106238. serialize(): any;
  106239. /**
  106240. * Parses a anisotropy Configuration from a serialized object.
  106241. * @param source - Serialized object.
  106242. * @param scene Defines the scene we are parsing for
  106243. * @param rootUrl Defines the rootUrl to load from
  106244. */
  106245. parse(source: any, scene: Scene, rootUrl: string): void;
  106246. }
  106247. }
  106248. declare module BABYLON {
  106249. /**
  106250. * @hidden
  106251. */
  106252. export interface IMaterialBRDFDefines {
  106253. BRDF_V_HEIGHT_CORRELATED: boolean;
  106254. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106255. SPHERICAL_HARMONICS: boolean;
  106256. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  106257. /** @hidden */
  106258. _areMiscDirty: boolean;
  106259. }
  106260. /**
  106261. * Define the code related to the BRDF parameters of the pbr material.
  106262. */
  106263. export class PBRBRDFConfiguration {
  106264. /**
  106265. * Default value used for the energy conservation.
  106266. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  106267. */
  106268. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  106269. /**
  106270. * Default value used for the Smith Visibility Height Correlated mode.
  106271. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  106272. */
  106273. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  106274. /**
  106275. * Default value used for the IBL diffuse part.
  106276. * This can help switching back to the polynomials mode globally which is a tiny bit
  106277. * less GPU intensive at the drawback of a lower quality.
  106278. */
  106279. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  106280. /**
  106281. * Default value used for activating energy conservation for the specular workflow.
  106282. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  106283. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  106284. */
  106285. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  106286. private _useEnergyConservation;
  106287. /**
  106288. * Defines if the material uses energy conservation.
  106289. */
  106290. useEnergyConservation: boolean;
  106291. private _useSmithVisibilityHeightCorrelated;
  106292. /**
  106293. * LEGACY Mode set to false
  106294. * Defines if the material uses height smith correlated visibility term.
  106295. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  106296. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  106297. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  106298. * Not relying on height correlated will also disable energy conservation.
  106299. */
  106300. useSmithVisibilityHeightCorrelated: boolean;
  106301. private _useSphericalHarmonics;
  106302. /**
  106303. * LEGACY Mode set to false
  106304. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  106305. * diffuse part of the IBL.
  106306. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  106307. * to the ground truth.
  106308. */
  106309. useSphericalHarmonics: boolean;
  106310. private _useSpecularGlossinessInputEnergyConservation;
  106311. /**
  106312. * Defines if the material uses energy conservation, when the specular workflow is active.
  106313. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  106314. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  106315. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  106316. */
  106317. useSpecularGlossinessInputEnergyConservation: boolean;
  106318. /** @hidden */
  106319. private _internalMarkAllSubMeshesAsMiscDirty;
  106320. /** @hidden */
  106321. _markAllSubMeshesAsMiscDirty(): void;
  106322. /**
  106323. * Instantiate a new istance of clear coat configuration.
  106324. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  106325. */
  106326. constructor(markAllSubMeshesAsMiscDirty: () => void);
  106327. /**
  106328. * Checks to see if a texture is used in the material.
  106329. * @param defines the list of "defines" to update.
  106330. */
  106331. prepareDefines(defines: IMaterialBRDFDefines): void;
  106332. /**
  106333. * Get the current class name of the texture useful for serialization or dynamic coding.
  106334. * @returns "PBRClearCoatConfiguration"
  106335. */
  106336. getClassName(): string;
  106337. /**
  106338. * Makes a duplicate of the current configuration into another one.
  106339. * @param brdfConfiguration define the config where to copy the info
  106340. */
  106341. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  106342. /**
  106343. * Serializes this BRDF configuration.
  106344. * @returns - An object with the serialized config.
  106345. */
  106346. serialize(): any;
  106347. /**
  106348. * Parses a anisotropy Configuration from a serialized object.
  106349. * @param source - Serialized object.
  106350. * @param scene Defines the scene we are parsing for
  106351. * @param rootUrl Defines the rootUrl to load from
  106352. */
  106353. parse(source: any, scene: Scene, rootUrl: string): void;
  106354. }
  106355. }
  106356. declare module BABYLON {
  106357. /**
  106358. * @hidden
  106359. */
  106360. export interface IMaterialSheenDefines {
  106361. SHEEN: boolean;
  106362. SHEEN_TEXTURE: boolean;
  106363. SHEEN_TEXTURE_ROUGHNESS: boolean;
  106364. SHEEN_TEXTUREDIRECTUV: number;
  106365. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  106366. SHEEN_LINKWITHALBEDO: boolean;
  106367. SHEEN_ROUGHNESS: boolean;
  106368. SHEEN_ALBEDOSCALING: boolean;
  106369. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  106370. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  106371. /** @hidden */
  106372. _areTexturesDirty: boolean;
  106373. }
  106374. /**
  106375. * Define the code related to the Sheen parameters of the pbr material.
  106376. */
  106377. export class PBRSheenConfiguration {
  106378. private _isEnabled;
  106379. /**
  106380. * Defines if the material uses sheen.
  106381. */
  106382. isEnabled: boolean;
  106383. private _linkSheenWithAlbedo;
  106384. /**
  106385. * Defines if the sheen is linked to the sheen color.
  106386. */
  106387. linkSheenWithAlbedo: boolean;
  106388. /**
  106389. * Defines the sheen intensity.
  106390. */
  106391. intensity: number;
  106392. /**
  106393. * Defines the sheen color.
  106394. */
  106395. color: Color3;
  106396. private _texture;
  106397. /**
  106398. * Stores the sheen tint values in a texture.
  106399. * rgb is tint
  106400. * 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)
  106401. * If the roughness property has been defined and useRoughnessFromTexture is false then the alpha channel is not used to modulate roughness
  106402. */
  106403. texture: Nullable<BaseTexture>;
  106404. private _useRoughnessFromMainTexture;
  106405. /**
  106406. * Indicates that the alpha channel of the texture property will be used for roughness.
  106407. * Has no effect if the roughness (and texture!) property is not defined
  106408. */
  106409. useRoughnessFromMainTexture: boolean;
  106410. private _roughness;
  106411. /**
  106412. * Defines the sheen roughness.
  106413. * It is not taken into account if linkSheenWithAlbedo is true.
  106414. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  106415. */
  106416. roughness: Nullable<number>;
  106417. private _textureRoughness;
  106418. /**
  106419. * Stores the sheen roughness in a texture.
  106420. * alpha channel is the roughness. This texture won't be used if the texture property is not empty and useRoughnessFromTexture is true
  106421. */
  106422. textureRoughness: Nullable<BaseTexture>;
  106423. private _albedoScaling;
  106424. /**
  106425. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  106426. * It allows the strength of the sheen effect to not depend on the base color of the material,
  106427. * making it easier to setup and tweak the effect
  106428. */
  106429. albedoScaling: boolean;
  106430. /** @hidden */
  106431. private _internalMarkAllSubMeshesAsTexturesDirty;
  106432. /** @hidden */
  106433. _markAllSubMeshesAsTexturesDirty(): void;
  106434. /**
  106435. * Instantiate a new istance of clear coat configuration.
  106436. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106437. */
  106438. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106439. /**
  106440. * Specifies that the submesh is ready to be used.
  106441. * @param defines the list of "defines" to update.
  106442. * @param scene defines the scene the material belongs to.
  106443. * @returns - boolean indicating that the submesh is ready or not.
  106444. */
  106445. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  106446. /**
  106447. * Checks to see if a texture is used in the material.
  106448. * @param defines the list of "defines" to update.
  106449. * @param scene defines the scene the material belongs to.
  106450. */
  106451. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  106452. /**
  106453. * Binds the material data.
  106454. * @param uniformBuffer defines the Uniform buffer to fill in.
  106455. * @param scene defines the scene the material belongs to.
  106456. * @param isFrozen defines wether the material is frozen or not.
  106457. * @param subMesh the submesh to bind data for
  106458. */
  106459. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean, subMesh?: SubMesh): void;
  106460. /**
  106461. * Checks to see if a texture is used in the material.
  106462. * @param texture - Base texture to use.
  106463. * @returns - Boolean specifying if a texture is used in the material.
  106464. */
  106465. hasTexture(texture: BaseTexture): boolean;
  106466. /**
  106467. * Returns an array of the actively used textures.
  106468. * @param activeTextures Array of BaseTextures
  106469. */
  106470. getActiveTextures(activeTextures: BaseTexture[]): void;
  106471. /**
  106472. * Returns the animatable textures.
  106473. * @param animatables Array of animatable textures.
  106474. */
  106475. getAnimatables(animatables: IAnimatable[]): void;
  106476. /**
  106477. * Disposes the resources of the material.
  106478. * @param forceDisposeTextures - Forces the disposal of all textures.
  106479. */
  106480. dispose(forceDisposeTextures?: boolean): void;
  106481. /**
  106482. * Get the current class name of the texture useful for serialization or dynamic coding.
  106483. * @returns "PBRSheenConfiguration"
  106484. */
  106485. getClassName(): string;
  106486. /**
  106487. * Add fallbacks to the effect fallbacks list.
  106488. * @param defines defines the Base texture to use.
  106489. * @param fallbacks defines the current fallback list.
  106490. * @param currentRank defines the current fallback rank.
  106491. * @returns the new fallback rank.
  106492. */
  106493. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106494. /**
  106495. * Add the required uniforms to the current list.
  106496. * @param uniforms defines the current uniform list.
  106497. */
  106498. static AddUniforms(uniforms: string[]): void;
  106499. /**
  106500. * Add the required uniforms to the current buffer.
  106501. * @param uniformBuffer defines the current uniform buffer.
  106502. */
  106503. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106504. /**
  106505. * Add the required samplers to the current list.
  106506. * @param samplers defines the current sampler list.
  106507. */
  106508. static AddSamplers(samplers: string[]): void;
  106509. /**
  106510. * Makes a duplicate of the current configuration into another one.
  106511. * @param sheenConfiguration define the config where to copy the info
  106512. */
  106513. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  106514. /**
  106515. * Serializes this BRDF configuration.
  106516. * @returns - An object with the serialized config.
  106517. */
  106518. serialize(): any;
  106519. /**
  106520. * Parses a anisotropy Configuration from a serialized object.
  106521. * @param source - Serialized object.
  106522. * @param scene Defines the scene we are parsing for
  106523. * @param rootUrl Defines the rootUrl to load from
  106524. */
  106525. parse(source: any, scene: Scene, rootUrl: string): void;
  106526. }
  106527. }
  106528. declare module BABYLON {
  106529. /**
  106530. * @hidden
  106531. */
  106532. export interface IMaterialSubSurfaceDefines {
  106533. SUBSURFACE: boolean;
  106534. SS_REFRACTION: boolean;
  106535. SS_TRANSLUCENCY: boolean;
  106536. SS_SCATTERING: boolean;
  106537. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106538. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106539. SS_REFRACTIONMAP_3D: boolean;
  106540. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106541. SS_LODINREFRACTIONALPHA: boolean;
  106542. SS_GAMMAREFRACTION: boolean;
  106543. SS_RGBDREFRACTION: boolean;
  106544. SS_LINEARSPECULARREFRACTION: boolean;
  106545. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106546. SS_ALBEDOFORREFRACTIONTINT: boolean;
  106547. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106548. /** @hidden */
  106549. _areTexturesDirty: boolean;
  106550. }
  106551. /**
  106552. * Define the code related to the sub surface parameters of the pbr material.
  106553. */
  106554. export class PBRSubSurfaceConfiguration {
  106555. private _isRefractionEnabled;
  106556. /**
  106557. * Defines if the refraction is enabled in the material.
  106558. */
  106559. isRefractionEnabled: boolean;
  106560. private _isTranslucencyEnabled;
  106561. /**
  106562. * Defines if the translucency is enabled in the material.
  106563. */
  106564. isTranslucencyEnabled: boolean;
  106565. private _isScatteringEnabled;
  106566. /**
  106567. * Defines if the sub surface scattering is enabled in the material.
  106568. */
  106569. isScatteringEnabled: boolean;
  106570. private _scatteringDiffusionProfileIndex;
  106571. /**
  106572. * Diffusion profile for subsurface scattering.
  106573. * Useful for better scattering in the skins or foliages.
  106574. */
  106575. get scatteringDiffusionProfile(): Nullable<Color3>;
  106576. set scatteringDiffusionProfile(c: Nullable<Color3>);
  106577. /**
  106578. * Defines the refraction intensity of the material.
  106579. * The refraction when enabled replaces the Diffuse part of the material.
  106580. * The intensity helps transitionning between diffuse and refraction.
  106581. */
  106582. refractionIntensity: number;
  106583. /**
  106584. * Defines the translucency intensity of the material.
  106585. * When translucency has been enabled, this defines how much of the "translucency"
  106586. * is addded to the diffuse part of the material.
  106587. */
  106588. translucencyIntensity: number;
  106589. /**
  106590. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  106591. */
  106592. useAlbedoToTintRefraction: boolean;
  106593. private _thicknessTexture;
  106594. /**
  106595. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  106596. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  106597. * 0 would mean minimumThickness
  106598. * 1 would mean maximumThickness
  106599. * The other channels might be use as a mask to vary the different effects intensity.
  106600. */
  106601. thicknessTexture: Nullable<BaseTexture>;
  106602. private _refractionTexture;
  106603. /**
  106604. * Defines the texture to use for refraction.
  106605. */
  106606. refractionTexture: Nullable<BaseTexture>;
  106607. private _indexOfRefraction;
  106608. /**
  106609. * Index of refraction of the material base layer.
  106610. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106611. *
  106612. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  106613. *
  106614. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  106615. */
  106616. indexOfRefraction: number;
  106617. private _volumeIndexOfRefraction;
  106618. /**
  106619. * Index of refraction of the material's volume.
  106620. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106621. *
  106622. * This ONLY impacts refraction. If not provided or given a non-valid value,
  106623. * the volume will use the same IOR as the surface.
  106624. */
  106625. get volumeIndexOfRefraction(): number;
  106626. set volumeIndexOfRefraction(value: number);
  106627. private _invertRefractionY;
  106628. /**
  106629. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  106630. */
  106631. invertRefractionY: boolean;
  106632. private _linkRefractionWithTransparency;
  106633. /**
  106634. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  106635. * Materials half opaque for instance using refraction could benefit from this control.
  106636. */
  106637. linkRefractionWithTransparency: boolean;
  106638. /**
  106639. * Defines the minimum thickness stored in the thickness map.
  106640. * If no thickness map is defined, this value will be used to simulate thickness.
  106641. */
  106642. minimumThickness: number;
  106643. /**
  106644. * Defines the maximum thickness stored in the thickness map.
  106645. */
  106646. maximumThickness: number;
  106647. /**
  106648. * Defines the volume tint of the material.
  106649. * This is used for both translucency and scattering.
  106650. */
  106651. tintColor: Color3;
  106652. /**
  106653. * Defines the distance at which the tint color should be found in the media.
  106654. * This is used for refraction only.
  106655. */
  106656. tintColorAtDistance: number;
  106657. /**
  106658. * Defines how far each channel transmit through the media.
  106659. * It is defined as a color to simplify it selection.
  106660. */
  106661. diffusionDistance: Color3;
  106662. private _useMaskFromThicknessTexture;
  106663. /**
  106664. * Stores the intensity of the different subsurface effects in the thickness texture.
  106665. * * the green channel is the translucency intensity.
  106666. * * the blue channel is the scattering intensity.
  106667. * * the alpha channel is the refraction intensity.
  106668. */
  106669. useMaskFromThicknessTexture: boolean;
  106670. private _scene;
  106671. /** @hidden */
  106672. private _internalMarkAllSubMeshesAsTexturesDirty;
  106673. private _internalMarkScenePrePassDirty;
  106674. /** @hidden */
  106675. _markAllSubMeshesAsTexturesDirty(): void;
  106676. /** @hidden */
  106677. _markScenePrePassDirty(): void;
  106678. /**
  106679. * Instantiate a new istance of sub surface configuration.
  106680. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106681. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  106682. * @param scene The scene
  106683. */
  106684. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  106685. /**
  106686. * Gets wehter the submesh is ready to be used or not.
  106687. * @param defines the list of "defines" to update.
  106688. * @param scene defines the scene the material belongs to.
  106689. * @returns - boolean indicating that the submesh is ready or not.
  106690. */
  106691. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  106692. /**
  106693. * Checks to see if a texture is used in the material.
  106694. * @param defines the list of "defines" to update.
  106695. * @param scene defines the scene to the material belongs to.
  106696. */
  106697. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  106698. /**
  106699. * Binds the material data.
  106700. * @param uniformBuffer defines the Uniform buffer to fill in.
  106701. * @param scene defines the scene the material belongs to.
  106702. * @param engine defines the engine the material belongs to.
  106703. * @param isFrozen defines whether the material is frozen or not.
  106704. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  106705. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  106706. */
  106707. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  106708. /**
  106709. * Unbinds the material from the mesh.
  106710. * @param activeEffect defines the effect that should be unbound from.
  106711. * @returns true if unbound, otherwise false
  106712. */
  106713. unbind(activeEffect: Effect): boolean;
  106714. /**
  106715. * Returns the texture used for refraction or null if none is used.
  106716. * @param scene defines the scene the material belongs to.
  106717. * @returns - Refraction texture if present. If no refraction texture and refraction
  106718. * is linked with transparency, returns environment texture. Otherwise, returns null.
  106719. */
  106720. private _getRefractionTexture;
  106721. /**
  106722. * Returns true if alpha blending should be disabled.
  106723. */
  106724. get disableAlphaBlending(): boolean;
  106725. /**
  106726. * Fills the list of render target textures.
  106727. * @param renderTargets the list of render targets to update
  106728. */
  106729. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  106730. /**
  106731. * Checks to see if a texture is used in the material.
  106732. * @param texture - Base texture to use.
  106733. * @returns - Boolean specifying if a texture is used in the material.
  106734. */
  106735. hasTexture(texture: BaseTexture): boolean;
  106736. /**
  106737. * Gets a boolean indicating that current material needs to register RTT
  106738. * @returns true if this uses a render target otherwise false.
  106739. */
  106740. hasRenderTargetTextures(): boolean;
  106741. /**
  106742. * Returns an array of the actively used textures.
  106743. * @param activeTextures Array of BaseTextures
  106744. */
  106745. getActiveTextures(activeTextures: BaseTexture[]): void;
  106746. /**
  106747. * Returns the animatable textures.
  106748. * @param animatables Array of animatable textures.
  106749. */
  106750. getAnimatables(animatables: IAnimatable[]): void;
  106751. /**
  106752. * Disposes the resources of the material.
  106753. * @param forceDisposeTextures - Forces the disposal of all textures.
  106754. */
  106755. dispose(forceDisposeTextures?: boolean): void;
  106756. /**
  106757. * Get the current class name of the texture useful for serialization or dynamic coding.
  106758. * @returns "PBRSubSurfaceConfiguration"
  106759. */
  106760. getClassName(): string;
  106761. /**
  106762. * Add fallbacks to the effect fallbacks list.
  106763. * @param defines defines the Base texture to use.
  106764. * @param fallbacks defines the current fallback list.
  106765. * @param currentRank defines the current fallback rank.
  106766. * @returns the new fallback rank.
  106767. */
  106768. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106769. /**
  106770. * Add the required uniforms to the current list.
  106771. * @param uniforms defines the current uniform list.
  106772. */
  106773. static AddUniforms(uniforms: string[]): void;
  106774. /**
  106775. * Add the required samplers to the current list.
  106776. * @param samplers defines the current sampler list.
  106777. */
  106778. static AddSamplers(samplers: string[]): void;
  106779. /**
  106780. * Add the required uniforms to the current buffer.
  106781. * @param uniformBuffer defines the current uniform buffer.
  106782. */
  106783. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106784. /**
  106785. * Makes a duplicate of the current configuration into another one.
  106786. * @param configuration define the config where to copy the info
  106787. */
  106788. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  106789. /**
  106790. * Serializes this Sub Surface configuration.
  106791. * @returns - An object with the serialized config.
  106792. */
  106793. serialize(): any;
  106794. /**
  106795. * Parses a anisotropy Configuration from a serialized object.
  106796. * @param source - Serialized object.
  106797. * @param scene Defines the scene we are parsing for
  106798. * @param rootUrl Defines the rootUrl to load from
  106799. */
  106800. parse(source: any, scene: Scene, rootUrl: string): void;
  106801. }
  106802. }
  106803. declare module BABYLON {
  106804. /**
  106805. * Class representing spherical harmonics coefficients to the 3rd degree
  106806. */
  106807. export class SphericalHarmonics {
  106808. /**
  106809. * Defines whether or not the harmonics have been prescaled for rendering.
  106810. */
  106811. preScaled: boolean;
  106812. /**
  106813. * The l0,0 coefficients of the spherical harmonics
  106814. */
  106815. l00: Vector3;
  106816. /**
  106817. * The l1,-1 coefficients of the spherical harmonics
  106818. */
  106819. l1_1: Vector3;
  106820. /**
  106821. * The l1,0 coefficients of the spherical harmonics
  106822. */
  106823. l10: Vector3;
  106824. /**
  106825. * The l1,1 coefficients of the spherical harmonics
  106826. */
  106827. l11: Vector3;
  106828. /**
  106829. * The l2,-2 coefficients of the spherical harmonics
  106830. */
  106831. l2_2: Vector3;
  106832. /**
  106833. * The l2,-1 coefficients of the spherical harmonics
  106834. */
  106835. l2_1: Vector3;
  106836. /**
  106837. * The l2,0 coefficients of the spherical harmonics
  106838. */
  106839. l20: Vector3;
  106840. /**
  106841. * The l2,1 coefficients of the spherical harmonics
  106842. */
  106843. l21: Vector3;
  106844. /**
  106845. * The l2,2 coefficients of the spherical harmonics
  106846. */
  106847. l22: Vector3;
  106848. /**
  106849. * Adds a light to the spherical harmonics
  106850. * @param direction the direction of the light
  106851. * @param color the color of the light
  106852. * @param deltaSolidAngle the delta solid angle of the light
  106853. */
  106854. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106855. /**
  106856. * Scales the spherical harmonics by the given amount
  106857. * @param scale the amount to scale
  106858. */
  106859. scaleInPlace(scale: number): void;
  106860. /**
  106861. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106862. *
  106863. * ```
  106864. * E_lm = A_l * L_lm
  106865. * ```
  106866. *
  106867. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106868. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106869. * the scaling factors are given in equation 9.
  106870. */
  106871. convertIncidentRadianceToIrradiance(): void;
  106872. /**
  106873. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106874. *
  106875. * ```
  106876. * L = (1/pi) * E * rho
  106877. * ```
  106878. *
  106879. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106880. */
  106881. convertIrradianceToLambertianRadiance(): void;
  106882. /**
  106883. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106884. * required operations at run time.
  106885. *
  106886. * This is simply done by scaling back the SH with Ylm constants parameter.
  106887. * The trigonometric part being applied by the shader at run time.
  106888. */
  106889. preScaleForRendering(): void;
  106890. /**
  106891. * Constructs a spherical harmonics from an array.
  106892. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106893. * @returns the spherical harmonics
  106894. */
  106895. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106896. /**
  106897. * Gets the spherical harmonics from polynomial
  106898. * @param polynomial the spherical polynomial
  106899. * @returns the spherical harmonics
  106900. */
  106901. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106902. }
  106903. /**
  106904. * Class representing spherical polynomial coefficients to the 3rd degree
  106905. */
  106906. export class SphericalPolynomial {
  106907. private _harmonics;
  106908. /**
  106909. * The spherical harmonics used to create the polynomials.
  106910. */
  106911. get preScaledHarmonics(): SphericalHarmonics;
  106912. /**
  106913. * The x coefficients of the spherical polynomial
  106914. */
  106915. x: Vector3;
  106916. /**
  106917. * The y coefficients of the spherical polynomial
  106918. */
  106919. y: Vector3;
  106920. /**
  106921. * The z coefficients of the spherical polynomial
  106922. */
  106923. z: Vector3;
  106924. /**
  106925. * The xx coefficients of the spherical polynomial
  106926. */
  106927. xx: Vector3;
  106928. /**
  106929. * The yy coefficients of the spherical polynomial
  106930. */
  106931. yy: Vector3;
  106932. /**
  106933. * The zz coefficients of the spherical polynomial
  106934. */
  106935. zz: Vector3;
  106936. /**
  106937. * The xy coefficients of the spherical polynomial
  106938. */
  106939. xy: Vector3;
  106940. /**
  106941. * The yz coefficients of the spherical polynomial
  106942. */
  106943. yz: Vector3;
  106944. /**
  106945. * The zx coefficients of the spherical polynomial
  106946. */
  106947. zx: Vector3;
  106948. /**
  106949. * Adds an ambient color to the spherical polynomial
  106950. * @param color the color to add
  106951. */
  106952. addAmbient(color: Color3): void;
  106953. /**
  106954. * Scales the spherical polynomial by the given amount
  106955. * @param scale the amount to scale
  106956. */
  106957. scaleInPlace(scale: number): void;
  106958. /**
  106959. * Gets the spherical polynomial from harmonics
  106960. * @param harmonics the spherical harmonics
  106961. * @returns the spherical polynomial
  106962. */
  106963. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106964. /**
  106965. * Constructs a spherical polynomial from an array.
  106966. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106967. * @returns the spherical polynomial
  106968. */
  106969. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106970. }
  106971. }
  106972. declare module BABYLON {
  106973. /**
  106974. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  106975. */
  106976. export interface CubeMapInfo {
  106977. /**
  106978. * The pixel array for the front face.
  106979. * This is stored in format, left to right, up to down format.
  106980. */
  106981. front: Nullable<ArrayBufferView>;
  106982. /**
  106983. * The pixel array for the back face.
  106984. * This is stored in format, left to right, up to down format.
  106985. */
  106986. back: Nullable<ArrayBufferView>;
  106987. /**
  106988. * The pixel array for the left face.
  106989. * This is stored in format, left to right, up to down format.
  106990. */
  106991. left: Nullable<ArrayBufferView>;
  106992. /**
  106993. * The pixel array for the right face.
  106994. * This is stored in format, left to right, up to down format.
  106995. */
  106996. right: Nullable<ArrayBufferView>;
  106997. /**
  106998. * The pixel array for the up face.
  106999. * This is stored in format, left to right, up to down format.
  107000. */
  107001. up: Nullable<ArrayBufferView>;
  107002. /**
  107003. * The pixel array for the down face.
  107004. * This is stored in format, left to right, up to down format.
  107005. */
  107006. down: Nullable<ArrayBufferView>;
  107007. /**
  107008. * The size of the cubemap stored.
  107009. *
  107010. * Each faces will be size * size pixels.
  107011. */
  107012. size: number;
  107013. /**
  107014. * The format of the texture.
  107015. *
  107016. * RGBA, RGB.
  107017. */
  107018. format: number;
  107019. /**
  107020. * The type of the texture data.
  107021. *
  107022. * UNSIGNED_INT, FLOAT.
  107023. */
  107024. type: number;
  107025. /**
  107026. * Specifies whether the texture is in gamma space.
  107027. */
  107028. gammaSpace: boolean;
  107029. }
  107030. /**
  107031. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  107032. */
  107033. export class PanoramaToCubeMapTools {
  107034. private static FACE_LEFT;
  107035. private static FACE_RIGHT;
  107036. private static FACE_FRONT;
  107037. private static FACE_BACK;
  107038. private static FACE_DOWN;
  107039. private static FACE_UP;
  107040. /**
  107041. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  107042. *
  107043. * @param float32Array The source data.
  107044. * @param inputWidth The width of the input panorama.
  107045. * @param inputHeight The height of the input panorama.
  107046. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  107047. * @return The cubemap data
  107048. */
  107049. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  107050. private static CreateCubemapTexture;
  107051. private static CalcProjectionSpherical;
  107052. }
  107053. }
  107054. declare module BABYLON {
  107055. /**
  107056. * Helper class dealing with the extraction of spherical polynomial dataArray
  107057. * from a cube map.
  107058. */
  107059. export class CubeMapToSphericalPolynomialTools {
  107060. private static FileFaces;
  107061. /**
  107062. * Converts a texture to the according Spherical Polynomial data.
  107063. * This extracts the first 3 orders only as they are the only one used in the lighting.
  107064. *
  107065. * @param texture The texture to extract the information from.
  107066. * @return The Spherical Polynomial data.
  107067. */
  107068. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  107069. /**
  107070. * Converts a cubemap to the according Spherical Polynomial data.
  107071. * This extracts the first 3 orders only as they are the only one used in the lighting.
  107072. *
  107073. * @param cubeInfo The Cube map to extract the information from.
  107074. * @return The Spherical Polynomial data.
  107075. */
  107076. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  107077. }
  107078. }
  107079. declare module BABYLON {
  107080. interface BaseTexture {
  107081. /**
  107082. * Get the polynomial representation of the texture data.
  107083. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  107084. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  107085. */
  107086. sphericalPolynomial: Nullable<SphericalPolynomial>;
  107087. }
  107088. }
  107089. declare module BABYLON {
  107090. /** @hidden */
  107091. export var pbrFragmentDeclaration: {
  107092. name: string;
  107093. shader: string;
  107094. };
  107095. }
  107096. declare module BABYLON {
  107097. /** @hidden */
  107098. export var pbrUboDeclaration: {
  107099. name: string;
  107100. shader: string;
  107101. };
  107102. }
  107103. declare module BABYLON {
  107104. /** @hidden */
  107105. export var pbrFragmentExtraDeclaration: {
  107106. name: string;
  107107. shader: string;
  107108. };
  107109. }
  107110. declare module BABYLON {
  107111. /** @hidden */
  107112. export var pbrFragmentSamplersDeclaration: {
  107113. name: string;
  107114. shader: string;
  107115. };
  107116. }
  107117. declare module BABYLON {
  107118. /** @hidden */
  107119. export var subSurfaceScatteringFunctions: {
  107120. name: string;
  107121. shader: string;
  107122. };
  107123. }
  107124. declare module BABYLON {
  107125. /** @hidden */
  107126. export var importanceSampling: {
  107127. name: string;
  107128. shader: string;
  107129. };
  107130. }
  107131. declare module BABYLON {
  107132. /** @hidden */
  107133. export var pbrHelperFunctions: {
  107134. name: string;
  107135. shader: string;
  107136. };
  107137. }
  107138. declare module BABYLON {
  107139. /** @hidden */
  107140. export var harmonicsFunctions: {
  107141. name: string;
  107142. shader: string;
  107143. };
  107144. }
  107145. declare module BABYLON {
  107146. /** @hidden */
  107147. export var pbrDirectLightingSetupFunctions: {
  107148. name: string;
  107149. shader: string;
  107150. };
  107151. }
  107152. declare module BABYLON {
  107153. /** @hidden */
  107154. export var pbrDirectLightingFalloffFunctions: {
  107155. name: string;
  107156. shader: string;
  107157. };
  107158. }
  107159. declare module BABYLON {
  107160. /** @hidden */
  107161. export var pbrBRDFFunctions: {
  107162. name: string;
  107163. shader: string;
  107164. };
  107165. }
  107166. declare module BABYLON {
  107167. /** @hidden */
  107168. export var hdrFilteringFunctions: {
  107169. name: string;
  107170. shader: string;
  107171. };
  107172. }
  107173. declare module BABYLON {
  107174. /** @hidden */
  107175. export var pbrDirectLightingFunctions: {
  107176. name: string;
  107177. shader: string;
  107178. };
  107179. }
  107180. declare module BABYLON {
  107181. /** @hidden */
  107182. export var pbrIBLFunctions: {
  107183. name: string;
  107184. shader: string;
  107185. };
  107186. }
  107187. declare module BABYLON {
  107188. /** @hidden */
  107189. export var pbrBlockAlbedoOpacity: {
  107190. name: string;
  107191. shader: string;
  107192. };
  107193. }
  107194. declare module BABYLON {
  107195. /** @hidden */
  107196. export var pbrBlockReflectivity: {
  107197. name: string;
  107198. shader: string;
  107199. };
  107200. }
  107201. declare module BABYLON {
  107202. /** @hidden */
  107203. export var pbrBlockAmbientOcclusion: {
  107204. name: string;
  107205. shader: string;
  107206. };
  107207. }
  107208. declare module BABYLON {
  107209. /** @hidden */
  107210. export var pbrBlockAlphaFresnel: {
  107211. name: string;
  107212. shader: string;
  107213. };
  107214. }
  107215. declare module BABYLON {
  107216. /** @hidden */
  107217. export var pbrBlockAnisotropic: {
  107218. name: string;
  107219. shader: string;
  107220. };
  107221. }
  107222. declare module BABYLON {
  107223. /** @hidden */
  107224. export var pbrBlockReflection: {
  107225. name: string;
  107226. shader: string;
  107227. };
  107228. }
  107229. declare module BABYLON {
  107230. /** @hidden */
  107231. export var pbrBlockSheen: {
  107232. name: string;
  107233. shader: string;
  107234. };
  107235. }
  107236. declare module BABYLON {
  107237. /** @hidden */
  107238. export var pbrBlockClearcoat: {
  107239. name: string;
  107240. shader: string;
  107241. };
  107242. }
  107243. declare module BABYLON {
  107244. /** @hidden */
  107245. export var pbrBlockSubSurface: {
  107246. name: string;
  107247. shader: string;
  107248. };
  107249. }
  107250. declare module BABYLON {
  107251. /** @hidden */
  107252. export var pbrBlockNormalGeometric: {
  107253. name: string;
  107254. shader: string;
  107255. };
  107256. }
  107257. declare module BABYLON {
  107258. /** @hidden */
  107259. export var pbrBlockNormalFinal: {
  107260. name: string;
  107261. shader: string;
  107262. };
  107263. }
  107264. declare module BABYLON {
  107265. /** @hidden */
  107266. export var pbrBlockLightmapInit: {
  107267. name: string;
  107268. shader: string;
  107269. };
  107270. }
  107271. declare module BABYLON {
  107272. /** @hidden */
  107273. export var pbrBlockGeometryInfo: {
  107274. name: string;
  107275. shader: string;
  107276. };
  107277. }
  107278. declare module BABYLON {
  107279. /** @hidden */
  107280. export var pbrBlockReflectance0: {
  107281. name: string;
  107282. shader: string;
  107283. };
  107284. }
  107285. declare module BABYLON {
  107286. /** @hidden */
  107287. export var pbrBlockReflectance: {
  107288. name: string;
  107289. shader: string;
  107290. };
  107291. }
  107292. declare module BABYLON {
  107293. /** @hidden */
  107294. export var pbrBlockDirectLighting: {
  107295. name: string;
  107296. shader: string;
  107297. };
  107298. }
  107299. declare module BABYLON {
  107300. /** @hidden */
  107301. export var pbrBlockFinalLitComponents: {
  107302. name: string;
  107303. shader: string;
  107304. };
  107305. }
  107306. declare module BABYLON {
  107307. /** @hidden */
  107308. export var pbrBlockFinalUnlitComponents: {
  107309. name: string;
  107310. shader: string;
  107311. };
  107312. }
  107313. declare module BABYLON {
  107314. /** @hidden */
  107315. export var pbrBlockFinalColorComposition: {
  107316. name: string;
  107317. shader: string;
  107318. };
  107319. }
  107320. declare module BABYLON {
  107321. /** @hidden */
  107322. export var pbrBlockImageProcessing: {
  107323. name: string;
  107324. shader: string;
  107325. };
  107326. }
  107327. declare module BABYLON {
  107328. /** @hidden */
  107329. export var pbrDebug: {
  107330. name: string;
  107331. shader: string;
  107332. };
  107333. }
  107334. declare module BABYLON {
  107335. /** @hidden */
  107336. export var pbrPixelShader: {
  107337. name: string;
  107338. shader: string;
  107339. };
  107340. }
  107341. declare module BABYLON {
  107342. /** @hidden */
  107343. export var pbrVertexDeclaration: {
  107344. name: string;
  107345. shader: string;
  107346. };
  107347. }
  107348. declare module BABYLON {
  107349. /** @hidden */
  107350. export var pbrVertexShader: {
  107351. name: string;
  107352. shader: string;
  107353. };
  107354. }
  107355. declare module BABYLON {
  107356. /**
  107357. * Manages the defines for the PBR Material.
  107358. * @hidden
  107359. */
  107360. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  107361. PBR: boolean;
  107362. NUM_SAMPLES: string;
  107363. REALTIME_FILTERING: boolean;
  107364. MAINUV1: boolean;
  107365. MAINUV2: boolean;
  107366. UV1: boolean;
  107367. UV2: boolean;
  107368. ALBEDO: boolean;
  107369. GAMMAALBEDO: boolean;
  107370. ALBEDODIRECTUV: number;
  107371. VERTEXCOLOR: boolean;
  107372. DETAIL: boolean;
  107373. DETAILDIRECTUV: number;
  107374. DETAIL_NORMALBLENDMETHOD: number;
  107375. AMBIENT: boolean;
  107376. AMBIENTDIRECTUV: number;
  107377. AMBIENTINGRAYSCALE: boolean;
  107378. OPACITY: boolean;
  107379. VERTEXALPHA: boolean;
  107380. OPACITYDIRECTUV: number;
  107381. OPACITYRGB: boolean;
  107382. ALPHATEST: boolean;
  107383. DEPTHPREPASS: boolean;
  107384. ALPHABLEND: boolean;
  107385. ALPHAFROMALBEDO: boolean;
  107386. ALPHATESTVALUE: string;
  107387. SPECULAROVERALPHA: boolean;
  107388. RADIANCEOVERALPHA: boolean;
  107389. ALPHAFRESNEL: boolean;
  107390. LINEARALPHAFRESNEL: boolean;
  107391. PREMULTIPLYALPHA: boolean;
  107392. EMISSIVE: boolean;
  107393. EMISSIVEDIRECTUV: number;
  107394. REFLECTIVITY: boolean;
  107395. REFLECTIVITYDIRECTUV: number;
  107396. SPECULARTERM: boolean;
  107397. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  107398. MICROSURFACEAUTOMATIC: boolean;
  107399. LODBASEDMICROSFURACE: boolean;
  107400. MICROSURFACEMAP: boolean;
  107401. MICROSURFACEMAPDIRECTUV: number;
  107402. METALLICWORKFLOW: boolean;
  107403. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  107404. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  107405. METALLNESSSTOREINMETALMAPBLUE: boolean;
  107406. AOSTOREINMETALMAPRED: boolean;
  107407. METALLIC_REFLECTANCE: boolean;
  107408. METALLIC_REFLECTANCEDIRECTUV: number;
  107409. ENVIRONMENTBRDF: boolean;
  107410. ENVIRONMENTBRDF_RGBD: boolean;
  107411. NORMAL: boolean;
  107412. TANGENT: boolean;
  107413. BUMP: boolean;
  107414. BUMPDIRECTUV: number;
  107415. OBJECTSPACE_NORMALMAP: boolean;
  107416. PARALLAX: boolean;
  107417. PARALLAXOCCLUSION: boolean;
  107418. NORMALXYSCALE: boolean;
  107419. LIGHTMAP: boolean;
  107420. LIGHTMAPDIRECTUV: number;
  107421. USELIGHTMAPASSHADOWMAP: boolean;
  107422. GAMMALIGHTMAP: boolean;
  107423. RGBDLIGHTMAP: boolean;
  107424. REFLECTION: boolean;
  107425. REFLECTIONMAP_3D: boolean;
  107426. REFLECTIONMAP_SPHERICAL: boolean;
  107427. REFLECTIONMAP_PLANAR: boolean;
  107428. REFLECTIONMAP_CUBIC: boolean;
  107429. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107430. REFLECTIONMAP_PROJECTION: boolean;
  107431. REFLECTIONMAP_SKYBOX: boolean;
  107432. REFLECTIONMAP_EXPLICIT: boolean;
  107433. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107434. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107435. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107436. INVERTCUBICMAP: boolean;
  107437. USESPHERICALFROMREFLECTIONMAP: boolean;
  107438. USEIRRADIANCEMAP: boolean;
  107439. SPHERICAL_HARMONICS: boolean;
  107440. USESPHERICALINVERTEX: boolean;
  107441. REFLECTIONMAP_OPPOSITEZ: boolean;
  107442. LODINREFLECTIONALPHA: boolean;
  107443. GAMMAREFLECTION: boolean;
  107444. RGBDREFLECTION: boolean;
  107445. LINEARSPECULARREFLECTION: boolean;
  107446. RADIANCEOCCLUSION: boolean;
  107447. HORIZONOCCLUSION: boolean;
  107448. INSTANCES: boolean;
  107449. THIN_INSTANCES: boolean;
  107450. PREPASS: boolean;
  107451. PREPASS_IRRADIANCE: boolean;
  107452. PREPASS_IRRADIANCE_INDEX: number;
  107453. PREPASS_ALBEDO: boolean;
  107454. PREPASS_ALBEDO_INDEX: number;
  107455. PREPASS_DEPTHNORMAL: boolean;
  107456. PREPASS_DEPTHNORMAL_INDEX: number;
  107457. PREPASS_POSITION: boolean;
  107458. PREPASS_POSITION_INDEX: number;
  107459. PREPASS_VELOCITY: boolean;
  107460. PREPASS_VELOCITY_INDEX: number;
  107461. PREPASS_REFLECTIVITY: boolean;
  107462. PREPASS_REFLECTIVITY_INDEX: number;
  107463. SCENE_MRT_COUNT: number;
  107464. NUM_BONE_INFLUENCERS: number;
  107465. BonesPerMesh: number;
  107466. BONETEXTURE: boolean;
  107467. BONES_VELOCITY_ENABLED: boolean;
  107468. NONUNIFORMSCALING: boolean;
  107469. MORPHTARGETS: boolean;
  107470. MORPHTARGETS_NORMAL: boolean;
  107471. MORPHTARGETS_TANGENT: boolean;
  107472. MORPHTARGETS_UV: boolean;
  107473. NUM_MORPH_INFLUENCERS: number;
  107474. IMAGEPROCESSING: boolean;
  107475. VIGNETTE: boolean;
  107476. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107477. VIGNETTEBLENDMODEOPAQUE: boolean;
  107478. TONEMAPPING: boolean;
  107479. TONEMAPPING_ACES: boolean;
  107480. CONTRAST: boolean;
  107481. COLORCURVES: boolean;
  107482. COLORGRADING: boolean;
  107483. COLORGRADING3D: boolean;
  107484. SAMPLER3DGREENDEPTH: boolean;
  107485. SAMPLER3DBGRMAP: boolean;
  107486. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107487. EXPOSURE: boolean;
  107488. MULTIVIEW: boolean;
  107489. USEPHYSICALLIGHTFALLOFF: boolean;
  107490. USEGLTFLIGHTFALLOFF: boolean;
  107491. TWOSIDEDLIGHTING: boolean;
  107492. SHADOWFLOAT: boolean;
  107493. CLIPPLANE: boolean;
  107494. CLIPPLANE2: boolean;
  107495. CLIPPLANE3: boolean;
  107496. CLIPPLANE4: boolean;
  107497. CLIPPLANE5: boolean;
  107498. CLIPPLANE6: boolean;
  107499. POINTSIZE: boolean;
  107500. FOG: boolean;
  107501. LOGARITHMICDEPTH: boolean;
  107502. FORCENORMALFORWARD: boolean;
  107503. SPECULARAA: boolean;
  107504. CLEARCOAT: boolean;
  107505. CLEARCOAT_DEFAULTIOR: boolean;
  107506. CLEARCOAT_TEXTURE: boolean;
  107507. CLEARCOAT_TEXTURE_ROUGHNESS: boolean;
  107508. CLEARCOAT_TEXTUREDIRECTUV: number;
  107509. CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV: number;
  107510. CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  107511. CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  107512. CLEARCOAT_BUMP: boolean;
  107513. CLEARCOAT_BUMPDIRECTUV: number;
  107514. CLEARCOAT_REMAP_F0: boolean;
  107515. CLEARCOAT_TINT: boolean;
  107516. CLEARCOAT_TINT_TEXTURE: boolean;
  107517. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107518. ANISOTROPIC: boolean;
  107519. ANISOTROPIC_TEXTURE: boolean;
  107520. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107521. BRDF_V_HEIGHT_CORRELATED: boolean;
  107522. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107523. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  107524. SHEEN: boolean;
  107525. SHEEN_TEXTURE: boolean;
  107526. SHEEN_TEXTURE_ROUGHNESS: boolean;
  107527. SHEEN_TEXTUREDIRECTUV: number;
  107528. SHEEN_TEXTURE_ROUGHNESSDIRECTUV: number;
  107529. SHEEN_LINKWITHALBEDO: boolean;
  107530. SHEEN_ROUGHNESS: boolean;
  107531. SHEEN_ALBEDOSCALING: boolean;
  107532. SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE: boolean;
  107533. SHEEN_TEXTURE_ROUGHNESS_IDENTICAL: boolean;
  107534. SUBSURFACE: boolean;
  107535. SS_REFRACTION: boolean;
  107536. SS_TRANSLUCENCY: boolean;
  107537. SS_SCATTERING: boolean;
  107538. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107539. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107540. SS_REFRACTIONMAP_3D: boolean;
  107541. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107542. SS_LODINREFRACTIONALPHA: boolean;
  107543. SS_GAMMAREFRACTION: boolean;
  107544. SS_RGBDREFRACTION: boolean;
  107545. SS_LINEARSPECULARREFRACTION: boolean;
  107546. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107547. SS_ALBEDOFORREFRACTIONTINT: boolean;
  107548. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107549. UNLIT: boolean;
  107550. DEBUGMODE: number;
  107551. /**
  107552. * Initializes the PBR Material defines.
  107553. */
  107554. constructor();
  107555. /**
  107556. * Resets the PBR Material defines.
  107557. */
  107558. reset(): void;
  107559. }
  107560. /**
  107561. * The Physically based material base class of BJS.
  107562. *
  107563. * This offers the main features of a standard PBR material.
  107564. * For more information, please refer to the documentation :
  107565. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107566. */
  107567. export abstract class PBRBaseMaterial extends PushMaterial {
  107568. /**
  107569. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107570. */
  107571. static readonly PBRMATERIAL_OPAQUE: number;
  107572. /**
  107573. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107574. */
  107575. static readonly PBRMATERIAL_ALPHATEST: number;
  107576. /**
  107577. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107578. */
  107579. static readonly PBRMATERIAL_ALPHABLEND: number;
  107580. /**
  107581. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107582. * They are also discarded below the alpha cutoff threshold to improve performances.
  107583. */
  107584. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107585. /**
  107586. * Defines the default value of how much AO map is occluding the analytical lights
  107587. * (point spot...).
  107588. */
  107589. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107590. /**
  107591. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  107592. */
  107593. static readonly LIGHTFALLOFF_PHYSICAL: number;
  107594. /**
  107595. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  107596. * to enhance interoperability with other engines.
  107597. */
  107598. static readonly LIGHTFALLOFF_GLTF: number;
  107599. /**
  107600. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  107601. * to enhance interoperability with other materials.
  107602. */
  107603. static readonly LIGHTFALLOFF_STANDARD: number;
  107604. /**
  107605. * Intensity of the direct lights e.g. the four lights available in your scene.
  107606. * This impacts both the direct diffuse and specular highlights.
  107607. */
  107608. protected _directIntensity: number;
  107609. /**
  107610. * Intensity of the emissive part of the material.
  107611. * This helps controlling the emissive effect without modifying the emissive color.
  107612. */
  107613. protected _emissiveIntensity: number;
  107614. /**
  107615. * Intensity of the environment e.g. how much the environment will light the object
  107616. * either through harmonics for rough material or through the refelction for shiny ones.
  107617. */
  107618. protected _environmentIntensity: number;
  107619. /**
  107620. * This is a special control allowing the reduction of the specular highlights coming from the
  107621. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107622. */
  107623. protected _specularIntensity: number;
  107624. /**
  107625. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  107626. */
  107627. private _lightingInfos;
  107628. /**
  107629. * Debug Control allowing disabling the bump map on this material.
  107630. */
  107631. protected _disableBumpMap: boolean;
  107632. /**
  107633. * AKA Diffuse Texture in standard nomenclature.
  107634. */
  107635. protected _albedoTexture: Nullable<BaseTexture>;
  107636. /**
  107637. * AKA Occlusion Texture in other nomenclature.
  107638. */
  107639. protected _ambientTexture: Nullable<BaseTexture>;
  107640. /**
  107641. * AKA Occlusion Texture Intensity in other nomenclature.
  107642. */
  107643. protected _ambientTextureStrength: number;
  107644. /**
  107645. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107646. * 1 means it completely occludes it
  107647. * 0 mean it has no impact
  107648. */
  107649. protected _ambientTextureImpactOnAnalyticalLights: number;
  107650. /**
  107651. * Stores the alpha values in a texture.
  107652. */
  107653. protected _opacityTexture: Nullable<BaseTexture>;
  107654. /**
  107655. * Stores the reflection values in a texture.
  107656. */
  107657. protected _reflectionTexture: Nullable<BaseTexture>;
  107658. /**
  107659. * Stores the emissive values in a texture.
  107660. */
  107661. protected _emissiveTexture: Nullable<BaseTexture>;
  107662. /**
  107663. * AKA Specular texture in other nomenclature.
  107664. */
  107665. protected _reflectivityTexture: Nullable<BaseTexture>;
  107666. /**
  107667. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107668. */
  107669. protected _metallicTexture: Nullable<BaseTexture>;
  107670. /**
  107671. * Specifies the metallic scalar of the metallic/roughness workflow.
  107672. * Can also be used to scale the metalness values of the metallic texture.
  107673. */
  107674. protected _metallic: Nullable<number>;
  107675. /**
  107676. * Specifies the roughness scalar of the metallic/roughness workflow.
  107677. * Can also be used to scale the roughness values of the metallic texture.
  107678. */
  107679. protected _roughness: Nullable<number>;
  107680. /**
  107681. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  107682. * By default the indexOfrefraction is used to compute F0;
  107683. *
  107684. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  107685. *
  107686. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  107687. * F90 = metallicReflectanceColor;
  107688. */
  107689. protected _metallicF0Factor: number;
  107690. /**
  107691. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  107692. * By default the F90 is always 1;
  107693. *
  107694. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  107695. *
  107696. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  107697. * F90 = metallicReflectanceColor;
  107698. */
  107699. protected _metallicReflectanceColor: Color3;
  107700. /**
  107701. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  107702. * This is multiply against the scalar values defined in the material.
  107703. */
  107704. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  107705. /**
  107706. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107707. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107708. */
  107709. protected _microSurfaceTexture: Nullable<BaseTexture>;
  107710. /**
  107711. * Stores surface normal data used to displace a mesh in a texture.
  107712. */
  107713. protected _bumpTexture: Nullable<BaseTexture>;
  107714. /**
  107715. * Stores the pre-calculated light information of a mesh in a texture.
  107716. */
  107717. protected _lightmapTexture: Nullable<BaseTexture>;
  107718. /**
  107719. * The color of a material in ambient lighting.
  107720. */
  107721. protected _ambientColor: Color3;
  107722. /**
  107723. * AKA Diffuse Color in other nomenclature.
  107724. */
  107725. protected _albedoColor: Color3;
  107726. /**
  107727. * AKA Specular Color in other nomenclature.
  107728. */
  107729. protected _reflectivityColor: Color3;
  107730. /**
  107731. * The color applied when light is reflected from a material.
  107732. */
  107733. protected _reflectionColor: Color3;
  107734. /**
  107735. * The color applied when light is emitted from a material.
  107736. */
  107737. protected _emissiveColor: Color3;
  107738. /**
  107739. * AKA Glossiness in other nomenclature.
  107740. */
  107741. protected _microSurface: number;
  107742. /**
  107743. * Specifies that the material will use the light map as a show map.
  107744. */
  107745. protected _useLightmapAsShadowmap: boolean;
  107746. /**
  107747. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107748. * makes the reflect vector face the model (under horizon).
  107749. */
  107750. protected _useHorizonOcclusion: boolean;
  107751. /**
  107752. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107753. * too much the area relying on ambient texture to define their ambient occlusion.
  107754. */
  107755. protected _useRadianceOcclusion: boolean;
  107756. /**
  107757. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107758. */
  107759. protected _useAlphaFromAlbedoTexture: boolean;
  107760. /**
  107761. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  107762. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107763. */
  107764. protected _useSpecularOverAlpha: boolean;
  107765. /**
  107766. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107767. */
  107768. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107769. /**
  107770. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107771. */
  107772. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107773. /**
  107774. * Specifies if the metallic texture contains the roughness information in its green channel.
  107775. */
  107776. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107777. /**
  107778. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107779. */
  107780. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107781. /**
  107782. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107783. */
  107784. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  107785. /**
  107786. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107787. */
  107788. protected _useAmbientInGrayScale: boolean;
  107789. /**
  107790. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107791. * The material will try to infer what glossiness each pixel should be.
  107792. */
  107793. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  107794. /**
  107795. * Defines the falloff type used in this material.
  107796. * It by default is Physical.
  107797. */
  107798. protected _lightFalloff: number;
  107799. /**
  107800. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107801. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107802. */
  107803. protected _useRadianceOverAlpha: boolean;
  107804. /**
  107805. * Allows using an object space normal map (instead of tangent space).
  107806. */
  107807. protected _useObjectSpaceNormalMap: boolean;
  107808. /**
  107809. * Allows using the bump map in parallax mode.
  107810. */
  107811. protected _useParallax: boolean;
  107812. /**
  107813. * Allows using the bump map in parallax occlusion mode.
  107814. */
  107815. protected _useParallaxOcclusion: boolean;
  107816. /**
  107817. * Controls the scale bias of the parallax mode.
  107818. */
  107819. protected _parallaxScaleBias: number;
  107820. /**
  107821. * If sets to true, disables all the lights affecting the material.
  107822. */
  107823. protected _disableLighting: boolean;
  107824. /**
  107825. * Number of Simultaneous lights allowed on the material.
  107826. */
  107827. protected _maxSimultaneousLights: number;
  107828. /**
  107829. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107830. */
  107831. protected _invertNormalMapX: boolean;
  107832. /**
  107833. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107834. */
  107835. protected _invertNormalMapY: boolean;
  107836. /**
  107837. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107838. */
  107839. protected _twoSidedLighting: boolean;
  107840. /**
  107841. * Defines the alpha limits in alpha test mode.
  107842. */
  107843. protected _alphaCutOff: number;
  107844. /**
  107845. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107846. */
  107847. protected _forceAlphaTest: boolean;
  107848. /**
  107849. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107850. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107851. */
  107852. protected _useAlphaFresnel: boolean;
  107853. /**
  107854. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107855. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107856. */
  107857. protected _useLinearAlphaFresnel: boolean;
  107858. /**
  107859. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  107860. * from cos thetav and roughness:
  107861. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107862. */
  107863. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107864. /**
  107865. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107866. */
  107867. protected _forceIrradianceInFragment: boolean;
  107868. private _realTimeFiltering;
  107869. /**
  107870. * Enables realtime filtering on the texture.
  107871. */
  107872. get realTimeFiltering(): boolean;
  107873. set realTimeFiltering(b: boolean);
  107874. private _realTimeFilteringQuality;
  107875. /**
  107876. * Quality switch for realtime filtering
  107877. */
  107878. get realTimeFilteringQuality(): number;
  107879. set realTimeFilteringQuality(n: number);
  107880. /**
  107881. * Can this material render to several textures at once
  107882. */
  107883. get canRenderToMRT(): boolean;
  107884. /**
  107885. * Force normal to face away from face.
  107886. */
  107887. protected _forceNormalForward: boolean;
  107888. /**
  107889. * Enables specular anti aliasing in the PBR shader.
  107890. * It will both interacts on the Geometry for analytical and IBL lighting.
  107891. * It also prefilter the roughness map based on the bump values.
  107892. */
  107893. protected _enableSpecularAntiAliasing: boolean;
  107894. /**
  107895. * Default configuration related to image processing available in the PBR Material.
  107896. */
  107897. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107898. /**
  107899. * Keep track of the image processing observer to allow dispose and replace.
  107900. */
  107901. private _imageProcessingObserver;
  107902. /**
  107903. * Attaches a new image processing configuration to the PBR Material.
  107904. * @param configuration
  107905. */
  107906. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107907. /**
  107908. * Stores the available render targets.
  107909. */
  107910. private _renderTargets;
  107911. /**
  107912. * Sets the global ambient color for the material used in lighting calculations.
  107913. */
  107914. private _globalAmbientColor;
  107915. /**
  107916. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107917. */
  107918. private _useLogarithmicDepth;
  107919. /**
  107920. * If set to true, no lighting calculations will be applied.
  107921. */
  107922. private _unlit;
  107923. private _debugMode;
  107924. /**
  107925. * @hidden
  107926. * This is reserved for the inspector.
  107927. * Defines the material debug mode.
  107928. * It helps seeing only some components of the material while troubleshooting.
  107929. */
  107930. debugMode: number;
  107931. /**
  107932. * @hidden
  107933. * This is reserved for the inspector.
  107934. * Specify from where on screen the debug mode should start.
  107935. * The value goes from -1 (full screen) to 1 (not visible)
  107936. * It helps with side by side comparison against the final render
  107937. * This defaults to -1
  107938. */
  107939. private debugLimit;
  107940. /**
  107941. * @hidden
  107942. * This is reserved for the inspector.
  107943. * As the default viewing range might not be enough (if the ambient is really small for instance)
  107944. * You can use the factor to better multiply the final value.
  107945. */
  107946. private debugFactor;
  107947. /**
  107948. * Defines the clear coat layer parameters for the material.
  107949. */
  107950. readonly clearCoat: PBRClearCoatConfiguration;
  107951. /**
  107952. * Defines the anisotropic parameters for the material.
  107953. */
  107954. readonly anisotropy: PBRAnisotropicConfiguration;
  107955. /**
  107956. * Defines the BRDF parameters for the material.
  107957. */
  107958. readonly brdf: PBRBRDFConfiguration;
  107959. /**
  107960. * Defines the Sheen parameters for the material.
  107961. */
  107962. readonly sheen: PBRSheenConfiguration;
  107963. /**
  107964. * Defines the SubSurface parameters for the material.
  107965. */
  107966. readonly subSurface: PBRSubSurfaceConfiguration;
  107967. /**
  107968. * Defines additionnal PrePass parameters for the material.
  107969. */
  107970. readonly prePassConfiguration: PrePassConfiguration;
  107971. /**
  107972. * Defines the detail map parameters for the material.
  107973. */
  107974. readonly detailMap: DetailMapConfiguration;
  107975. protected _rebuildInParallel: boolean;
  107976. /**
  107977. * Instantiates a new PBRMaterial instance.
  107978. *
  107979. * @param name The material name
  107980. * @param scene The scene the material will be use in.
  107981. */
  107982. constructor(name: string, scene: Scene);
  107983. /**
  107984. * Gets a boolean indicating that current material needs to register RTT
  107985. */
  107986. get hasRenderTargetTextures(): boolean;
  107987. /**
  107988. * Gets the name of the material class.
  107989. */
  107990. getClassName(): string;
  107991. /**
  107992. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107993. */
  107994. get useLogarithmicDepth(): boolean;
  107995. /**
  107996. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107997. */
  107998. set useLogarithmicDepth(value: boolean);
  107999. /**
  108000. * Returns true if alpha blending should be disabled.
  108001. */
  108002. protected get _disableAlphaBlending(): boolean;
  108003. /**
  108004. * Specifies whether or not this material should be rendered in alpha blend mode.
  108005. */
  108006. needAlphaBlending(): boolean;
  108007. /**
  108008. * Specifies whether or not this material should be rendered in alpha test mode.
  108009. */
  108010. needAlphaTesting(): boolean;
  108011. /**
  108012. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  108013. */
  108014. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  108015. /**
  108016. * Specifies whether or not there is a usable alpha channel for transparency.
  108017. */
  108018. protected _hasAlphaChannel(): boolean;
  108019. /**
  108020. * Gets the texture used for the alpha test.
  108021. */
  108022. getAlphaTestTexture(): Nullable<BaseTexture>;
  108023. /**
  108024. * Specifies that the submesh is ready to be used.
  108025. * @param mesh - BJS mesh.
  108026. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  108027. * @param useInstances - Specifies that instances should be used.
  108028. * @returns - boolean indicating that the submesh is ready or not.
  108029. */
  108030. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108031. /**
  108032. * Specifies if the material uses metallic roughness workflow.
  108033. * @returns boolean specifiying if the material uses metallic roughness workflow.
  108034. */
  108035. isMetallicWorkflow(): boolean;
  108036. private _prepareEffect;
  108037. private _prepareDefines;
  108038. /**
  108039. * Force shader compilation
  108040. */
  108041. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  108042. /**
  108043. * Initializes the uniform buffer layout for the shader.
  108044. */
  108045. buildUniformLayout(): void;
  108046. /**
  108047. * Unbinds the material from the mesh
  108048. */
  108049. unbind(): void;
  108050. /**
  108051. * Binds the submesh data.
  108052. * @param world - The world matrix.
  108053. * @param mesh - The BJS mesh.
  108054. * @param subMesh - A submesh of the BJS mesh.
  108055. */
  108056. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108057. /**
  108058. * Returns the animatable textures.
  108059. * @returns - Array of animatable textures.
  108060. */
  108061. getAnimatables(): IAnimatable[];
  108062. /**
  108063. * Returns the texture used for reflections.
  108064. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  108065. */
  108066. private _getReflectionTexture;
  108067. /**
  108068. * Returns an array of the actively used textures.
  108069. * @returns - Array of BaseTextures
  108070. */
  108071. getActiveTextures(): BaseTexture[];
  108072. /**
  108073. * Checks to see if a texture is used in the material.
  108074. * @param texture - Base texture to use.
  108075. * @returns - Boolean specifying if a texture is used in the material.
  108076. */
  108077. hasTexture(texture: BaseTexture): boolean;
  108078. /**
  108079. * Sets the required values to the prepass renderer.
  108080. * @param prePassRenderer defines the prepass renderer to setup
  108081. */
  108082. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  108083. /**
  108084. * Disposes the resources of the material.
  108085. * @param forceDisposeEffect - Forces the disposal of effects.
  108086. * @param forceDisposeTextures - Forces the disposal of all textures.
  108087. */
  108088. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108089. }
  108090. }
  108091. declare module BABYLON {
  108092. /**
  108093. * The Physically based material of BJS.
  108094. *
  108095. * This offers the main features of a standard PBR material.
  108096. * For more information, please refer to the documentation :
  108097. * https://doc.babylonjs.com/how_to/physically_based_rendering
  108098. */
  108099. export class PBRMaterial extends PBRBaseMaterial {
  108100. /**
  108101. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  108102. */
  108103. static readonly PBRMATERIAL_OPAQUE: number;
  108104. /**
  108105. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  108106. */
  108107. static readonly PBRMATERIAL_ALPHATEST: number;
  108108. /**
  108109. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108110. */
  108111. static readonly PBRMATERIAL_ALPHABLEND: number;
  108112. /**
  108113. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  108114. * They are also discarded below the alpha cutoff threshold to improve performances.
  108115. */
  108116. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  108117. /**
  108118. * Defines the default value of how much AO map is occluding the analytical lights
  108119. * (point spot...).
  108120. */
  108121. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  108122. /**
  108123. * Intensity of the direct lights e.g. the four lights available in your scene.
  108124. * This impacts both the direct diffuse and specular highlights.
  108125. */
  108126. directIntensity: number;
  108127. /**
  108128. * Intensity of the emissive part of the material.
  108129. * This helps controlling the emissive effect without modifying the emissive color.
  108130. */
  108131. emissiveIntensity: number;
  108132. /**
  108133. * Intensity of the environment e.g. how much the environment will light the object
  108134. * either through harmonics for rough material or through the refelction for shiny ones.
  108135. */
  108136. environmentIntensity: number;
  108137. /**
  108138. * This is a special control allowing the reduction of the specular highlights coming from the
  108139. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  108140. */
  108141. specularIntensity: number;
  108142. /**
  108143. * Debug Control allowing disabling the bump map on this material.
  108144. */
  108145. disableBumpMap: boolean;
  108146. /**
  108147. * AKA Diffuse Texture in standard nomenclature.
  108148. */
  108149. albedoTexture: BaseTexture;
  108150. /**
  108151. * AKA Occlusion Texture in other nomenclature.
  108152. */
  108153. ambientTexture: BaseTexture;
  108154. /**
  108155. * AKA Occlusion Texture Intensity in other nomenclature.
  108156. */
  108157. ambientTextureStrength: number;
  108158. /**
  108159. * Defines how much the AO map is occluding the analytical lights (point spot...).
  108160. * 1 means it completely occludes it
  108161. * 0 mean it has no impact
  108162. */
  108163. ambientTextureImpactOnAnalyticalLights: number;
  108164. /**
  108165. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  108166. */
  108167. opacityTexture: BaseTexture;
  108168. /**
  108169. * Stores the reflection values in a texture.
  108170. */
  108171. reflectionTexture: Nullable<BaseTexture>;
  108172. /**
  108173. * Stores the emissive values in a texture.
  108174. */
  108175. emissiveTexture: BaseTexture;
  108176. /**
  108177. * AKA Specular texture in other nomenclature.
  108178. */
  108179. reflectivityTexture: BaseTexture;
  108180. /**
  108181. * Used to switch from specular/glossiness to metallic/roughness workflow.
  108182. */
  108183. metallicTexture: BaseTexture;
  108184. /**
  108185. * Specifies the metallic scalar of the metallic/roughness workflow.
  108186. * Can also be used to scale the metalness values of the metallic texture.
  108187. */
  108188. metallic: Nullable<number>;
  108189. /**
  108190. * Specifies the roughness scalar of the metallic/roughness workflow.
  108191. * Can also be used to scale the roughness values of the metallic texture.
  108192. */
  108193. roughness: Nullable<number>;
  108194. /**
  108195. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  108196. * By default the indexOfrefraction is used to compute F0;
  108197. *
  108198. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  108199. *
  108200. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  108201. * F90 = metallicReflectanceColor;
  108202. */
  108203. metallicF0Factor: number;
  108204. /**
  108205. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  108206. * By default the F90 is always 1;
  108207. *
  108208. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  108209. *
  108210. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  108211. * F90 = metallicReflectanceColor;
  108212. */
  108213. metallicReflectanceColor: Color3;
  108214. /**
  108215. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  108216. * This is multiply against the scalar values defined in the material.
  108217. */
  108218. metallicReflectanceTexture: Nullable<BaseTexture>;
  108219. /**
  108220. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  108221. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  108222. */
  108223. microSurfaceTexture: BaseTexture;
  108224. /**
  108225. * Stores surface normal data used to displace a mesh in a texture.
  108226. */
  108227. bumpTexture: BaseTexture;
  108228. /**
  108229. * Stores the pre-calculated light information of a mesh in a texture.
  108230. */
  108231. lightmapTexture: BaseTexture;
  108232. /**
  108233. * Stores the refracted light information in a texture.
  108234. */
  108235. get refractionTexture(): Nullable<BaseTexture>;
  108236. set refractionTexture(value: Nullable<BaseTexture>);
  108237. /**
  108238. * The color of a material in ambient lighting.
  108239. */
  108240. ambientColor: Color3;
  108241. /**
  108242. * AKA Diffuse Color in other nomenclature.
  108243. */
  108244. albedoColor: Color3;
  108245. /**
  108246. * AKA Specular Color in other nomenclature.
  108247. */
  108248. reflectivityColor: Color3;
  108249. /**
  108250. * The color reflected from the material.
  108251. */
  108252. reflectionColor: Color3;
  108253. /**
  108254. * The color emitted from the material.
  108255. */
  108256. emissiveColor: Color3;
  108257. /**
  108258. * AKA Glossiness in other nomenclature.
  108259. */
  108260. microSurface: number;
  108261. /**
  108262. * Index of refraction of the material base layer.
  108263. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  108264. *
  108265. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  108266. *
  108267. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  108268. */
  108269. get indexOfRefraction(): number;
  108270. set indexOfRefraction(value: number);
  108271. /**
  108272. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108273. */
  108274. get invertRefractionY(): boolean;
  108275. set invertRefractionY(value: boolean);
  108276. /**
  108277. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108278. * Materials half opaque for instance using refraction could benefit from this control.
  108279. */
  108280. get linkRefractionWithTransparency(): boolean;
  108281. set linkRefractionWithTransparency(value: boolean);
  108282. /**
  108283. * If true, the light map contains occlusion information instead of lighting info.
  108284. */
  108285. useLightmapAsShadowmap: boolean;
  108286. /**
  108287. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108288. */
  108289. useAlphaFromAlbedoTexture: boolean;
  108290. /**
  108291. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108292. */
  108293. forceAlphaTest: boolean;
  108294. /**
  108295. * Defines the alpha limits in alpha test mode.
  108296. */
  108297. alphaCutOff: number;
  108298. /**
  108299. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108300. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108301. */
  108302. useSpecularOverAlpha: boolean;
  108303. /**
  108304. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108305. */
  108306. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108307. /**
  108308. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108309. */
  108310. useRoughnessFromMetallicTextureAlpha: boolean;
  108311. /**
  108312. * Specifies if the metallic texture contains the roughness information in its green channel.
  108313. */
  108314. useRoughnessFromMetallicTextureGreen: boolean;
  108315. /**
  108316. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108317. */
  108318. useMetallnessFromMetallicTextureBlue: boolean;
  108319. /**
  108320. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108321. */
  108322. useAmbientOcclusionFromMetallicTextureRed: boolean;
  108323. /**
  108324. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108325. */
  108326. useAmbientInGrayScale: boolean;
  108327. /**
  108328. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108329. * The material will try to infer what glossiness each pixel should be.
  108330. */
  108331. useAutoMicroSurfaceFromReflectivityMap: boolean;
  108332. /**
  108333. * BJS is using an harcoded light falloff based on a manually sets up range.
  108334. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108335. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108336. */
  108337. get usePhysicalLightFalloff(): boolean;
  108338. /**
  108339. * BJS is using an harcoded light falloff based on a manually sets up range.
  108340. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108341. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108342. */
  108343. set usePhysicalLightFalloff(value: boolean);
  108344. /**
  108345. * In order to support the falloff compatibility with gltf, a special mode has been added
  108346. * to reproduce the gltf light falloff.
  108347. */
  108348. get useGLTFLightFalloff(): boolean;
  108349. /**
  108350. * In order to support the falloff compatibility with gltf, a special mode has been added
  108351. * to reproduce the gltf light falloff.
  108352. */
  108353. set useGLTFLightFalloff(value: boolean);
  108354. /**
  108355. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108356. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108357. */
  108358. useRadianceOverAlpha: boolean;
  108359. /**
  108360. * Allows using an object space normal map (instead of tangent space).
  108361. */
  108362. useObjectSpaceNormalMap: boolean;
  108363. /**
  108364. * Allows using the bump map in parallax mode.
  108365. */
  108366. useParallax: boolean;
  108367. /**
  108368. * Allows using the bump map in parallax occlusion mode.
  108369. */
  108370. useParallaxOcclusion: boolean;
  108371. /**
  108372. * Controls the scale bias of the parallax mode.
  108373. */
  108374. parallaxScaleBias: number;
  108375. /**
  108376. * If sets to true, disables all the lights affecting the material.
  108377. */
  108378. disableLighting: boolean;
  108379. /**
  108380. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108381. */
  108382. forceIrradianceInFragment: boolean;
  108383. /**
  108384. * Number of Simultaneous lights allowed on the material.
  108385. */
  108386. maxSimultaneousLights: number;
  108387. /**
  108388. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108389. */
  108390. invertNormalMapX: boolean;
  108391. /**
  108392. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108393. */
  108394. invertNormalMapY: boolean;
  108395. /**
  108396. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108397. */
  108398. twoSidedLighting: boolean;
  108399. /**
  108400. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108401. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108402. */
  108403. useAlphaFresnel: boolean;
  108404. /**
  108405. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108406. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108407. */
  108408. useLinearAlphaFresnel: boolean;
  108409. /**
  108410. * Let user defines the brdf lookup texture used for IBL.
  108411. * A default 8bit version is embedded but you could point at :
  108412. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  108413. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108414. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  108415. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108416. */
  108417. environmentBRDFTexture: Nullable<BaseTexture>;
  108418. /**
  108419. * Force normal to face away from face.
  108420. */
  108421. forceNormalForward: boolean;
  108422. /**
  108423. * Enables specular anti aliasing in the PBR shader.
  108424. * It will both interacts on the Geometry for analytical and IBL lighting.
  108425. * It also prefilter the roughness map based on the bump values.
  108426. */
  108427. enableSpecularAntiAliasing: boolean;
  108428. /**
  108429. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108430. * makes the reflect vector face the model (under horizon).
  108431. */
  108432. useHorizonOcclusion: boolean;
  108433. /**
  108434. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108435. * too much the area relying on ambient texture to define their ambient occlusion.
  108436. */
  108437. useRadianceOcclusion: boolean;
  108438. /**
  108439. * If set to true, no lighting calculations will be applied.
  108440. */
  108441. unlit: boolean;
  108442. /**
  108443. * Gets the image processing configuration used either in this material.
  108444. */
  108445. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108446. /**
  108447. * Sets the Default image processing configuration used either in the this material.
  108448. *
  108449. * If sets to null, the scene one is in use.
  108450. */
  108451. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  108452. /**
  108453. * Gets wether the color curves effect is enabled.
  108454. */
  108455. get cameraColorCurvesEnabled(): boolean;
  108456. /**
  108457. * Sets wether the color curves effect is enabled.
  108458. */
  108459. set cameraColorCurvesEnabled(value: boolean);
  108460. /**
  108461. * Gets wether the color grading effect is enabled.
  108462. */
  108463. get cameraColorGradingEnabled(): boolean;
  108464. /**
  108465. * Gets wether the color grading effect is enabled.
  108466. */
  108467. set cameraColorGradingEnabled(value: boolean);
  108468. /**
  108469. * Gets wether tonemapping is enabled or not.
  108470. */
  108471. get cameraToneMappingEnabled(): boolean;
  108472. /**
  108473. * Sets wether tonemapping is enabled or not
  108474. */
  108475. set cameraToneMappingEnabled(value: boolean);
  108476. /**
  108477. * The camera exposure used on this material.
  108478. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108479. * This corresponds to a photographic exposure.
  108480. */
  108481. get cameraExposure(): number;
  108482. /**
  108483. * The camera exposure used on this material.
  108484. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108485. * This corresponds to a photographic exposure.
  108486. */
  108487. set cameraExposure(value: number);
  108488. /**
  108489. * Gets The camera contrast used on this material.
  108490. */
  108491. get cameraContrast(): number;
  108492. /**
  108493. * Sets The camera contrast used on this material.
  108494. */
  108495. set cameraContrast(value: number);
  108496. /**
  108497. * Gets the Color Grading 2D Lookup Texture.
  108498. */
  108499. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  108500. /**
  108501. * Sets the Color Grading 2D Lookup Texture.
  108502. */
  108503. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  108504. /**
  108505. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108506. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108507. * 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;
  108508. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108509. */
  108510. get cameraColorCurves(): Nullable<ColorCurves>;
  108511. /**
  108512. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108513. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108514. * 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;
  108515. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108516. */
  108517. set cameraColorCurves(value: Nullable<ColorCurves>);
  108518. /**
  108519. * Instantiates a new PBRMaterial instance.
  108520. *
  108521. * @param name The material name
  108522. * @param scene The scene the material will be use in.
  108523. */
  108524. constructor(name: string, scene: Scene);
  108525. /**
  108526. * Returns the name of this material class.
  108527. */
  108528. getClassName(): string;
  108529. /**
  108530. * Makes a duplicate of the current material.
  108531. * @param name - name to use for the new material.
  108532. */
  108533. clone(name: string): PBRMaterial;
  108534. /**
  108535. * Serializes this PBR Material.
  108536. * @returns - An object with the serialized material.
  108537. */
  108538. serialize(): any;
  108539. /**
  108540. * Parses a PBR Material from a serialized object.
  108541. * @param source - Serialized object.
  108542. * @param scene - BJS scene instance.
  108543. * @param rootUrl - url for the scene object
  108544. * @returns - PBRMaterial
  108545. */
  108546. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  108547. }
  108548. }
  108549. declare module BABYLON {
  108550. /** @hidden */
  108551. export var mrtFragmentDeclaration: {
  108552. name: string;
  108553. shader: string;
  108554. };
  108555. }
  108556. declare module BABYLON {
  108557. /** @hidden */
  108558. export var geometryPixelShader: {
  108559. name: string;
  108560. shader: string;
  108561. };
  108562. }
  108563. declare module BABYLON {
  108564. /** @hidden */
  108565. export var geometryVertexShader: {
  108566. name: string;
  108567. shader: string;
  108568. };
  108569. }
  108570. declare module BABYLON {
  108571. /** @hidden */
  108572. interface ISavedTransformationMatrix {
  108573. world: Matrix;
  108574. viewProjection: Matrix;
  108575. }
  108576. /**
  108577. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  108578. */
  108579. export class GeometryBufferRenderer {
  108580. /**
  108581. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  108582. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  108583. */
  108584. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  108585. /**
  108586. * Constant used to retrieve the position texture index in the G-Buffer textures array
  108587. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  108588. */
  108589. static readonly POSITION_TEXTURE_TYPE: number;
  108590. /**
  108591. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  108592. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  108593. */
  108594. static readonly VELOCITY_TEXTURE_TYPE: number;
  108595. /**
  108596. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  108597. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  108598. */
  108599. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  108600. /**
  108601. * Dictionary used to store the previous transformation matrices of each rendered mesh
  108602. * in order to compute objects velocities when enableVelocity is set to "true"
  108603. * @hidden
  108604. */
  108605. _previousTransformationMatrices: {
  108606. [index: number]: ISavedTransformationMatrix;
  108607. };
  108608. /**
  108609. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  108610. * in order to compute objects velocities when enableVelocity is set to "true"
  108611. * @hidden
  108612. */
  108613. _previousBonesTransformationMatrices: {
  108614. [index: number]: Float32Array;
  108615. };
  108616. /**
  108617. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  108618. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  108619. */
  108620. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  108621. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  108622. renderTransparentMeshes: boolean;
  108623. private _scene;
  108624. private _resizeObserver;
  108625. private _multiRenderTarget;
  108626. private _ratio;
  108627. private _enablePosition;
  108628. private _enableVelocity;
  108629. private _enableReflectivity;
  108630. private _positionIndex;
  108631. private _velocityIndex;
  108632. private _reflectivityIndex;
  108633. private _depthNormalIndex;
  108634. private _linkedWithPrePass;
  108635. private _prePassRenderer;
  108636. private _attachments;
  108637. protected _effect: Effect;
  108638. protected _cachedDefines: string;
  108639. /**
  108640. * @hidden
  108641. * Sets up internal structures to share outputs with PrePassRenderer
  108642. * This method should only be called by the PrePassRenderer itself
  108643. */
  108644. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  108645. /**
  108646. * @hidden
  108647. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  108648. * This method should only be called by the PrePassRenderer itself
  108649. */
  108650. _unlinkPrePassRenderer(): void;
  108651. /**
  108652. * @hidden
  108653. * Resets the geometry buffer layout
  108654. */
  108655. _resetLayout(): void;
  108656. /**
  108657. * @hidden
  108658. * Replaces a texture in the geometry buffer renderer
  108659. * Useful when linking textures of the prepass renderer
  108660. */
  108661. _forceTextureType(geometryBufferType: number, index: number): void;
  108662. /**
  108663. * @hidden
  108664. * Sets texture attachments
  108665. * Useful when linking textures of the prepass renderer
  108666. */
  108667. _setAttachments(attachments: number[]): void;
  108668. /**
  108669. * @hidden
  108670. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  108671. * Useful when linking textures of the prepass renderer
  108672. */
  108673. _linkInternalTexture(internalTexture: InternalTexture): void;
  108674. /**
  108675. * Gets the render list (meshes to be rendered) used in the G buffer.
  108676. */
  108677. get renderList(): Nullable<AbstractMesh[]>;
  108678. /**
  108679. * Set the render list (meshes to be rendered) used in the G buffer.
  108680. */
  108681. set renderList(meshes: Nullable<AbstractMesh[]>);
  108682. /**
  108683. * Gets wether or not G buffer are supported by the running hardware.
  108684. * This requires draw buffer supports
  108685. */
  108686. get isSupported(): boolean;
  108687. /**
  108688. * Returns the index of the given texture type in the G-Buffer textures array
  108689. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  108690. * @returns the index of the given texture type in the G-Buffer textures array
  108691. */
  108692. getTextureIndex(textureType: number): number;
  108693. /**
  108694. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  108695. */
  108696. get enablePosition(): boolean;
  108697. /**
  108698. * Sets whether or not objects positions are enabled for the G buffer.
  108699. */
  108700. set enablePosition(enable: boolean);
  108701. /**
  108702. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  108703. */
  108704. get enableVelocity(): boolean;
  108705. /**
  108706. * Sets wether or not objects velocities are enabled for the G buffer.
  108707. */
  108708. set enableVelocity(enable: boolean);
  108709. /**
  108710. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  108711. */
  108712. get enableReflectivity(): boolean;
  108713. /**
  108714. * Sets wether or not objects roughness are enabled for the G buffer.
  108715. */
  108716. set enableReflectivity(enable: boolean);
  108717. /**
  108718. * Gets the scene associated with the buffer.
  108719. */
  108720. get scene(): Scene;
  108721. /**
  108722. * Gets the ratio used by the buffer during its creation.
  108723. * How big is the buffer related to the main canvas.
  108724. */
  108725. get ratio(): number;
  108726. /** @hidden */
  108727. static _SceneComponentInitialization: (scene: Scene) => void;
  108728. /**
  108729. * Creates a new G Buffer for the scene
  108730. * @param scene The scene the buffer belongs to
  108731. * @param ratio How big is the buffer related to the main canvas.
  108732. */
  108733. constructor(scene: Scene, ratio?: number);
  108734. /**
  108735. * Checks wether everything is ready to render a submesh to the G buffer.
  108736. * @param subMesh the submesh to check readiness for
  108737. * @param useInstances is the mesh drawn using instance or not
  108738. * @returns true if ready otherwise false
  108739. */
  108740. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  108741. /**
  108742. * Gets the current underlying G Buffer.
  108743. * @returns the buffer
  108744. */
  108745. getGBuffer(): MultiRenderTarget;
  108746. /**
  108747. * Gets the number of samples used to render the buffer (anti aliasing).
  108748. */
  108749. get samples(): number;
  108750. /**
  108751. * Sets the number of samples used to render the buffer (anti aliasing).
  108752. */
  108753. set samples(value: number);
  108754. /**
  108755. * Disposes the renderer and frees up associated resources.
  108756. */
  108757. dispose(): void;
  108758. private _assignRenderTargetIndices;
  108759. protected _createRenderTargets(): void;
  108760. private _copyBonesTransformationMatrices;
  108761. }
  108762. }
  108763. declare module BABYLON {
  108764. /**
  108765. * Renders a pre pass of the scene
  108766. * This means every mesh in the scene will be rendered to a render target texture
  108767. * And then this texture will be composited to the rendering canvas with post processes
  108768. * It is necessary for effects like subsurface scattering or deferred shading
  108769. */
  108770. export class PrePassRenderer {
  108771. /** @hidden */
  108772. static _SceneComponentInitialization: (scene: Scene) => void;
  108773. private _textureFormats;
  108774. /**
  108775. * To save performance, we can excluded skinned meshes from the prepass
  108776. */
  108777. excludedSkinnedMesh: AbstractMesh[];
  108778. /**
  108779. * Force material to be excluded from the prepass
  108780. * Can be useful when `useGeometryBufferFallback` is set to `true`
  108781. * and you don't want a material to show in the effect.
  108782. */
  108783. excludedMaterials: Material[];
  108784. private _textureIndices;
  108785. private _scene;
  108786. private _engine;
  108787. private _isDirty;
  108788. /**
  108789. * Number of textures in the multi render target texture where the scene is directly rendered
  108790. */
  108791. mrtCount: number;
  108792. /**
  108793. * The render target where the scene is directly rendered
  108794. */
  108795. prePassRT: MultiRenderTarget;
  108796. private _multiRenderAttachments;
  108797. private _defaultAttachments;
  108798. private _clearAttachments;
  108799. private _postProcesses;
  108800. private readonly _clearColor;
  108801. /**
  108802. * Image processing post process for composition
  108803. */
  108804. imageProcessingPostProcess: ImageProcessingPostProcess;
  108805. /**
  108806. * Configuration for prepass effects
  108807. */
  108808. private _effectConfigurations;
  108809. private _mrtFormats;
  108810. private _mrtLayout;
  108811. private _enabled;
  108812. /**
  108813. * Indicates if the prepass is enabled
  108814. */
  108815. get enabled(): boolean;
  108816. /**
  108817. * How many samples are used for MSAA of the scene render target
  108818. */
  108819. get samples(): number;
  108820. set samples(n: number);
  108821. private _geometryBuffer;
  108822. private _useGeometryBufferFallback;
  108823. /**
  108824. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  108825. */
  108826. get useGeometryBufferFallback(): boolean;
  108827. set useGeometryBufferFallback(value: boolean);
  108828. /**
  108829. * Instanciates a prepass renderer
  108830. * @param scene The scene
  108831. */
  108832. constructor(scene: Scene);
  108833. private _initializeAttachments;
  108834. private _createCompositionEffect;
  108835. /**
  108836. * Indicates if rendering a prepass is supported
  108837. */
  108838. get isSupported(): boolean;
  108839. /**
  108840. * Sets the proper output textures to draw in the engine.
  108841. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  108842. * @param subMesh Submesh on which the effect is applied
  108843. */
  108844. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  108845. /**
  108846. * @hidden
  108847. */
  108848. _beforeCameraDraw(): void;
  108849. /**
  108850. * @hidden
  108851. */
  108852. _afterCameraDraw(): void;
  108853. private _checkRTSize;
  108854. private _bindFrameBuffer;
  108855. /**
  108856. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  108857. */
  108858. clear(): void;
  108859. private _setState;
  108860. private _updateGeometryBufferLayout;
  108861. /**
  108862. * Adds an effect configuration to the prepass.
  108863. * If an effect has already been added, it won't add it twice and will return the configuration
  108864. * already present.
  108865. * @param cfg the effect configuration
  108866. * @return the effect configuration now used by the prepass
  108867. */
  108868. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  108869. /**
  108870. * Returns the index of a texture in the multi render target texture array.
  108871. * @param type Texture type
  108872. * @return The index
  108873. */
  108874. getIndex(type: number): number;
  108875. private _enable;
  108876. private _disable;
  108877. private _resetLayout;
  108878. private _resetPostProcessChain;
  108879. private _bindPostProcessChain;
  108880. /**
  108881. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  108882. */
  108883. markAsDirty(): void;
  108884. /**
  108885. * Enables a texture on the MultiRenderTarget for prepass
  108886. */
  108887. private _enableTextures;
  108888. private _update;
  108889. private _markAllMaterialsAsPrePassDirty;
  108890. /**
  108891. * Disposes the prepass renderer.
  108892. */
  108893. dispose(): void;
  108894. }
  108895. }
  108896. declare module BABYLON {
  108897. /**
  108898. * Size options for a post process
  108899. */
  108900. export type PostProcessOptions = {
  108901. width: number;
  108902. height: number;
  108903. };
  108904. /**
  108905. * PostProcess can be used to apply a shader to a texture after it has been rendered
  108906. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  108907. */
  108908. export class PostProcess {
  108909. /**
  108910. * Gets or sets the unique id of the post process
  108911. */
  108912. uniqueId: number;
  108913. /** Name of the PostProcess. */
  108914. name: string;
  108915. /**
  108916. * Width of the texture to apply the post process on
  108917. */
  108918. width: number;
  108919. /**
  108920. * Height of the texture to apply the post process on
  108921. */
  108922. height: number;
  108923. /**
  108924. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  108925. */
  108926. nodeMaterialSource: Nullable<NodeMaterial>;
  108927. /**
  108928. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  108929. * @hidden
  108930. */
  108931. _outputTexture: Nullable<InternalTexture>;
  108932. /**
  108933. * Sampling mode used by the shader
  108934. * See https://doc.babylonjs.com/classes/3.1/texture
  108935. */
  108936. renderTargetSamplingMode: number;
  108937. /**
  108938. * Clear color to use when screen clearing
  108939. */
  108940. clearColor: Color4;
  108941. /**
  108942. * If the buffer needs to be cleared before applying the post process. (default: true)
  108943. * Should be set to false if shader will overwrite all previous pixels.
  108944. */
  108945. autoClear: boolean;
  108946. /**
  108947. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  108948. */
  108949. alphaMode: number;
  108950. /**
  108951. * Sets the setAlphaBlendConstants of the babylon engine
  108952. */
  108953. alphaConstants: Color4;
  108954. /**
  108955. * Animations to be used for the post processing
  108956. */
  108957. animations: Animation[];
  108958. /**
  108959. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  108960. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  108961. */
  108962. enablePixelPerfectMode: boolean;
  108963. /**
  108964. * Force the postprocess to be applied without taking in account viewport
  108965. */
  108966. forceFullscreenViewport: boolean;
  108967. /**
  108968. * List of inspectable custom properties (used by the Inspector)
  108969. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  108970. */
  108971. inspectableCustomProperties: IInspectable[];
  108972. /**
  108973. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  108974. *
  108975. * | Value | Type | Description |
  108976. * | ----- | ----------------------------------- | ----------- |
  108977. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  108978. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  108979. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  108980. *
  108981. */
  108982. scaleMode: number;
  108983. /**
  108984. * Force textures to be a power of two (default: false)
  108985. */
  108986. alwaysForcePOT: boolean;
  108987. private _samples;
  108988. /**
  108989. * Number of sample textures (default: 1)
  108990. */
  108991. get samples(): number;
  108992. set samples(n: number);
  108993. /**
  108994. * Modify the scale of the post process to be the same as the viewport (default: false)
  108995. */
  108996. adaptScaleToCurrentViewport: boolean;
  108997. private _camera;
  108998. protected _scene: Scene;
  108999. private _engine;
  109000. private _options;
  109001. private _reusable;
  109002. private _textureType;
  109003. private _textureFormat;
  109004. /**
  109005. * Smart array of input and output textures for the post process.
  109006. * @hidden
  109007. */
  109008. _textures: SmartArray<InternalTexture>;
  109009. /**
  109010. * The index in _textures that corresponds to the output texture.
  109011. * @hidden
  109012. */
  109013. _currentRenderTextureInd: number;
  109014. private _effect;
  109015. private _samplers;
  109016. private _fragmentUrl;
  109017. private _vertexUrl;
  109018. private _parameters;
  109019. private _scaleRatio;
  109020. protected _indexParameters: any;
  109021. private _shareOutputWithPostProcess;
  109022. private _texelSize;
  109023. private _forcedOutputTexture;
  109024. /**
  109025. * Prepass configuration in case this post process needs a texture from prepass
  109026. * @hidden
  109027. */
  109028. _prePassEffectConfiguration: PrePassEffectConfiguration;
  109029. /**
  109030. * Returns the fragment url or shader name used in the post process.
  109031. * @returns the fragment url or name in the shader store.
  109032. */
  109033. getEffectName(): string;
  109034. /**
  109035. * An event triggered when the postprocess is activated.
  109036. */
  109037. onActivateObservable: Observable<Camera>;
  109038. private _onActivateObserver;
  109039. /**
  109040. * A function that is added to the onActivateObservable
  109041. */
  109042. set onActivate(callback: Nullable<(camera: Camera) => void>);
  109043. /**
  109044. * An event triggered when the postprocess changes its size.
  109045. */
  109046. onSizeChangedObservable: Observable<PostProcess>;
  109047. private _onSizeChangedObserver;
  109048. /**
  109049. * A function that is added to the onSizeChangedObservable
  109050. */
  109051. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  109052. /**
  109053. * An event triggered when the postprocess applies its effect.
  109054. */
  109055. onApplyObservable: Observable<Effect>;
  109056. private _onApplyObserver;
  109057. /**
  109058. * A function that is added to the onApplyObservable
  109059. */
  109060. set onApply(callback: (effect: Effect) => void);
  109061. /**
  109062. * An event triggered before rendering the postprocess
  109063. */
  109064. onBeforeRenderObservable: Observable<Effect>;
  109065. private _onBeforeRenderObserver;
  109066. /**
  109067. * A function that is added to the onBeforeRenderObservable
  109068. */
  109069. set onBeforeRender(callback: (effect: Effect) => void);
  109070. /**
  109071. * An event triggered after rendering the postprocess
  109072. */
  109073. onAfterRenderObservable: Observable<Effect>;
  109074. private _onAfterRenderObserver;
  109075. /**
  109076. * A function that is added to the onAfterRenderObservable
  109077. */
  109078. set onAfterRender(callback: (efect: Effect) => void);
  109079. /**
  109080. * 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
  109081. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  109082. */
  109083. get inputTexture(): InternalTexture;
  109084. set inputTexture(value: InternalTexture);
  109085. /**
  109086. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  109087. * the only way to unset it is to use this function to restore its internal state
  109088. */
  109089. restoreDefaultInputTexture(): void;
  109090. /**
  109091. * Gets the camera which post process is applied to.
  109092. * @returns The camera the post process is applied to.
  109093. */
  109094. getCamera(): Camera;
  109095. /**
  109096. * Gets the texel size of the postprocess.
  109097. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  109098. */
  109099. get texelSize(): Vector2;
  109100. /**
  109101. * Creates a new instance PostProcess
  109102. * @param name The name of the PostProcess.
  109103. * @param fragmentUrl The url of the fragment shader to be used.
  109104. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  109105. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  109106. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  109107. * @param camera The camera to apply the render pass to.
  109108. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109109. * @param engine The engine which the post process will be applied. (default: current engine)
  109110. * @param reusable If the post process can be reused on the same frame. (default: false)
  109111. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  109112. * @param textureType Type of textures used when performing the post process. (default: 0)
  109113. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  109114. * @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
  109115. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  109116. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  109117. */
  109118. 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);
  109119. /**
  109120. * Gets a string identifying the name of the class
  109121. * @returns "PostProcess" string
  109122. */
  109123. getClassName(): string;
  109124. /**
  109125. * Gets the engine which this post process belongs to.
  109126. * @returns The engine the post process was enabled with.
  109127. */
  109128. getEngine(): Engine;
  109129. /**
  109130. * The effect that is created when initializing the post process.
  109131. * @returns The created effect corresponding the the postprocess.
  109132. */
  109133. getEffect(): Effect;
  109134. /**
  109135. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  109136. * @param postProcess The post process to share the output with.
  109137. * @returns This post process.
  109138. */
  109139. shareOutputWith(postProcess: PostProcess): PostProcess;
  109140. /**
  109141. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  109142. * This should be called if the post process that shares output with this post process is disabled/disposed.
  109143. */
  109144. useOwnOutput(): void;
  109145. /**
  109146. * Updates the effect with the current post process compile time values and recompiles the shader.
  109147. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  109148. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  109149. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  109150. * @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
  109151. * @param onCompiled Called when the shader has been compiled.
  109152. * @param onError Called if there is an error when compiling a shader.
  109153. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  109154. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  109155. */
  109156. 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;
  109157. /**
  109158. * The post process is reusable if it can be used multiple times within one frame.
  109159. * @returns If the post process is reusable
  109160. */
  109161. isReusable(): boolean;
  109162. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  109163. markTextureDirty(): void;
  109164. /**
  109165. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  109166. * 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.
  109167. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  109168. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  109169. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  109170. * @returns The target texture that was bound to be written to.
  109171. */
  109172. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  109173. /**
  109174. * If the post process is supported.
  109175. */
  109176. get isSupported(): boolean;
  109177. /**
  109178. * The aspect ratio of the output texture.
  109179. */
  109180. get aspectRatio(): number;
  109181. /**
  109182. * Get a value indicating if the post-process is ready to be used
  109183. * @returns true if the post-process is ready (shader is compiled)
  109184. */
  109185. isReady(): boolean;
  109186. /**
  109187. * Binds all textures and uniforms to the shader, this will be run on every pass.
  109188. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  109189. */
  109190. apply(): Nullable<Effect>;
  109191. private _disposeTextures;
  109192. /**
  109193. * Sets the required values to the prepass renderer.
  109194. * @param prePassRenderer defines the prepass renderer to setup.
  109195. * @returns true if the pre pass is needed.
  109196. */
  109197. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  109198. /**
  109199. * Disposes the post process.
  109200. * @param camera The camera to dispose the post process on.
  109201. */
  109202. dispose(camera?: Camera): void;
  109203. /**
  109204. * Serializes the particle system to a JSON object
  109205. * @returns the JSON object
  109206. */
  109207. serialize(): any;
  109208. /**
  109209. * Creates a material from parsed material data
  109210. * @param parsedPostProcess defines parsed post process data
  109211. * @param scene defines the hosting scene
  109212. * @param rootUrl defines the root URL to use to load textures
  109213. * @returns a new post process
  109214. */
  109215. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  109216. }
  109217. }
  109218. declare module BABYLON {
  109219. /** @hidden */
  109220. export var kernelBlurVaryingDeclaration: {
  109221. name: string;
  109222. shader: string;
  109223. };
  109224. }
  109225. declare module BABYLON {
  109226. /** @hidden */
  109227. export var kernelBlurFragment: {
  109228. name: string;
  109229. shader: string;
  109230. };
  109231. }
  109232. declare module BABYLON {
  109233. /** @hidden */
  109234. export var kernelBlurFragment2: {
  109235. name: string;
  109236. shader: string;
  109237. };
  109238. }
  109239. declare module BABYLON {
  109240. /** @hidden */
  109241. export var kernelBlurPixelShader: {
  109242. name: string;
  109243. shader: string;
  109244. };
  109245. }
  109246. declare module BABYLON {
  109247. /** @hidden */
  109248. export var kernelBlurVertex: {
  109249. name: string;
  109250. shader: string;
  109251. };
  109252. }
  109253. declare module BABYLON {
  109254. /** @hidden */
  109255. export var kernelBlurVertexShader: {
  109256. name: string;
  109257. shader: string;
  109258. };
  109259. }
  109260. declare module BABYLON {
  109261. /**
  109262. * The Blur Post Process which blurs an image based on a kernel and direction.
  109263. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  109264. */
  109265. export class BlurPostProcess extends PostProcess {
  109266. private blockCompilation;
  109267. protected _kernel: number;
  109268. protected _idealKernel: number;
  109269. protected _packedFloat: boolean;
  109270. private _staticDefines;
  109271. /** The direction in which to blur the image. */
  109272. direction: Vector2;
  109273. /**
  109274. * Sets the length in pixels of the blur sample region
  109275. */
  109276. set kernel(v: number);
  109277. /**
  109278. * Gets the length in pixels of the blur sample region
  109279. */
  109280. get kernel(): number;
  109281. /**
  109282. * Sets wether or not the blur needs to unpack/repack floats
  109283. */
  109284. set packedFloat(v: boolean);
  109285. /**
  109286. * Gets wether or not the blur is unpacking/repacking floats
  109287. */
  109288. get packedFloat(): boolean;
  109289. /**
  109290. * Gets a string identifying the name of the class
  109291. * @returns "BlurPostProcess" string
  109292. */
  109293. getClassName(): string;
  109294. /**
  109295. * Creates a new instance BlurPostProcess
  109296. * @param name The name of the effect.
  109297. * @param direction The direction in which to blur the image.
  109298. * @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.
  109299. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  109300. * @param camera The camera to apply the render pass to.
  109301. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  109302. * @param engine The engine which the post process will be applied. (default: current engine)
  109303. * @param reusable If the post process can be reused on the same frame. (default: false)
  109304. * @param textureType Type of textures used when performing the post process. (default: 0)
  109305. * @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)
  109306. */
  109307. 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);
  109308. /**
  109309. * Updates the effect with the current post process compile time values and recompiles the shader.
  109310. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  109311. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  109312. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  109313. * @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
  109314. * @param onCompiled Called when the shader has been compiled.
  109315. * @param onError Called if there is an error when compiling a shader.
  109316. */
  109317. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  109318. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  109319. /**
  109320. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  109321. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  109322. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  109323. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  109324. * The gaps between physical kernels are compensated for in the weighting of the samples
  109325. * @param idealKernel Ideal blur kernel.
  109326. * @return Nearest best kernel.
  109327. */
  109328. protected _nearestBestKernel(idealKernel: number): number;
  109329. /**
  109330. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  109331. * @param x The point on the Gaussian distribution to sample.
  109332. * @return the value of the Gaussian function at x.
  109333. */
  109334. protected _gaussianWeight(x: number): number;
  109335. /**
  109336. * Generates a string that can be used as a floating point number in GLSL.
  109337. * @param x Value to print.
  109338. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  109339. * @return GLSL float string.
  109340. */
  109341. protected _glslFloat(x: number, decimalFigures?: number): string;
  109342. /** @hidden */
  109343. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  109344. }
  109345. }
  109346. declare module BABYLON {
  109347. /**
  109348. * Mirror texture can be used to simulate the view from a mirror in a scene.
  109349. * It will dynamically be rendered every frame to adapt to the camera point of view.
  109350. * You can then easily use it as a reflectionTexture on a flat surface.
  109351. * In case the surface is not a plane, please consider relying on reflection probes.
  109352. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  109353. */
  109354. export class MirrorTexture extends RenderTargetTexture {
  109355. private scene;
  109356. /**
  109357. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  109358. * 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.
  109359. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  109360. */
  109361. mirrorPlane: Plane;
  109362. /**
  109363. * Define the blur ratio used to blur the reflection if needed.
  109364. */
  109365. set blurRatio(value: number);
  109366. get blurRatio(): number;
  109367. /**
  109368. * Define the adaptive blur kernel used to blur the reflection if needed.
  109369. * This will autocompute the closest best match for the `blurKernel`
  109370. */
  109371. set adaptiveBlurKernel(value: number);
  109372. /**
  109373. * Define the blur kernel used to blur the reflection if needed.
  109374. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  109375. */
  109376. set blurKernel(value: number);
  109377. /**
  109378. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  109379. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  109380. */
  109381. set blurKernelX(value: number);
  109382. get blurKernelX(): number;
  109383. /**
  109384. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  109385. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  109386. */
  109387. set blurKernelY(value: number);
  109388. get blurKernelY(): number;
  109389. private _autoComputeBlurKernel;
  109390. protected _onRatioRescale(): void;
  109391. private _updateGammaSpace;
  109392. private _imageProcessingConfigChangeObserver;
  109393. private _transformMatrix;
  109394. private _mirrorMatrix;
  109395. private _savedViewMatrix;
  109396. private _blurX;
  109397. private _blurY;
  109398. private _adaptiveBlurKernel;
  109399. private _blurKernelX;
  109400. private _blurKernelY;
  109401. private _blurRatio;
  109402. /**
  109403. * Instantiates a Mirror Texture.
  109404. * Mirror texture can be used to simulate the view from a mirror in a scene.
  109405. * It will dynamically be rendered every frame to adapt to the camera point of view.
  109406. * You can then easily use it as a reflectionTexture on a flat surface.
  109407. * In case the surface is not a plane, please consider relying on reflection probes.
  109408. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  109409. * @param name
  109410. * @param size
  109411. * @param scene
  109412. * @param generateMipMaps
  109413. * @param type
  109414. * @param samplingMode
  109415. * @param generateDepthBuffer
  109416. */
  109417. constructor(name: string, size: number | {
  109418. width: number;
  109419. height: number;
  109420. } | {
  109421. ratio: number;
  109422. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  109423. private _preparePostProcesses;
  109424. /**
  109425. * Clone the mirror texture.
  109426. * @returns the cloned texture
  109427. */
  109428. clone(): MirrorTexture;
  109429. /**
  109430. * Serialize the texture to a JSON representation you could use in Parse later on
  109431. * @returns the serialized JSON representation
  109432. */
  109433. serialize(): any;
  109434. /**
  109435. * Dispose the texture and release its associated resources.
  109436. */
  109437. dispose(): void;
  109438. }
  109439. }
  109440. declare module BABYLON {
  109441. /**
  109442. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  109443. * @see https://doc.babylonjs.com/babylon101/materials#texture
  109444. */
  109445. export class Texture extends BaseTexture {
  109446. /**
  109447. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  109448. */
  109449. static SerializeBuffers: boolean;
  109450. /** @hidden */
  109451. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  109452. /** @hidden */
  109453. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  109454. /** @hidden */
  109455. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  109456. /** nearest is mag = nearest and min = nearest and mip = linear */
  109457. static readonly NEAREST_SAMPLINGMODE: number;
  109458. /** nearest is mag = nearest and min = nearest and mip = linear */
  109459. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  109460. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109461. static readonly BILINEAR_SAMPLINGMODE: number;
  109462. /** Bilinear is mag = linear and min = linear and mip = nearest */
  109463. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  109464. /** Trilinear is mag = linear and min = linear and mip = linear */
  109465. static readonly TRILINEAR_SAMPLINGMODE: number;
  109466. /** Trilinear is mag = linear and min = linear and mip = linear */
  109467. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  109468. /** mag = nearest and min = nearest and mip = nearest */
  109469. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  109470. /** mag = nearest and min = linear and mip = nearest */
  109471. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  109472. /** mag = nearest and min = linear and mip = linear */
  109473. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  109474. /** mag = nearest and min = linear and mip = none */
  109475. static readonly NEAREST_LINEAR: number;
  109476. /** mag = nearest and min = nearest and mip = none */
  109477. static readonly NEAREST_NEAREST: number;
  109478. /** mag = linear and min = nearest and mip = nearest */
  109479. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  109480. /** mag = linear and min = nearest and mip = linear */
  109481. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  109482. /** mag = linear and min = linear and mip = none */
  109483. static readonly LINEAR_LINEAR: number;
  109484. /** mag = linear and min = nearest and mip = none */
  109485. static readonly LINEAR_NEAREST: number;
  109486. /** Explicit coordinates mode */
  109487. static readonly EXPLICIT_MODE: number;
  109488. /** Spherical coordinates mode */
  109489. static readonly SPHERICAL_MODE: number;
  109490. /** Planar coordinates mode */
  109491. static readonly PLANAR_MODE: number;
  109492. /** Cubic coordinates mode */
  109493. static readonly CUBIC_MODE: number;
  109494. /** Projection coordinates mode */
  109495. static readonly PROJECTION_MODE: number;
  109496. /** Inverse Cubic coordinates mode */
  109497. static readonly SKYBOX_MODE: number;
  109498. /** Inverse Cubic coordinates mode */
  109499. static readonly INVCUBIC_MODE: number;
  109500. /** Equirectangular coordinates mode */
  109501. static readonly EQUIRECTANGULAR_MODE: number;
  109502. /** Equirectangular Fixed coordinates mode */
  109503. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  109504. /** Equirectangular Fixed Mirrored coordinates mode */
  109505. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  109506. /** Texture is not repeating outside of 0..1 UVs */
  109507. static readonly CLAMP_ADDRESSMODE: number;
  109508. /** Texture is repeating outside of 0..1 UVs */
  109509. static readonly WRAP_ADDRESSMODE: number;
  109510. /** Texture is repeating and mirrored */
  109511. static readonly MIRROR_ADDRESSMODE: number;
  109512. /**
  109513. * 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
  109514. */
  109515. static UseSerializedUrlIfAny: boolean;
  109516. /**
  109517. * Define the url of the texture.
  109518. */
  109519. url: Nullable<string>;
  109520. /**
  109521. * Define an offset on the texture to offset the u coordinates of the UVs
  109522. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  109523. */
  109524. uOffset: number;
  109525. /**
  109526. * Define an offset on the texture to offset the v coordinates of the UVs
  109527. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  109528. */
  109529. vOffset: number;
  109530. /**
  109531. * Define an offset on the texture to scale the u coordinates of the UVs
  109532. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  109533. */
  109534. uScale: number;
  109535. /**
  109536. * Define an offset on the texture to scale the v coordinates of the UVs
  109537. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  109538. */
  109539. vScale: number;
  109540. /**
  109541. * Define an offset on the texture to rotate around the u coordinates of the UVs
  109542. * @see https://doc.babylonjs.com/how_to/more_materials
  109543. */
  109544. uAng: number;
  109545. /**
  109546. * Define an offset on the texture to rotate around the v coordinates of the UVs
  109547. * @see https://doc.babylonjs.com/how_to/more_materials
  109548. */
  109549. vAng: number;
  109550. /**
  109551. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  109552. * @see https://doc.babylonjs.com/how_to/more_materials
  109553. */
  109554. wAng: number;
  109555. /**
  109556. * Defines the center of rotation (U)
  109557. */
  109558. uRotationCenter: number;
  109559. /**
  109560. * Defines the center of rotation (V)
  109561. */
  109562. vRotationCenter: number;
  109563. /**
  109564. * Defines the center of rotation (W)
  109565. */
  109566. wRotationCenter: number;
  109567. /**
  109568. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  109569. */
  109570. homogeneousRotationInUVTransform: boolean;
  109571. /**
  109572. * Are mip maps generated for this texture or not.
  109573. */
  109574. get noMipmap(): boolean;
  109575. /**
  109576. * List of inspectable custom properties (used by the Inspector)
  109577. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  109578. */
  109579. inspectableCustomProperties: Nullable<IInspectable[]>;
  109580. private _noMipmap;
  109581. /** @hidden */
  109582. _invertY: boolean;
  109583. private _rowGenerationMatrix;
  109584. private _cachedTextureMatrix;
  109585. private _projectionModeMatrix;
  109586. private _t0;
  109587. private _t1;
  109588. private _t2;
  109589. private _cachedUOffset;
  109590. private _cachedVOffset;
  109591. private _cachedUScale;
  109592. private _cachedVScale;
  109593. private _cachedUAng;
  109594. private _cachedVAng;
  109595. private _cachedWAng;
  109596. private _cachedProjectionMatrixId;
  109597. private _cachedURotationCenter;
  109598. private _cachedVRotationCenter;
  109599. private _cachedWRotationCenter;
  109600. private _cachedHomogeneousRotationInUVTransform;
  109601. private _cachedCoordinatesMode;
  109602. /** @hidden */
  109603. protected _initialSamplingMode: number;
  109604. /** @hidden */
  109605. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  109606. private _deleteBuffer;
  109607. protected _format: Nullable<number>;
  109608. private _delayedOnLoad;
  109609. private _delayedOnError;
  109610. private _mimeType?;
  109611. private _loaderOptions?;
  109612. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  109613. get mimeType(): string | undefined;
  109614. /**
  109615. * Observable triggered once the texture has been loaded.
  109616. */
  109617. onLoadObservable: Observable<Texture>;
  109618. protected _isBlocking: boolean;
  109619. /**
  109620. * Is the texture preventing material to render while loading.
  109621. * If false, a default texture will be used instead of the loading one during the preparation step.
  109622. */
  109623. set isBlocking(value: boolean);
  109624. get isBlocking(): boolean;
  109625. /**
  109626. * Get the current sampling mode associated with the texture.
  109627. */
  109628. get samplingMode(): number;
  109629. /**
  109630. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  109631. */
  109632. get invertY(): boolean;
  109633. /**
  109634. * Instantiates a new texture.
  109635. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  109636. * @see https://doc.babylonjs.com/babylon101/materials#texture
  109637. * @param url defines the url of the picture to load as a texture
  109638. * @param sceneOrEngine defines the scene or engine the texture will belong to
  109639. * @param noMipmap defines if the texture will require mip maps or not
  109640. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  109641. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109642. * @param onLoad defines a callback triggered when the texture has been loaded
  109643. * @param onError defines a callback triggered when an error occurred during the loading session
  109644. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  109645. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  109646. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109647. * @param mimeType defines an optional mime type information
  109648. * @param loaderOptions options to be passed to the loader
  109649. */
  109650. 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);
  109651. /**
  109652. * Update the url (and optional buffer) of this texture if url was null during construction.
  109653. * @param url the url of the texture
  109654. * @param buffer the buffer of the texture (defaults to null)
  109655. * @param onLoad callback called when the texture is loaded (defaults to null)
  109656. */
  109657. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  109658. /**
  109659. * Finish the loading sequence of a texture flagged as delayed load.
  109660. * @hidden
  109661. */
  109662. delayLoad(): void;
  109663. private _prepareRowForTextureGeneration;
  109664. /**
  109665. * Checks if the texture has the same transform matrix than another texture
  109666. * @param texture texture to check against
  109667. * @returns true if the transforms are the same, else false
  109668. */
  109669. checkTransformsAreIdentical(texture: Nullable<Texture>): boolean;
  109670. /**
  109671. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  109672. * @returns the transform matrix of the texture.
  109673. */
  109674. getTextureMatrix(uBase?: number): Matrix;
  109675. /**
  109676. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  109677. * @returns The reflection texture transform
  109678. */
  109679. getReflectionTextureMatrix(): Matrix;
  109680. /**
  109681. * Clones the texture.
  109682. * @returns the cloned texture
  109683. */
  109684. clone(): Texture;
  109685. /**
  109686. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  109687. * @returns The JSON representation of the texture
  109688. */
  109689. serialize(): any;
  109690. /**
  109691. * Get the current class name of the texture useful for serialization or dynamic coding.
  109692. * @returns "Texture"
  109693. */
  109694. getClassName(): string;
  109695. /**
  109696. * Dispose the texture and release its associated resources.
  109697. */
  109698. dispose(): void;
  109699. /**
  109700. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  109701. * @param parsedTexture Define the JSON representation of the texture
  109702. * @param scene Define the scene the parsed texture should be instantiated in
  109703. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  109704. * @returns The parsed texture if successful
  109705. */
  109706. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  109707. /**
  109708. * Creates a texture from its base 64 representation.
  109709. * @param data Define the base64 payload without the data: prefix
  109710. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109711. * @param scene Define the scene the texture should belong to
  109712. * @param noMipmap Forces the texture to not create mip map information if true
  109713. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109714. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109715. * @param onLoad define a callback triggered when the texture has been loaded
  109716. * @param onError define a callback triggered when an error occurred during the loading session
  109717. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109718. * @returns the created texture
  109719. */
  109720. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  109721. /**
  109722. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  109723. * @param data Define the base64 payload without the data: prefix
  109724. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  109725. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  109726. * @param scene Define the scene the texture should belong to
  109727. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  109728. * @param noMipmap Forces the texture to not create mip map information if true
  109729. * @param invertY define if the texture needs to be inverted on the y axis during loading
  109730. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  109731. * @param onLoad define a callback triggered when the texture has been loaded
  109732. * @param onError define a callback triggered when an error occurred during the loading session
  109733. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  109734. * @returns the created texture
  109735. */
  109736. 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;
  109737. }
  109738. }
  109739. declare module BABYLON {
  109740. /**
  109741. * PostProcessManager is used to manage one or more post processes or post process pipelines
  109742. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  109743. */
  109744. export class PostProcessManager {
  109745. private _scene;
  109746. private _indexBuffer;
  109747. private _vertexBuffers;
  109748. /**
  109749. * Creates a new instance PostProcess
  109750. * @param scene The scene that the post process is associated with.
  109751. */
  109752. constructor(scene: Scene);
  109753. private _prepareBuffers;
  109754. private _buildIndexBuffer;
  109755. /**
  109756. * Rebuilds the vertex buffers of the manager.
  109757. * @hidden
  109758. */
  109759. _rebuild(): void;
  109760. /**
  109761. * Prepares a frame to be run through a post process.
  109762. * @param sourceTexture The input texture to the post procesess. (default: null)
  109763. * @param postProcesses An array of post processes to be run. (default: null)
  109764. * @returns True if the post processes were able to be run.
  109765. * @hidden
  109766. */
  109767. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  109768. /**
  109769. * Manually render a set of post processes to a texture.
  109770. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  109771. * @param postProcesses An array of post processes to be run.
  109772. * @param targetTexture The target texture to render to.
  109773. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  109774. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  109775. * @param lodLevel defines which lod of the texture to render to
  109776. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  109777. */
  109778. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  109779. /**
  109780. * Finalize the result of the output of the postprocesses.
  109781. * @param doNotPresent If true the result will not be displayed to the screen.
  109782. * @param targetTexture The target texture to render to.
  109783. * @param faceIndex The index of the face to bind the target texture to.
  109784. * @param postProcesses The array of post processes to render.
  109785. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  109786. * @hidden
  109787. */
  109788. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  109789. /**
  109790. * Disposes of the post process manager.
  109791. */
  109792. dispose(): void;
  109793. }
  109794. }
  109795. declare module BABYLON {
  109796. /**
  109797. * This Helps creating a texture that will be created from a camera in your scene.
  109798. * It is basically a dynamic texture that could be used to create special effects for instance.
  109799. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  109800. */
  109801. export class RenderTargetTexture extends Texture {
  109802. /**
  109803. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  109804. */
  109805. static readonly REFRESHRATE_RENDER_ONCE: number;
  109806. /**
  109807. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  109808. */
  109809. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  109810. /**
  109811. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  109812. * the central point of your effect and can save a lot of performances.
  109813. */
  109814. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  109815. /**
  109816. * Use this predicate to dynamically define the list of mesh you want to render.
  109817. * If set, the renderList property will be overwritten.
  109818. */
  109819. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  109820. private _renderList;
  109821. /**
  109822. * Use this list to define the list of mesh you want to render.
  109823. */
  109824. get renderList(): Nullable<Array<AbstractMesh>>;
  109825. set renderList(value: Nullable<Array<AbstractMesh>>);
  109826. /**
  109827. * Use this function to overload the renderList array at rendering time.
  109828. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  109829. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  109830. * the cube (if the RTT is a cube, else layerOrFace=0).
  109831. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  109832. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  109833. * hold dummy elements!
  109834. */
  109835. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  109836. private _hookArray;
  109837. /**
  109838. * Define if particles should be rendered in your texture.
  109839. */
  109840. renderParticles: boolean;
  109841. /**
  109842. * Define if sprites should be rendered in your texture.
  109843. */
  109844. renderSprites: boolean;
  109845. /**
  109846. * Define the camera used to render the texture.
  109847. */
  109848. activeCamera: Nullable<Camera>;
  109849. /**
  109850. * Override the mesh isReady function with your own one.
  109851. */
  109852. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  109853. /**
  109854. * Override the render function of the texture with your own one.
  109855. */
  109856. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  109857. /**
  109858. * Define if camera post processes should be use while rendering the texture.
  109859. */
  109860. useCameraPostProcesses: boolean;
  109861. /**
  109862. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  109863. */
  109864. ignoreCameraViewport: boolean;
  109865. private _postProcessManager;
  109866. private _postProcesses;
  109867. private _resizeObserver;
  109868. /**
  109869. * An event triggered when the texture is unbind.
  109870. */
  109871. onBeforeBindObservable: Observable<RenderTargetTexture>;
  109872. /**
  109873. * An event triggered when the texture is unbind.
  109874. */
  109875. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  109876. private _onAfterUnbindObserver;
  109877. /**
  109878. * Set a after unbind callback in the texture.
  109879. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  109880. */
  109881. set onAfterUnbind(callback: () => void);
  109882. /**
  109883. * An event triggered before rendering the texture
  109884. */
  109885. onBeforeRenderObservable: Observable<number>;
  109886. private _onBeforeRenderObserver;
  109887. /**
  109888. * Set a before render callback in the texture.
  109889. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  109890. */
  109891. set onBeforeRender(callback: (faceIndex: number) => void);
  109892. /**
  109893. * An event triggered after rendering the texture
  109894. */
  109895. onAfterRenderObservable: Observable<number>;
  109896. private _onAfterRenderObserver;
  109897. /**
  109898. * Set a after render callback in the texture.
  109899. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  109900. */
  109901. set onAfterRender(callback: (faceIndex: number) => void);
  109902. /**
  109903. * An event triggered after the texture clear
  109904. */
  109905. onClearObservable: Observable<Engine>;
  109906. private _onClearObserver;
  109907. /**
  109908. * Set a clear callback in the texture.
  109909. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  109910. */
  109911. set onClear(callback: (Engine: Engine) => void);
  109912. /**
  109913. * An event triggered when the texture is resized.
  109914. */
  109915. onResizeObservable: Observable<RenderTargetTexture>;
  109916. /**
  109917. * Define the clear color of the Render Target if it should be different from the scene.
  109918. */
  109919. clearColor: Color4;
  109920. protected _size: number | {
  109921. width: number;
  109922. height: number;
  109923. layers?: number;
  109924. };
  109925. protected _initialSizeParameter: number | {
  109926. width: number;
  109927. height: number;
  109928. } | {
  109929. ratio: number;
  109930. };
  109931. protected _sizeRatio: Nullable<number>;
  109932. /** @hidden */
  109933. _generateMipMaps: boolean;
  109934. protected _renderingManager: RenderingManager;
  109935. /** @hidden */
  109936. _waitingRenderList?: string[];
  109937. protected _doNotChangeAspectRatio: boolean;
  109938. protected _currentRefreshId: number;
  109939. protected _refreshRate: number;
  109940. protected _textureMatrix: Matrix;
  109941. protected _samples: number;
  109942. protected _renderTargetOptions: RenderTargetCreationOptions;
  109943. /**
  109944. * Gets render target creation options that were used.
  109945. */
  109946. get renderTargetOptions(): RenderTargetCreationOptions;
  109947. protected _onRatioRescale(): void;
  109948. /**
  109949. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  109950. * It must define where the camera used to render the texture is set
  109951. */
  109952. boundingBoxPosition: Vector3;
  109953. private _boundingBoxSize;
  109954. /**
  109955. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  109956. * When defined, the cubemap will switch to local mode
  109957. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  109958. * @example https://www.babylonjs-playground.com/#RNASML
  109959. */
  109960. set boundingBoxSize(value: Vector3);
  109961. get boundingBoxSize(): Vector3;
  109962. /**
  109963. * In case the RTT has been created with a depth texture, get the associated
  109964. * depth texture.
  109965. * Otherwise, return null.
  109966. */
  109967. get depthStencilTexture(): Nullable<InternalTexture>;
  109968. /**
  109969. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  109970. * or used a shadow, depth texture...
  109971. * @param name The friendly name of the texture
  109972. * @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)
  109973. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  109974. * @param generateMipMaps True if mip maps need to be generated after render.
  109975. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  109976. * @param type The type of the buffer in the RTT (int, half float, float...)
  109977. * @param isCube True if a cube texture needs to be created
  109978. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  109979. * @param generateDepthBuffer True to generate a depth buffer
  109980. * @param generateStencilBuffer True to generate a stencil buffer
  109981. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  109982. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  109983. * @param delayAllocation if the texture allocation should be delayed (default: false)
  109984. */
  109985. constructor(name: string, size: number | {
  109986. width: number;
  109987. height: number;
  109988. layers?: number;
  109989. } | {
  109990. ratio: number;
  109991. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  109992. /**
  109993. * Creates a depth stencil texture.
  109994. * This is only available in WebGL 2 or with the depth texture extension available.
  109995. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  109996. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  109997. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  109998. */
  109999. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  110000. private _processSizeParameter;
  110001. /**
  110002. * Define the number of samples to use in case of MSAA.
  110003. * It defaults to one meaning no MSAA has been enabled.
  110004. */
  110005. get samples(): number;
  110006. set samples(value: number);
  110007. /**
  110008. * Resets the refresh counter of the texture and start bak from scratch.
  110009. * Could be useful to regenerate the texture if it is setup to render only once.
  110010. */
  110011. resetRefreshCounter(): void;
  110012. /**
  110013. * Define the refresh rate of the texture or the rendering frequency.
  110014. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  110015. */
  110016. get refreshRate(): number;
  110017. set refreshRate(value: number);
  110018. /**
  110019. * Adds a post process to the render target rendering passes.
  110020. * @param postProcess define the post process to add
  110021. */
  110022. addPostProcess(postProcess: PostProcess): void;
  110023. /**
  110024. * Clear all the post processes attached to the render target
  110025. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  110026. */
  110027. clearPostProcesses(dispose?: boolean): void;
  110028. /**
  110029. * Remove one of the post process from the list of attached post processes to the texture
  110030. * @param postProcess define the post process to remove from the list
  110031. */
  110032. removePostProcess(postProcess: PostProcess): void;
  110033. /** @hidden */
  110034. _shouldRender(): boolean;
  110035. /**
  110036. * Gets the actual render size of the texture.
  110037. * @returns the width of the render size
  110038. */
  110039. getRenderSize(): number;
  110040. /**
  110041. * Gets the actual render width of the texture.
  110042. * @returns the width of the render size
  110043. */
  110044. getRenderWidth(): number;
  110045. /**
  110046. * Gets the actual render height of the texture.
  110047. * @returns the height of the render size
  110048. */
  110049. getRenderHeight(): number;
  110050. /**
  110051. * Gets the actual number of layers of the texture.
  110052. * @returns the number of layers
  110053. */
  110054. getRenderLayers(): number;
  110055. /**
  110056. * Get if the texture can be rescaled or not.
  110057. */
  110058. get canRescale(): boolean;
  110059. /**
  110060. * Resize the texture using a ratio.
  110061. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  110062. */
  110063. scale(ratio: number): void;
  110064. /**
  110065. * Get the texture reflection matrix used to rotate/transform the reflection.
  110066. * @returns the reflection matrix
  110067. */
  110068. getReflectionTextureMatrix(): Matrix;
  110069. /**
  110070. * Resize the texture to a new desired size.
  110071. * Be carrefull as it will recreate all the data in the new texture.
  110072. * @param size Define the new size. It can be:
  110073. * - a number for squared texture,
  110074. * - an object containing { width: number, height: number }
  110075. * - or an object containing a ratio { ratio: number }
  110076. */
  110077. resize(size: number | {
  110078. width: number;
  110079. height: number;
  110080. } | {
  110081. ratio: number;
  110082. }): void;
  110083. private _defaultRenderListPrepared;
  110084. /**
  110085. * Renders all the objects from the render list into the texture.
  110086. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  110087. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  110088. */
  110089. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  110090. private _bestReflectionRenderTargetDimension;
  110091. private _prepareRenderingManager;
  110092. /**
  110093. * @hidden
  110094. * @param faceIndex face index to bind to if this is a cubetexture
  110095. * @param layer defines the index of the texture to bind in the array
  110096. */
  110097. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  110098. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  110099. private renderToTarget;
  110100. /**
  110101. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110102. * This allowed control for front to back rendering or reversly depending of the special needs.
  110103. *
  110104. * @param renderingGroupId The rendering group id corresponding to its index
  110105. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110106. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110107. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110108. */
  110109. 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;
  110110. /**
  110111. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110112. *
  110113. * @param renderingGroupId The rendering group id corresponding to its index
  110114. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110115. */
  110116. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  110117. /**
  110118. * Clones the texture.
  110119. * @returns the cloned texture
  110120. */
  110121. clone(): RenderTargetTexture;
  110122. /**
  110123. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  110124. * @returns The JSON representation of the texture
  110125. */
  110126. serialize(): any;
  110127. /**
  110128. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  110129. */
  110130. disposeFramebufferObjects(): void;
  110131. /**
  110132. * Dispose the texture and release its associated resources.
  110133. */
  110134. dispose(): void;
  110135. /** @hidden */
  110136. _rebuild(): void;
  110137. /**
  110138. * Clear the info related to rendering groups preventing retention point in material dispose.
  110139. */
  110140. freeRenderingGroups(): void;
  110141. /**
  110142. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  110143. * @returns the view count
  110144. */
  110145. getViewCount(): number;
  110146. }
  110147. }
  110148. declare module BABYLON {
  110149. /**
  110150. * Class used to manipulate GUIDs
  110151. */
  110152. export class GUID {
  110153. /**
  110154. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  110155. * Be aware Math.random() could cause collisions, but:
  110156. * "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"
  110157. * @returns a pseudo random id
  110158. */
  110159. static RandomId(): string;
  110160. }
  110161. }
  110162. declare module BABYLON {
  110163. /**
  110164. * Options to be used when creating a shadow depth material
  110165. */
  110166. export interface IIOptionShadowDepthMaterial {
  110167. /** Variables in the vertex shader code that need to have their names remapped.
  110168. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  110169. * "var_name" should be either: worldPos or vNormalW
  110170. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  110171. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  110172. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  110173. */
  110174. remappedVariables?: string[];
  110175. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  110176. standalone?: boolean;
  110177. }
  110178. /**
  110179. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  110180. */
  110181. export class ShadowDepthWrapper {
  110182. private _scene;
  110183. private _options?;
  110184. private _baseMaterial;
  110185. private _onEffectCreatedObserver;
  110186. private _subMeshToEffect;
  110187. private _subMeshToDepthEffect;
  110188. private _meshes;
  110189. /** @hidden */
  110190. _matriceNames: any;
  110191. /** Gets the standalone status of the wrapper */
  110192. get standalone(): boolean;
  110193. /** Gets the base material the wrapper is built upon */
  110194. get baseMaterial(): Material;
  110195. /**
  110196. * Instantiate a new shadow depth wrapper.
  110197. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  110198. * generate the shadow depth map. For more information, please refer to the documentation:
  110199. * https://doc.babylonjs.com/babylon101/shadows
  110200. * @param baseMaterial Material to wrap
  110201. * @param scene Define the scene the material belongs to
  110202. * @param options Options used to create the wrapper
  110203. */
  110204. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  110205. /**
  110206. * Gets the effect to use to generate the depth map
  110207. * @param subMesh subMesh to get the effect for
  110208. * @param shadowGenerator shadow generator to get the effect for
  110209. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  110210. */
  110211. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  110212. /**
  110213. * Specifies that the submesh is ready to be used for depth rendering
  110214. * @param subMesh submesh to check
  110215. * @param defines the list of defines to take into account when checking the effect
  110216. * @param shadowGenerator combined with subMesh, it defines the effect to check
  110217. * @param useInstances specifies that instances should be used
  110218. * @returns a boolean indicating that the submesh is ready or not
  110219. */
  110220. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  110221. /**
  110222. * Disposes the resources
  110223. */
  110224. dispose(): void;
  110225. private _makeEffect;
  110226. }
  110227. }
  110228. declare module BABYLON {
  110229. /**
  110230. * Options for compiling materials.
  110231. */
  110232. export interface IMaterialCompilationOptions {
  110233. /**
  110234. * Defines whether clip planes are enabled.
  110235. */
  110236. clipPlane: boolean;
  110237. /**
  110238. * Defines whether instances are enabled.
  110239. */
  110240. useInstances: boolean;
  110241. }
  110242. /**
  110243. * Options passed when calling customShaderNameResolve
  110244. */
  110245. export interface ICustomShaderNameResolveOptions {
  110246. /**
  110247. * 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
  110248. */
  110249. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  110250. }
  110251. /**
  110252. * Base class for the main features of a material in Babylon.js
  110253. */
  110254. export class Material implements IAnimatable {
  110255. /**
  110256. * Returns the triangle fill mode
  110257. */
  110258. static readonly TriangleFillMode: number;
  110259. /**
  110260. * Returns the wireframe mode
  110261. */
  110262. static readonly WireFrameFillMode: number;
  110263. /**
  110264. * Returns the point fill mode
  110265. */
  110266. static readonly PointFillMode: number;
  110267. /**
  110268. * Returns the point list draw mode
  110269. */
  110270. static readonly PointListDrawMode: number;
  110271. /**
  110272. * Returns the line list draw mode
  110273. */
  110274. static readonly LineListDrawMode: number;
  110275. /**
  110276. * Returns the line loop draw mode
  110277. */
  110278. static readonly LineLoopDrawMode: number;
  110279. /**
  110280. * Returns the line strip draw mode
  110281. */
  110282. static readonly LineStripDrawMode: number;
  110283. /**
  110284. * Returns the triangle strip draw mode
  110285. */
  110286. static readonly TriangleStripDrawMode: number;
  110287. /**
  110288. * Returns the triangle fan draw mode
  110289. */
  110290. static readonly TriangleFanDrawMode: number;
  110291. /**
  110292. * Stores the clock-wise side orientation
  110293. */
  110294. static readonly ClockWiseSideOrientation: number;
  110295. /**
  110296. * Stores the counter clock-wise side orientation
  110297. */
  110298. static readonly CounterClockWiseSideOrientation: number;
  110299. /**
  110300. * The dirty texture flag value
  110301. */
  110302. static readonly TextureDirtyFlag: number;
  110303. /**
  110304. * The dirty light flag value
  110305. */
  110306. static readonly LightDirtyFlag: number;
  110307. /**
  110308. * The dirty fresnel flag value
  110309. */
  110310. static readonly FresnelDirtyFlag: number;
  110311. /**
  110312. * The dirty attribute flag value
  110313. */
  110314. static readonly AttributesDirtyFlag: number;
  110315. /**
  110316. * The dirty misc flag value
  110317. */
  110318. static readonly MiscDirtyFlag: number;
  110319. /**
  110320. * The dirty prepass flag value
  110321. */
  110322. static readonly PrePassDirtyFlag: number;
  110323. /**
  110324. * The all dirty flag value
  110325. */
  110326. static readonly AllDirtyFlag: number;
  110327. /**
  110328. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  110329. */
  110330. static readonly MATERIAL_OPAQUE: number;
  110331. /**
  110332. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  110333. */
  110334. static readonly MATERIAL_ALPHATEST: number;
  110335. /**
  110336. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110337. */
  110338. static readonly MATERIAL_ALPHABLEND: number;
  110339. /**
  110340. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  110341. * They are also discarded below the alpha cutoff threshold to improve performances.
  110342. */
  110343. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  110344. /**
  110345. * The Whiteout method is used to blend normals.
  110346. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  110347. */
  110348. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  110349. /**
  110350. * The Reoriented Normal Mapping method is used to blend normals.
  110351. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  110352. */
  110353. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  110354. /**
  110355. * Custom callback helping to override the default shader used in the material.
  110356. */
  110357. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  110358. /**
  110359. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  110360. */
  110361. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  110362. /**
  110363. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  110364. * This means that the material can keep using a previous shader while a new one is being compiled.
  110365. * This is mostly used when shader parallel compilation is supported (true by default)
  110366. */
  110367. allowShaderHotSwapping: boolean;
  110368. /**
  110369. * The ID of the material
  110370. */
  110371. id: string;
  110372. /**
  110373. * Gets or sets the unique id of the material
  110374. */
  110375. uniqueId: number;
  110376. /**
  110377. * The name of the material
  110378. */
  110379. name: string;
  110380. /**
  110381. * Gets or sets user defined metadata
  110382. */
  110383. metadata: any;
  110384. /**
  110385. * For internal use only. Please do not use.
  110386. */
  110387. reservedDataStore: any;
  110388. /**
  110389. * Specifies if the ready state should be checked on each call
  110390. */
  110391. checkReadyOnEveryCall: boolean;
  110392. /**
  110393. * Specifies if the ready state should be checked once
  110394. */
  110395. checkReadyOnlyOnce: boolean;
  110396. /**
  110397. * The state of the material
  110398. */
  110399. state: string;
  110400. /**
  110401. * If the material can be rendered to several textures with MRT extension
  110402. */
  110403. get canRenderToMRT(): boolean;
  110404. /**
  110405. * The alpha value of the material
  110406. */
  110407. protected _alpha: number;
  110408. /**
  110409. * List of inspectable custom properties (used by the Inspector)
  110410. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110411. */
  110412. inspectableCustomProperties: IInspectable[];
  110413. /**
  110414. * Sets the alpha value of the material
  110415. */
  110416. set alpha(value: number);
  110417. /**
  110418. * Gets the alpha value of the material
  110419. */
  110420. get alpha(): number;
  110421. /**
  110422. * Specifies if back face culling is enabled
  110423. */
  110424. protected _backFaceCulling: boolean;
  110425. /**
  110426. * Sets the back-face culling state
  110427. */
  110428. set backFaceCulling(value: boolean);
  110429. /**
  110430. * Gets the back-face culling state
  110431. */
  110432. get backFaceCulling(): boolean;
  110433. /**
  110434. * Stores the value for side orientation
  110435. */
  110436. sideOrientation: number;
  110437. /**
  110438. * Callback triggered when the material is compiled
  110439. */
  110440. onCompiled: Nullable<(effect: Effect) => void>;
  110441. /**
  110442. * Callback triggered when an error occurs
  110443. */
  110444. onError: Nullable<(effect: Effect, errors: string) => void>;
  110445. /**
  110446. * Callback triggered to get the render target textures
  110447. */
  110448. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  110449. /**
  110450. * Gets a boolean indicating that current material needs to register RTT
  110451. */
  110452. get hasRenderTargetTextures(): boolean;
  110453. /**
  110454. * Specifies if the material should be serialized
  110455. */
  110456. doNotSerialize: boolean;
  110457. /**
  110458. * @hidden
  110459. */
  110460. _storeEffectOnSubMeshes: boolean;
  110461. /**
  110462. * Stores the animations for the material
  110463. */
  110464. animations: Nullable<Array<Animation>>;
  110465. /**
  110466. * An event triggered when the material is disposed
  110467. */
  110468. onDisposeObservable: Observable<Material>;
  110469. /**
  110470. * An observer which watches for dispose events
  110471. */
  110472. private _onDisposeObserver;
  110473. private _onUnBindObservable;
  110474. /**
  110475. * Called during a dispose event
  110476. */
  110477. set onDispose(callback: () => void);
  110478. private _onBindObservable;
  110479. /**
  110480. * An event triggered when the material is bound
  110481. */
  110482. get onBindObservable(): Observable<AbstractMesh>;
  110483. /**
  110484. * An observer which watches for bind events
  110485. */
  110486. private _onBindObserver;
  110487. /**
  110488. * Called during a bind event
  110489. */
  110490. set onBind(callback: (Mesh: AbstractMesh) => void);
  110491. /**
  110492. * An event triggered when the material is unbound
  110493. */
  110494. get onUnBindObservable(): Observable<Material>;
  110495. protected _onEffectCreatedObservable: Nullable<Observable<{
  110496. effect: Effect;
  110497. subMesh: Nullable<SubMesh>;
  110498. }>>;
  110499. /**
  110500. * An event triggered when the effect is (re)created
  110501. */
  110502. get onEffectCreatedObservable(): Observable<{
  110503. effect: Effect;
  110504. subMesh: Nullable<SubMesh>;
  110505. }>;
  110506. /**
  110507. * Stores the value of the alpha mode
  110508. */
  110509. private _alphaMode;
  110510. /**
  110511. * Sets the value of the alpha mode.
  110512. *
  110513. * | Value | Type | Description |
  110514. * | --- | --- | --- |
  110515. * | 0 | ALPHA_DISABLE | |
  110516. * | 1 | ALPHA_ADD | |
  110517. * | 2 | ALPHA_COMBINE | |
  110518. * | 3 | ALPHA_SUBTRACT | |
  110519. * | 4 | ALPHA_MULTIPLY | |
  110520. * | 5 | ALPHA_MAXIMIZED | |
  110521. * | 6 | ALPHA_ONEONE | |
  110522. * | 7 | ALPHA_PREMULTIPLIED | |
  110523. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  110524. * | 9 | ALPHA_INTERPOLATE | |
  110525. * | 10 | ALPHA_SCREENMODE | |
  110526. *
  110527. */
  110528. set alphaMode(value: number);
  110529. /**
  110530. * Gets the value of the alpha mode
  110531. */
  110532. get alphaMode(): number;
  110533. /**
  110534. * Stores the state of the need depth pre-pass value
  110535. */
  110536. private _needDepthPrePass;
  110537. /**
  110538. * Sets the need depth pre-pass value
  110539. */
  110540. set needDepthPrePass(value: boolean);
  110541. /**
  110542. * Gets the depth pre-pass value
  110543. */
  110544. get needDepthPrePass(): boolean;
  110545. /**
  110546. * Specifies if depth writing should be disabled
  110547. */
  110548. disableDepthWrite: boolean;
  110549. /**
  110550. * Specifies if color writing should be disabled
  110551. */
  110552. disableColorWrite: boolean;
  110553. /**
  110554. * Specifies if depth writing should be forced
  110555. */
  110556. forceDepthWrite: boolean;
  110557. /**
  110558. * Specifies the depth function that should be used. 0 means the default engine function
  110559. */
  110560. depthFunction: number;
  110561. /**
  110562. * Specifies if there should be a separate pass for culling
  110563. */
  110564. separateCullingPass: boolean;
  110565. /**
  110566. * Stores the state specifing if fog should be enabled
  110567. */
  110568. private _fogEnabled;
  110569. /**
  110570. * Sets the state for enabling fog
  110571. */
  110572. set fogEnabled(value: boolean);
  110573. /**
  110574. * Gets the value of the fog enabled state
  110575. */
  110576. get fogEnabled(): boolean;
  110577. /**
  110578. * Stores the size of points
  110579. */
  110580. pointSize: number;
  110581. /**
  110582. * Stores the z offset value
  110583. */
  110584. zOffset: number;
  110585. get wireframe(): boolean;
  110586. /**
  110587. * Sets the state of wireframe mode
  110588. */
  110589. set wireframe(value: boolean);
  110590. /**
  110591. * Gets the value specifying if point clouds are enabled
  110592. */
  110593. get pointsCloud(): boolean;
  110594. /**
  110595. * Sets the state of point cloud mode
  110596. */
  110597. set pointsCloud(value: boolean);
  110598. /**
  110599. * Gets the material fill mode
  110600. */
  110601. get fillMode(): number;
  110602. /**
  110603. * Sets the material fill mode
  110604. */
  110605. set fillMode(value: number);
  110606. /**
  110607. * @hidden
  110608. * Stores the effects for the material
  110609. */
  110610. _effect: Nullable<Effect>;
  110611. /**
  110612. * Specifies if uniform buffers should be used
  110613. */
  110614. private _useUBO;
  110615. /**
  110616. * Stores a reference to the scene
  110617. */
  110618. private _scene;
  110619. /**
  110620. * Stores the fill mode state
  110621. */
  110622. private _fillMode;
  110623. /**
  110624. * Specifies if the depth write state should be cached
  110625. */
  110626. private _cachedDepthWriteState;
  110627. /**
  110628. * Specifies if the color write state should be cached
  110629. */
  110630. private _cachedColorWriteState;
  110631. /**
  110632. * Specifies if the depth function state should be cached
  110633. */
  110634. private _cachedDepthFunctionState;
  110635. /**
  110636. * Stores the uniform buffer
  110637. */
  110638. protected _uniformBuffer: UniformBuffer;
  110639. /** @hidden */
  110640. _indexInSceneMaterialArray: number;
  110641. /** @hidden */
  110642. meshMap: Nullable<{
  110643. [id: string]: AbstractMesh | undefined;
  110644. }>;
  110645. /**
  110646. * Creates a material instance
  110647. * @param name defines the name of the material
  110648. * @param scene defines the scene to reference
  110649. * @param doNotAdd specifies if the material should be added to the scene
  110650. */
  110651. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  110652. /**
  110653. * Returns a string representation of the current material
  110654. * @param fullDetails defines a boolean indicating which levels of logging is desired
  110655. * @returns a string with material information
  110656. */
  110657. toString(fullDetails?: boolean): string;
  110658. /**
  110659. * Gets the class name of the material
  110660. * @returns a string with the class name of the material
  110661. */
  110662. getClassName(): string;
  110663. /**
  110664. * Specifies if updates for the material been locked
  110665. */
  110666. get isFrozen(): boolean;
  110667. /**
  110668. * Locks updates for the material
  110669. */
  110670. freeze(): void;
  110671. /**
  110672. * Unlocks updates for the material
  110673. */
  110674. unfreeze(): void;
  110675. /**
  110676. * Specifies if the material is ready to be used
  110677. * @param mesh defines the mesh to check
  110678. * @param useInstances specifies if instances should be used
  110679. * @returns a boolean indicating if the material is ready to be used
  110680. */
  110681. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  110682. /**
  110683. * Specifies that the submesh is ready to be used
  110684. * @param mesh defines the mesh to check
  110685. * @param subMesh defines which submesh to check
  110686. * @param useInstances specifies that instances should be used
  110687. * @returns a boolean indicating that the submesh is ready or not
  110688. */
  110689. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110690. /**
  110691. * Returns the material effect
  110692. * @returns the effect associated with the material
  110693. */
  110694. getEffect(): Nullable<Effect>;
  110695. /**
  110696. * Returns the current scene
  110697. * @returns a Scene
  110698. */
  110699. getScene(): Scene;
  110700. /**
  110701. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  110702. */
  110703. protected _forceAlphaTest: boolean;
  110704. /**
  110705. * The transparency mode of the material.
  110706. */
  110707. protected _transparencyMode: Nullable<number>;
  110708. /**
  110709. * Gets the current transparency mode.
  110710. */
  110711. get transparencyMode(): Nullable<number>;
  110712. /**
  110713. * Sets the transparency mode of the material.
  110714. *
  110715. * | Value | Type | Description |
  110716. * | ----- | ----------------------------------- | ----------- |
  110717. * | 0 | OPAQUE | |
  110718. * | 1 | ALPHATEST | |
  110719. * | 2 | ALPHABLEND | |
  110720. * | 3 | ALPHATESTANDBLEND | |
  110721. *
  110722. */
  110723. set transparencyMode(value: Nullable<number>);
  110724. /**
  110725. * Returns true if alpha blending should be disabled.
  110726. */
  110727. protected get _disableAlphaBlending(): boolean;
  110728. /**
  110729. * Specifies whether or not this material should be rendered in alpha blend mode.
  110730. * @returns a boolean specifying if alpha blending is needed
  110731. */
  110732. needAlphaBlending(): boolean;
  110733. /**
  110734. * Specifies if the mesh will require alpha blending
  110735. * @param mesh defines the mesh to check
  110736. * @returns a boolean specifying if alpha blending is needed for the mesh
  110737. */
  110738. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  110739. /**
  110740. * Specifies whether or not this material should be rendered in alpha test mode.
  110741. * @returns a boolean specifying if an alpha test is needed.
  110742. */
  110743. needAlphaTesting(): boolean;
  110744. /**
  110745. * Specifies if material alpha testing should be turned on for the mesh
  110746. * @param mesh defines the mesh to check
  110747. */
  110748. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  110749. /**
  110750. * Gets the texture used for the alpha test
  110751. * @returns the texture to use for alpha testing
  110752. */
  110753. getAlphaTestTexture(): Nullable<BaseTexture>;
  110754. /**
  110755. * Marks the material to indicate that it needs to be re-calculated
  110756. */
  110757. markDirty(): void;
  110758. /** @hidden */
  110759. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  110760. /**
  110761. * Binds the material to the mesh
  110762. * @param world defines the world transformation matrix
  110763. * @param mesh defines the mesh to bind the material to
  110764. */
  110765. bind(world: Matrix, mesh?: Mesh): void;
  110766. /**
  110767. * Binds the submesh to the material
  110768. * @param world defines the world transformation matrix
  110769. * @param mesh defines the mesh containing the submesh
  110770. * @param subMesh defines the submesh to bind the material to
  110771. */
  110772. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  110773. /**
  110774. * Binds the world matrix to the material
  110775. * @param world defines the world transformation matrix
  110776. */
  110777. bindOnlyWorldMatrix(world: Matrix): void;
  110778. /**
  110779. * Binds the scene's uniform buffer to the effect.
  110780. * @param effect defines the effect to bind to the scene uniform buffer
  110781. * @param sceneUbo defines the uniform buffer storing scene data
  110782. */
  110783. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  110784. /**
  110785. * Binds the view matrix to the effect
  110786. * @param effect defines the effect to bind the view matrix to
  110787. */
  110788. bindView(effect: Effect): void;
  110789. /**
  110790. * Binds the view projection matrix to the effect
  110791. * @param effect defines the effect to bind the view projection matrix to
  110792. */
  110793. bindViewProjection(effect: Effect): void;
  110794. /**
  110795. * Processes to execute after binding the material to a mesh
  110796. * @param mesh defines the rendered mesh
  110797. */
  110798. protected _afterBind(mesh?: Mesh): void;
  110799. /**
  110800. * Unbinds the material from the mesh
  110801. */
  110802. unbind(): void;
  110803. /**
  110804. * Gets the active textures from the material
  110805. * @returns an array of textures
  110806. */
  110807. getActiveTextures(): BaseTexture[];
  110808. /**
  110809. * Specifies if the material uses a texture
  110810. * @param texture defines the texture to check against the material
  110811. * @returns a boolean specifying if the material uses the texture
  110812. */
  110813. hasTexture(texture: BaseTexture): boolean;
  110814. /**
  110815. * Makes a duplicate of the material, and gives it a new name
  110816. * @param name defines the new name for the duplicated material
  110817. * @returns the cloned material
  110818. */
  110819. clone(name: string): Nullable<Material>;
  110820. /**
  110821. * Gets the meshes bound to the material
  110822. * @returns an array of meshes bound to the material
  110823. */
  110824. getBindedMeshes(): AbstractMesh[];
  110825. /**
  110826. * Force shader compilation
  110827. * @param mesh defines the mesh associated with this material
  110828. * @param onCompiled defines a function to execute once the material is compiled
  110829. * @param options defines the options to configure the compilation
  110830. * @param onError defines a function to execute if the material fails compiling
  110831. */
  110832. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  110833. /**
  110834. * Force shader compilation
  110835. * @param mesh defines the mesh that will use this material
  110836. * @param options defines additional options for compiling the shaders
  110837. * @returns a promise that resolves when the compilation completes
  110838. */
  110839. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  110840. private static readonly _AllDirtyCallBack;
  110841. private static readonly _ImageProcessingDirtyCallBack;
  110842. private static readonly _TextureDirtyCallBack;
  110843. private static readonly _FresnelDirtyCallBack;
  110844. private static readonly _MiscDirtyCallBack;
  110845. private static readonly _PrePassDirtyCallBack;
  110846. private static readonly _LightsDirtyCallBack;
  110847. private static readonly _AttributeDirtyCallBack;
  110848. private static _FresnelAndMiscDirtyCallBack;
  110849. private static _TextureAndMiscDirtyCallBack;
  110850. private static readonly _DirtyCallbackArray;
  110851. private static readonly _RunDirtyCallBacks;
  110852. /**
  110853. * Marks a define in the material to indicate that it needs to be re-computed
  110854. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  110855. */
  110856. markAsDirty(flag: number): void;
  110857. /**
  110858. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  110859. * @param func defines a function which checks material defines against the submeshes
  110860. */
  110861. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  110862. /**
  110863. * Indicates that the scene should check if the rendering now needs a prepass
  110864. */
  110865. protected _markScenePrePassDirty(): void;
  110866. /**
  110867. * Indicates that we need to re-calculated for all submeshes
  110868. */
  110869. protected _markAllSubMeshesAsAllDirty(): void;
  110870. /**
  110871. * Indicates that image processing needs to be re-calculated for all submeshes
  110872. */
  110873. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  110874. /**
  110875. * Indicates that textures need to be re-calculated for all submeshes
  110876. */
  110877. protected _markAllSubMeshesAsTexturesDirty(): void;
  110878. /**
  110879. * Indicates that fresnel needs to be re-calculated for all submeshes
  110880. */
  110881. protected _markAllSubMeshesAsFresnelDirty(): void;
  110882. /**
  110883. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  110884. */
  110885. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  110886. /**
  110887. * Indicates that lights need to be re-calculated for all submeshes
  110888. */
  110889. protected _markAllSubMeshesAsLightsDirty(): void;
  110890. /**
  110891. * Indicates that attributes need to be re-calculated for all submeshes
  110892. */
  110893. protected _markAllSubMeshesAsAttributesDirty(): void;
  110894. /**
  110895. * Indicates that misc needs to be re-calculated for all submeshes
  110896. */
  110897. protected _markAllSubMeshesAsMiscDirty(): void;
  110898. /**
  110899. * Indicates that prepass needs to be re-calculated for all submeshes
  110900. */
  110901. protected _markAllSubMeshesAsPrePassDirty(): void;
  110902. /**
  110903. * Indicates that textures and misc need to be re-calculated for all submeshes
  110904. */
  110905. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  110906. /**
  110907. * Sets the required values to the prepass renderer.
  110908. * @param prePassRenderer defines the prepass renderer to setup.
  110909. * @returns true if the pre pass is needed.
  110910. */
  110911. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  110912. /**
  110913. * Disposes the material
  110914. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  110915. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  110916. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  110917. */
  110918. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  110919. /** @hidden */
  110920. private releaseVertexArrayObject;
  110921. /**
  110922. * Serializes this material
  110923. * @returns the serialized material object
  110924. */
  110925. serialize(): any;
  110926. /**
  110927. * Creates a material from parsed material data
  110928. * @param parsedMaterial defines parsed material data
  110929. * @param scene defines the hosting scene
  110930. * @param rootUrl defines the root URL to use to load textures
  110931. * @returns a new material
  110932. */
  110933. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  110934. }
  110935. }
  110936. declare module BABYLON {
  110937. /**
  110938. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110939. * separate meshes. This can be use to improve performances.
  110940. * @see https://doc.babylonjs.com/how_to/multi_materials
  110941. */
  110942. export class MultiMaterial extends Material {
  110943. private _subMaterials;
  110944. /**
  110945. * Gets or Sets the list of Materials used within the multi material.
  110946. * They need to be ordered according to the submeshes order in the associated mesh
  110947. */
  110948. get subMaterials(): Nullable<Material>[];
  110949. set subMaterials(value: Nullable<Material>[]);
  110950. /**
  110951. * Function used to align with Node.getChildren()
  110952. * @returns the list of Materials used within the multi material
  110953. */
  110954. getChildren(): Nullable<Material>[];
  110955. /**
  110956. * Instantiates a new Multi Material
  110957. * A multi-material is used to apply different materials to different parts of the same object without the need of
  110958. * separate meshes. This can be use to improve performances.
  110959. * @see https://doc.babylonjs.com/how_to/multi_materials
  110960. * @param name Define the name in the scene
  110961. * @param scene Define the scene the material belongs to
  110962. */
  110963. constructor(name: string, scene: Scene);
  110964. private _hookArray;
  110965. /**
  110966. * Get one of the submaterial by its index in the submaterials array
  110967. * @param index The index to look the sub material at
  110968. * @returns The Material if the index has been defined
  110969. */
  110970. getSubMaterial(index: number): Nullable<Material>;
  110971. /**
  110972. * Get the list of active textures for the whole sub materials list.
  110973. * @returns All the textures that will be used during the rendering
  110974. */
  110975. getActiveTextures(): BaseTexture[];
  110976. /**
  110977. * Gets the current class name of the material e.g. "MultiMaterial"
  110978. * Mainly use in serialization.
  110979. * @returns the class name
  110980. */
  110981. getClassName(): string;
  110982. /**
  110983. * Checks if the material is ready to render the requested sub mesh
  110984. * @param mesh Define the mesh the submesh belongs to
  110985. * @param subMesh Define the sub mesh to look readyness for
  110986. * @param useInstances Define whether or not the material is used with instances
  110987. * @returns true if ready, otherwise false
  110988. */
  110989. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  110990. /**
  110991. * Clones the current material and its related sub materials
  110992. * @param name Define the name of the newly cloned material
  110993. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  110994. * @returns the cloned material
  110995. */
  110996. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  110997. /**
  110998. * Serializes the materials into a JSON representation.
  110999. * @returns the JSON representation
  111000. */
  111001. serialize(): any;
  111002. /**
  111003. * Dispose the material and release its associated resources
  111004. * @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)
  111005. * @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)
  111006. * @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)
  111007. */
  111008. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  111009. /**
  111010. * Creates a MultiMaterial from parsed MultiMaterial data.
  111011. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  111012. * @param scene defines the hosting scene
  111013. * @returns a new MultiMaterial
  111014. */
  111015. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  111016. }
  111017. }
  111018. declare module BABYLON {
  111019. /**
  111020. * Defines a subdivision inside a mesh
  111021. */
  111022. export class SubMesh implements ICullable {
  111023. /** the material index to use */
  111024. materialIndex: number;
  111025. /** vertex index start */
  111026. verticesStart: number;
  111027. /** vertices count */
  111028. verticesCount: number;
  111029. /** index start */
  111030. indexStart: number;
  111031. /** indices count */
  111032. indexCount: number;
  111033. /** @hidden */
  111034. _materialDefines: Nullable<MaterialDefines>;
  111035. /** @hidden */
  111036. _materialEffect: Nullable<Effect>;
  111037. /** @hidden */
  111038. _effectOverride: Nullable<Effect>;
  111039. /**
  111040. * Gets material defines used by the effect associated to the sub mesh
  111041. */
  111042. get materialDefines(): Nullable<MaterialDefines>;
  111043. /**
  111044. * Sets material defines used by the effect associated to the sub mesh
  111045. */
  111046. set materialDefines(defines: Nullable<MaterialDefines>);
  111047. /**
  111048. * Gets associated effect
  111049. */
  111050. get effect(): Nullable<Effect>;
  111051. /**
  111052. * Sets associated effect (effect used to render this submesh)
  111053. * @param effect defines the effect to associate with
  111054. * @param defines defines the set of defines used to compile this effect
  111055. */
  111056. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  111057. /** @hidden */
  111058. _linesIndexCount: number;
  111059. private _mesh;
  111060. private _renderingMesh;
  111061. private _boundingInfo;
  111062. private _linesIndexBuffer;
  111063. /** @hidden */
  111064. _lastColliderWorldVertices: Nullable<Vector3[]>;
  111065. /** @hidden */
  111066. _trianglePlanes: Plane[];
  111067. /** @hidden */
  111068. _lastColliderTransformMatrix: Nullable<Matrix>;
  111069. /** @hidden */
  111070. _renderId: number;
  111071. /** @hidden */
  111072. _alphaIndex: number;
  111073. /** @hidden */
  111074. _distanceToCamera: number;
  111075. /** @hidden */
  111076. _id: number;
  111077. private _currentMaterial;
  111078. /**
  111079. * Add a new submesh to a mesh
  111080. * @param materialIndex defines the material index to use
  111081. * @param verticesStart defines vertex index start
  111082. * @param verticesCount defines vertices count
  111083. * @param indexStart defines index start
  111084. * @param indexCount defines indices count
  111085. * @param mesh defines the parent mesh
  111086. * @param renderingMesh defines an optional rendering mesh
  111087. * @param createBoundingBox defines if bounding box should be created for this submesh
  111088. * @returns the new submesh
  111089. */
  111090. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  111091. /**
  111092. * Creates a new submesh
  111093. * @param materialIndex defines the material index to use
  111094. * @param verticesStart defines vertex index start
  111095. * @param verticesCount defines vertices count
  111096. * @param indexStart defines index start
  111097. * @param indexCount defines indices count
  111098. * @param mesh defines the parent mesh
  111099. * @param renderingMesh defines an optional rendering mesh
  111100. * @param createBoundingBox defines if bounding box should be created for this submesh
  111101. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  111102. */
  111103. constructor(
  111104. /** the material index to use */
  111105. materialIndex: number,
  111106. /** vertex index start */
  111107. verticesStart: number,
  111108. /** vertices count */
  111109. verticesCount: number,
  111110. /** index start */
  111111. indexStart: number,
  111112. /** indices count */
  111113. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  111114. /**
  111115. * Returns true if this submesh covers the entire parent mesh
  111116. * @ignorenaming
  111117. */
  111118. get IsGlobal(): boolean;
  111119. /**
  111120. * Returns the submesh BoudingInfo object
  111121. * @returns current bounding info (or mesh's one if the submesh is global)
  111122. */
  111123. getBoundingInfo(): BoundingInfo;
  111124. /**
  111125. * Sets the submesh BoundingInfo
  111126. * @param boundingInfo defines the new bounding info to use
  111127. * @returns the SubMesh
  111128. */
  111129. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  111130. /**
  111131. * Returns the mesh of the current submesh
  111132. * @return the parent mesh
  111133. */
  111134. getMesh(): AbstractMesh;
  111135. /**
  111136. * Returns the rendering mesh of the submesh
  111137. * @returns the rendering mesh (could be different from parent mesh)
  111138. */
  111139. getRenderingMesh(): Mesh;
  111140. /**
  111141. * Returns the replacement mesh of the submesh
  111142. * @returns the replacement mesh (could be different from parent mesh)
  111143. */
  111144. getReplacementMesh(): Nullable<AbstractMesh>;
  111145. /**
  111146. * Returns the effective mesh of the submesh
  111147. * @returns the effective mesh (could be different from parent mesh)
  111148. */
  111149. getEffectiveMesh(): AbstractMesh;
  111150. /**
  111151. * Returns the submesh material
  111152. * @returns null or the current material
  111153. */
  111154. getMaterial(): Nullable<Material>;
  111155. private _IsMultiMaterial;
  111156. /**
  111157. * Sets a new updated BoundingInfo object to the submesh
  111158. * @param data defines an optional position array to use to determine the bounding info
  111159. * @returns the SubMesh
  111160. */
  111161. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  111162. /** @hidden */
  111163. _checkCollision(collider: Collider): boolean;
  111164. /**
  111165. * Updates the submesh BoundingInfo
  111166. * @param world defines the world matrix to use to update the bounding info
  111167. * @returns the submesh
  111168. */
  111169. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  111170. /**
  111171. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  111172. * @param frustumPlanes defines the frustum planes
  111173. * @returns true if the submesh is intersecting with the frustum
  111174. */
  111175. isInFrustum(frustumPlanes: Plane[]): boolean;
  111176. /**
  111177. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  111178. * @param frustumPlanes defines the frustum planes
  111179. * @returns true if the submesh is inside the frustum
  111180. */
  111181. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  111182. /**
  111183. * Renders the submesh
  111184. * @param enableAlphaMode defines if alpha needs to be used
  111185. * @returns the submesh
  111186. */
  111187. render(enableAlphaMode: boolean): SubMesh;
  111188. /**
  111189. * @hidden
  111190. */
  111191. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  111192. /**
  111193. * Checks if the submesh intersects with a ray
  111194. * @param ray defines the ray to test
  111195. * @returns true is the passed ray intersects the submesh bounding box
  111196. */
  111197. canIntersects(ray: Ray): boolean;
  111198. /**
  111199. * Intersects current submesh with a ray
  111200. * @param ray defines the ray to test
  111201. * @param positions defines mesh's positions array
  111202. * @param indices defines mesh's indices array
  111203. * @param fastCheck defines if the first intersection will be used (and not the closest)
  111204. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111205. * @returns intersection info or null if no intersection
  111206. */
  111207. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  111208. /** @hidden */
  111209. private _intersectLines;
  111210. /** @hidden */
  111211. private _intersectUnIndexedLines;
  111212. /** @hidden */
  111213. private _intersectTriangles;
  111214. /** @hidden */
  111215. private _intersectUnIndexedTriangles;
  111216. /** @hidden */
  111217. _rebuild(): void;
  111218. /**
  111219. * Creates a new submesh from the passed mesh
  111220. * @param newMesh defines the new hosting mesh
  111221. * @param newRenderingMesh defines an optional rendering mesh
  111222. * @returns the new submesh
  111223. */
  111224. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  111225. /**
  111226. * Release associated resources
  111227. */
  111228. dispose(): void;
  111229. /**
  111230. * Gets the class name
  111231. * @returns the string "SubMesh".
  111232. */
  111233. getClassName(): string;
  111234. /**
  111235. * Creates a new submesh from indices data
  111236. * @param materialIndex the index of the main mesh material
  111237. * @param startIndex the index where to start the copy in the mesh indices array
  111238. * @param indexCount the number of indices to copy then from the startIndex
  111239. * @param mesh the main mesh to create the submesh from
  111240. * @param renderingMesh the optional rendering mesh
  111241. * @returns a new submesh
  111242. */
  111243. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  111244. }
  111245. }
  111246. declare module BABYLON {
  111247. /**
  111248. * Class used to represent data loading progression
  111249. */
  111250. export class SceneLoaderFlags {
  111251. private static _ForceFullSceneLoadingForIncremental;
  111252. private static _ShowLoadingScreen;
  111253. private static _CleanBoneMatrixWeights;
  111254. private static _loggingLevel;
  111255. /**
  111256. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  111257. */
  111258. static get ForceFullSceneLoadingForIncremental(): boolean;
  111259. static set ForceFullSceneLoadingForIncremental(value: boolean);
  111260. /**
  111261. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  111262. */
  111263. static get ShowLoadingScreen(): boolean;
  111264. static set ShowLoadingScreen(value: boolean);
  111265. /**
  111266. * Defines the current logging level (while loading the scene)
  111267. * @ignorenaming
  111268. */
  111269. static get loggingLevel(): number;
  111270. static set loggingLevel(value: number);
  111271. /**
  111272. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  111273. */
  111274. static get CleanBoneMatrixWeights(): boolean;
  111275. static set CleanBoneMatrixWeights(value: boolean);
  111276. }
  111277. }
  111278. declare module BABYLON {
  111279. /**
  111280. * Class used to store geometry data (vertex buffers + index buffer)
  111281. */
  111282. export class Geometry implements IGetSetVerticesData {
  111283. /**
  111284. * Gets or sets the ID of the geometry
  111285. */
  111286. id: string;
  111287. /**
  111288. * Gets or sets the unique ID of the geometry
  111289. */
  111290. uniqueId: number;
  111291. /**
  111292. * Gets the delay loading state of the geometry (none by default which means not delayed)
  111293. */
  111294. delayLoadState: number;
  111295. /**
  111296. * Gets the file containing the data to load when running in delay load state
  111297. */
  111298. delayLoadingFile: Nullable<string>;
  111299. /**
  111300. * Callback called when the geometry is updated
  111301. */
  111302. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  111303. private _scene;
  111304. private _engine;
  111305. private _meshes;
  111306. private _totalVertices;
  111307. /** @hidden */
  111308. _indices: IndicesArray;
  111309. /** @hidden */
  111310. _vertexBuffers: {
  111311. [key: string]: VertexBuffer;
  111312. };
  111313. private _isDisposed;
  111314. private _extend;
  111315. private _boundingBias;
  111316. /** @hidden */
  111317. _delayInfo: Array<string>;
  111318. private _indexBuffer;
  111319. private _indexBufferIsUpdatable;
  111320. /** @hidden */
  111321. _boundingInfo: Nullable<BoundingInfo>;
  111322. /** @hidden */
  111323. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  111324. /** @hidden */
  111325. _softwareSkinningFrameId: number;
  111326. private _vertexArrayObjects;
  111327. private _updatable;
  111328. /** @hidden */
  111329. _positions: Nullable<Vector3[]>;
  111330. private _positionsCache;
  111331. /**
  111332. * 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
  111333. */
  111334. get boundingBias(): Vector2;
  111335. /**
  111336. * 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
  111337. */
  111338. set boundingBias(value: Vector2);
  111339. /**
  111340. * Static function used to attach a new empty geometry to a mesh
  111341. * @param mesh defines the mesh to attach the geometry to
  111342. * @returns the new Geometry
  111343. */
  111344. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  111345. /** Get the list of meshes using this geometry */
  111346. get meshes(): Mesh[];
  111347. /**
  111348. * 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
  111349. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  111350. */
  111351. useBoundingInfoFromGeometry: boolean;
  111352. /**
  111353. * Creates a new geometry
  111354. * @param id defines the unique ID
  111355. * @param scene defines the hosting scene
  111356. * @param vertexData defines the VertexData used to get geometry data
  111357. * @param updatable defines if geometry must be updatable (false by default)
  111358. * @param mesh defines the mesh that will be associated with the geometry
  111359. */
  111360. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  111361. /**
  111362. * Gets the current extend of the geometry
  111363. */
  111364. get extend(): {
  111365. minimum: Vector3;
  111366. maximum: Vector3;
  111367. };
  111368. /**
  111369. * Gets the hosting scene
  111370. * @returns the hosting Scene
  111371. */
  111372. getScene(): Scene;
  111373. /**
  111374. * Gets the hosting engine
  111375. * @returns the hosting Engine
  111376. */
  111377. getEngine(): Engine;
  111378. /**
  111379. * Defines if the geometry is ready to use
  111380. * @returns true if the geometry is ready to be used
  111381. */
  111382. isReady(): boolean;
  111383. /**
  111384. * Gets a value indicating that the geometry should not be serialized
  111385. */
  111386. get doNotSerialize(): boolean;
  111387. /** @hidden */
  111388. _rebuild(): void;
  111389. /**
  111390. * Affects all geometry data in one call
  111391. * @param vertexData defines the geometry data
  111392. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  111393. */
  111394. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  111395. /**
  111396. * Set specific vertex data
  111397. * @param kind defines the data kind (Position, normal, etc...)
  111398. * @param data defines the vertex data to use
  111399. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  111400. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  111401. */
  111402. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  111403. /**
  111404. * Removes a specific vertex data
  111405. * @param kind defines the data kind (Position, normal, etc...)
  111406. */
  111407. removeVerticesData(kind: string): void;
  111408. /**
  111409. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  111410. * @param buffer defines the vertex buffer to use
  111411. * @param totalVertices defines the total number of vertices for position kind (could be null)
  111412. */
  111413. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  111414. /**
  111415. * Update a specific vertex buffer
  111416. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  111417. * It will do nothing if the buffer is not updatable
  111418. * @param kind defines the data kind (Position, normal, etc...)
  111419. * @param data defines the data to use
  111420. * @param offset defines the offset in the target buffer where to store the data
  111421. * @param useBytes set to true if the offset is in bytes
  111422. */
  111423. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  111424. /**
  111425. * Update a specific vertex buffer
  111426. * This function will create a new buffer if the current one is not updatable
  111427. * @param kind defines the data kind (Position, normal, etc...)
  111428. * @param data defines the data to use
  111429. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  111430. */
  111431. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  111432. private _updateBoundingInfo;
  111433. /** @hidden */
  111434. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  111435. /**
  111436. * Gets total number of vertices
  111437. * @returns the total number of vertices
  111438. */
  111439. getTotalVertices(): number;
  111440. /**
  111441. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  111442. * @param kind defines the data kind (Position, normal, etc...)
  111443. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111444. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111445. * @returns a float array containing vertex data
  111446. */
  111447. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  111448. /**
  111449. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  111450. * @param kind defines the data kind (Position, normal, etc...)
  111451. * @returns true if the vertex buffer with the specified kind is updatable
  111452. */
  111453. isVertexBufferUpdatable(kind: string): boolean;
  111454. /**
  111455. * Gets a specific vertex buffer
  111456. * @param kind defines the data kind (Position, normal, etc...)
  111457. * @returns a VertexBuffer
  111458. */
  111459. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  111460. /**
  111461. * Returns all vertex buffers
  111462. * @return an object holding all vertex buffers indexed by kind
  111463. */
  111464. getVertexBuffers(): Nullable<{
  111465. [key: string]: VertexBuffer;
  111466. }>;
  111467. /**
  111468. * Gets a boolean indicating if specific vertex buffer is present
  111469. * @param kind defines the data kind (Position, normal, etc...)
  111470. * @returns true if data is present
  111471. */
  111472. isVerticesDataPresent(kind: string): boolean;
  111473. /**
  111474. * Gets a list of all attached data kinds (Position, normal, etc...)
  111475. * @returns a list of string containing all kinds
  111476. */
  111477. getVerticesDataKinds(): string[];
  111478. /**
  111479. * Update index buffer
  111480. * @param indices defines the indices to store in the index buffer
  111481. * @param offset defines the offset in the target buffer where to store the data
  111482. * @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)
  111483. */
  111484. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  111485. /**
  111486. * Creates a new index buffer
  111487. * @param indices defines the indices to store in the index buffer
  111488. * @param totalVertices defines the total number of vertices (could be null)
  111489. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  111490. */
  111491. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  111492. /**
  111493. * Return the total number of indices
  111494. * @returns the total number of indices
  111495. */
  111496. getTotalIndices(): number;
  111497. /**
  111498. * Gets the index buffer array
  111499. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111500. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111501. * @returns the index buffer array
  111502. */
  111503. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  111504. /**
  111505. * Gets the index buffer
  111506. * @return the index buffer
  111507. */
  111508. getIndexBuffer(): Nullable<DataBuffer>;
  111509. /** @hidden */
  111510. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  111511. /**
  111512. * Release the associated resources for a specific mesh
  111513. * @param mesh defines the source mesh
  111514. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  111515. */
  111516. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  111517. /**
  111518. * Apply current geometry to a given mesh
  111519. * @param mesh defines the mesh to apply geometry to
  111520. */
  111521. applyToMesh(mesh: Mesh): void;
  111522. private _updateExtend;
  111523. private _applyToMesh;
  111524. private notifyUpdate;
  111525. /**
  111526. * Load the geometry if it was flagged as delay loaded
  111527. * @param scene defines the hosting scene
  111528. * @param onLoaded defines a callback called when the geometry is loaded
  111529. */
  111530. load(scene: Scene, onLoaded?: () => void): void;
  111531. private _queueLoad;
  111532. /**
  111533. * Invert the geometry to move from a right handed system to a left handed one.
  111534. */
  111535. toLeftHanded(): void;
  111536. /** @hidden */
  111537. _resetPointsArrayCache(): void;
  111538. /** @hidden */
  111539. _generatePointsArray(): boolean;
  111540. /**
  111541. * Gets a value indicating if the geometry is disposed
  111542. * @returns true if the geometry was disposed
  111543. */
  111544. isDisposed(): boolean;
  111545. private _disposeVertexArrayObjects;
  111546. /**
  111547. * Free all associated resources
  111548. */
  111549. dispose(): void;
  111550. /**
  111551. * Clone the current geometry into a new geometry
  111552. * @param id defines the unique ID of the new geometry
  111553. * @returns a new geometry object
  111554. */
  111555. copy(id: string): Geometry;
  111556. /**
  111557. * Serialize the current geometry info (and not the vertices data) into a JSON object
  111558. * @return a JSON representation of the current geometry data (without the vertices data)
  111559. */
  111560. serialize(): any;
  111561. private toNumberArray;
  111562. /**
  111563. * Serialize all vertices data into a JSON oject
  111564. * @returns a JSON representation of the current geometry data
  111565. */
  111566. serializeVerticeData(): any;
  111567. /**
  111568. * Extracts a clone of a mesh geometry
  111569. * @param mesh defines the source mesh
  111570. * @param id defines the unique ID of the new geometry object
  111571. * @returns the new geometry object
  111572. */
  111573. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  111574. /**
  111575. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  111576. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  111577. * Be aware Math.random() could cause collisions, but:
  111578. * "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"
  111579. * @returns a string containing a new GUID
  111580. */
  111581. static RandomId(): string;
  111582. /** @hidden */
  111583. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  111584. private static _CleanMatricesWeights;
  111585. /**
  111586. * Create a new geometry from persisted data (Using .babylon file format)
  111587. * @param parsedVertexData defines the persisted data
  111588. * @param scene defines the hosting scene
  111589. * @param rootUrl defines the root url to use to load assets (like delayed data)
  111590. * @returns the new geometry object
  111591. */
  111592. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  111593. }
  111594. }
  111595. declare module BABYLON {
  111596. /**
  111597. * Define an interface for all classes that will get and set the data on vertices
  111598. */
  111599. export interface IGetSetVerticesData {
  111600. /**
  111601. * Gets a boolean indicating if specific vertex data is present
  111602. * @param kind defines the vertex data kind to use
  111603. * @returns true is data kind is present
  111604. */
  111605. isVerticesDataPresent(kind: string): boolean;
  111606. /**
  111607. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  111608. * @param kind defines the data kind (Position, normal, etc...)
  111609. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  111610. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111611. * @returns a float array containing vertex data
  111612. */
  111613. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  111614. /**
  111615. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  111616. * @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.
  111617. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  111618. * @returns the indices array or an empty array if the mesh has no geometry
  111619. */
  111620. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  111621. /**
  111622. * Set specific vertex data
  111623. * @param kind defines the data kind (Position, normal, etc...)
  111624. * @param data defines the vertex data to use
  111625. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  111626. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  111627. */
  111628. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  111629. /**
  111630. * Update a specific associated vertex buffer
  111631. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  111632. * - VertexBuffer.PositionKind
  111633. * - VertexBuffer.UVKind
  111634. * - VertexBuffer.UV2Kind
  111635. * - VertexBuffer.UV3Kind
  111636. * - VertexBuffer.UV4Kind
  111637. * - VertexBuffer.UV5Kind
  111638. * - VertexBuffer.UV6Kind
  111639. * - VertexBuffer.ColorKind
  111640. * - VertexBuffer.MatricesIndicesKind
  111641. * - VertexBuffer.MatricesIndicesExtraKind
  111642. * - VertexBuffer.MatricesWeightsKind
  111643. * - VertexBuffer.MatricesWeightsExtraKind
  111644. * @param data defines the data source
  111645. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  111646. * @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)
  111647. */
  111648. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  111649. /**
  111650. * Creates a new index buffer
  111651. * @param indices defines the indices to store in the index buffer
  111652. * @param totalVertices defines the total number of vertices (could be null)
  111653. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  111654. */
  111655. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  111656. }
  111657. /**
  111658. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  111659. */
  111660. export class VertexData {
  111661. /**
  111662. * Mesh side orientation : usually the external or front surface
  111663. */
  111664. static readonly FRONTSIDE: number;
  111665. /**
  111666. * Mesh side orientation : usually the internal or back surface
  111667. */
  111668. static readonly BACKSIDE: number;
  111669. /**
  111670. * Mesh side orientation : both internal and external or front and back surfaces
  111671. */
  111672. static readonly DOUBLESIDE: number;
  111673. /**
  111674. * Mesh side orientation : by default, `FRONTSIDE`
  111675. */
  111676. static readonly DEFAULTSIDE: number;
  111677. /**
  111678. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  111679. */
  111680. positions: Nullable<FloatArray>;
  111681. /**
  111682. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  111683. */
  111684. normals: Nullable<FloatArray>;
  111685. /**
  111686. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  111687. */
  111688. tangents: Nullable<FloatArray>;
  111689. /**
  111690. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111691. */
  111692. uvs: Nullable<FloatArray>;
  111693. /**
  111694. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111695. */
  111696. uvs2: Nullable<FloatArray>;
  111697. /**
  111698. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111699. */
  111700. uvs3: Nullable<FloatArray>;
  111701. /**
  111702. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111703. */
  111704. uvs4: Nullable<FloatArray>;
  111705. /**
  111706. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111707. */
  111708. uvs5: Nullable<FloatArray>;
  111709. /**
  111710. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  111711. */
  111712. uvs6: Nullable<FloatArray>;
  111713. /**
  111714. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  111715. */
  111716. colors: Nullable<FloatArray>;
  111717. /**
  111718. * 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).
  111719. */
  111720. matricesIndices: Nullable<FloatArray>;
  111721. /**
  111722. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  111723. */
  111724. matricesWeights: Nullable<FloatArray>;
  111725. /**
  111726. * An array extending the number of possible indices
  111727. */
  111728. matricesIndicesExtra: Nullable<FloatArray>;
  111729. /**
  111730. * An array extending the number of possible weights when the number of indices is extended
  111731. */
  111732. matricesWeightsExtra: Nullable<FloatArray>;
  111733. /**
  111734. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  111735. */
  111736. indices: Nullable<IndicesArray>;
  111737. /**
  111738. * Uses the passed data array to set the set the values for the specified kind of data
  111739. * @param data a linear array of floating numbers
  111740. * @param kind the type of data that is being set, eg positions, colors etc
  111741. */
  111742. set(data: FloatArray, kind: string): void;
  111743. /**
  111744. * Associates the vertexData to the passed Mesh.
  111745. * Sets it as updatable or not (default `false`)
  111746. * @param mesh the mesh the vertexData is applied to
  111747. * @param updatable when used and having the value true allows new data to update the vertexData
  111748. * @returns the VertexData
  111749. */
  111750. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  111751. /**
  111752. * Associates the vertexData to the passed Geometry.
  111753. * Sets it as updatable or not (default `false`)
  111754. * @param geometry the geometry the vertexData is applied to
  111755. * @param updatable when used and having the value true allows new data to update the vertexData
  111756. * @returns VertexData
  111757. */
  111758. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  111759. /**
  111760. * Updates the associated mesh
  111761. * @param mesh the mesh to be updated
  111762. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111763. * @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
  111764. * @returns VertexData
  111765. */
  111766. updateMesh(mesh: Mesh): VertexData;
  111767. /**
  111768. * Updates the associated geometry
  111769. * @param geometry the geometry to be updated
  111770. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  111771. * @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
  111772. * @returns VertexData.
  111773. */
  111774. updateGeometry(geometry: Geometry): VertexData;
  111775. private _applyTo;
  111776. private _update;
  111777. /**
  111778. * Transforms each position and each normal of the vertexData according to the passed Matrix
  111779. * @param matrix the transforming matrix
  111780. * @returns the VertexData
  111781. */
  111782. transform(matrix: Matrix): VertexData;
  111783. /**
  111784. * Merges the passed VertexData into the current one
  111785. * @param other the VertexData to be merged into the current one
  111786. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  111787. * @returns the modified VertexData
  111788. */
  111789. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  111790. private _mergeElement;
  111791. private _validate;
  111792. /**
  111793. * Serializes the VertexData
  111794. * @returns a serialized object
  111795. */
  111796. serialize(): any;
  111797. /**
  111798. * Extracts the vertexData from a mesh
  111799. * @param mesh the mesh from which to extract the VertexData
  111800. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  111801. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111802. * @returns the object VertexData associated to the passed mesh
  111803. */
  111804. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111805. /**
  111806. * Extracts the vertexData from the geometry
  111807. * @param geometry the geometry from which to extract the VertexData
  111808. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  111809. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  111810. * @returns the object VertexData associated to the passed mesh
  111811. */
  111812. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  111813. private static _ExtractFrom;
  111814. /**
  111815. * Creates the VertexData for a Ribbon
  111816. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  111817. * * pathArray array of paths, each of which an array of successive Vector3
  111818. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  111819. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  111820. * * 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
  111821. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111822. * * 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)
  111823. * * 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)
  111824. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  111825. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  111826. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  111827. * @returns the VertexData of the ribbon
  111828. */
  111829. static CreateRibbon(options: {
  111830. pathArray: Vector3[][];
  111831. closeArray?: boolean;
  111832. closePath?: boolean;
  111833. offset?: number;
  111834. sideOrientation?: number;
  111835. frontUVs?: Vector4;
  111836. backUVs?: Vector4;
  111837. invertUV?: boolean;
  111838. uvs?: Vector2[];
  111839. colors?: Color4[];
  111840. }): VertexData;
  111841. /**
  111842. * Creates the VertexData for a box
  111843. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111844. * * size sets the width, height and depth of the box to the value of size, optional default 1
  111845. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  111846. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  111847. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  111848. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111849. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111850. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111851. * * 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)
  111852. * * 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)
  111853. * @returns the VertexData of the box
  111854. */
  111855. static CreateBox(options: {
  111856. size?: number;
  111857. width?: number;
  111858. height?: number;
  111859. depth?: number;
  111860. faceUV?: Vector4[];
  111861. faceColors?: Color4[];
  111862. sideOrientation?: number;
  111863. frontUVs?: Vector4;
  111864. backUVs?: Vector4;
  111865. }): VertexData;
  111866. /**
  111867. * Creates the VertexData for a tiled box
  111868. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111869. * * faceTiles sets the pattern, tile size and number of tiles for a face
  111870. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  111871. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  111872. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111873. * @returns the VertexData of the box
  111874. */
  111875. static CreateTiledBox(options: {
  111876. pattern?: number;
  111877. width?: number;
  111878. height?: number;
  111879. depth?: number;
  111880. tileSize?: number;
  111881. tileWidth?: number;
  111882. tileHeight?: number;
  111883. alignHorizontal?: number;
  111884. alignVertical?: number;
  111885. faceUV?: Vector4[];
  111886. faceColors?: Color4[];
  111887. sideOrientation?: number;
  111888. }): VertexData;
  111889. /**
  111890. * Creates the VertexData for a tiled plane
  111891. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111892. * * pattern a limited pattern arrangement depending on the number
  111893. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  111894. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  111895. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  111896. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111897. * * 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)
  111898. * * 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)
  111899. * @returns the VertexData of the tiled plane
  111900. */
  111901. static CreateTiledPlane(options: {
  111902. pattern?: number;
  111903. tileSize?: number;
  111904. tileWidth?: number;
  111905. tileHeight?: number;
  111906. size?: number;
  111907. width?: number;
  111908. height?: number;
  111909. alignHorizontal?: number;
  111910. alignVertical?: number;
  111911. sideOrientation?: number;
  111912. frontUVs?: Vector4;
  111913. backUVs?: Vector4;
  111914. }): VertexData;
  111915. /**
  111916. * Creates the VertexData for an ellipsoid, defaults to a sphere
  111917. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111918. * * segments sets the number of horizontal strips optional, default 32
  111919. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  111920. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  111921. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  111922. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  111923. * * 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
  111924. * * 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
  111925. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111926. * * 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)
  111927. * * 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)
  111928. * @returns the VertexData of the ellipsoid
  111929. */
  111930. static CreateSphere(options: {
  111931. segments?: number;
  111932. diameter?: number;
  111933. diameterX?: number;
  111934. diameterY?: number;
  111935. diameterZ?: number;
  111936. arc?: number;
  111937. slice?: number;
  111938. sideOrientation?: number;
  111939. frontUVs?: Vector4;
  111940. backUVs?: Vector4;
  111941. }): VertexData;
  111942. /**
  111943. * Creates the VertexData for a cylinder, cone or prism
  111944. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111945. * * height sets the height (y direction) of the cylinder, optional, default 2
  111946. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  111947. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  111948. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  111949. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111950. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  111951. * * 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
  111952. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  111953. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  111954. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  111955. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  111956. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111957. * * 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)
  111958. * * 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)
  111959. * @returns the VertexData of the cylinder, cone or prism
  111960. */
  111961. static CreateCylinder(options: {
  111962. height?: number;
  111963. diameterTop?: number;
  111964. diameterBottom?: number;
  111965. diameter?: number;
  111966. tessellation?: number;
  111967. subdivisions?: number;
  111968. arc?: number;
  111969. faceColors?: Color4[];
  111970. faceUV?: Vector4[];
  111971. hasRings?: boolean;
  111972. enclose?: boolean;
  111973. sideOrientation?: number;
  111974. frontUVs?: Vector4;
  111975. backUVs?: Vector4;
  111976. }): VertexData;
  111977. /**
  111978. * Creates the VertexData for a torus
  111979. * @param options an object used to set the following optional parameters for the box, required but can be empty
  111980. * * diameter the diameter of the torus, optional default 1
  111981. * * thickness the diameter of the tube forming the torus, optional default 0.5
  111982. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  111983. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  111984. * * 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)
  111985. * * 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)
  111986. * @returns the VertexData of the torus
  111987. */
  111988. static CreateTorus(options: {
  111989. diameter?: number;
  111990. thickness?: number;
  111991. tessellation?: number;
  111992. sideOrientation?: number;
  111993. frontUVs?: Vector4;
  111994. backUVs?: Vector4;
  111995. }): VertexData;
  111996. /**
  111997. * Creates the VertexData of the LineSystem
  111998. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  111999. * - lines an array of lines, each line being an array of successive Vector3
  112000. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  112001. * @returns the VertexData of the LineSystem
  112002. */
  112003. static CreateLineSystem(options: {
  112004. lines: Vector3[][];
  112005. colors?: Nullable<Color4[][]>;
  112006. }): VertexData;
  112007. /**
  112008. * Create the VertexData for a DashedLines
  112009. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  112010. * - points an array successive Vector3
  112011. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  112012. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  112013. * - dashNb the intended total number of dashes, optional, default 200
  112014. * @returns the VertexData for the DashedLines
  112015. */
  112016. static CreateDashedLines(options: {
  112017. points: Vector3[];
  112018. dashSize?: number;
  112019. gapSize?: number;
  112020. dashNb?: number;
  112021. }): VertexData;
  112022. /**
  112023. * Creates the VertexData for a Ground
  112024. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  112025. * - width the width (x direction) of the ground, optional, default 1
  112026. * - height the height (z direction) of the ground, optional, default 1
  112027. * - subdivisions the number of subdivisions per side, optional, default 1
  112028. * @returns the VertexData of the Ground
  112029. */
  112030. static CreateGround(options: {
  112031. width?: number;
  112032. height?: number;
  112033. subdivisions?: number;
  112034. subdivisionsX?: number;
  112035. subdivisionsY?: number;
  112036. }): VertexData;
  112037. /**
  112038. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  112039. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  112040. * * xmin the ground minimum X coordinate, optional, default -1
  112041. * * zmin the ground minimum Z coordinate, optional, default -1
  112042. * * xmax the ground maximum X coordinate, optional, default 1
  112043. * * zmax the ground maximum Z coordinate, optional, default 1
  112044. * * 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}
  112045. * * 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}
  112046. * @returns the VertexData of the TiledGround
  112047. */
  112048. static CreateTiledGround(options: {
  112049. xmin: number;
  112050. zmin: number;
  112051. xmax: number;
  112052. zmax: number;
  112053. subdivisions?: {
  112054. w: number;
  112055. h: number;
  112056. };
  112057. precision?: {
  112058. w: number;
  112059. h: number;
  112060. };
  112061. }): VertexData;
  112062. /**
  112063. * Creates the VertexData of the Ground designed from a heightmap
  112064. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  112065. * * width the width (x direction) of the ground
  112066. * * height the height (z direction) of the ground
  112067. * * subdivisions the number of subdivisions per side
  112068. * * minHeight the minimum altitude on the ground, optional, default 0
  112069. * * maxHeight the maximum altitude on the ground, optional default 1
  112070. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  112071. * * buffer the array holding the image color data
  112072. * * bufferWidth the width of image
  112073. * * bufferHeight the height of image
  112074. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  112075. * @returns the VertexData of the Ground designed from a heightmap
  112076. */
  112077. static CreateGroundFromHeightMap(options: {
  112078. width: number;
  112079. height: number;
  112080. subdivisions: number;
  112081. minHeight: number;
  112082. maxHeight: number;
  112083. colorFilter: Color3;
  112084. buffer: Uint8Array;
  112085. bufferWidth: number;
  112086. bufferHeight: number;
  112087. alphaFilter: number;
  112088. }): VertexData;
  112089. /**
  112090. * Creates the VertexData for a Plane
  112091. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  112092. * * size sets the width and height of the plane to the value of size, optional default 1
  112093. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  112094. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  112095. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112096. * * 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)
  112097. * * 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)
  112098. * @returns the VertexData of the box
  112099. */
  112100. static CreatePlane(options: {
  112101. size?: number;
  112102. width?: number;
  112103. height?: number;
  112104. sideOrientation?: number;
  112105. frontUVs?: Vector4;
  112106. backUVs?: Vector4;
  112107. }): VertexData;
  112108. /**
  112109. * Creates the VertexData of the Disc or regular Polygon
  112110. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  112111. * * radius the radius of the disc, optional default 0.5
  112112. * * tessellation the number of polygon sides, optional, default 64
  112113. * * 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
  112114. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112115. * * 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)
  112116. * * 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)
  112117. * @returns the VertexData of the box
  112118. */
  112119. static CreateDisc(options: {
  112120. radius?: number;
  112121. tessellation?: number;
  112122. arc?: number;
  112123. sideOrientation?: number;
  112124. frontUVs?: Vector4;
  112125. backUVs?: Vector4;
  112126. }): VertexData;
  112127. /**
  112128. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  112129. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  112130. * @param polygon a mesh built from polygonTriangulation.build()
  112131. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112132. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  112133. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  112134. * @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)
  112135. * @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)
  112136. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  112137. * @returns the VertexData of the Polygon
  112138. */
  112139. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  112140. /**
  112141. * Creates the VertexData of the IcoSphere
  112142. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  112143. * * radius the radius of the IcoSphere, optional default 1
  112144. * * radiusX allows stretching in the x direction, optional, default radius
  112145. * * radiusY allows stretching in the y direction, optional, default radius
  112146. * * radiusZ allows stretching in the z direction, optional, default radius
  112147. * * flat when true creates a flat shaded mesh, optional, default true
  112148. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  112149. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112150. * * 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)
  112151. * * 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)
  112152. * @returns the VertexData of the IcoSphere
  112153. */
  112154. static CreateIcoSphere(options: {
  112155. radius?: number;
  112156. radiusX?: number;
  112157. radiusY?: number;
  112158. radiusZ?: number;
  112159. flat?: boolean;
  112160. subdivisions?: number;
  112161. sideOrientation?: number;
  112162. frontUVs?: Vector4;
  112163. backUVs?: Vector4;
  112164. }): VertexData;
  112165. /**
  112166. * Creates the VertexData for a Polyhedron
  112167. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  112168. * * type provided types are:
  112169. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  112170. * * 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)
  112171. * * size the size of the IcoSphere, optional default 1
  112172. * * sizeX allows stretching in the x direction, optional, default size
  112173. * * sizeY allows stretching in the y direction, optional, default size
  112174. * * sizeZ allows stretching in the z direction, optional, default size
  112175. * * 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
  112176. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  112177. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  112178. * * flat when true creates a flat shaded mesh, optional, default true
  112179. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  112180. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112181. * * 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)
  112182. * * 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)
  112183. * @returns the VertexData of the Polyhedron
  112184. */
  112185. static CreatePolyhedron(options: {
  112186. type?: number;
  112187. size?: number;
  112188. sizeX?: number;
  112189. sizeY?: number;
  112190. sizeZ?: number;
  112191. custom?: any;
  112192. faceUV?: Vector4[];
  112193. faceColors?: Color4[];
  112194. flat?: boolean;
  112195. sideOrientation?: number;
  112196. frontUVs?: Vector4;
  112197. backUVs?: Vector4;
  112198. }): VertexData;
  112199. /**
  112200. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  112201. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  112202. * @returns the VertexData of the Capsule
  112203. */
  112204. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  112205. /**
  112206. * Creates the VertexData for a TorusKnot
  112207. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  112208. * * radius the radius of the torus knot, optional, default 2
  112209. * * tube the thickness of the tube, optional, default 0.5
  112210. * * radialSegments the number of sides on each tube segments, optional, default 32
  112211. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  112212. * * p the number of windings around the z axis, optional, default 2
  112213. * * q the number of windings around the x axis, optional, default 3
  112214. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  112215. * * 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)
  112216. * * 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)
  112217. * @returns the VertexData of the Torus Knot
  112218. */
  112219. static CreateTorusKnot(options: {
  112220. radius?: number;
  112221. tube?: number;
  112222. radialSegments?: number;
  112223. tubularSegments?: number;
  112224. p?: number;
  112225. q?: number;
  112226. sideOrientation?: number;
  112227. frontUVs?: Vector4;
  112228. backUVs?: Vector4;
  112229. }): VertexData;
  112230. /**
  112231. * Compute normals for given positions and indices
  112232. * @param positions an array of vertex positions, [...., x, y, z, ......]
  112233. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  112234. * @param normals an array of vertex normals, [...., x, y, z, ......]
  112235. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  112236. * * facetNormals : optional array of facet normals (vector3)
  112237. * * facetPositions : optional array of facet positions (vector3)
  112238. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  112239. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  112240. * * bInfo : optional bounding info, required for facetPartitioning computation
  112241. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  112242. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  112243. * * useRightHandedSystem: optional boolean to for right handed system computation
  112244. * * depthSort : optional boolean to enable the facet depth sort computation
  112245. * * distanceTo : optional Vector3 to compute the facet depth from this location
  112246. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  112247. */
  112248. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  112249. facetNormals?: any;
  112250. facetPositions?: any;
  112251. facetPartitioning?: any;
  112252. ratio?: number;
  112253. bInfo?: any;
  112254. bbSize?: Vector3;
  112255. subDiv?: any;
  112256. useRightHandedSystem?: boolean;
  112257. depthSort?: boolean;
  112258. distanceTo?: Vector3;
  112259. depthSortedFacets?: any;
  112260. }): void;
  112261. /** @hidden */
  112262. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  112263. /**
  112264. * Applies VertexData created from the imported parameters to the geometry
  112265. * @param parsedVertexData the parsed data from an imported file
  112266. * @param geometry the geometry to apply the VertexData to
  112267. */
  112268. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  112269. }
  112270. }
  112271. declare module BABYLON {
  112272. /**
  112273. * Defines a target to use with MorphTargetManager
  112274. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112275. */
  112276. export class MorphTarget implements IAnimatable {
  112277. /** defines the name of the target */
  112278. name: string;
  112279. /**
  112280. * Gets or sets the list of animations
  112281. */
  112282. animations: Animation[];
  112283. private _scene;
  112284. private _positions;
  112285. private _normals;
  112286. private _tangents;
  112287. private _uvs;
  112288. private _influence;
  112289. private _uniqueId;
  112290. /**
  112291. * Observable raised when the influence changes
  112292. */
  112293. onInfluenceChanged: Observable<boolean>;
  112294. /** @hidden */
  112295. _onDataLayoutChanged: Observable<void>;
  112296. /**
  112297. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  112298. */
  112299. get influence(): number;
  112300. set influence(influence: number);
  112301. /**
  112302. * Gets or sets the id of the morph Target
  112303. */
  112304. id: string;
  112305. private _animationPropertiesOverride;
  112306. /**
  112307. * Gets or sets the animation properties override
  112308. */
  112309. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  112310. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  112311. /**
  112312. * Creates a new MorphTarget
  112313. * @param name defines the name of the target
  112314. * @param influence defines the influence to use
  112315. * @param scene defines the scene the morphtarget belongs to
  112316. */
  112317. constructor(
  112318. /** defines the name of the target */
  112319. name: string, influence?: number, scene?: Nullable<Scene>);
  112320. /**
  112321. * Gets the unique ID of this manager
  112322. */
  112323. get uniqueId(): number;
  112324. /**
  112325. * Gets a boolean defining if the target contains position data
  112326. */
  112327. get hasPositions(): boolean;
  112328. /**
  112329. * Gets a boolean defining if the target contains normal data
  112330. */
  112331. get hasNormals(): boolean;
  112332. /**
  112333. * Gets a boolean defining if the target contains tangent data
  112334. */
  112335. get hasTangents(): boolean;
  112336. /**
  112337. * Gets a boolean defining if the target contains texture coordinates data
  112338. */
  112339. get hasUVs(): boolean;
  112340. /**
  112341. * Affects position data to this target
  112342. * @param data defines the position data to use
  112343. */
  112344. setPositions(data: Nullable<FloatArray>): void;
  112345. /**
  112346. * Gets the position data stored in this target
  112347. * @returns a FloatArray containing the position data (or null if not present)
  112348. */
  112349. getPositions(): Nullable<FloatArray>;
  112350. /**
  112351. * Affects normal data to this target
  112352. * @param data defines the normal data to use
  112353. */
  112354. setNormals(data: Nullable<FloatArray>): void;
  112355. /**
  112356. * Gets the normal data stored in this target
  112357. * @returns a FloatArray containing the normal data (or null if not present)
  112358. */
  112359. getNormals(): Nullable<FloatArray>;
  112360. /**
  112361. * Affects tangent data to this target
  112362. * @param data defines the tangent data to use
  112363. */
  112364. setTangents(data: Nullable<FloatArray>): void;
  112365. /**
  112366. * Gets the tangent data stored in this target
  112367. * @returns a FloatArray containing the tangent data (or null if not present)
  112368. */
  112369. getTangents(): Nullable<FloatArray>;
  112370. /**
  112371. * Affects texture coordinates data to this target
  112372. * @param data defines the texture coordinates data to use
  112373. */
  112374. setUVs(data: Nullable<FloatArray>): void;
  112375. /**
  112376. * Gets the texture coordinates data stored in this target
  112377. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  112378. */
  112379. getUVs(): Nullable<FloatArray>;
  112380. /**
  112381. * Clone the current target
  112382. * @returns a new MorphTarget
  112383. */
  112384. clone(): MorphTarget;
  112385. /**
  112386. * Serializes the current target into a Serialization object
  112387. * @returns the serialized object
  112388. */
  112389. serialize(): any;
  112390. /**
  112391. * Returns the string "MorphTarget"
  112392. * @returns "MorphTarget"
  112393. */
  112394. getClassName(): string;
  112395. /**
  112396. * Creates a new target from serialized data
  112397. * @param serializationObject defines the serialized data to use
  112398. * @returns a new MorphTarget
  112399. */
  112400. static Parse(serializationObject: any): MorphTarget;
  112401. /**
  112402. * Creates a MorphTarget from mesh data
  112403. * @param mesh defines the source mesh
  112404. * @param name defines the name to use for the new target
  112405. * @param influence defines the influence to attach to the target
  112406. * @returns a new MorphTarget
  112407. */
  112408. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  112409. }
  112410. }
  112411. declare module BABYLON {
  112412. /**
  112413. * This class is used to deform meshes using morphing between different targets
  112414. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  112415. */
  112416. export class MorphTargetManager {
  112417. private _targets;
  112418. private _targetInfluenceChangedObservers;
  112419. private _targetDataLayoutChangedObservers;
  112420. private _activeTargets;
  112421. private _scene;
  112422. private _influences;
  112423. private _supportsNormals;
  112424. private _supportsTangents;
  112425. private _supportsUVs;
  112426. private _vertexCount;
  112427. private _uniqueId;
  112428. private _tempInfluences;
  112429. /**
  112430. * Gets or sets a boolean indicating if normals must be morphed
  112431. */
  112432. enableNormalMorphing: boolean;
  112433. /**
  112434. * Gets or sets a boolean indicating if tangents must be morphed
  112435. */
  112436. enableTangentMorphing: boolean;
  112437. /**
  112438. * Gets or sets a boolean indicating if UV must be morphed
  112439. */
  112440. enableUVMorphing: boolean;
  112441. /**
  112442. * Creates a new MorphTargetManager
  112443. * @param scene defines the current scene
  112444. */
  112445. constructor(scene?: Nullable<Scene>);
  112446. /**
  112447. * Gets the unique ID of this manager
  112448. */
  112449. get uniqueId(): number;
  112450. /**
  112451. * Gets the number of vertices handled by this manager
  112452. */
  112453. get vertexCount(): number;
  112454. /**
  112455. * Gets a boolean indicating if this manager supports morphing of normals
  112456. */
  112457. get supportsNormals(): boolean;
  112458. /**
  112459. * Gets a boolean indicating if this manager supports morphing of tangents
  112460. */
  112461. get supportsTangents(): boolean;
  112462. /**
  112463. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  112464. */
  112465. get supportsUVs(): boolean;
  112466. /**
  112467. * Gets the number of targets stored in this manager
  112468. */
  112469. get numTargets(): number;
  112470. /**
  112471. * Gets the number of influencers (ie. the number of targets with influences > 0)
  112472. */
  112473. get numInfluencers(): number;
  112474. /**
  112475. * Gets the list of influences (one per target)
  112476. */
  112477. get influences(): Float32Array;
  112478. /**
  112479. * Gets the active target at specified index. An active target is a target with an influence > 0
  112480. * @param index defines the index to check
  112481. * @returns the requested target
  112482. */
  112483. getActiveTarget(index: number): MorphTarget;
  112484. /**
  112485. * Gets the target at specified index
  112486. * @param index defines the index to check
  112487. * @returns the requested target
  112488. */
  112489. getTarget(index: number): MorphTarget;
  112490. /**
  112491. * Add a new target to this manager
  112492. * @param target defines the target to add
  112493. */
  112494. addTarget(target: MorphTarget): void;
  112495. /**
  112496. * Removes a target from the manager
  112497. * @param target defines the target to remove
  112498. */
  112499. removeTarget(target: MorphTarget): void;
  112500. /**
  112501. * Clone the current manager
  112502. * @returns a new MorphTargetManager
  112503. */
  112504. clone(): MorphTargetManager;
  112505. /**
  112506. * Serializes the current manager into a Serialization object
  112507. * @returns the serialized object
  112508. */
  112509. serialize(): any;
  112510. private _syncActiveTargets;
  112511. /**
  112512. * Syncrhonize the targets with all the meshes using this morph target manager
  112513. */
  112514. synchronize(): void;
  112515. /**
  112516. * Creates a new MorphTargetManager from serialized data
  112517. * @param serializationObject defines the serialized data
  112518. * @param scene defines the hosting scene
  112519. * @returns the new MorphTargetManager
  112520. */
  112521. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  112522. }
  112523. }
  112524. declare module BABYLON {
  112525. /**
  112526. * Class used to represent a specific level of detail of a mesh
  112527. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  112528. */
  112529. export class MeshLODLevel {
  112530. /** Defines the distance where this level should start being displayed */
  112531. distance: number;
  112532. /** Defines the mesh to use to render this level */
  112533. mesh: Nullable<Mesh>;
  112534. /**
  112535. * Creates a new LOD level
  112536. * @param distance defines the distance where this level should star being displayed
  112537. * @param mesh defines the mesh to use to render this level
  112538. */
  112539. constructor(
  112540. /** Defines the distance where this level should start being displayed */
  112541. distance: number,
  112542. /** Defines the mesh to use to render this level */
  112543. mesh: Nullable<Mesh>);
  112544. }
  112545. }
  112546. declare module BABYLON {
  112547. /**
  112548. * Helper class used to generate a canvas to manipulate images
  112549. */
  112550. export class CanvasGenerator {
  112551. /**
  112552. * Create a new canvas (or offscreen canvas depending on the context)
  112553. * @param width defines the expected width
  112554. * @param height defines the expected height
  112555. * @return a new canvas or offscreen canvas
  112556. */
  112557. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  112558. }
  112559. }
  112560. declare module BABYLON {
  112561. /**
  112562. * Mesh representing the gorund
  112563. */
  112564. export class GroundMesh extends Mesh {
  112565. /** If octree should be generated */
  112566. generateOctree: boolean;
  112567. private _heightQuads;
  112568. /** @hidden */
  112569. _subdivisionsX: number;
  112570. /** @hidden */
  112571. _subdivisionsY: number;
  112572. /** @hidden */
  112573. _width: number;
  112574. /** @hidden */
  112575. _height: number;
  112576. /** @hidden */
  112577. _minX: number;
  112578. /** @hidden */
  112579. _maxX: number;
  112580. /** @hidden */
  112581. _minZ: number;
  112582. /** @hidden */
  112583. _maxZ: number;
  112584. constructor(name: string, scene: Scene);
  112585. /**
  112586. * "GroundMesh"
  112587. * @returns "GroundMesh"
  112588. */
  112589. getClassName(): string;
  112590. /**
  112591. * The minimum of x and y subdivisions
  112592. */
  112593. get subdivisions(): number;
  112594. /**
  112595. * X subdivisions
  112596. */
  112597. get subdivisionsX(): number;
  112598. /**
  112599. * Y subdivisions
  112600. */
  112601. get subdivisionsY(): number;
  112602. /**
  112603. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  112604. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  112605. * @param chunksCount the number of subdivisions for x and y
  112606. * @param octreeBlocksSize (Default: 32)
  112607. */
  112608. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  112609. /**
  112610. * Returns a height (y) value in the Worl system :
  112611. * the ground altitude at the coordinates (x, z) expressed in the World system.
  112612. * @param x x coordinate
  112613. * @param z z coordinate
  112614. * @returns the ground y position if (x, z) are outside the ground surface.
  112615. */
  112616. getHeightAtCoordinates(x: number, z: number): number;
  112617. /**
  112618. * Returns a normalized vector (Vector3) orthogonal to the ground
  112619. * at the ground coordinates (x, z) expressed in the World system.
  112620. * @param x x coordinate
  112621. * @param z z coordinate
  112622. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  112623. */
  112624. getNormalAtCoordinates(x: number, z: number): Vector3;
  112625. /**
  112626. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  112627. * at the ground coordinates (x, z) expressed in the World system.
  112628. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  112629. * @param x x coordinate
  112630. * @param z z coordinate
  112631. * @param ref vector to store the result
  112632. * @returns the GroundMesh.
  112633. */
  112634. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  112635. /**
  112636. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  112637. * if the ground has been updated.
  112638. * This can be used in the render loop.
  112639. * @returns the GroundMesh.
  112640. */
  112641. updateCoordinateHeights(): GroundMesh;
  112642. private _getFacetAt;
  112643. private _initHeightQuads;
  112644. private _computeHeightQuads;
  112645. /**
  112646. * Serializes this ground mesh
  112647. * @param serializationObject object to write serialization to
  112648. */
  112649. serialize(serializationObject: any): void;
  112650. /**
  112651. * Parses a serialized ground mesh
  112652. * @param parsedMesh the serialized mesh
  112653. * @param scene the scene to create the ground mesh in
  112654. * @returns the created ground mesh
  112655. */
  112656. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  112657. }
  112658. }
  112659. declare module BABYLON {
  112660. /**
  112661. * Interface for Physics-Joint data
  112662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112663. */
  112664. export interface PhysicsJointData {
  112665. /**
  112666. * The main pivot of the joint
  112667. */
  112668. mainPivot?: Vector3;
  112669. /**
  112670. * The connected pivot of the joint
  112671. */
  112672. connectedPivot?: Vector3;
  112673. /**
  112674. * The main axis of the joint
  112675. */
  112676. mainAxis?: Vector3;
  112677. /**
  112678. * The connected axis of the joint
  112679. */
  112680. connectedAxis?: Vector3;
  112681. /**
  112682. * The collision of the joint
  112683. */
  112684. collision?: boolean;
  112685. /**
  112686. * Native Oimo/Cannon/Energy data
  112687. */
  112688. nativeParams?: any;
  112689. }
  112690. /**
  112691. * This is a holder class for the physics joint created by the physics plugin
  112692. * It holds a set of functions to control the underlying joint
  112693. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112694. */
  112695. export class PhysicsJoint {
  112696. /**
  112697. * The type of the physics joint
  112698. */
  112699. type: number;
  112700. /**
  112701. * The data for the physics joint
  112702. */
  112703. jointData: PhysicsJointData;
  112704. private _physicsJoint;
  112705. protected _physicsPlugin: IPhysicsEnginePlugin;
  112706. /**
  112707. * Initializes the physics joint
  112708. * @param type The type of the physics joint
  112709. * @param jointData The data for the physics joint
  112710. */
  112711. constructor(
  112712. /**
  112713. * The type of the physics joint
  112714. */
  112715. type: number,
  112716. /**
  112717. * The data for the physics joint
  112718. */
  112719. jointData: PhysicsJointData);
  112720. /**
  112721. * Gets the physics joint
  112722. */
  112723. get physicsJoint(): any;
  112724. /**
  112725. * Sets the physics joint
  112726. */
  112727. set physicsJoint(newJoint: any);
  112728. /**
  112729. * Sets the physics plugin
  112730. */
  112731. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  112732. /**
  112733. * Execute a function that is physics-plugin specific.
  112734. * @param {Function} func the function that will be executed.
  112735. * It accepts two parameters: the physics world and the physics joint
  112736. */
  112737. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  112738. /**
  112739. * Distance-Joint type
  112740. */
  112741. static DistanceJoint: number;
  112742. /**
  112743. * Hinge-Joint type
  112744. */
  112745. static HingeJoint: number;
  112746. /**
  112747. * Ball-and-Socket joint type
  112748. */
  112749. static BallAndSocketJoint: number;
  112750. /**
  112751. * Wheel-Joint type
  112752. */
  112753. static WheelJoint: number;
  112754. /**
  112755. * Slider-Joint type
  112756. */
  112757. static SliderJoint: number;
  112758. /**
  112759. * Prismatic-Joint type
  112760. */
  112761. static PrismaticJoint: number;
  112762. /**
  112763. * Universal-Joint type
  112764. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  112765. */
  112766. static UniversalJoint: number;
  112767. /**
  112768. * Hinge-Joint 2 type
  112769. */
  112770. static Hinge2Joint: number;
  112771. /**
  112772. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  112773. */
  112774. static PointToPointJoint: number;
  112775. /**
  112776. * Spring-Joint type
  112777. */
  112778. static SpringJoint: number;
  112779. /**
  112780. * Lock-Joint type
  112781. */
  112782. static LockJoint: number;
  112783. }
  112784. /**
  112785. * A class representing a physics distance joint
  112786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112787. */
  112788. export class DistanceJoint extends PhysicsJoint {
  112789. /**
  112790. *
  112791. * @param jointData The data for the Distance-Joint
  112792. */
  112793. constructor(jointData: DistanceJointData);
  112794. /**
  112795. * Update the predefined distance.
  112796. * @param maxDistance The maximum preferred distance
  112797. * @param minDistance The minimum preferred distance
  112798. */
  112799. updateDistance(maxDistance: number, minDistance?: number): void;
  112800. }
  112801. /**
  112802. * Represents a Motor-Enabled Joint
  112803. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112804. */
  112805. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  112806. /**
  112807. * Initializes the Motor-Enabled Joint
  112808. * @param type The type of the joint
  112809. * @param jointData The physica joint data for the joint
  112810. */
  112811. constructor(type: number, jointData: PhysicsJointData);
  112812. /**
  112813. * Set the motor values.
  112814. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112815. * @param force the force to apply
  112816. * @param maxForce max force for this motor.
  112817. */
  112818. setMotor(force?: number, maxForce?: number): void;
  112819. /**
  112820. * Set the motor's limits.
  112821. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112822. * @param upperLimit The upper limit of the motor
  112823. * @param lowerLimit The lower limit of the motor
  112824. */
  112825. setLimit(upperLimit: number, lowerLimit?: number): void;
  112826. }
  112827. /**
  112828. * This class represents a single physics Hinge-Joint
  112829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112830. */
  112831. export class HingeJoint extends MotorEnabledJoint {
  112832. /**
  112833. * Initializes the Hinge-Joint
  112834. * @param jointData The joint data for the Hinge-Joint
  112835. */
  112836. constructor(jointData: PhysicsJointData);
  112837. /**
  112838. * Set the motor values.
  112839. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112840. * @param {number} force the force to apply
  112841. * @param {number} maxForce max force for this motor.
  112842. */
  112843. setMotor(force?: number, maxForce?: number): void;
  112844. /**
  112845. * Set the motor's limits.
  112846. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112847. * @param upperLimit The upper limit of the motor
  112848. * @param lowerLimit The lower limit of the motor
  112849. */
  112850. setLimit(upperLimit: number, lowerLimit?: number): void;
  112851. }
  112852. /**
  112853. * This class represents a dual hinge physics joint (same as wheel joint)
  112854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112855. */
  112856. export class Hinge2Joint extends MotorEnabledJoint {
  112857. /**
  112858. * Initializes the Hinge2-Joint
  112859. * @param jointData The joint data for the Hinge2-Joint
  112860. */
  112861. constructor(jointData: PhysicsJointData);
  112862. /**
  112863. * Set the motor values.
  112864. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112865. * @param {number} targetSpeed the speed the motor is to reach
  112866. * @param {number} maxForce max force for this motor.
  112867. * @param {motorIndex} the motor's index, 0 or 1.
  112868. */
  112869. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  112870. /**
  112871. * Set the motor limits.
  112872. * Attention, this function is plugin specific. Engines won't react 100% the same.
  112873. * @param {number} upperLimit the upper limit
  112874. * @param {number} lowerLimit lower limit
  112875. * @param {motorIndex} the motor's index, 0 or 1.
  112876. */
  112877. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112878. }
  112879. /**
  112880. * Interface for a motor enabled joint
  112881. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112882. */
  112883. export interface IMotorEnabledJoint {
  112884. /**
  112885. * Physics joint
  112886. */
  112887. physicsJoint: any;
  112888. /**
  112889. * Sets the motor of the motor-enabled joint
  112890. * @param force The force of the motor
  112891. * @param maxForce The maximum force of the motor
  112892. * @param motorIndex The index of the motor
  112893. */
  112894. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  112895. /**
  112896. * Sets the limit of the motor
  112897. * @param upperLimit The upper limit of the motor
  112898. * @param lowerLimit The lower limit of the motor
  112899. * @param motorIndex The index of the motor
  112900. */
  112901. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  112902. }
  112903. /**
  112904. * Joint data for a Distance-Joint
  112905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112906. */
  112907. export interface DistanceJointData extends PhysicsJointData {
  112908. /**
  112909. * Max distance the 2 joint objects can be apart
  112910. */
  112911. maxDistance: number;
  112912. }
  112913. /**
  112914. * Joint data from a spring joint
  112915. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112916. */
  112917. export interface SpringJointData extends PhysicsJointData {
  112918. /**
  112919. * Length of the spring
  112920. */
  112921. length: number;
  112922. /**
  112923. * Stiffness of the spring
  112924. */
  112925. stiffness: number;
  112926. /**
  112927. * Damping of the spring
  112928. */
  112929. damping: number;
  112930. /** this callback will be called when applying the force to the impostors. */
  112931. forceApplicationCallback: () => void;
  112932. }
  112933. }
  112934. declare module BABYLON {
  112935. /**
  112936. * Holds the data for the raycast result
  112937. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112938. */
  112939. export class PhysicsRaycastResult {
  112940. private _hasHit;
  112941. private _hitDistance;
  112942. private _hitNormalWorld;
  112943. private _hitPointWorld;
  112944. private _rayFromWorld;
  112945. private _rayToWorld;
  112946. /**
  112947. * Gets if there was a hit
  112948. */
  112949. get hasHit(): boolean;
  112950. /**
  112951. * Gets the distance from the hit
  112952. */
  112953. get hitDistance(): number;
  112954. /**
  112955. * Gets the hit normal/direction in the world
  112956. */
  112957. get hitNormalWorld(): Vector3;
  112958. /**
  112959. * Gets the hit point in the world
  112960. */
  112961. get hitPointWorld(): Vector3;
  112962. /**
  112963. * Gets the ray "start point" of the ray in the world
  112964. */
  112965. get rayFromWorld(): Vector3;
  112966. /**
  112967. * Gets the ray "end point" of the ray in the world
  112968. */
  112969. get rayToWorld(): Vector3;
  112970. /**
  112971. * Sets the hit data (normal & point in world space)
  112972. * @param hitNormalWorld defines the normal in world space
  112973. * @param hitPointWorld defines the point in world space
  112974. */
  112975. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  112976. /**
  112977. * Sets the distance from the start point to the hit point
  112978. * @param distance
  112979. */
  112980. setHitDistance(distance: number): void;
  112981. /**
  112982. * Calculates the distance manually
  112983. */
  112984. calculateHitDistance(): void;
  112985. /**
  112986. * Resets all the values to default
  112987. * @param from The from point on world space
  112988. * @param to The to point on world space
  112989. */
  112990. reset(from?: Vector3, to?: Vector3): void;
  112991. }
  112992. /**
  112993. * Interface for the size containing width and height
  112994. */
  112995. interface IXYZ {
  112996. /**
  112997. * X
  112998. */
  112999. x: number;
  113000. /**
  113001. * Y
  113002. */
  113003. y: number;
  113004. /**
  113005. * Z
  113006. */
  113007. z: number;
  113008. }
  113009. }
  113010. declare module BABYLON {
  113011. /**
  113012. * Interface used to describe a physics joint
  113013. */
  113014. export interface PhysicsImpostorJoint {
  113015. /** Defines the main impostor to which the joint is linked */
  113016. mainImpostor: PhysicsImpostor;
  113017. /** Defines the impostor that is connected to the main impostor using this joint */
  113018. connectedImpostor: PhysicsImpostor;
  113019. /** Defines the joint itself */
  113020. joint: PhysicsJoint;
  113021. }
  113022. /** @hidden */
  113023. export interface IPhysicsEnginePlugin {
  113024. world: any;
  113025. name: string;
  113026. setGravity(gravity: Vector3): void;
  113027. setTimeStep(timeStep: number): void;
  113028. getTimeStep(): number;
  113029. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  113030. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113031. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  113032. generatePhysicsBody(impostor: PhysicsImpostor): void;
  113033. removePhysicsBody(impostor: PhysicsImpostor): void;
  113034. generateJoint(joint: PhysicsImpostorJoint): void;
  113035. removeJoint(joint: PhysicsImpostorJoint): void;
  113036. isSupported(): boolean;
  113037. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  113038. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  113039. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  113040. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  113041. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113042. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  113043. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  113044. getBodyMass(impostor: PhysicsImpostor): number;
  113045. getBodyFriction(impostor: PhysicsImpostor): number;
  113046. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  113047. getBodyRestitution(impostor: PhysicsImpostor): number;
  113048. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  113049. getBodyPressure?(impostor: PhysicsImpostor): number;
  113050. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  113051. getBodyStiffness?(impostor: PhysicsImpostor): number;
  113052. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  113053. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  113054. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  113055. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  113056. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  113057. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  113058. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  113059. sleepBody(impostor: PhysicsImpostor): void;
  113060. wakeUpBody(impostor: PhysicsImpostor): void;
  113061. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113062. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  113063. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  113064. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  113065. getRadius(impostor: PhysicsImpostor): number;
  113066. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  113067. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  113068. dispose(): void;
  113069. }
  113070. /**
  113071. * Interface used to define a physics engine
  113072. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113073. */
  113074. export interface IPhysicsEngine {
  113075. /**
  113076. * Gets the gravity vector used by the simulation
  113077. */
  113078. gravity: Vector3;
  113079. /**
  113080. * Sets the gravity vector used by the simulation
  113081. * @param gravity defines the gravity vector to use
  113082. */
  113083. setGravity(gravity: Vector3): void;
  113084. /**
  113085. * Set the time step of the physics engine.
  113086. * Default is 1/60.
  113087. * To slow it down, enter 1/600 for example.
  113088. * To speed it up, 1/30
  113089. * @param newTimeStep the new timestep to apply to this world.
  113090. */
  113091. setTimeStep(newTimeStep: number): void;
  113092. /**
  113093. * Get the time step of the physics engine.
  113094. * @returns the current time step
  113095. */
  113096. getTimeStep(): number;
  113097. /**
  113098. * Set the sub time step of the physics engine.
  113099. * Default is 0 meaning there is no sub steps
  113100. * To increase physics resolution precision, set a small value (like 1 ms)
  113101. * @param subTimeStep defines the new sub timestep used for physics resolution.
  113102. */
  113103. setSubTimeStep(subTimeStep: number): void;
  113104. /**
  113105. * Get the sub time step of the physics engine.
  113106. * @returns the current sub time step
  113107. */
  113108. getSubTimeStep(): number;
  113109. /**
  113110. * Release all resources
  113111. */
  113112. dispose(): void;
  113113. /**
  113114. * Gets the name of the current physics plugin
  113115. * @returns the name of the plugin
  113116. */
  113117. getPhysicsPluginName(): string;
  113118. /**
  113119. * Adding a new impostor for the impostor tracking.
  113120. * This will be done by the impostor itself.
  113121. * @param impostor the impostor to add
  113122. */
  113123. addImpostor(impostor: PhysicsImpostor): void;
  113124. /**
  113125. * Remove an impostor from the engine.
  113126. * This impostor and its mesh will not longer be updated by the physics engine.
  113127. * @param impostor the impostor to remove
  113128. */
  113129. removeImpostor(impostor: PhysicsImpostor): void;
  113130. /**
  113131. * Add a joint to the physics engine
  113132. * @param mainImpostor defines the main impostor to which the joint is added.
  113133. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  113134. * @param joint defines the joint that will connect both impostors.
  113135. */
  113136. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113137. /**
  113138. * Removes a joint from the simulation
  113139. * @param mainImpostor defines the impostor used with the joint
  113140. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  113141. * @param joint defines the joint to remove
  113142. */
  113143. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  113144. /**
  113145. * Gets the current plugin used to run the simulation
  113146. * @returns current plugin
  113147. */
  113148. getPhysicsPlugin(): IPhysicsEnginePlugin;
  113149. /**
  113150. * Gets the list of physic impostors
  113151. * @returns an array of PhysicsImpostor
  113152. */
  113153. getImpostors(): Array<PhysicsImpostor>;
  113154. /**
  113155. * Gets the impostor for a physics enabled object
  113156. * @param object defines the object impersonated by the impostor
  113157. * @returns the PhysicsImpostor or null if not found
  113158. */
  113159. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113160. /**
  113161. * Gets the impostor for a physics body object
  113162. * @param body defines physics body used by the impostor
  113163. * @returns the PhysicsImpostor or null if not found
  113164. */
  113165. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  113166. /**
  113167. * Does a raycast in the physics world
  113168. * @param from when should the ray start?
  113169. * @param to when should the ray end?
  113170. * @returns PhysicsRaycastResult
  113171. */
  113172. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  113173. /**
  113174. * Called by the scene. No need to call it.
  113175. * @param delta defines the timespam between frames
  113176. */
  113177. _step(delta: number): void;
  113178. }
  113179. }
  113180. declare module BABYLON {
  113181. /**
  113182. * The interface for the physics imposter parameters
  113183. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113184. */
  113185. export interface PhysicsImpostorParameters {
  113186. /**
  113187. * The mass of the physics imposter
  113188. */
  113189. mass: number;
  113190. /**
  113191. * The friction of the physics imposter
  113192. */
  113193. friction?: number;
  113194. /**
  113195. * The coefficient of restitution of the physics imposter
  113196. */
  113197. restitution?: number;
  113198. /**
  113199. * The native options of the physics imposter
  113200. */
  113201. nativeOptions?: any;
  113202. /**
  113203. * Specifies if the parent should be ignored
  113204. */
  113205. ignoreParent?: boolean;
  113206. /**
  113207. * Specifies if bi-directional transformations should be disabled
  113208. */
  113209. disableBidirectionalTransformation?: boolean;
  113210. /**
  113211. * The pressure inside the physics imposter, soft object only
  113212. */
  113213. pressure?: number;
  113214. /**
  113215. * The stiffness the physics imposter, soft object only
  113216. */
  113217. stiffness?: number;
  113218. /**
  113219. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  113220. */
  113221. velocityIterations?: number;
  113222. /**
  113223. * The number of iterations used in maintaining consistent vertex positions, soft object only
  113224. */
  113225. positionIterations?: number;
  113226. /**
  113227. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  113228. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  113229. * Add to fix multiple points
  113230. */
  113231. fixedPoints?: number;
  113232. /**
  113233. * The collision margin around a soft object
  113234. */
  113235. margin?: number;
  113236. /**
  113237. * The collision margin around a soft object
  113238. */
  113239. damping?: number;
  113240. /**
  113241. * The path for a rope based on an extrusion
  113242. */
  113243. path?: any;
  113244. /**
  113245. * The shape of an extrusion used for a rope based on an extrusion
  113246. */
  113247. shape?: any;
  113248. }
  113249. /**
  113250. * Interface for a physics-enabled object
  113251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113252. */
  113253. export interface IPhysicsEnabledObject {
  113254. /**
  113255. * The position of the physics-enabled object
  113256. */
  113257. position: Vector3;
  113258. /**
  113259. * The rotation of the physics-enabled object
  113260. */
  113261. rotationQuaternion: Nullable<Quaternion>;
  113262. /**
  113263. * The scale of the physics-enabled object
  113264. */
  113265. scaling: Vector3;
  113266. /**
  113267. * The rotation of the physics-enabled object
  113268. */
  113269. rotation?: Vector3;
  113270. /**
  113271. * The parent of the physics-enabled object
  113272. */
  113273. parent?: any;
  113274. /**
  113275. * The bounding info of the physics-enabled object
  113276. * @returns The bounding info of the physics-enabled object
  113277. */
  113278. getBoundingInfo(): BoundingInfo;
  113279. /**
  113280. * Computes the world matrix
  113281. * @param force Specifies if the world matrix should be computed by force
  113282. * @returns A world matrix
  113283. */
  113284. computeWorldMatrix(force: boolean): Matrix;
  113285. /**
  113286. * Gets the world matrix
  113287. * @returns A world matrix
  113288. */
  113289. getWorldMatrix?(): Matrix;
  113290. /**
  113291. * Gets the child meshes
  113292. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  113293. * @returns An array of abstract meshes
  113294. */
  113295. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  113296. /**
  113297. * Gets the vertex data
  113298. * @param kind The type of vertex data
  113299. * @returns A nullable array of numbers, or a float32 array
  113300. */
  113301. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  113302. /**
  113303. * Gets the indices from the mesh
  113304. * @returns A nullable array of index arrays
  113305. */
  113306. getIndices?(): Nullable<IndicesArray>;
  113307. /**
  113308. * Gets the scene from the mesh
  113309. * @returns the indices array or null
  113310. */
  113311. getScene?(): Scene;
  113312. /**
  113313. * Gets the absolute position from the mesh
  113314. * @returns the absolute position
  113315. */
  113316. getAbsolutePosition(): Vector3;
  113317. /**
  113318. * Gets the absolute pivot point from the mesh
  113319. * @returns the absolute pivot point
  113320. */
  113321. getAbsolutePivotPoint(): Vector3;
  113322. /**
  113323. * Rotates the mesh
  113324. * @param axis The axis of rotation
  113325. * @param amount The amount of rotation
  113326. * @param space The space of the rotation
  113327. * @returns The rotation transform node
  113328. */
  113329. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  113330. /**
  113331. * Translates the mesh
  113332. * @param axis The axis of translation
  113333. * @param distance The distance of translation
  113334. * @param space The space of the translation
  113335. * @returns The transform node
  113336. */
  113337. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  113338. /**
  113339. * Sets the absolute position of the mesh
  113340. * @param absolutePosition The absolute position of the mesh
  113341. * @returns The transform node
  113342. */
  113343. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  113344. /**
  113345. * Gets the class name of the mesh
  113346. * @returns The class name
  113347. */
  113348. getClassName(): string;
  113349. }
  113350. /**
  113351. * Represents a physics imposter
  113352. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113353. */
  113354. export class PhysicsImpostor {
  113355. /**
  113356. * The physics-enabled object used as the physics imposter
  113357. */
  113358. object: IPhysicsEnabledObject;
  113359. /**
  113360. * The type of the physics imposter
  113361. */
  113362. type: number;
  113363. private _options;
  113364. private _scene?;
  113365. /**
  113366. * The default object size of the imposter
  113367. */
  113368. static DEFAULT_OBJECT_SIZE: Vector3;
  113369. /**
  113370. * The identity quaternion of the imposter
  113371. */
  113372. static IDENTITY_QUATERNION: Quaternion;
  113373. /** @hidden */
  113374. _pluginData: any;
  113375. private _physicsEngine;
  113376. private _physicsBody;
  113377. private _bodyUpdateRequired;
  113378. private _onBeforePhysicsStepCallbacks;
  113379. private _onAfterPhysicsStepCallbacks;
  113380. /** @hidden */
  113381. _onPhysicsCollideCallbacks: Array<{
  113382. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor, point: Nullable<Vector3>) => void;
  113383. otherImpostors: Array<PhysicsImpostor>;
  113384. }>;
  113385. private _deltaPosition;
  113386. private _deltaRotation;
  113387. private _deltaRotationConjugated;
  113388. /** @hidden */
  113389. _isFromLine: boolean;
  113390. private _parent;
  113391. private _isDisposed;
  113392. private static _tmpVecs;
  113393. private static _tmpQuat;
  113394. /**
  113395. * Specifies if the physics imposter is disposed
  113396. */
  113397. get isDisposed(): boolean;
  113398. /**
  113399. * Gets the mass of the physics imposter
  113400. */
  113401. get mass(): number;
  113402. set mass(value: number);
  113403. /**
  113404. * Gets the coefficient of friction
  113405. */
  113406. get friction(): number;
  113407. /**
  113408. * Sets the coefficient of friction
  113409. */
  113410. set friction(value: number);
  113411. /**
  113412. * Gets the coefficient of restitution
  113413. */
  113414. get restitution(): number;
  113415. /**
  113416. * Sets the coefficient of restitution
  113417. */
  113418. set restitution(value: number);
  113419. /**
  113420. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  113421. */
  113422. get pressure(): number;
  113423. /**
  113424. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  113425. */
  113426. set pressure(value: number);
  113427. /**
  113428. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113429. */
  113430. get stiffness(): number;
  113431. /**
  113432. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  113433. */
  113434. set stiffness(value: number);
  113435. /**
  113436. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113437. */
  113438. get velocityIterations(): number;
  113439. /**
  113440. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  113441. */
  113442. set velocityIterations(value: number);
  113443. /**
  113444. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113445. */
  113446. get positionIterations(): number;
  113447. /**
  113448. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  113449. */
  113450. set positionIterations(value: number);
  113451. /**
  113452. * The unique id of the physics imposter
  113453. * set by the physics engine when adding this impostor to the array
  113454. */
  113455. uniqueId: number;
  113456. /**
  113457. * @hidden
  113458. */
  113459. soft: boolean;
  113460. /**
  113461. * @hidden
  113462. */
  113463. segments: number;
  113464. private _joints;
  113465. /**
  113466. * Initializes the physics imposter
  113467. * @param object The physics-enabled object used as the physics imposter
  113468. * @param type The type of the physics imposter
  113469. * @param _options The options for the physics imposter
  113470. * @param _scene The Babylon scene
  113471. */
  113472. constructor(
  113473. /**
  113474. * The physics-enabled object used as the physics imposter
  113475. */
  113476. object: IPhysicsEnabledObject,
  113477. /**
  113478. * The type of the physics imposter
  113479. */
  113480. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  113481. /**
  113482. * This function will completly initialize this impostor.
  113483. * It will create a new body - but only if this mesh has no parent.
  113484. * If it has, this impostor will not be used other than to define the impostor
  113485. * of the child mesh.
  113486. * @hidden
  113487. */
  113488. _init(): void;
  113489. private _getPhysicsParent;
  113490. /**
  113491. * Should a new body be generated.
  113492. * @returns boolean specifying if body initialization is required
  113493. */
  113494. isBodyInitRequired(): boolean;
  113495. /**
  113496. * Sets the updated scaling
  113497. * @param updated Specifies if the scaling is updated
  113498. */
  113499. setScalingUpdated(): void;
  113500. /**
  113501. * Force a regeneration of this or the parent's impostor's body.
  113502. * Use under cautious - This will remove all joints already implemented.
  113503. */
  113504. forceUpdate(): void;
  113505. /**
  113506. * Gets the body that holds this impostor. Either its own, or its parent.
  113507. */
  113508. get physicsBody(): any;
  113509. /**
  113510. * Get the parent of the physics imposter
  113511. * @returns Physics imposter or null
  113512. */
  113513. get parent(): Nullable<PhysicsImpostor>;
  113514. /**
  113515. * Sets the parent of the physics imposter
  113516. */
  113517. set parent(value: Nullable<PhysicsImpostor>);
  113518. /**
  113519. * Set the physics body. Used mainly by the physics engine/plugin
  113520. */
  113521. set physicsBody(physicsBody: any);
  113522. /**
  113523. * Resets the update flags
  113524. */
  113525. resetUpdateFlags(): void;
  113526. /**
  113527. * Gets the object extend size
  113528. * @returns the object extend size
  113529. */
  113530. getObjectExtendSize(): Vector3;
  113531. /**
  113532. * Gets the object center
  113533. * @returns The object center
  113534. */
  113535. getObjectCenter(): Vector3;
  113536. /**
  113537. * Get a specific parameter from the options parameters
  113538. * @param paramName The object parameter name
  113539. * @returns The object parameter
  113540. */
  113541. getParam(paramName: string): any;
  113542. /**
  113543. * Sets a specific parameter in the options given to the physics plugin
  113544. * @param paramName The parameter name
  113545. * @param value The value of the parameter
  113546. */
  113547. setParam(paramName: string, value: number): void;
  113548. /**
  113549. * Specifically change the body's mass option. Won't recreate the physics body object
  113550. * @param mass The mass of the physics imposter
  113551. */
  113552. setMass(mass: number): void;
  113553. /**
  113554. * Gets the linear velocity
  113555. * @returns linear velocity or null
  113556. */
  113557. getLinearVelocity(): Nullable<Vector3>;
  113558. /**
  113559. * Sets the linear velocity
  113560. * @param velocity linear velocity or null
  113561. */
  113562. setLinearVelocity(velocity: Nullable<Vector3>): void;
  113563. /**
  113564. * Gets the angular velocity
  113565. * @returns angular velocity or null
  113566. */
  113567. getAngularVelocity(): Nullable<Vector3>;
  113568. /**
  113569. * Sets the angular velocity
  113570. * @param velocity The velocity or null
  113571. */
  113572. setAngularVelocity(velocity: Nullable<Vector3>): void;
  113573. /**
  113574. * Execute a function with the physics plugin native code
  113575. * Provide a function the will have two variables - the world object and the physics body object
  113576. * @param func The function to execute with the physics plugin native code
  113577. */
  113578. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  113579. /**
  113580. * Register a function that will be executed before the physics world is stepping forward
  113581. * @param func The function to execute before the physics world is stepped forward
  113582. */
  113583. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113584. /**
  113585. * Unregister a function that will be executed before the physics world is stepping forward
  113586. * @param func The function to execute before the physics world is stepped forward
  113587. */
  113588. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113589. /**
  113590. * Register a function that will be executed after the physics step
  113591. * @param func The function to execute after physics step
  113592. */
  113593. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113594. /**
  113595. * Unregisters a function that will be executed after the physics step
  113596. * @param func The function to execute after physics step
  113597. */
  113598. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  113599. /**
  113600. * register a function that will be executed when this impostor collides against a different body
  113601. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  113602. * @param func Callback that is executed on collision
  113603. */
  113604. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  113605. /**
  113606. * Unregisters the physics imposter on contact
  113607. * @param collideAgainst The physics object to collide against
  113608. * @param func Callback to execute on collision
  113609. */
  113610. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  113611. private _tmpQuat;
  113612. private _tmpQuat2;
  113613. /**
  113614. * Get the parent rotation
  113615. * @returns The parent rotation
  113616. */
  113617. getParentsRotation(): Quaternion;
  113618. /**
  113619. * this function is executed by the physics engine.
  113620. */
  113621. beforeStep: () => void;
  113622. /**
  113623. * this function is executed by the physics engine
  113624. */
  113625. afterStep: () => void;
  113626. /**
  113627. * Legacy collision detection event support
  113628. */
  113629. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  113630. /**
  113631. * event and body object due to cannon's event-based architecture.
  113632. */
  113633. onCollide: (e: {
  113634. body: any;
  113635. point: Nullable<Vector3>;
  113636. }) => void;
  113637. /**
  113638. * Apply a force
  113639. * @param force The force to apply
  113640. * @param contactPoint The contact point for the force
  113641. * @returns The physics imposter
  113642. */
  113643. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113644. /**
  113645. * Apply an impulse
  113646. * @param force The impulse force
  113647. * @param contactPoint The contact point for the impulse force
  113648. * @returns The physics imposter
  113649. */
  113650. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  113651. /**
  113652. * A help function to create a joint
  113653. * @param otherImpostor A physics imposter used to create a joint
  113654. * @param jointType The type of joint
  113655. * @param jointData The data for the joint
  113656. * @returns The physics imposter
  113657. */
  113658. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  113659. /**
  113660. * Add a joint to this impostor with a different impostor
  113661. * @param otherImpostor A physics imposter used to add a joint
  113662. * @param joint The joint to add
  113663. * @returns The physics imposter
  113664. */
  113665. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  113666. /**
  113667. * Add an anchor to a cloth impostor
  113668. * @param otherImpostor rigid impostor to anchor to
  113669. * @param width ratio across width from 0 to 1
  113670. * @param height ratio up height from 0 to 1
  113671. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  113672. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  113673. * @returns impostor the soft imposter
  113674. */
  113675. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113676. /**
  113677. * Add a hook to a rope impostor
  113678. * @param otherImpostor rigid impostor to anchor to
  113679. * @param length ratio across rope from 0 to 1
  113680. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  113681. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  113682. * @returns impostor the rope imposter
  113683. */
  113684. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  113685. /**
  113686. * Will keep this body still, in a sleep mode.
  113687. * @returns the physics imposter
  113688. */
  113689. sleep(): PhysicsImpostor;
  113690. /**
  113691. * Wake the body up.
  113692. * @returns The physics imposter
  113693. */
  113694. wakeUp(): PhysicsImpostor;
  113695. /**
  113696. * Clones the physics imposter
  113697. * @param newObject The physics imposter clones to this physics-enabled object
  113698. * @returns A nullable physics imposter
  113699. */
  113700. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  113701. /**
  113702. * Disposes the physics imposter
  113703. */
  113704. dispose(): void;
  113705. /**
  113706. * Sets the delta position
  113707. * @param position The delta position amount
  113708. */
  113709. setDeltaPosition(position: Vector3): void;
  113710. /**
  113711. * Sets the delta rotation
  113712. * @param rotation The delta rotation amount
  113713. */
  113714. setDeltaRotation(rotation: Quaternion): void;
  113715. /**
  113716. * Gets the box size of the physics imposter and stores the result in the input parameter
  113717. * @param result Stores the box size
  113718. * @returns The physics imposter
  113719. */
  113720. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  113721. /**
  113722. * Gets the radius of the physics imposter
  113723. * @returns Radius of the physics imposter
  113724. */
  113725. getRadius(): number;
  113726. /**
  113727. * Sync a bone with this impostor
  113728. * @param bone The bone to sync to the impostor.
  113729. * @param boneMesh The mesh that the bone is influencing.
  113730. * @param jointPivot The pivot of the joint / bone in local space.
  113731. * @param distToJoint Optional distance from the impostor to the joint.
  113732. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113733. */
  113734. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  113735. /**
  113736. * Sync impostor to a bone
  113737. * @param bone The bone that the impostor will be synced to.
  113738. * @param boneMesh The mesh that the bone is influencing.
  113739. * @param jointPivot The pivot of the joint / bone in local space.
  113740. * @param distToJoint Optional distance from the impostor to the joint.
  113741. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113742. * @param boneAxis Optional vector3 axis the bone is aligned with
  113743. */
  113744. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  113745. /**
  113746. * No-Imposter type
  113747. */
  113748. static NoImpostor: number;
  113749. /**
  113750. * Sphere-Imposter type
  113751. */
  113752. static SphereImpostor: number;
  113753. /**
  113754. * Box-Imposter type
  113755. */
  113756. static BoxImpostor: number;
  113757. /**
  113758. * Plane-Imposter type
  113759. */
  113760. static PlaneImpostor: number;
  113761. /**
  113762. * Mesh-imposter type
  113763. */
  113764. static MeshImpostor: number;
  113765. /**
  113766. * Capsule-Impostor type (Ammo.js plugin only)
  113767. */
  113768. static CapsuleImpostor: number;
  113769. /**
  113770. * Cylinder-Imposter type
  113771. */
  113772. static CylinderImpostor: number;
  113773. /**
  113774. * Particle-Imposter type
  113775. */
  113776. static ParticleImpostor: number;
  113777. /**
  113778. * Heightmap-Imposter type
  113779. */
  113780. static HeightmapImpostor: number;
  113781. /**
  113782. * ConvexHull-Impostor type (Ammo.js plugin only)
  113783. */
  113784. static ConvexHullImpostor: number;
  113785. /**
  113786. * Custom-Imposter type (Ammo.js plugin only)
  113787. */
  113788. static CustomImpostor: number;
  113789. /**
  113790. * Rope-Imposter type
  113791. */
  113792. static RopeImpostor: number;
  113793. /**
  113794. * Cloth-Imposter type
  113795. */
  113796. static ClothImpostor: number;
  113797. /**
  113798. * Softbody-Imposter type
  113799. */
  113800. static SoftbodyImpostor: number;
  113801. }
  113802. }
  113803. declare module BABYLON {
  113804. /**
  113805. * @hidden
  113806. **/
  113807. export class _CreationDataStorage {
  113808. closePath?: boolean;
  113809. closeArray?: boolean;
  113810. idx: number[];
  113811. dashSize: number;
  113812. gapSize: number;
  113813. path3D: Path3D;
  113814. pathArray: Vector3[][];
  113815. arc: number;
  113816. radius: number;
  113817. cap: number;
  113818. tessellation: number;
  113819. }
  113820. /**
  113821. * @hidden
  113822. **/
  113823. class _InstanceDataStorage {
  113824. visibleInstances: any;
  113825. batchCache: _InstancesBatch;
  113826. instancesBufferSize: number;
  113827. instancesBuffer: Nullable<Buffer>;
  113828. instancesData: Float32Array;
  113829. overridenInstanceCount: number;
  113830. isFrozen: boolean;
  113831. previousBatch: Nullable<_InstancesBatch>;
  113832. hardwareInstancedRendering: boolean;
  113833. sideOrientation: number;
  113834. manualUpdate: boolean;
  113835. previousRenderId: number;
  113836. }
  113837. /**
  113838. * @hidden
  113839. **/
  113840. export class _InstancesBatch {
  113841. mustReturn: boolean;
  113842. visibleInstances: Nullable<InstancedMesh[]>[];
  113843. renderSelf: boolean[];
  113844. hardwareInstancedRendering: boolean[];
  113845. }
  113846. /**
  113847. * @hidden
  113848. **/
  113849. class _ThinInstanceDataStorage {
  113850. instancesCount: number;
  113851. matrixBuffer: Nullable<Buffer>;
  113852. matrixBufferSize: number;
  113853. matrixData: Nullable<Float32Array>;
  113854. boundingVectors: Array<Vector3>;
  113855. worldMatrices: Nullable<Matrix[]>;
  113856. }
  113857. /**
  113858. * Class used to represent renderable models
  113859. */
  113860. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  113861. /**
  113862. * Mesh side orientation : usually the external or front surface
  113863. */
  113864. static readonly FRONTSIDE: number;
  113865. /**
  113866. * Mesh side orientation : usually the internal or back surface
  113867. */
  113868. static readonly BACKSIDE: number;
  113869. /**
  113870. * Mesh side orientation : both internal and external or front and back surfaces
  113871. */
  113872. static readonly DOUBLESIDE: number;
  113873. /**
  113874. * Mesh side orientation : by default, `FRONTSIDE`
  113875. */
  113876. static readonly DEFAULTSIDE: number;
  113877. /**
  113878. * Mesh cap setting : no cap
  113879. */
  113880. static readonly NO_CAP: number;
  113881. /**
  113882. * Mesh cap setting : one cap at the beginning of the mesh
  113883. */
  113884. static readonly CAP_START: number;
  113885. /**
  113886. * Mesh cap setting : one cap at the end of the mesh
  113887. */
  113888. static readonly CAP_END: number;
  113889. /**
  113890. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  113891. */
  113892. static readonly CAP_ALL: number;
  113893. /**
  113894. * Mesh pattern setting : no flip or rotate
  113895. */
  113896. static readonly NO_FLIP: number;
  113897. /**
  113898. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  113899. */
  113900. static readonly FLIP_TILE: number;
  113901. /**
  113902. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  113903. */
  113904. static readonly ROTATE_TILE: number;
  113905. /**
  113906. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  113907. */
  113908. static readonly FLIP_ROW: number;
  113909. /**
  113910. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  113911. */
  113912. static readonly ROTATE_ROW: number;
  113913. /**
  113914. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  113915. */
  113916. static readonly FLIP_N_ROTATE_TILE: number;
  113917. /**
  113918. * Mesh pattern setting : rotate pattern and rotate
  113919. */
  113920. static readonly FLIP_N_ROTATE_ROW: number;
  113921. /**
  113922. * Mesh tile positioning : part tiles same on left/right or top/bottom
  113923. */
  113924. static readonly CENTER: number;
  113925. /**
  113926. * Mesh tile positioning : part tiles on left
  113927. */
  113928. static readonly LEFT: number;
  113929. /**
  113930. * Mesh tile positioning : part tiles on right
  113931. */
  113932. static readonly RIGHT: number;
  113933. /**
  113934. * Mesh tile positioning : part tiles on top
  113935. */
  113936. static readonly TOP: number;
  113937. /**
  113938. * Mesh tile positioning : part tiles on bottom
  113939. */
  113940. static readonly BOTTOM: number;
  113941. /**
  113942. * Gets the default side orientation.
  113943. * @param orientation the orientation to value to attempt to get
  113944. * @returns the default orientation
  113945. * @hidden
  113946. */
  113947. static _GetDefaultSideOrientation(orientation?: number): number;
  113948. private _internalMeshDataInfo;
  113949. get computeBonesUsingShaders(): boolean;
  113950. set computeBonesUsingShaders(value: boolean);
  113951. /**
  113952. * An event triggered before rendering the mesh
  113953. */
  113954. get onBeforeRenderObservable(): Observable<Mesh>;
  113955. /**
  113956. * An event triggered before binding the mesh
  113957. */
  113958. get onBeforeBindObservable(): Observable<Mesh>;
  113959. /**
  113960. * An event triggered after rendering the mesh
  113961. */
  113962. get onAfterRenderObservable(): Observable<Mesh>;
  113963. /**
  113964. * An event triggered before drawing the mesh
  113965. */
  113966. get onBeforeDrawObservable(): Observable<Mesh>;
  113967. private _onBeforeDrawObserver;
  113968. /**
  113969. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  113970. */
  113971. set onBeforeDraw(callback: () => void);
  113972. get hasInstances(): boolean;
  113973. get hasThinInstances(): boolean;
  113974. /**
  113975. * Gets the delay loading state of the mesh (when delay loading is turned on)
  113976. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  113977. */
  113978. delayLoadState: number;
  113979. /**
  113980. * Gets the list of instances created from this mesh
  113981. * it is not supposed to be modified manually.
  113982. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  113983. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113984. */
  113985. instances: InstancedMesh[];
  113986. /**
  113987. * Gets the file containing delay loading data for this mesh
  113988. */
  113989. delayLoadingFile: string;
  113990. /** @hidden */
  113991. _binaryInfo: any;
  113992. /**
  113993. * User defined function used to change how LOD level selection is done
  113994. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  113995. */
  113996. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  113997. /**
  113998. * Gets or sets the morph target manager
  113999. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  114000. */
  114001. get morphTargetManager(): Nullable<MorphTargetManager>;
  114002. set morphTargetManager(value: Nullable<MorphTargetManager>);
  114003. /** @hidden */
  114004. _creationDataStorage: Nullable<_CreationDataStorage>;
  114005. /** @hidden */
  114006. _geometry: Nullable<Geometry>;
  114007. /** @hidden */
  114008. _delayInfo: Array<string>;
  114009. /** @hidden */
  114010. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  114011. /** @hidden */
  114012. _instanceDataStorage: _InstanceDataStorage;
  114013. /** @hidden */
  114014. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  114015. private _effectiveMaterial;
  114016. /** @hidden */
  114017. _shouldGenerateFlatShading: boolean;
  114018. /** @hidden */
  114019. _originalBuilderSideOrientation: number;
  114020. /**
  114021. * Use this property to change the original side orientation defined at construction time
  114022. */
  114023. overrideMaterialSideOrientation: Nullable<number>;
  114024. /**
  114025. * Gets the source mesh (the one used to clone this one from)
  114026. */
  114027. get source(): Nullable<Mesh>;
  114028. /**
  114029. * Gets the list of clones of this mesh
  114030. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  114031. * Note that useClonedMeshMap=true is the default setting
  114032. */
  114033. get cloneMeshMap(): Nullable<{
  114034. [id: string]: Mesh | undefined;
  114035. }>;
  114036. /**
  114037. * Gets or sets a boolean indicating that this mesh does not use index buffer
  114038. */
  114039. get isUnIndexed(): boolean;
  114040. set isUnIndexed(value: boolean);
  114041. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  114042. get worldMatrixInstancedBuffer(): Float32Array;
  114043. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  114044. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  114045. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  114046. /**
  114047. * @constructor
  114048. * @param name The value used by scene.getMeshByName() to do a lookup.
  114049. * @param scene The scene to add this mesh to.
  114050. * @param parent The parent of this mesh, if it has one
  114051. * @param source An optional Mesh from which geometry is shared, cloned.
  114052. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  114053. * When false, achieved by calling a clone(), also passing False.
  114054. * This will make creation of children, recursive.
  114055. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  114056. */
  114057. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  114058. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  114059. doNotInstantiate: boolean;
  114060. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  114061. /**
  114062. * Gets the class name
  114063. * @returns the string "Mesh".
  114064. */
  114065. getClassName(): string;
  114066. /** @hidden */
  114067. get _isMesh(): boolean;
  114068. /**
  114069. * Returns a description of this mesh
  114070. * @param fullDetails define if full details about this mesh must be used
  114071. * @returns a descriptive string representing this mesh
  114072. */
  114073. toString(fullDetails?: boolean): string;
  114074. /** @hidden */
  114075. _unBindEffect(): void;
  114076. /**
  114077. * Gets a boolean indicating if this mesh has LOD
  114078. */
  114079. get hasLODLevels(): boolean;
  114080. /**
  114081. * Gets the list of MeshLODLevel associated with the current mesh
  114082. * @returns an array of MeshLODLevel
  114083. */
  114084. getLODLevels(): MeshLODLevel[];
  114085. private _sortLODLevels;
  114086. /**
  114087. * Add a mesh as LOD level triggered at the given distance.
  114088. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114089. * @param distance The distance from the center of the object to show this level
  114090. * @param mesh The mesh to be added as LOD level (can be null)
  114091. * @return This mesh (for chaining)
  114092. */
  114093. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  114094. /**
  114095. * Returns the LOD level mesh at the passed distance or null if not found.
  114096. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114097. * @param distance The distance from the center of the object to show this level
  114098. * @returns a Mesh or `null`
  114099. */
  114100. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  114101. /**
  114102. * Remove a mesh from the LOD array
  114103. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114104. * @param mesh defines the mesh to be removed
  114105. * @return This mesh (for chaining)
  114106. */
  114107. removeLODLevel(mesh: Mesh): Mesh;
  114108. /**
  114109. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  114110. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  114111. * @param camera defines the camera to use to compute distance
  114112. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  114113. * @return This mesh (for chaining)
  114114. */
  114115. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  114116. /**
  114117. * Gets the mesh internal Geometry object
  114118. */
  114119. get geometry(): Nullable<Geometry>;
  114120. /**
  114121. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  114122. * @returns the total number of vertices
  114123. */
  114124. getTotalVertices(): number;
  114125. /**
  114126. * Returns the content of an associated vertex buffer
  114127. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114128. * - VertexBuffer.PositionKind
  114129. * - VertexBuffer.UVKind
  114130. * - VertexBuffer.UV2Kind
  114131. * - VertexBuffer.UV3Kind
  114132. * - VertexBuffer.UV4Kind
  114133. * - VertexBuffer.UV5Kind
  114134. * - VertexBuffer.UV6Kind
  114135. * - VertexBuffer.ColorKind
  114136. * - VertexBuffer.MatricesIndicesKind
  114137. * - VertexBuffer.MatricesIndicesExtraKind
  114138. * - VertexBuffer.MatricesWeightsKind
  114139. * - VertexBuffer.MatricesWeightsExtraKind
  114140. * @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
  114141. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  114142. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  114143. */
  114144. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  114145. /**
  114146. * Returns the mesh VertexBuffer object from the requested `kind`
  114147. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114148. * - VertexBuffer.PositionKind
  114149. * - VertexBuffer.NormalKind
  114150. * - VertexBuffer.UVKind
  114151. * - VertexBuffer.UV2Kind
  114152. * - VertexBuffer.UV3Kind
  114153. * - VertexBuffer.UV4Kind
  114154. * - VertexBuffer.UV5Kind
  114155. * - VertexBuffer.UV6Kind
  114156. * - VertexBuffer.ColorKind
  114157. * - VertexBuffer.MatricesIndicesKind
  114158. * - VertexBuffer.MatricesIndicesExtraKind
  114159. * - VertexBuffer.MatricesWeightsKind
  114160. * - VertexBuffer.MatricesWeightsExtraKind
  114161. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  114162. */
  114163. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  114164. /**
  114165. * Tests if a specific vertex buffer is associated with this mesh
  114166. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114167. * - VertexBuffer.PositionKind
  114168. * - VertexBuffer.NormalKind
  114169. * - VertexBuffer.UVKind
  114170. * - VertexBuffer.UV2Kind
  114171. * - VertexBuffer.UV3Kind
  114172. * - VertexBuffer.UV4Kind
  114173. * - VertexBuffer.UV5Kind
  114174. * - VertexBuffer.UV6Kind
  114175. * - VertexBuffer.ColorKind
  114176. * - VertexBuffer.MatricesIndicesKind
  114177. * - VertexBuffer.MatricesIndicesExtraKind
  114178. * - VertexBuffer.MatricesWeightsKind
  114179. * - VertexBuffer.MatricesWeightsExtraKind
  114180. * @returns a boolean
  114181. */
  114182. isVerticesDataPresent(kind: string): boolean;
  114183. /**
  114184. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  114185. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  114186. * - VertexBuffer.PositionKind
  114187. * - VertexBuffer.UVKind
  114188. * - VertexBuffer.UV2Kind
  114189. * - VertexBuffer.UV3Kind
  114190. * - VertexBuffer.UV4Kind
  114191. * - VertexBuffer.UV5Kind
  114192. * - VertexBuffer.UV6Kind
  114193. * - VertexBuffer.ColorKind
  114194. * - VertexBuffer.MatricesIndicesKind
  114195. * - VertexBuffer.MatricesIndicesExtraKind
  114196. * - VertexBuffer.MatricesWeightsKind
  114197. * - VertexBuffer.MatricesWeightsExtraKind
  114198. * @returns a boolean
  114199. */
  114200. isVertexBufferUpdatable(kind: string): boolean;
  114201. /**
  114202. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  114203. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  114204. * - VertexBuffer.PositionKind
  114205. * - VertexBuffer.NormalKind
  114206. * - VertexBuffer.UVKind
  114207. * - VertexBuffer.UV2Kind
  114208. * - VertexBuffer.UV3Kind
  114209. * - VertexBuffer.UV4Kind
  114210. * - VertexBuffer.UV5Kind
  114211. * - VertexBuffer.UV6Kind
  114212. * - VertexBuffer.ColorKind
  114213. * - VertexBuffer.MatricesIndicesKind
  114214. * - VertexBuffer.MatricesIndicesExtraKind
  114215. * - VertexBuffer.MatricesWeightsKind
  114216. * - VertexBuffer.MatricesWeightsExtraKind
  114217. * @returns an array of strings
  114218. */
  114219. getVerticesDataKinds(): string[];
  114220. /**
  114221. * Returns a positive integer : the total number of indices in this mesh geometry.
  114222. * @returns the numner of indices or zero if the mesh has no geometry.
  114223. */
  114224. getTotalIndices(): number;
  114225. /**
  114226. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  114227. * @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.
  114228. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  114229. * @returns the indices array or an empty array if the mesh has no geometry
  114230. */
  114231. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  114232. get isBlocked(): boolean;
  114233. /**
  114234. * Determine if the current mesh is ready to be rendered
  114235. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  114236. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  114237. * @returns true if all associated assets are ready (material, textures, shaders)
  114238. */
  114239. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  114240. /**
  114241. * 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.
  114242. */
  114243. get areNormalsFrozen(): boolean;
  114244. /**
  114245. * 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.
  114246. * @returns the current mesh
  114247. */
  114248. freezeNormals(): Mesh;
  114249. /**
  114250. * 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
  114251. * @returns the current mesh
  114252. */
  114253. unfreezeNormals(): Mesh;
  114254. /**
  114255. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  114256. */
  114257. set overridenInstanceCount(count: number);
  114258. /** @hidden */
  114259. _preActivate(): Mesh;
  114260. /** @hidden */
  114261. _preActivateForIntermediateRendering(renderId: number): Mesh;
  114262. /** @hidden */
  114263. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  114264. protected _afterComputeWorldMatrix(): void;
  114265. /** @hidden */
  114266. _postActivate(): void;
  114267. /**
  114268. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  114269. * This means the mesh underlying bounding box and sphere are recomputed.
  114270. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  114271. * @returns the current mesh
  114272. */
  114273. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  114274. /** @hidden */
  114275. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  114276. /**
  114277. * This function will subdivide the mesh into multiple submeshes
  114278. * @param count defines the expected number of submeshes
  114279. */
  114280. subdivide(count: number): void;
  114281. /**
  114282. * Copy a FloatArray into a specific associated vertex buffer
  114283. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114284. * - VertexBuffer.PositionKind
  114285. * - VertexBuffer.UVKind
  114286. * - VertexBuffer.UV2Kind
  114287. * - VertexBuffer.UV3Kind
  114288. * - VertexBuffer.UV4Kind
  114289. * - VertexBuffer.UV5Kind
  114290. * - VertexBuffer.UV6Kind
  114291. * - VertexBuffer.ColorKind
  114292. * - VertexBuffer.MatricesIndicesKind
  114293. * - VertexBuffer.MatricesIndicesExtraKind
  114294. * - VertexBuffer.MatricesWeightsKind
  114295. * - VertexBuffer.MatricesWeightsExtraKind
  114296. * @param data defines the data source
  114297. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114298. * @param stride defines the data stride size (can be null)
  114299. * @returns the current mesh
  114300. */
  114301. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  114302. /**
  114303. * Delete a vertex buffer associated with this mesh
  114304. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  114305. * - VertexBuffer.PositionKind
  114306. * - VertexBuffer.UVKind
  114307. * - VertexBuffer.UV2Kind
  114308. * - VertexBuffer.UV3Kind
  114309. * - VertexBuffer.UV4Kind
  114310. * - VertexBuffer.UV5Kind
  114311. * - VertexBuffer.UV6Kind
  114312. * - VertexBuffer.ColorKind
  114313. * - VertexBuffer.MatricesIndicesKind
  114314. * - VertexBuffer.MatricesIndicesExtraKind
  114315. * - VertexBuffer.MatricesWeightsKind
  114316. * - VertexBuffer.MatricesWeightsExtraKind
  114317. */
  114318. removeVerticesData(kind: string): void;
  114319. /**
  114320. * Flags an associated vertex buffer as updatable
  114321. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  114322. * - VertexBuffer.PositionKind
  114323. * - VertexBuffer.UVKind
  114324. * - VertexBuffer.UV2Kind
  114325. * - VertexBuffer.UV3Kind
  114326. * - VertexBuffer.UV4Kind
  114327. * - VertexBuffer.UV5Kind
  114328. * - VertexBuffer.UV6Kind
  114329. * - VertexBuffer.ColorKind
  114330. * - VertexBuffer.MatricesIndicesKind
  114331. * - VertexBuffer.MatricesIndicesExtraKind
  114332. * - VertexBuffer.MatricesWeightsKind
  114333. * - VertexBuffer.MatricesWeightsExtraKind
  114334. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  114335. */
  114336. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  114337. /**
  114338. * Sets the mesh global Vertex Buffer
  114339. * @param buffer defines the buffer to use
  114340. * @returns the current mesh
  114341. */
  114342. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  114343. /**
  114344. * Update a specific associated vertex buffer
  114345. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  114346. * - VertexBuffer.PositionKind
  114347. * - VertexBuffer.UVKind
  114348. * - VertexBuffer.UV2Kind
  114349. * - VertexBuffer.UV3Kind
  114350. * - VertexBuffer.UV4Kind
  114351. * - VertexBuffer.UV5Kind
  114352. * - VertexBuffer.UV6Kind
  114353. * - VertexBuffer.ColorKind
  114354. * - VertexBuffer.MatricesIndicesKind
  114355. * - VertexBuffer.MatricesIndicesExtraKind
  114356. * - VertexBuffer.MatricesWeightsKind
  114357. * - VertexBuffer.MatricesWeightsExtraKind
  114358. * @param data defines the data source
  114359. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  114360. * @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)
  114361. * @returns the current mesh
  114362. */
  114363. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  114364. /**
  114365. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  114366. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  114367. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  114368. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  114369. * @returns the current mesh
  114370. */
  114371. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  114372. /**
  114373. * Creates a un-shared specific occurence of the geometry for the mesh.
  114374. * @returns the current mesh
  114375. */
  114376. makeGeometryUnique(): Mesh;
  114377. /**
  114378. * Set the index buffer of this mesh
  114379. * @param indices defines the source data
  114380. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  114381. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  114382. * @returns the current mesh
  114383. */
  114384. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  114385. /**
  114386. * Update the current index buffer
  114387. * @param indices defines the source data
  114388. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  114389. * @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)
  114390. * @returns the current mesh
  114391. */
  114392. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  114393. /**
  114394. * Invert the geometry to move from a right handed system to a left handed one.
  114395. * @returns the current mesh
  114396. */
  114397. toLeftHanded(): Mesh;
  114398. /** @hidden */
  114399. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  114400. /** @hidden */
  114401. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  114402. /**
  114403. * Registers for this mesh a javascript function called just before the rendering process
  114404. * @param func defines the function to call before rendering this mesh
  114405. * @returns the current mesh
  114406. */
  114407. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114408. /**
  114409. * Disposes a previously registered javascript function called before the rendering
  114410. * @param func defines the function to remove
  114411. * @returns the current mesh
  114412. */
  114413. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  114414. /**
  114415. * Registers for this mesh a javascript function called just after the rendering is complete
  114416. * @param func defines the function to call after rendering this mesh
  114417. * @returns the current mesh
  114418. */
  114419. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114420. /**
  114421. * Disposes a previously registered javascript function called after the rendering.
  114422. * @param func defines the function to remove
  114423. * @returns the current mesh
  114424. */
  114425. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  114426. /** @hidden */
  114427. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  114428. /** @hidden */
  114429. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  114430. /** @hidden */
  114431. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  114432. /** @hidden */
  114433. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  114434. /** @hidden */
  114435. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  114436. /** @hidden */
  114437. _rebuild(): void;
  114438. /** @hidden */
  114439. _freeze(): void;
  114440. /** @hidden */
  114441. _unFreeze(): void;
  114442. /**
  114443. * 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
  114444. * @param subMesh defines the subMesh to render
  114445. * @param enableAlphaMode defines if alpha mode can be changed
  114446. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  114447. * @returns the current mesh
  114448. */
  114449. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  114450. private _onBeforeDraw;
  114451. /**
  114452. * Renormalize the mesh and patch it up if there are no weights
  114453. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  114454. * However in the case of zero weights then we set just a single influence to 1.
  114455. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  114456. */
  114457. cleanMatrixWeights(): void;
  114458. private normalizeSkinFourWeights;
  114459. private normalizeSkinWeightsAndExtra;
  114460. /**
  114461. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  114462. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  114463. * the user know there was an issue with importing the mesh
  114464. * @returns a validation object with skinned, valid and report string
  114465. */
  114466. validateSkinning(): {
  114467. skinned: boolean;
  114468. valid: boolean;
  114469. report: string;
  114470. };
  114471. /** @hidden */
  114472. _checkDelayState(): Mesh;
  114473. private _queueLoad;
  114474. /**
  114475. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  114476. * A mesh is in the frustum if its bounding box intersects the frustum
  114477. * @param frustumPlanes defines the frustum to test
  114478. * @returns true if the mesh is in the frustum planes
  114479. */
  114480. isInFrustum(frustumPlanes: Plane[]): boolean;
  114481. /**
  114482. * Sets the mesh material by the material or multiMaterial `id` property
  114483. * @param id is a string identifying the material or the multiMaterial
  114484. * @returns the current mesh
  114485. */
  114486. setMaterialByID(id: string): Mesh;
  114487. /**
  114488. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  114489. * @returns an array of IAnimatable
  114490. */
  114491. getAnimatables(): IAnimatable[];
  114492. /**
  114493. * Modifies the mesh geometry according to the passed transformation matrix.
  114494. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  114495. * The mesh normals are modified using the same transformation.
  114496. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114497. * @param transform defines the transform matrix to use
  114498. * @see https://doc.babylonjs.com/resources/baking_transformations
  114499. * @returns the current mesh
  114500. */
  114501. bakeTransformIntoVertices(transform: Matrix): Mesh;
  114502. /**
  114503. * Modifies the mesh geometry according to its own current World Matrix.
  114504. * The mesh World Matrix is then reset.
  114505. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  114506. * Note that, under the hood, this method sets a new VertexBuffer each call.
  114507. * @see https://doc.babylonjs.com/resources/baking_transformations
  114508. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  114509. * @returns the current mesh
  114510. */
  114511. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  114512. /** @hidden */
  114513. get _positions(): Nullable<Vector3[]>;
  114514. /** @hidden */
  114515. _resetPointsArrayCache(): Mesh;
  114516. /** @hidden */
  114517. _generatePointsArray(): boolean;
  114518. /**
  114519. * Returns a new Mesh object generated from the current mesh properties.
  114520. * This method must not get confused with createInstance()
  114521. * @param name is a string, the name given to the new mesh
  114522. * @param newParent can be any Node object (default `null`)
  114523. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  114524. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  114525. * @returns a new mesh
  114526. */
  114527. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  114528. /**
  114529. * Releases resources associated with this mesh.
  114530. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  114531. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  114532. */
  114533. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  114534. /** @hidden */
  114535. _disposeInstanceSpecificData(): void;
  114536. /** @hidden */
  114537. _disposeThinInstanceSpecificData(): void;
  114538. /**
  114539. * Modifies the mesh geometry according to a displacement map.
  114540. * 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.
  114541. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114542. * @param url is a string, the URL from the image file is to be downloaded.
  114543. * @param minHeight is the lower limit of the displacement.
  114544. * @param maxHeight is the upper limit of the displacement.
  114545. * @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.
  114546. * @param uvOffset is an optional vector2 used to offset UV.
  114547. * @param uvScale is an optional vector2 used to scale UV.
  114548. * @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.
  114549. * @returns the Mesh.
  114550. */
  114551. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114552. /**
  114553. * Modifies the mesh geometry according to a displacementMap buffer.
  114554. * 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.
  114555. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  114556. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  114557. * @param heightMapWidth is the width of the buffer image.
  114558. * @param heightMapHeight is the height of the buffer image.
  114559. * @param minHeight is the lower limit of the displacement.
  114560. * @param maxHeight is the upper limit of the displacement.
  114561. * @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.
  114562. * @param uvOffset is an optional vector2 used to offset UV.
  114563. * @param uvScale is an optional vector2 used to scale UV.
  114564. * @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.
  114565. * @returns the Mesh.
  114566. */
  114567. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  114568. /**
  114569. * Modify the mesh to get a flat shading rendering.
  114570. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  114571. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  114572. * @returns current mesh
  114573. */
  114574. convertToFlatShadedMesh(): Mesh;
  114575. /**
  114576. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  114577. * In other words, more vertices, no more indices and a single bigger VBO.
  114578. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  114579. * @returns current mesh
  114580. */
  114581. convertToUnIndexedMesh(): Mesh;
  114582. /**
  114583. * Inverses facet orientations.
  114584. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114585. * @param flipNormals will also inverts the normals
  114586. * @returns current mesh
  114587. */
  114588. flipFaces(flipNormals?: boolean): Mesh;
  114589. /**
  114590. * Increase the number of facets and hence vertices in a mesh
  114591. * Vertex normals are interpolated from existing vertex normals
  114592. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114593. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  114594. */
  114595. increaseVertices(numberPerEdge: number): void;
  114596. /**
  114597. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  114598. * This will undo any application of covertToFlatShadedMesh
  114599. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  114600. */
  114601. forceSharedVertices(): void;
  114602. /** @hidden */
  114603. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  114604. /** @hidden */
  114605. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  114606. /**
  114607. * Creates a new InstancedMesh object from the mesh model.
  114608. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  114609. * @param name defines the name of the new instance
  114610. * @returns a new InstancedMesh
  114611. */
  114612. createInstance(name: string): InstancedMesh;
  114613. /**
  114614. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  114615. * After this call, all the mesh instances have the same submeshes than the current mesh.
  114616. * @returns the current mesh
  114617. */
  114618. synchronizeInstances(): Mesh;
  114619. /**
  114620. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  114621. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  114622. * This should be used together with the simplification to avoid disappearing triangles.
  114623. * @param successCallback an optional success callback to be called after the optimization finished.
  114624. * @returns the current mesh
  114625. */
  114626. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  114627. /**
  114628. * Serialize current mesh
  114629. * @param serializationObject defines the object which will receive the serialization data
  114630. */
  114631. serialize(serializationObject: any): void;
  114632. /** @hidden */
  114633. _syncGeometryWithMorphTargetManager(): void;
  114634. /** @hidden */
  114635. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  114636. /**
  114637. * Returns a new Mesh object parsed from the source provided.
  114638. * @param parsedMesh is the source
  114639. * @param scene defines the hosting scene
  114640. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  114641. * @returns a new Mesh
  114642. */
  114643. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  114644. /**
  114645. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  114646. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114647. * @param name defines the name of the mesh to create
  114648. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  114649. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  114650. * @param closePath creates a seam between the first and the last points of each path of the path array
  114651. * @param offset is taken in account only if the `pathArray` is containing a single path
  114652. * @param scene defines the hosting scene
  114653. * @param updatable defines if the mesh must be flagged as updatable
  114654. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114655. * @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)
  114656. * @returns a new Mesh
  114657. */
  114658. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114659. /**
  114660. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  114661. * @param name defines the name of the mesh to create
  114662. * @param radius sets the radius size (float) of the polygon (default 0.5)
  114663. * @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
  114664. * @param scene defines the hosting scene
  114665. * @param updatable defines if the mesh must be flagged as updatable
  114666. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114667. * @returns a new Mesh
  114668. */
  114669. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114670. /**
  114671. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  114672. * @param name defines the name of the mesh to create
  114673. * @param size sets the size (float) of each box side (default 1)
  114674. * @param scene defines the hosting scene
  114675. * @param updatable defines if the mesh must be flagged as updatable
  114676. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114677. * @returns a new Mesh
  114678. */
  114679. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  114680. /**
  114681. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  114682. * @param name defines the name of the mesh to create
  114683. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114684. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114685. * @param scene defines the hosting scene
  114686. * @param updatable defines if the mesh must be flagged as updatable
  114687. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114688. * @returns a new Mesh
  114689. */
  114690. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114691. /**
  114692. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  114693. * @param name defines the name of the mesh to create
  114694. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  114695. * @param diameter sets the diameter size (float) of the sphere (default 1)
  114696. * @param scene defines the hosting scene
  114697. * @returns a new Mesh
  114698. */
  114699. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  114700. /**
  114701. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  114702. * @param name defines the name of the mesh to create
  114703. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  114704. * @param diameterTop set the top cap diameter (floats, default 1)
  114705. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  114706. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  114707. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  114708. * @param scene defines the hosting scene
  114709. * @param updatable defines if the mesh must be flagged as updatable
  114710. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114711. * @returns a new Mesh
  114712. */
  114713. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  114714. /**
  114715. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  114716. * @param name defines the name of the mesh to create
  114717. * @param diameter sets the diameter size (float) of the torus (default 1)
  114718. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  114719. * @param tessellation sets the number of torus sides (postive integer, default 16)
  114720. * @param scene defines the hosting scene
  114721. * @param updatable defines if the mesh must be flagged as updatable
  114722. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114723. * @returns a new Mesh
  114724. */
  114725. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114726. /**
  114727. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  114728. * @param name defines the name of the mesh to create
  114729. * @param radius sets the global radius size (float) of the torus knot (default 2)
  114730. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  114731. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  114732. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  114733. * @param p the number of windings on X axis (positive integers, default 2)
  114734. * @param q the number of windings on Y axis (positive integers, default 3)
  114735. * @param scene defines the hosting scene
  114736. * @param updatable defines if the mesh must be flagged as updatable
  114737. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114738. * @returns a new Mesh
  114739. */
  114740. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114741. /**
  114742. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  114743. * @param name defines the name of the mesh to create
  114744. * @param points is an array successive Vector3
  114745. * @param scene defines the hosting scene
  114746. * @param updatable defines if the mesh must be flagged as updatable
  114747. * @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).
  114748. * @returns a new Mesh
  114749. */
  114750. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  114751. /**
  114752. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  114753. * @param name defines the name of the mesh to create
  114754. * @param points is an array successive Vector3
  114755. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  114756. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114757. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  114758. * @param scene defines the hosting scene
  114759. * @param updatable defines if the mesh must be flagged as updatable
  114760. * @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)
  114761. * @returns a new Mesh
  114762. */
  114763. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  114764. /**
  114765. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  114766. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  114767. * 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.
  114768. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114769. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114770. * Remember you can only change the shape positions, not their number when updating a polygon.
  114771. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  114772. * @param name defines the name of the mesh to create
  114773. * @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
  114774. * @param scene defines the hosting scene
  114775. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114776. * @param updatable defines if the mesh must be flagged as updatable
  114777. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114778. * @param earcutInjection can be used to inject your own earcut reference
  114779. * @returns a new Mesh
  114780. */
  114781. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114782. /**
  114783. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  114784. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  114785. * @param name defines the name of the mesh to create
  114786. * @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
  114787. * @param depth defines the height of extrusion
  114788. * @param scene defines the hosting scene
  114789. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  114790. * @param updatable defines if the mesh must be flagged as updatable
  114791. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114792. * @param earcutInjection can be used to inject your own earcut reference
  114793. * @returns a new Mesh
  114794. */
  114795. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  114796. /**
  114797. * Creates an extruded shape mesh.
  114798. * 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
  114799. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114800. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114801. * @param name defines the name of the mesh to create
  114802. * @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
  114803. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114804. * @param scale is the value to scale the shape
  114805. * @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
  114806. * @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
  114807. * @param scene defines the hosting scene
  114808. * @param updatable defines if the mesh must be flagged as updatable
  114809. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114810. * @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)
  114811. * @returns a new Mesh
  114812. */
  114813. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114814. /**
  114815. * Creates an custom extruded shape mesh.
  114816. * The custom extrusion is a parametric shape.
  114817. * It has no predefined shape. Its final shape will depend on the input parameters.
  114818. * Please consider using the same method from the MeshBuilder class instead
  114819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114820. * @param name defines the name of the mesh to create
  114821. * @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
  114822. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  114823. * @param scaleFunction is a custom Javascript function called on each path point
  114824. * @param rotationFunction is a custom Javascript function called on each path point
  114825. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114826. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  114827. * @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
  114828. * @param scene defines the hosting scene
  114829. * @param updatable defines if the mesh must be flagged as updatable
  114830. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114831. * @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)
  114832. * @returns a new Mesh
  114833. */
  114834. 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;
  114835. /**
  114836. * Creates lathe mesh.
  114837. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  114838. * Please consider using the same method from the MeshBuilder class instead
  114839. * @param name defines the name of the mesh to create
  114840. * @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
  114841. * @param radius is the radius value of the lathe
  114842. * @param tessellation is the side number of the lathe.
  114843. * @param scene defines the hosting scene
  114844. * @param updatable defines if the mesh must be flagged as updatable
  114845. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114846. * @returns a new Mesh
  114847. */
  114848. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114849. /**
  114850. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  114851. * @param name defines the name of the mesh to create
  114852. * @param size sets the size (float) of both sides of the plane at once (default 1)
  114853. * @param scene defines the hosting scene
  114854. * @param updatable defines if the mesh must be flagged as updatable
  114855. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114856. * @returns a new Mesh
  114857. */
  114858. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  114859. /**
  114860. * Creates a ground mesh.
  114861. * Please consider using the same method from the MeshBuilder class instead
  114862. * @param name defines the name of the mesh to create
  114863. * @param width set the width of the ground
  114864. * @param height set the height of the ground
  114865. * @param subdivisions sets the number of subdivisions per side
  114866. * @param scene defines the hosting scene
  114867. * @param updatable defines if the mesh must be flagged as updatable
  114868. * @returns a new Mesh
  114869. */
  114870. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  114871. /**
  114872. * Creates a tiled ground mesh.
  114873. * Please consider using the same method from the MeshBuilder class instead
  114874. * @param name defines the name of the mesh to create
  114875. * @param xmin set the ground minimum X coordinate
  114876. * @param zmin set the ground minimum Y coordinate
  114877. * @param xmax set the ground maximum X coordinate
  114878. * @param zmax set the ground maximum Z coordinate
  114879. * @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
  114880. * @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
  114881. * @param scene defines the hosting scene
  114882. * @param updatable defines if the mesh must be flagged as updatable
  114883. * @returns a new Mesh
  114884. */
  114885. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  114886. w: number;
  114887. h: number;
  114888. }, precision: {
  114889. w: number;
  114890. h: number;
  114891. }, scene: Scene, updatable?: boolean): Mesh;
  114892. /**
  114893. * Creates a ground mesh from a height map.
  114894. * Please consider using the same method from the MeshBuilder class instead
  114895. * @see https://doc.babylonjs.com/babylon101/height_map
  114896. * @param name defines the name of the mesh to create
  114897. * @param url sets the URL of the height map image resource
  114898. * @param width set the ground width size
  114899. * @param height set the ground height size
  114900. * @param subdivisions sets the number of subdivision per side
  114901. * @param minHeight is the minimum altitude on the ground
  114902. * @param maxHeight is the maximum altitude on the ground
  114903. * @param scene defines the hosting scene
  114904. * @param updatable defines if the mesh must be flagged as updatable
  114905. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  114906. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114907. * @returns a new Mesh
  114908. */
  114909. 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;
  114910. /**
  114911. * Creates a tube mesh.
  114912. * The tube is a parametric shape.
  114913. * It has no predefined shape. Its final shape will depend on the input parameters.
  114914. * Please consider using the same method from the MeshBuilder class instead
  114915. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114916. * @param name defines the name of the mesh to create
  114917. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  114918. * @param radius sets the tube radius size
  114919. * @param tessellation is the number of sides on the tubular surface
  114920. * @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
  114921. * @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
  114922. * @param scene defines the hosting scene
  114923. * @param updatable defines if the mesh must be flagged as updatable
  114924. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  114925. * @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)
  114926. * @returns a new Mesh
  114927. */
  114928. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  114929. (i: number, distance: number): number;
  114930. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  114931. /**
  114932. * Creates a polyhedron mesh.
  114933. * Please consider using the same method from the MeshBuilder class instead.
  114934. * * 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
  114935. * * The parameter `size` (positive float, default 1) sets the polygon size
  114936. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114937. * * 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`
  114938. * * 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
  114939. * * 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)`)
  114940. * * 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
  114941. * * 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
  114942. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114943. * * 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
  114944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114945. * @param name defines the name of the mesh to create
  114946. * @param options defines the options used to create the mesh
  114947. * @param scene defines the hosting scene
  114948. * @returns a new Mesh
  114949. */
  114950. static CreatePolyhedron(name: string, options: {
  114951. type?: number;
  114952. size?: number;
  114953. sizeX?: number;
  114954. sizeY?: number;
  114955. sizeZ?: number;
  114956. custom?: any;
  114957. faceUV?: Vector4[];
  114958. faceColors?: Color4[];
  114959. updatable?: boolean;
  114960. sideOrientation?: number;
  114961. }, scene: Scene): Mesh;
  114962. /**
  114963. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114964. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114965. * * 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`)
  114966. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114967. * * 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
  114968. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114969. * * 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
  114970. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114971. * @param name defines the name of the mesh
  114972. * @param options defines the options used to create the mesh
  114973. * @param scene defines the hosting scene
  114974. * @returns a new Mesh
  114975. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114976. */
  114977. static CreateIcoSphere(name: string, options: {
  114978. radius?: number;
  114979. flat?: boolean;
  114980. subdivisions?: number;
  114981. sideOrientation?: number;
  114982. updatable?: boolean;
  114983. }, scene: Scene): Mesh;
  114984. /**
  114985. * Creates a decal mesh.
  114986. * Please consider using the same method from the MeshBuilder class instead.
  114987. * A decal is a mesh usually applied as a model onto the surface of another mesh
  114988. * @param name defines the name of the mesh
  114989. * @param sourceMesh defines the mesh receiving the decal
  114990. * @param position sets the position of the decal in world coordinates
  114991. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  114992. * @param size sets the decal scaling
  114993. * @param angle sets the angle to rotate the decal
  114994. * @returns a new Mesh
  114995. */
  114996. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  114997. /** Creates a Capsule Mesh
  114998. * @param name defines the name of the mesh.
  114999. * @param options the constructors options used to shape the mesh.
  115000. * @param scene defines the scene the mesh is scoped to.
  115001. * @returns the capsule mesh
  115002. * @see https://doc.babylonjs.com/how_to/capsule_shape
  115003. */
  115004. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  115005. /**
  115006. * Prepare internal position array for software CPU skinning
  115007. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  115008. */
  115009. setPositionsForCPUSkinning(): Float32Array;
  115010. /**
  115011. * Prepare internal normal array for software CPU skinning
  115012. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  115013. */
  115014. setNormalsForCPUSkinning(): Float32Array;
  115015. /**
  115016. * Updates the vertex buffer by applying transformation from the bones
  115017. * @param skeleton defines the skeleton to apply to current mesh
  115018. * @returns the current mesh
  115019. */
  115020. applySkeleton(skeleton: Skeleton): Mesh;
  115021. /**
  115022. * 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
  115023. * @param meshes defines the list of meshes to scan
  115024. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  115025. */
  115026. static MinMax(meshes: AbstractMesh[]): {
  115027. min: Vector3;
  115028. max: Vector3;
  115029. };
  115030. /**
  115031. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  115032. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  115033. * @returns a vector3
  115034. */
  115035. static Center(meshesOrMinMaxVector: {
  115036. min: Vector3;
  115037. max: Vector3;
  115038. } | AbstractMesh[]): Vector3;
  115039. /**
  115040. * Merge the array of meshes into a single mesh for performance reasons.
  115041. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  115042. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  115043. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  115044. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  115045. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  115046. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  115047. * @returns a new mesh
  115048. */
  115049. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  115050. /** @hidden */
  115051. addInstance(instance: InstancedMesh): void;
  115052. /** @hidden */
  115053. removeInstance(instance: InstancedMesh): void;
  115054. }
  115055. }
  115056. declare module BABYLON {
  115057. /**
  115058. * This is the base class of all the camera used in the application.
  115059. * @see https://doc.babylonjs.com/features/cameras
  115060. */
  115061. export class Camera extends Node {
  115062. /** @hidden */
  115063. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  115064. /**
  115065. * This is the default projection mode used by the cameras.
  115066. * It helps recreating a feeling of perspective and better appreciate depth.
  115067. * This is the best way to simulate real life cameras.
  115068. */
  115069. static readonly PERSPECTIVE_CAMERA: number;
  115070. /**
  115071. * This helps creating camera with an orthographic mode.
  115072. * 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.
  115073. */
  115074. static readonly ORTHOGRAPHIC_CAMERA: number;
  115075. /**
  115076. * This is the default FOV mode for perspective cameras.
  115077. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  115078. */
  115079. static readonly FOVMODE_VERTICAL_FIXED: number;
  115080. /**
  115081. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  115082. */
  115083. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  115084. /**
  115085. * This specifies ther is no need for a camera rig.
  115086. * Basically only one eye is rendered corresponding to the camera.
  115087. */
  115088. static readonly RIG_MODE_NONE: number;
  115089. /**
  115090. * Simulates a camera Rig with one blue eye and one red eye.
  115091. * This can be use with 3d blue and red glasses.
  115092. */
  115093. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  115094. /**
  115095. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  115096. */
  115097. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  115098. /**
  115099. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  115100. */
  115101. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  115102. /**
  115103. * Defines that both eyes of the camera will be rendered over under each other.
  115104. */
  115105. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  115106. /**
  115107. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  115108. */
  115109. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  115110. /**
  115111. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  115112. */
  115113. static readonly RIG_MODE_VR: number;
  115114. /**
  115115. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  115116. */
  115117. static readonly RIG_MODE_WEBVR: number;
  115118. /**
  115119. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  115120. */
  115121. static readonly RIG_MODE_CUSTOM: number;
  115122. /**
  115123. * Defines if by default attaching controls should prevent the default javascript event to continue.
  115124. */
  115125. static ForceAttachControlToAlwaysPreventDefault: boolean;
  115126. /**
  115127. * Define the input manager associated with the camera.
  115128. */
  115129. inputs: CameraInputsManager<Camera>;
  115130. /** @hidden */
  115131. _position: Vector3;
  115132. /**
  115133. * Define the current local position of the camera in the scene
  115134. */
  115135. get position(): Vector3;
  115136. set position(newPosition: Vector3);
  115137. protected _upVector: Vector3;
  115138. /**
  115139. * The vector the camera should consider as up.
  115140. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  115141. */
  115142. set upVector(vec: Vector3);
  115143. get upVector(): Vector3;
  115144. /**
  115145. * Define the current limit on the left side for an orthographic camera
  115146. * In scene unit
  115147. */
  115148. orthoLeft: Nullable<number>;
  115149. /**
  115150. * Define the current limit on the right side for an orthographic camera
  115151. * In scene unit
  115152. */
  115153. orthoRight: Nullable<number>;
  115154. /**
  115155. * Define the current limit on the bottom side for an orthographic camera
  115156. * In scene unit
  115157. */
  115158. orthoBottom: Nullable<number>;
  115159. /**
  115160. * Define the current limit on the top side for an orthographic camera
  115161. * In scene unit
  115162. */
  115163. orthoTop: Nullable<number>;
  115164. /**
  115165. * Field Of View is set in Radians. (default is 0.8)
  115166. */
  115167. fov: number;
  115168. /**
  115169. * Define the minimum distance the camera can see from.
  115170. * This is important to note that the depth buffer are not infinite and the closer it starts
  115171. * the more your scene might encounter depth fighting issue.
  115172. */
  115173. minZ: number;
  115174. /**
  115175. * Define the maximum distance the camera can see to.
  115176. * This is important to note that the depth buffer are not infinite and the further it end
  115177. * the more your scene might encounter depth fighting issue.
  115178. */
  115179. maxZ: number;
  115180. /**
  115181. * Define the default inertia of the camera.
  115182. * This helps giving a smooth feeling to the camera movement.
  115183. */
  115184. inertia: number;
  115185. /**
  115186. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  115187. */
  115188. mode: number;
  115189. /**
  115190. * Define whether the camera is intermediate.
  115191. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  115192. */
  115193. isIntermediate: boolean;
  115194. /**
  115195. * Define the viewport of the camera.
  115196. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  115197. */
  115198. viewport: Viewport;
  115199. /**
  115200. * Restricts the camera to viewing objects with the same layerMask.
  115201. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  115202. */
  115203. layerMask: number;
  115204. /**
  115205. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  115206. */
  115207. fovMode: number;
  115208. /**
  115209. * Rig mode of the camera.
  115210. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  115211. * This is normally controlled byt the camera themselves as internal use.
  115212. */
  115213. cameraRigMode: number;
  115214. /**
  115215. * Defines the distance between both "eyes" in case of a RIG
  115216. */
  115217. interaxialDistance: number;
  115218. /**
  115219. * Defines if stereoscopic rendering is done side by side or over under.
  115220. */
  115221. isStereoscopicSideBySide: boolean;
  115222. /**
  115223. * 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
  115224. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  115225. * else in the scene. (Eg. security camera)
  115226. *
  115227. * 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)
  115228. */
  115229. customRenderTargets: RenderTargetTexture[];
  115230. /**
  115231. * When set, the camera will render to this render target instead of the default canvas
  115232. *
  115233. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  115234. */
  115235. outputRenderTarget: Nullable<RenderTargetTexture>;
  115236. /**
  115237. * Observable triggered when the camera view matrix has changed.
  115238. */
  115239. onViewMatrixChangedObservable: Observable<Camera>;
  115240. /**
  115241. * Observable triggered when the camera Projection matrix has changed.
  115242. */
  115243. onProjectionMatrixChangedObservable: Observable<Camera>;
  115244. /**
  115245. * Observable triggered when the inputs have been processed.
  115246. */
  115247. onAfterCheckInputsObservable: Observable<Camera>;
  115248. /**
  115249. * Observable triggered when reset has been called and applied to the camera.
  115250. */
  115251. onRestoreStateObservable: Observable<Camera>;
  115252. /**
  115253. * Is this camera a part of a rig system?
  115254. */
  115255. isRigCamera: boolean;
  115256. /**
  115257. * If isRigCamera set to true this will be set with the parent camera.
  115258. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  115259. */
  115260. rigParent?: Camera;
  115261. /** @hidden */
  115262. _cameraRigParams: any;
  115263. /** @hidden */
  115264. _rigCameras: Camera[];
  115265. /** @hidden */
  115266. _rigPostProcess: Nullable<PostProcess>;
  115267. protected _webvrViewMatrix: Matrix;
  115268. /** @hidden */
  115269. _skipRendering: boolean;
  115270. /** @hidden */
  115271. _projectionMatrix: Matrix;
  115272. /** @hidden */
  115273. _postProcesses: Nullable<PostProcess>[];
  115274. /** @hidden */
  115275. _activeMeshes: SmartArray<AbstractMesh>;
  115276. protected _globalPosition: Vector3;
  115277. /** @hidden */
  115278. _computedViewMatrix: Matrix;
  115279. private _doNotComputeProjectionMatrix;
  115280. private _transformMatrix;
  115281. private _frustumPlanes;
  115282. private _refreshFrustumPlanes;
  115283. private _storedFov;
  115284. private _stateStored;
  115285. /**
  115286. * Instantiates a new camera object.
  115287. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  115288. * @see https://doc.babylonjs.com/features/cameras
  115289. * @param name Defines the name of the camera in the scene
  115290. * @param position Defines the position of the camera
  115291. * @param scene Defines the scene the camera belongs too
  115292. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  115293. */
  115294. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  115295. /**
  115296. * Store current camera state (fov, position, etc..)
  115297. * @returns the camera
  115298. */
  115299. storeState(): Camera;
  115300. /**
  115301. * Restores the camera state values if it has been stored. You must call storeState() first
  115302. */
  115303. protected _restoreStateValues(): boolean;
  115304. /**
  115305. * Restored camera state. You must call storeState() first.
  115306. * @returns true if restored and false otherwise
  115307. */
  115308. restoreState(): boolean;
  115309. /**
  115310. * Gets the class name of the camera.
  115311. * @returns the class name
  115312. */
  115313. getClassName(): string;
  115314. /** @hidden */
  115315. readonly _isCamera: boolean;
  115316. /**
  115317. * Gets a string representation of the camera useful for debug purpose.
  115318. * @param fullDetails Defines that a more verboe level of logging is required
  115319. * @returns the string representation
  115320. */
  115321. toString(fullDetails?: boolean): string;
  115322. /**
  115323. * Gets the current world space position of the camera.
  115324. */
  115325. get globalPosition(): Vector3;
  115326. /**
  115327. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  115328. * @returns the active meshe list
  115329. */
  115330. getActiveMeshes(): SmartArray<AbstractMesh>;
  115331. /**
  115332. * Check whether a mesh is part of the current active mesh list of the camera
  115333. * @param mesh Defines the mesh to check
  115334. * @returns true if active, false otherwise
  115335. */
  115336. isActiveMesh(mesh: Mesh): boolean;
  115337. /**
  115338. * Is this camera ready to be used/rendered
  115339. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  115340. * @return true if the camera is ready
  115341. */
  115342. isReady(completeCheck?: boolean): boolean;
  115343. /** @hidden */
  115344. _initCache(): void;
  115345. /** @hidden */
  115346. _updateCache(ignoreParentClass?: boolean): void;
  115347. /** @hidden */
  115348. _isSynchronized(): boolean;
  115349. /** @hidden */
  115350. _isSynchronizedViewMatrix(): boolean;
  115351. /** @hidden */
  115352. _isSynchronizedProjectionMatrix(): boolean;
  115353. /**
  115354. * Attach the input controls to a specific dom element to get the input from.
  115355. * @param element Defines the element the controls should be listened from
  115356. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115357. */
  115358. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115359. /**
  115360. * Detach the current controls from the specified dom element.
  115361. * @param element Defines the element to stop listening the inputs from
  115362. */
  115363. detachControl(element: HTMLElement): void;
  115364. /**
  115365. * Update the camera state according to the different inputs gathered during the frame.
  115366. */
  115367. update(): void;
  115368. /** @hidden */
  115369. _checkInputs(): void;
  115370. /** @hidden */
  115371. get rigCameras(): Camera[];
  115372. /**
  115373. * Gets the post process used by the rig cameras
  115374. */
  115375. get rigPostProcess(): Nullable<PostProcess>;
  115376. /**
  115377. * Internal, gets the first post proces.
  115378. * @returns the first post process to be run on this camera.
  115379. */
  115380. _getFirstPostProcess(): Nullable<PostProcess>;
  115381. private _cascadePostProcessesToRigCams;
  115382. /**
  115383. * Attach a post process to the camera.
  115384. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  115385. * @param postProcess The post process to attach to the camera
  115386. * @param insertAt The position of the post process in case several of them are in use in the scene
  115387. * @returns the position the post process has been inserted at
  115388. */
  115389. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  115390. /**
  115391. * Detach a post process to the camera.
  115392. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  115393. * @param postProcess The post process to detach from the camera
  115394. */
  115395. detachPostProcess(postProcess: PostProcess): void;
  115396. /**
  115397. * Gets the current world matrix of the camera
  115398. */
  115399. getWorldMatrix(): Matrix;
  115400. /** @hidden */
  115401. _getViewMatrix(): Matrix;
  115402. /**
  115403. * Gets the current view matrix of the camera.
  115404. * @param force forces the camera to recompute the matrix without looking at the cached state
  115405. * @returns the view matrix
  115406. */
  115407. getViewMatrix(force?: boolean): Matrix;
  115408. /**
  115409. * Freeze the projection matrix.
  115410. * It will prevent the cache check of the camera projection compute and can speed up perf
  115411. * if no parameter of the camera are meant to change
  115412. * @param projection Defines manually a projection if necessary
  115413. */
  115414. freezeProjectionMatrix(projection?: Matrix): void;
  115415. /**
  115416. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  115417. */
  115418. unfreezeProjectionMatrix(): void;
  115419. /**
  115420. * Gets the current projection matrix of the camera.
  115421. * @param force forces the camera to recompute the matrix without looking at the cached state
  115422. * @returns the projection matrix
  115423. */
  115424. getProjectionMatrix(force?: boolean): Matrix;
  115425. /**
  115426. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  115427. * @returns a Matrix
  115428. */
  115429. getTransformationMatrix(): Matrix;
  115430. private _updateFrustumPlanes;
  115431. /**
  115432. * Checks if a cullable object (mesh...) is in the camera frustum
  115433. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  115434. * @param target The object to check
  115435. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  115436. * @returns true if the object is in frustum otherwise false
  115437. */
  115438. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  115439. /**
  115440. * Checks if a cullable object (mesh...) is in the camera frustum
  115441. * Unlike isInFrustum this cheks the full bounding box
  115442. * @param target The object to check
  115443. * @returns true if the object is in frustum otherwise false
  115444. */
  115445. isCompletelyInFrustum(target: ICullable): boolean;
  115446. /**
  115447. * Gets a ray in the forward direction from the camera.
  115448. * @param length Defines the length of the ray to create
  115449. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  115450. * @param origin Defines the start point of the ray which defaults to the camera position
  115451. * @returns the forward ray
  115452. */
  115453. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  115454. /**
  115455. * Gets a ray in the forward direction from the camera.
  115456. * @param refRay the ray to (re)use when setting the values
  115457. * @param length Defines the length of the ray to create
  115458. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  115459. * @param origin Defines the start point of the ray which defaults to the camera position
  115460. * @returns the forward ray
  115461. */
  115462. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  115463. /**
  115464. * Releases resources associated with this node.
  115465. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115466. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115467. */
  115468. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115469. /** @hidden */
  115470. _isLeftCamera: boolean;
  115471. /**
  115472. * Gets the left camera of a rig setup in case of Rigged Camera
  115473. */
  115474. get isLeftCamera(): boolean;
  115475. /** @hidden */
  115476. _isRightCamera: boolean;
  115477. /**
  115478. * Gets the right camera of a rig setup in case of Rigged Camera
  115479. */
  115480. get isRightCamera(): boolean;
  115481. /**
  115482. * Gets the left camera of a rig setup in case of Rigged Camera
  115483. */
  115484. get leftCamera(): Nullable<FreeCamera>;
  115485. /**
  115486. * Gets the right camera of a rig setup in case of Rigged Camera
  115487. */
  115488. get rightCamera(): Nullable<FreeCamera>;
  115489. /**
  115490. * Gets the left camera target of a rig setup in case of Rigged Camera
  115491. * @returns the target position
  115492. */
  115493. getLeftTarget(): Nullable<Vector3>;
  115494. /**
  115495. * Gets the right camera target of a rig setup in case of Rigged Camera
  115496. * @returns the target position
  115497. */
  115498. getRightTarget(): Nullable<Vector3>;
  115499. /**
  115500. * @hidden
  115501. */
  115502. setCameraRigMode(mode: number, rigParams: any): void;
  115503. /** @hidden */
  115504. static _setStereoscopicRigMode(camera: Camera): void;
  115505. /** @hidden */
  115506. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  115507. /** @hidden */
  115508. static _setVRRigMode(camera: Camera, rigParams: any): void;
  115509. /** @hidden */
  115510. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  115511. /** @hidden */
  115512. _getVRProjectionMatrix(): Matrix;
  115513. protected _updateCameraRotationMatrix(): void;
  115514. protected _updateWebVRCameraRotationMatrix(): void;
  115515. /**
  115516. * This function MUST be overwritten by the different WebVR cameras available.
  115517. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  115518. * @hidden
  115519. */
  115520. _getWebVRProjectionMatrix(): Matrix;
  115521. /**
  115522. * This function MUST be overwritten by the different WebVR cameras available.
  115523. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  115524. * @hidden
  115525. */
  115526. _getWebVRViewMatrix(): Matrix;
  115527. /** @hidden */
  115528. setCameraRigParameter(name: string, value: any): void;
  115529. /**
  115530. * needs to be overridden by children so sub has required properties to be copied
  115531. * @hidden
  115532. */
  115533. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  115534. /**
  115535. * May need to be overridden by children
  115536. * @hidden
  115537. */
  115538. _updateRigCameras(): void;
  115539. /** @hidden */
  115540. _setupInputs(): void;
  115541. /**
  115542. * Serialiaze the camera setup to a json represention
  115543. * @returns the JSON representation
  115544. */
  115545. serialize(): any;
  115546. /**
  115547. * Clones the current camera.
  115548. * @param name The cloned camera name
  115549. * @returns the cloned camera
  115550. */
  115551. clone(name: string): Camera;
  115552. /**
  115553. * Gets the direction of the camera relative to a given local axis.
  115554. * @param localAxis Defines the reference axis to provide a relative direction.
  115555. * @return the direction
  115556. */
  115557. getDirection(localAxis: Vector3): Vector3;
  115558. /**
  115559. * Returns the current camera absolute rotation
  115560. */
  115561. get absoluteRotation(): Quaternion;
  115562. /**
  115563. * Gets the direction of the camera relative to a given local axis into a passed vector.
  115564. * @param localAxis Defines the reference axis to provide a relative direction.
  115565. * @param result Defines the vector to store the result in
  115566. */
  115567. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  115568. /**
  115569. * Gets a camera constructor for a given camera type
  115570. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  115571. * @param name The name of the camera the result will be able to instantiate
  115572. * @param scene The scene the result will construct the camera in
  115573. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  115574. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  115575. * @returns a factory method to construc the camera
  115576. */
  115577. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  115578. /**
  115579. * Compute the world matrix of the camera.
  115580. * @returns the camera world matrix
  115581. */
  115582. computeWorldMatrix(): Matrix;
  115583. /**
  115584. * Parse a JSON and creates the camera from the parsed information
  115585. * @param parsedCamera The JSON to parse
  115586. * @param scene The scene to instantiate the camera in
  115587. * @returns the newly constructed camera
  115588. */
  115589. static Parse(parsedCamera: any, scene: Scene): Camera;
  115590. }
  115591. }
  115592. declare module BABYLON {
  115593. /**
  115594. * Class containing static functions to help procedurally build meshes
  115595. */
  115596. export class DiscBuilder {
  115597. /**
  115598. * Creates a plane polygonal mesh. By default, this is a disc
  115599. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  115600. * * 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
  115601. * * 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
  115602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115603. * * 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
  115604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115605. * @param name defines the name of the mesh
  115606. * @param options defines the options used to create the mesh
  115607. * @param scene defines the hosting scene
  115608. * @returns the plane polygonal mesh
  115609. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  115610. */
  115611. static CreateDisc(name: string, options: {
  115612. radius?: number;
  115613. tessellation?: number;
  115614. arc?: number;
  115615. updatable?: boolean;
  115616. sideOrientation?: number;
  115617. frontUVs?: Vector4;
  115618. backUVs?: Vector4;
  115619. }, scene?: Nullable<Scene>): Mesh;
  115620. }
  115621. }
  115622. declare module BABYLON {
  115623. /**
  115624. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  115625. *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.
  115626. * The SPS is also a particle system. It provides some methods to manage the particles.
  115627. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  115628. *
  115629. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  115630. */
  115631. export class SolidParticleSystem implements IDisposable {
  115632. /**
  115633. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  115634. * Example : var p = SPS.particles[i];
  115635. */
  115636. particles: SolidParticle[];
  115637. /**
  115638. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  115639. */
  115640. nbParticles: number;
  115641. /**
  115642. * If the particles must ever face the camera (default false). Useful for planar particles.
  115643. */
  115644. billboard: boolean;
  115645. /**
  115646. * Recompute normals when adding a shape
  115647. */
  115648. recomputeNormals: boolean;
  115649. /**
  115650. * This a counter ofr your own usage. It's not set by any SPS functions.
  115651. */
  115652. counter: number;
  115653. /**
  115654. * The SPS name. This name is also given to the underlying mesh.
  115655. */
  115656. name: string;
  115657. /**
  115658. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  115659. */
  115660. mesh: Mesh;
  115661. /**
  115662. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  115663. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  115664. */
  115665. vars: any;
  115666. /**
  115667. * This array is populated when the SPS is set as 'pickable'.
  115668. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  115669. * Each element of this array is an object `{idx: int, faceId: int}`.
  115670. * `idx` is the picked particle index in the `SPS.particles` array
  115671. * `faceId` is the picked face index counted within this particle.
  115672. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  115673. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  115674. * Use the method SPS.pickedParticle(pickingInfo) instead.
  115675. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115676. */
  115677. pickedParticles: {
  115678. idx: number;
  115679. faceId: number;
  115680. }[];
  115681. /**
  115682. * This array is populated when the SPS is set as 'pickable'
  115683. * Each key of this array is a submesh index.
  115684. * Each element of this array is a second array defined like this :
  115685. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  115686. * Each element of this second array is an object `{idx: int, faceId: int}`.
  115687. * `idx` is the picked particle index in the `SPS.particles` array
  115688. * `faceId` is the picked face index counted within this particle.
  115689. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  115690. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  115691. */
  115692. pickedBySubMesh: {
  115693. idx: number;
  115694. faceId: number;
  115695. }[][];
  115696. /**
  115697. * This array is populated when `enableDepthSort` is set to true.
  115698. * Each element of this array is an instance of the class DepthSortedParticle.
  115699. */
  115700. depthSortedParticles: DepthSortedParticle[];
  115701. /**
  115702. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  115703. * @hidden
  115704. */
  115705. _bSphereOnly: boolean;
  115706. /**
  115707. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  115708. * @hidden
  115709. */
  115710. _bSphereRadiusFactor: number;
  115711. private _scene;
  115712. private _positions;
  115713. private _indices;
  115714. private _normals;
  115715. private _colors;
  115716. private _uvs;
  115717. private _indices32;
  115718. private _positions32;
  115719. private _normals32;
  115720. private _fixedNormal32;
  115721. private _colors32;
  115722. private _uvs32;
  115723. private _index;
  115724. private _updatable;
  115725. private _pickable;
  115726. private _isVisibilityBoxLocked;
  115727. private _alwaysVisible;
  115728. private _depthSort;
  115729. private _expandable;
  115730. private _shapeCounter;
  115731. private _copy;
  115732. private _color;
  115733. private _computeParticleColor;
  115734. private _computeParticleTexture;
  115735. private _computeParticleRotation;
  115736. private _computeParticleVertex;
  115737. private _computeBoundingBox;
  115738. private _depthSortParticles;
  115739. private _camera;
  115740. private _mustUnrotateFixedNormals;
  115741. private _particlesIntersect;
  115742. private _needs32Bits;
  115743. private _isNotBuilt;
  115744. private _lastParticleId;
  115745. private _idxOfId;
  115746. private _multimaterialEnabled;
  115747. private _useModelMaterial;
  115748. private _indicesByMaterial;
  115749. private _materialIndexes;
  115750. private _depthSortFunction;
  115751. private _materialSortFunction;
  115752. private _materials;
  115753. private _multimaterial;
  115754. private _materialIndexesById;
  115755. private _defaultMaterial;
  115756. private _autoUpdateSubMeshes;
  115757. private _tmpVertex;
  115758. /**
  115759. * Creates a SPS (Solid Particle System) object.
  115760. * @param name (String) is the SPS name, this will be the underlying mesh name.
  115761. * @param scene (Scene) is the scene in which the SPS is added.
  115762. * @param options defines the options of the sps e.g.
  115763. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  115764. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  115765. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  115766. * * 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.
  115767. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  115768. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  115769. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  115770. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  115771. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  115772. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  115773. */
  115774. constructor(name: string, scene: Scene, options?: {
  115775. updatable?: boolean;
  115776. isPickable?: boolean;
  115777. enableDepthSort?: boolean;
  115778. particleIntersection?: boolean;
  115779. boundingSphereOnly?: boolean;
  115780. bSphereRadiusFactor?: number;
  115781. expandable?: boolean;
  115782. useModelMaterial?: boolean;
  115783. enableMultiMaterial?: boolean;
  115784. });
  115785. /**
  115786. * Builds the SPS underlying mesh. Returns a standard Mesh.
  115787. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  115788. * @returns the created mesh
  115789. */
  115790. buildMesh(): Mesh;
  115791. /**
  115792. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  115793. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  115794. * Thus the particles generated from `digest()` have their property `position` set yet.
  115795. * @param mesh ( Mesh ) is the mesh to be digested
  115796. * @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
  115797. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  115798. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  115799. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115800. * @returns the current SPS
  115801. */
  115802. digest(mesh: Mesh, options?: {
  115803. facetNb?: number;
  115804. number?: number;
  115805. delta?: number;
  115806. storage?: [];
  115807. }): SolidParticleSystem;
  115808. /**
  115809. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  115810. * @hidden
  115811. */
  115812. private _unrotateFixedNormals;
  115813. /**
  115814. * Resets the temporary working copy particle
  115815. * @hidden
  115816. */
  115817. private _resetCopy;
  115818. /**
  115819. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  115820. * @param p the current index in the positions array to be updated
  115821. * @param ind the current index in the indices array
  115822. * @param shape a Vector3 array, the shape geometry
  115823. * @param positions the positions array to be updated
  115824. * @param meshInd the shape indices array
  115825. * @param indices the indices array to be updated
  115826. * @param meshUV the shape uv array
  115827. * @param uvs the uv array to be updated
  115828. * @param meshCol the shape color array
  115829. * @param colors the color array to be updated
  115830. * @param meshNor the shape normals array
  115831. * @param normals the normals array to be updated
  115832. * @param idx the particle index
  115833. * @param idxInShape the particle index in its shape
  115834. * @param options the addShape() method passed options
  115835. * @model the particle model
  115836. * @hidden
  115837. */
  115838. private _meshBuilder;
  115839. /**
  115840. * Returns a shape Vector3 array from positions float array
  115841. * @param positions float array
  115842. * @returns a vector3 array
  115843. * @hidden
  115844. */
  115845. private _posToShape;
  115846. /**
  115847. * Returns a shapeUV array from a float uvs (array deep copy)
  115848. * @param uvs as a float array
  115849. * @returns a shapeUV array
  115850. * @hidden
  115851. */
  115852. private _uvsToShapeUV;
  115853. /**
  115854. * Adds a new particle object in the particles array
  115855. * @param idx particle index in particles array
  115856. * @param id particle id
  115857. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  115858. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  115859. * @param model particle ModelShape object
  115860. * @param shapeId model shape identifier
  115861. * @param idxInShape index of the particle in the current model
  115862. * @param bInfo model bounding info object
  115863. * @param storage target storage array, if any
  115864. * @hidden
  115865. */
  115866. private _addParticle;
  115867. /**
  115868. * Adds some particles to the SPS from the model shape. Returns the shape id.
  115869. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  115870. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  115871. * @param nb (positive integer) the number of particles to be created from this model
  115872. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  115873. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  115874. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  115875. * @returns the number of shapes in the system
  115876. */
  115877. addShape(mesh: Mesh, nb: number, options?: {
  115878. positionFunction?: any;
  115879. vertexFunction?: any;
  115880. storage?: [];
  115881. }): number;
  115882. /**
  115883. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  115884. * @hidden
  115885. */
  115886. private _rebuildParticle;
  115887. /**
  115888. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  115889. * @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.
  115890. * @returns the SPS.
  115891. */
  115892. rebuildMesh(reset?: boolean): SolidParticleSystem;
  115893. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  115894. * Returns an array with the removed particles.
  115895. * 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.
  115896. * The SPS can't be empty so at least one particle needs to remain in place.
  115897. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  115898. * @param start index of the first particle to remove
  115899. * @param end index of the last particle to remove (included)
  115900. * @returns an array populated with the removed particles
  115901. */
  115902. removeParticles(start: number, end: number): SolidParticle[];
  115903. /**
  115904. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  115905. * @param solidParticleArray an array populated with Solid Particles objects
  115906. * @returns the SPS
  115907. */
  115908. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  115909. /**
  115910. * Creates a new particle and modifies the SPS mesh geometry :
  115911. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  115912. * - calls _addParticle() to populate the particle array
  115913. * factorized code from addShape() and insertParticlesFromArray()
  115914. * @param idx particle index in the particles array
  115915. * @param i particle index in its shape
  115916. * @param modelShape particle ModelShape object
  115917. * @param shape shape vertex array
  115918. * @param meshInd shape indices array
  115919. * @param meshUV shape uv array
  115920. * @param meshCol shape color array
  115921. * @param meshNor shape normals array
  115922. * @param bbInfo shape bounding info
  115923. * @param storage target particle storage
  115924. * @options addShape() passed options
  115925. * @hidden
  115926. */
  115927. private _insertNewParticle;
  115928. /**
  115929. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  115930. * This method calls `updateParticle()` for each particle of the SPS.
  115931. * For an animated SPS, it is usually called within the render loop.
  115932. * 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.
  115933. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  115934. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  115935. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  115936. * @returns the SPS.
  115937. */
  115938. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  115939. /**
  115940. * Disposes the SPS.
  115941. */
  115942. dispose(): void;
  115943. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  115944. * idx is the particle index in the SPS
  115945. * faceId is the picked face index counted within this particle.
  115946. * Returns null if the pickInfo can't identify a picked particle.
  115947. * @param pickingInfo (PickingInfo object)
  115948. * @returns {idx: number, faceId: number} or null
  115949. */
  115950. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  115951. idx: number;
  115952. faceId: number;
  115953. }>;
  115954. /**
  115955. * Returns a SolidParticle object from its identifier : particle.id
  115956. * @param id (integer) the particle Id
  115957. * @returns the searched particle or null if not found in the SPS.
  115958. */
  115959. getParticleById(id: number): Nullable<SolidParticle>;
  115960. /**
  115961. * Returns a new array populated with the particles having the passed shapeId.
  115962. * @param shapeId (integer) the shape identifier
  115963. * @returns a new solid particle array
  115964. */
  115965. getParticlesByShapeId(shapeId: number): SolidParticle[];
  115966. /**
  115967. * Populates the passed array "ref" with the particles having the passed shapeId.
  115968. * @param shapeId the shape identifier
  115969. * @returns the SPS
  115970. * @param ref
  115971. */
  115972. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  115973. /**
  115974. * Computes the required SubMeshes according the materials assigned to the particles.
  115975. * @returns the solid particle system.
  115976. * Does nothing if called before the SPS mesh is built.
  115977. */
  115978. computeSubMeshes(): SolidParticleSystem;
  115979. /**
  115980. * Sorts the solid particles by material when MultiMaterial is enabled.
  115981. * Updates the indices32 array.
  115982. * Updates the indicesByMaterial array.
  115983. * Updates the mesh indices array.
  115984. * @returns the SPS
  115985. * @hidden
  115986. */
  115987. private _sortParticlesByMaterial;
  115988. /**
  115989. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  115990. * @hidden
  115991. */
  115992. private _setMaterialIndexesById;
  115993. /**
  115994. * Returns an array with unique values of Materials from the passed array
  115995. * @param array the material array to be checked and filtered
  115996. * @hidden
  115997. */
  115998. private _filterUniqueMaterialId;
  115999. /**
  116000. * Sets a new Standard Material as _defaultMaterial if not already set.
  116001. * @hidden
  116002. */
  116003. private _setDefaultMaterial;
  116004. /**
  116005. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  116006. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116007. * @returns the SPS.
  116008. */
  116009. refreshVisibleSize(): SolidParticleSystem;
  116010. /**
  116011. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  116012. * @param size the size (float) of the visibility box
  116013. * note : this doesn't lock the SPS mesh bounding box.
  116014. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116015. */
  116016. setVisibilityBox(size: number): void;
  116017. /**
  116018. * Gets whether the SPS as always visible or not
  116019. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116020. */
  116021. get isAlwaysVisible(): boolean;
  116022. /**
  116023. * Sets the SPS as always visible or not
  116024. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116025. */
  116026. set isAlwaysVisible(val: boolean);
  116027. /**
  116028. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116029. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116030. */
  116031. set isVisibilityBoxLocked(val: boolean);
  116032. /**
  116033. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  116034. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  116035. */
  116036. get isVisibilityBoxLocked(): boolean;
  116037. /**
  116038. * Tells to `setParticles()` to compute the particle rotations or not.
  116039. * Default value : true. The SPS is faster when it's set to false.
  116040. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116041. */
  116042. set computeParticleRotation(val: boolean);
  116043. /**
  116044. * Tells to `setParticles()` to compute the particle colors or not.
  116045. * Default value : true. The SPS is faster when it's set to false.
  116046. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116047. */
  116048. set computeParticleColor(val: boolean);
  116049. set computeParticleTexture(val: boolean);
  116050. /**
  116051. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  116052. * Default value : false. The SPS is faster when it's set to false.
  116053. * Note : the particle custom vertex positions aren't stored values.
  116054. */
  116055. set computeParticleVertex(val: boolean);
  116056. /**
  116057. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  116058. */
  116059. set computeBoundingBox(val: boolean);
  116060. /**
  116061. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  116062. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116063. * Default : `true`
  116064. */
  116065. set depthSortParticles(val: boolean);
  116066. /**
  116067. * Gets if `setParticles()` computes the particle rotations or not.
  116068. * Default value : true. The SPS is faster when it's set to false.
  116069. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  116070. */
  116071. get computeParticleRotation(): boolean;
  116072. /**
  116073. * Gets if `setParticles()` computes the particle colors or not.
  116074. * Default value : true. The SPS is faster when it's set to false.
  116075. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  116076. */
  116077. get computeParticleColor(): boolean;
  116078. /**
  116079. * Gets if `setParticles()` computes the particle textures or not.
  116080. * Default value : true. The SPS is faster when it's set to false.
  116081. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  116082. */
  116083. get computeParticleTexture(): boolean;
  116084. /**
  116085. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  116086. * Default value : false. The SPS is faster when it's set to false.
  116087. * Note : the particle custom vertex positions aren't stored values.
  116088. */
  116089. get computeParticleVertex(): boolean;
  116090. /**
  116091. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  116092. */
  116093. get computeBoundingBox(): boolean;
  116094. /**
  116095. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  116096. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  116097. * Default : `true`
  116098. */
  116099. get depthSortParticles(): boolean;
  116100. /**
  116101. * Gets if the SPS is created as expandable at construction time.
  116102. * Default : `false`
  116103. */
  116104. get expandable(): boolean;
  116105. /**
  116106. * Gets if the SPS supports the Multi Materials
  116107. */
  116108. get multimaterialEnabled(): boolean;
  116109. /**
  116110. * Gets if the SPS uses the model materials for its own multimaterial.
  116111. */
  116112. get useModelMaterial(): boolean;
  116113. /**
  116114. * The SPS used material array.
  116115. */
  116116. get materials(): Material[];
  116117. /**
  116118. * Sets the SPS MultiMaterial from the passed materials.
  116119. * Note : the passed array is internally copied and not used then by reference.
  116120. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  116121. */
  116122. setMultiMaterial(materials: Material[]): void;
  116123. /**
  116124. * The SPS computed multimaterial object
  116125. */
  116126. get multimaterial(): MultiMaterial;
  116127. set multimaterial(mm: MultiMaterial);
  116128. /**
  116129. * If the subMeshes must be updated on the next call to setParticles()
  116130. */
  116131. get autoUpdateSubMeshes(): boolean;
  116132. set autoUpdateSubMeshes(val: boolean);
  116133. /**
  116134. * This function does nothing. It may be overwritten to set all the particle first values.
  116135. * The SPS doesn't call this function, you may have to call it by your own.
  116136. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116137. */
  116138. initParticles(): void;
  116139. /**
  116140. * This function does nothing. It may be overwritten to recycle a particle.
  116141. * The SPS doesn't call this function, you may have to call it by your own.
  116142. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116143. * @param particle The particle to recycle
  116144. * @returns the recycled particle
  116145. */
  116146. recycleParticle(particle: SolidParticle): SolidParticle;
  116147. /**
  116148. * Updates a particle : this function should be overwritten by the user.
  116149. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  116150. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  116151. * @example : just set a particle position or velocity and recycle conditions
  116152. * @param particle The particle to update
  116153. * @returns the updated particle
  116154. */
  116155. updateParticle(particle: SolidParticle): SolidParticle;
  116156. /**
  116157. * Updates a vertex of a particle : it can be overwritten by the user.
  116158. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  116159. * @param particle the current particle
  116160. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  116161. * @param pt the index of the current vertex in the particle shape
  116162. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  116163. * @example : just set a vertex particle position or color
  116164. * @returns the sps
  116165. */
  116166. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  116167. /**
  116168. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  116169. * This does nothing and may be overwritten by the user.
  116170. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116171. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116172. * @param update the boolean update value actually passed to setParticles()
  116173. */
  116174. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116175. /**
  116176. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  116177. * This will be passed three parameters.
  116178. * This does nothing and may be overwritten by the user.
  116179. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116180. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  116181. * @param update the boolean update value actually passed to setParticles()
  116182. */
  116183. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  116184. }
  116185. }
  116186. declare module BABYLON {
  116187. /**
  116188. * Represents one particle of a solid particle system.
  116189. */
  116190. export class SolidParticle {
  116191. /**
  116192. * particle global index
  116193. */
  116194. idx: number;
  116195. /**
  116196. * particle identifier
  116197. */
  116198. id: number;
  116199. /**
  116200. * The color of the particle
  116201. */
  116202. color: Nullable<Color4>;
  116203. /**
  116204. * The world space position of the particle.
  116205. */
  116206. position: Vector3;
  116207. /**
  116208. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  116209. */
  116210. rotation: Vector3;
  116211. /**
  116212. * The world space rotation quaternion of the particle.
  116213. */
  116214. rotationQuaternion: Nullable<Quaternion>;
  116215. /**
  116216. * The scaling of the particle.
  116217. */
  116218. scaling: Vector3;
  116219. /**
  116220. * The uvs of the particle.
  116221. */
  116222. uvs: Vector4;
  116223. /**
  116224. * The current speed of the particle.
  116225. */
  116226. velocity: Vector3;
  116227. /**
  116228. * The pivot point in the particle local space.
  116229. */
  116230. pivot: Vector3;
  116231. /**
  116232. * Must the particle be translated from its pivot point in its local space ?
  116233. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  116234. * Default : false
  116235. */
  116236. translateFromPivot: boolean;
  116237. /**
  116238. * Is the particle active or not ?
  116239. */
  116240. alive: boolean;
  116241. /**
  116242. * Is the particle visible or not ?
  116243. */
  116244. isVisible: boolean;
  116245. /**
  116246. * Index of this particle in the global "positions" array (Internal use)
  116247. * @hidden
  116248. */
  116249. _pos: number;
  116250. /**
  116251. * @hidden Index of this particle in the global "indices" array (Internal use)
  116252. */
  116253. _ind: number;
  116254. /**
  116255. * @hidden ModelShape of this particle (Internal use)
  116256. */
  116257. _model: ModelShape;
  116258. /**
  116259. * ModelShape id of this particle
  116260. */
  116261. shapeId: number;
  116262. /**
  116263. * Index of the particle in its shape id
  116264. */
  116265. idxInShape: number;
  116266. /**
  116267. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  116268. */
  116269. _modelBoundingInfo: BoundingInfo;
  116270. /**
  116271. * @hidden Particle BoundingInfo object (Internal use)
  116272. */
  116273. _boundingInfo: BoundingInfo;
  116274. /**
  116275. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  116276. */
  116277. _sps: SolidParticleSystem;
  116278. /**
  116279. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  116280. */
  116281. _stillInvisible: boolean;
  116282. /**
  116283. * @hidden Last computed particle rotation matrix
  116284. */
  116285. _rotationMatrix: number[];
  116286. /**
  116287. * Parent particle Id, if any.
  116288. * Default null.
  116289. */
  116290. parentId: Nullable<number>;
  116291. /**
  116292. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  116293. */
  116294. materialIndex: Nullable<number>;
  116295. /**
  116296. * Custom object or properties.
  116297. */
  116298. props: Nullable<any>;
  116299. /**
  116300. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  116301. * The possible values are :
  116302. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116303. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116304. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116305. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116306. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116307. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  116308. * */
  116309. cullingStrategy: number;
  116310. /**
  116311. * @hidden Internal global position in the SPS.
  116312. */
  116313. _globalPosition: Vector3;
  116314. /**
  116315. * Creates a Solid Particle object.
  116316. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  116317. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  116318. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  116319. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  116320. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  116321. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  116322. * @param shapeId (integer) is the model shape identifier in the SPS.
  116323. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  116324. * @param sps defines the sps it is associated to
  116325. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  116326. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  116327. */
  116328. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  116329. /**
  116330. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  116331. * @param target the particle target
  116332. * @returns the current particle
  116333. */
  116334. copyToRef(target: SolidParticle): SolidParticle;
  116335. /**
  116336. * Legacy support, changed scale to scaling
  116337. */
  116338. get scale(): Vector3;
  116339. /**
  116340. * Legacy support, changed scale to scaling
  116341. */
  116342. set scale(scale: Vector3);
  116343. /**
  116344. * Legacy support, changed quaternion to rotationQuaternion
  116345. */
  116346. get quaternion(): Nullable<Quaternion>;
  116347. /**
  116348. * Legacy support, changed quaternion to rotationQuaternion
  116349. */
  116350. set quaternion(q: Nullable<Quaternion>);
  116351. /**
  116352. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  116353. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  116354. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  116355. * @returns true if it intersects
  116356. */
  116357. intersectsMesh(target: Mesh | SolidParticle): boolean;
  116358. /**
  116359. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  116360. * A particle is in the frustum if its bounding box intersects the frustum
  116361. * @param frustumPlanes defines the frustum to test
  116362. * @returns true if the particle is in the frustum planes
  116363. */
  116364. isInFrustum(frustumPlanes: Plane[]): boolean;
  116365. /**
  116366. * get the rotation matrix of the particle
  116367. * @hidden
  116368. */
  116369. getRotationMatrix(m: Matrix): void;
  116370. }
  116371. /**
  116372. * Represents the shape of the model used by one particle of a solid particle system.
  116373. * SPS internal tool, don't use it manually.
  116374. */
  116375. export class ModelShape {
  116376. /**
  116377. * The shape id
  116378. * @hidden
  116379. */
  116380. shapeID: number;
  116381. /**
  116382. * flat array of model positions (internal use)
  116383. * @hidden
  116384. */
  116385. _shape: Vector3[];
  116386. /**
  116387. * flat array of model UVs (internal use)
  116388. * @hidden
  116389. */
  116390. _shapeUV: number[];
  116391. /**
  116392. * color array of the model
  116393. * @hidden
  116394. */
  116395. _shapeColors: number[];
  116396. /**
  116397. * indices array of the model
  116398. * @hidden
  116399. */
  116400. _indices: number[];
  116401. /**
  116402. * normals array of the model
  116403. * @hidden
  116404. */
  116405. _normals: number[];
  116406. /**
  116407. * length of the shape in the model indices array (internal use)
  116408. * @hidden
  116409. */
  116410. _indicesLength: number;
  116411. /**
  116412. * Custom position function (internal use)
  116413. * @hidden
  116414. */
  116415. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  116416. /**
  116417. * Custom vertex function (internal use)
  116418. * @hidden
  116419. */
  116420. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  116421. /**
  116422. * Model material (internal use)
  116423. * @hidden
  116424. */
  116425. _material: Nullable<Material>;
  116426. /**
  116427. * 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.
  116428. * SPS internal tool, don't use it manually.
  116429. * @hidden
  116430. */
  116431. 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>);
  116432. }
  116433. /**
  116434. * Represents a Depth Sorted Particle in the solid particle system.
  116435. * @hidden
  116436. */
  116437. export class DepthSortedParticle {
  116438. /**
  116439. * Particle index
  116440. */
  116441. idx: number;
  116442. /**
  116443. * Index of the particle in the "indices" array
  116444. */
  116445. ind: number;
  116446. /**
  116447. * Length of the particle shape in the "indices" array
  116448. */
  116449. indicesLength: number;
  116450. /**
  116451. * Squared distance from the particle to the camera
  116452. */
  116453. sqDistance: number;
  116454. /**
  116455. * Material index when used with MultiMaterials
  116456. */
  116457. materialIndex: number;
  116458. /**
  116459. * Creates a new sorted particle
  116460. * @param materialIndex
  116461. */
  116462. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  116463. }
  116464. /**
  116465. * Represents a solid particle vertex
  116466. */
  116467. export class SolidParticleVertex {
  116468. /**
  116469. * Vertex position
  116470. */
  116471. position: Vector3;
  116472. /**
  116473. * Vertex color
  116474. */
  116475. color: Color4;
  116476. /**
  116477. * Vertex UV
  116478. */
  116479. uv: Vector2;
  116480. /**
  116481. * Creates a new solid particle vertex
  116482. */
  116483. constructor();
  116484. /** Vertex x coordinate */
  116485. get x(): number;
  116486. set x(val: number);
  116487. /** Vertex y coordinate */
  116488. get y(): number;
  116489. set y(val: number);
  116490. /** Vertex z coordinate */
  116491. get z(): number;
  116492. set z(val: number);
  116493. }
  116494. }
  116495. declare module BABYLON {
  116496. /**
  116497. * @hidden
  116498. */
  116499. export class _MeshCollisionData {
  116500. _checkCollisions: boolean;
  116501. _collisionMask: number;
  116502. _collisionGroup: number;
  116503. _surroundingMeshes: Nullable<AbstractMesh[]>;
  116504. _collider: Nullable<Collider>;
  116505. _oldPositionForCollisions: Vector3;
  116506. _diffPositionForCollisions: Vector3;
  116507. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  116508. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  116509. _collisionResponse: boolean;
  116510. }
  116511. }
  116512. declare module BABYLON {
  116513. /** @hidden */
  116514. class _FacetDataStorage {
  116515. facetPositions: Vector3[];
  116516. facetNormals: Vector3[];
  116517. facetPartitioning: number[][];
  116518. facetNb: number;
  116519. partitioningSubdivisions: number;
  116520. partitioningBBoxRatio: number;
  116521. facetDataEnabled: boolean;
  116522. facetParameters: any;
  116523. bbSize: Vector3;
  116524. subDiv: {
  116525. max: number;
  116526. X: number;
  116527. Y: number;
  116528. Z: number;
  116529. };
  116530. facetDepthSort: boolean;
  116531. facetDepthSortEnabled: boolean;
  116532. depthSortedIndices: IndicesArray;
  116533. depthSortedFacets: {
  116534. ind: number;
  116535. sqDistance: number;
  116536. }[];
  116537. facetDepthSortFunction: (f1: {
  116538. ind: number;
  116539. sqDistance: number;
  116540. }, f2: {
  116541. ind: number;
  116542. sqDistance: number;
  116543. }) => number;
  116544. facetDepthSortFrom: Vector3;
  116545. facetDepthSortOrigin: Vector3;
  116546. invertedMatrix: Matrix;
  116547. }
  116548. /**
  116549. * @hidden
  116550. **/
  116551. class _InternalAbstractMeshDataInfo {
  116552. _hasVertexAlpha: boolean;
  116553. _useVertexColors: boolean;
  116554. _numBoneInfluencers: number;
  116555. _applyFog: boolean;
  116556. _receiveShadows: boolean;
  116557. _facetData: _FacetDataStorage;
  116558. _visibility: number;
  116559. _skeleton: Nullable<Skeleton>;
  116560. _layerMask: number;
  116561. _computeBonesUsingShaders: boolean;
  116562. _isActive: boolean;
  116563. _onlyForInstances: boolean;
  116564. _isActiveIntermediate: boolean;
  116565. _onlyForInstancesIntermediate: boolean;
  116566. _actAsRegularMesh: boolean;
  116567. _currentLOD: Nullable<AbstractMesh>;
  116568. }
  116569. /**
  116570. * Class used to store all common mesh properties
  116571. */
  116572. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  116573. /** No occlusion */
  116574. static OCCLUSION_TYPE_NONE: number;
  116575. /** Occlusion set to optimisitic */
  116576. static OCCLUSION_TYPE_OPTIMISTIC: number;
  116577. /** Occlusion set to strict */
  116578. static OCCLUSION_TYPE_STRICT: number;
  116579. /** Use an accurante occlusion algorithm */
  116580. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  116581. /** Use a conservative occlusion algorithm */
  116582. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  116583. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  116584. * Test order :
  116585. * Is the bounding sphere outside the frustum ?
  116586. * If not, are the bounding box vertices outside the frustum ?
  116587. * It not, then the cullable object is in the frustum.
  116588. */
  116589. static readonly CULLINGSTRATEGY_STANDARD: number;
  116590. /** Culling strategy : Bounding Sphere Only.
  116591. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  116592. * It's also less accurate than the standard because some not visible objects can still be selected.
  116593. * Test : is the bounding sphere outside the frustum ?
  116594. * If not, then the cullable object is in the frustum.
  116595. */
  116596. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  116597. /** Culling strategy : Optimistic Inclusion.
  116598. * This in an inclusion test first, then the standard exclusion test.
  116599. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  116600. * 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.
  116601. * Anyway, it's as accurate as the standard strategy.
  116602. * Test :
  116603. * Is the cullable object bounding sphere center in the frustum ?
  116604. * If not, apply the default culling strategy.
  116605. */
  116606. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  116607. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  116608. * This in an inclusion test first, then the bounding sphere only exclusion test.
  116609. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  116610. * 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.
  116611. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  116612. * Test :
  116613. * Is the cullable object bounding sphere center in the frustum ?
  116614. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  116615. */
  116616. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  116617. /**
  116618. * No billboard
  116619. */
  116620. static get BILLBOARDMODE_NONE(): number;
  116621. /** Billboard on X axis */
  116622. static get BILLBOARDMODE_X(): number;
  116623. /** Billboard on Y axis */
  116624. static get BILLBOARDMODE_Y(): number;
  116625. /** Billboard on Z axis */
  116626. static get BILLBOARDMODE_Z(): number;
  116627. /** Billboard on all axes */
  116628. static get BILLBOARDMODE_ALL(): number;
  116629. /** Billboard on using position instead of orientation */
  116630. static get BILLBOARDMODE_USE_POSITION(): number;
  116631. /** @hidden */
  116632. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  116633. /**
  116634. * The culling strategy to use to check whether the mesh must be rendered or not.
  116635. * This value can be changed at any time and will be used on the next render mesh selection.
  116636. * The possible values are :
  116637. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  116638. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  116639. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  116640. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  116641. * Please read each static variable documentation to get details about the culling process.
  116642. * */
  116643. cullingStrategy: number;
  116644. /**
  116645. * Gets the number of facets in the mesh
  116646. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116647. */
  116648. get facetNb(): number;
  116649. /**
  116650. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  116651. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116652. */
  116653. get partitioningSubdivisions(): number;
  116654. set partitioningSubdivisions(nb: number);
  116655. /**
  116656. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  116657. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  116658. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  116659. */
  116660. get partitioningBBoxRatio(): number;
  116661. set partitioningBBoxRatio(ratio: number);
  116662. /**
  116663. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  116664. * Works only for updatable meshes.
  116665. * Doesn't work with multi-materials
  116666. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116667. */
  116668. get mustDepthSortFacets(): boolean;
  116669. set mustDepthSortFacets(sort: boolean);
  116670. /**
  116671. * The location (Vector3) where the facet depth sort must be computed from.
  116672. * By default, the active camera position.
  116673. * Used only when facet depth sort is enabled
  116674. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  116675. */
  116676. get facetDepthSortFrom(): Vector3;
  116677. set facetDepthSortFrom(location: Vector3);
  116678. /**
  116679. * gets a boolean indicating if facetData is enabled
  116680. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  116681. */
  116682. get isFacetDataEnabled(): boolean;
  116683. /** @hidden */
  116684. _updateNonUniformScalingState(value: boolean): boolean;
  116685. /**
  116686. * An event triggered when this mesh collides with another one
  116687. */
  116688. onCollideObservable: Observable<AbstractMesh>;
  116689. /** Set a function to call when this mesh collides with another one */
  116690. set onCollide(callback: () => void);
  116691. /**
  116692. * An event triggered when the collision's position changes
  116693. */
  116694. onCollisionPositionChangeObservable: Observable<Vector3>;
  116695. /** Set a function to call when the collision's position changes */
  116696. set onCollisionPositionChange(callback: () => void);
  116697. /**
  116698. * An event triggered when material is changed
  116699. */
  116700. onMaterialChangedObservable: Observable<AbstractMesh>;
  116701. /**
  116702. * Gets or sets the orientation for POV movement & rotation
  116703. */
  116704. definedFacingForward: boolean;
  116705. /** @hidden */
  116706. _occlusionQuery: Nullable<WebGLQuery>;
  116707. /** @hidden */
  116708. _renderingGroup: Nullable<RenderingGroup>;
  116709. /**
  116710. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116711. */
  116712. get visibility(): number;
  116713. /**
  116714. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  116715. */
  116716. set visibility(value: number);
  116717. /** Gets or sets the alpha index used to sort transparent meshes
  116718. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  116719. */
  116720. alphaIndex: number;
  116721. /**
  116722. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  116723. */
  116724. isVisible: boolean;
  116725. /**
  116726. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  116727. */
  116728. isPickable: boolean;
  116729. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  116730. showSubMeshesBoundingBox: boolean;
  116731. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  116732. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  116733. */
  116734. isBlocker: boolean;
  116735. /**
  116736. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  116737. */
  116738. enablePointerMoveEvents: boolean;
  116739. private _renderingGroupId;
  116740. /**
  116741. * Specifies the rendering group id for this mesh (0 by default)
  116742. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  116743. */
  116744. get renderingGroupId(): number;
  116745. set renderingGroupId(value: number);
  116746. private _material;
  116747. /** Gets or sets current material */
  116748. get material(): Nullable<Material>;
  116749. set material(value: Nullable<Material>);
  116750. /**
  116751. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  116752. * @see https://doc.babylonjs.com/babylon101/shadows
  116753. */
  116754. get receiveShadows(): boolean;
  116755. set receiveShadows(value: boolean);
  116756. /** Defines color to use when rendering outline */
  116757. outlineColor: Color3;
  116758. /** Define width to use when rendering outline */
  116759. outlineWidth: number;
  116760. /** Defines color to use when rendering overlay */
  116761. overlayColor: Color3;
  116762. /** Defines alpha to use when rendering overlay */
  116763. overlayAlpha: number;
  116764. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  116765. get hasVertexAlpha(): boolean;
  116766. set hasVertexAlpha(value: boolean);
  116767. /** 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) */
  116768. get useVertexColors(): boolean;
  116769. set useVertexColors(value: boolean);
  116770. /**
  116771. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  116772. */
  116773. get computeBonesUsingShaders(): boolean;
  116774. set computeBonesUsingShaders(value: boolean);
  116775. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  116776. get numBoneInfluencers(): number;
  116777. set numBoneInfluencers(value: number);
  116778. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  116779. get applyFog(): boolean;
  116780. set applyFog(value: boolean);
  116781. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  116782. useOctreeForRenderingSelection: boolean;
  116783. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  116784. useOctreeForPicking: boolean;
  116785. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  116786. useOctreeForCollisions: boolean;
  116787. /**
  116788. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  116789. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  116790. */
  116791. get layerMask(): number;
  116792. set layerMask(value: number);
  116793. /**
  116794. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  116795. */
  116796. alwaysSelectAsActiveMesh: boolean;
  116797. /**
  116798. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  116799. */
  116800. doNotSyncBoundingInfo: boolean;
  116801. /**
  116802. * Gets or sets the current action manager
  116803. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  116804. */
  116805. actionManager: Nullable<AbstractActionManager>;
  116806. private _meshCollisionData;
  116807. /**
  116808. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  116809. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116810. */
  116811. ellipsoid: Vector3;
  116812. /**
  116813. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  116814. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  116815. */
  116816. ellipsoidOffset: Vector3;
  116817. /**
  116818. * Gets or sets a collision mask used to mask collisions (default is -1).
  116819. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116820. */
  116821. get collisionMask(): number;
  116822. set collisionMask(mask: number);
  116823. /**
  116824. * Gets or sets a collision response flag (default is true).
  116825. * when collisionResponse is false, events are still triggered but colliding entity has no response
  116826. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  116827. * to respond to the collision.
  116828. */
  116829. get collisionResponse(): boolean;
  116830. set collisionResponse(response: boolean);
  116831. /**
  116832. * Gets or sets the current collision group mask (-1 by default).
  116833. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  116834. */
  116835. get collisionGroup(): number;
  116836. set collisionGroup(mask: number);
  116837. /**
  116838. * Gets or sets current surrounding meshes (null by default).
  116839. *
  116840. * By default collision detection is tested against every mesh in the scene.
  116841. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  116842. * meshes will be tested for the collision.
  116843. *
  116844. * Note: if set to an empty array no collision will happen when this mesh is moved.
  116845. */
  116846. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  116847. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  116848. /**
  116849. * Defines edge width used when edgesRenderer is enabled
  116850. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116851. */
  116852. edgesWidth: number;
  116853. /**
  116854. * Defines edge color used when edgesRenderer is enabled
  116855. * @see https://www.babylonjs-playground.com/#10OJSG#13
  116856. */
  116857. edgesColor: Color4;
  116858. /** @hidden */
  116859. _edgesRenderer: Nullable<IEdgesRenderer>;
  116860. /** @hidden */
  116861. _masterMesh: Nullable<AbstractMesh>;
  116862. /** @hidden */
  116863. _boundingInfo: Nullable<BoundingInfo>;
  116864. /** @hidden */
  116865. _renderId: number;
  116866. /**
  116867. * Gets or sets the list of subMeshes
  116868. * @see https://doc.babylonjs.com/how_to/multi_materials
  116869. */
  116870. subMeshes: SubMesh[];
  116871. /** @hidden */
  116872. _intersectionsInProgress: AbstractMesh[];
  116873. /** @hidden */
  116874. _unIndexed: boolean;
  116875. /** @hidden */
  116876. _lightSources: Light[];
  116877. /** Gets the list of lights affecting that mesh */
  116878. get lightSources(): Light[];
  116879. /** @hidden */
  116880. get _positions(): Nullable<Vector3[]>;
  116881. /** @hidden */
  116882. _waitingData: {
  116883. lods: Nullable<any>;
  116884. actions: Nullable<any>;
  116885. freezeWorldMatrix: Nullable<boolean>;
  116886. };
  116887. /** @hidden */
  116888. _bonesTransformMatrices: Nullable<Float32Array>;
  116889. /** @hidden */
  116890. _transformMatrixTexture: Nullable<RawTexture>;
  116891. /**
  116892. * Gets or sets a skeleton to apply skining transformations
  116893. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  116894. */
  116895. set skeleton(value: Nullable<Skeleton>);
  116896. get skeleton(): Nullable<Skeleton>;
  116897. /**
  116898. * An event triggered when the mesh is rebuilt.
  116899. */
  116900. onRebuildObservable: Observable<AbstractMesh>;
  116901. /**
  116902. * Creates a new AbstractMesh
  116903. * @param name defines the name of the mesh
  116904. * @param scene defines the hosting scene
  116905. */
  116906. constructor(name: string, scene?: Nullable<Scene>);
  116907. /**
  116908. * Returns the string "AbstractMesh"
  116909. * @returns "AbstractMesh"
  116910. */
  116911. getClassName(): string;
  116912. /**
  116913. * Gets a string representation of the current mesh
  116914. * @param fullDetails defines a boolean indicating if full details must be included
  116915. * @returns a string representation of the current mesh
  116916. */
  116917. toString(fullDetails?: boolean): string;
  116918. /**
  116919. * @hidden
  116920. */
  116921. protected _getEffectiveParent(): Nullable<Node>;
  116922. /** @hidden */
  116923. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  116924. /** @hidden */
  116925. _rebuild(): void;
  116926. /** @hidden */
  116927. _resyncLightSources(): void;
  116928. /** @hidden */
  116929. _resyncLightSource(light: Light): void;
  116930. /** @hidden */
  116931. _unBindEffect(): void;
  116932. /** @hidden */
  116933. _removeLightSource(light: Light, dispose: boolean): void;
  116934. private _markSubMeshesAsDirty;
  116935. /** @hidden */
  116936. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  116937. /** @hidden */
  116938. _markSubMeshesAsAttributesDirty(): void;
  116939. /** @hidden */
  116940. _markSubMeshesAsMiscDirty(): void;
  116941. /**
  116942. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  116943. */
  116944. get scaling(): Vector3;
  116945. set scaling(newScaling: Vector3);
  116946. /**
  116947. * Returns true if the mesh is blocked. Implemented by child classes
  116948. */
  116949. get isBlocked(): boolean;
  116950. /**
  116951. * Returns the mesh itself by default. Implemented by child classes
  116952. * @param camera defines the camera to use to pick the right LOD level
  116953. * @returns the currentAbstractMesh
  116954. */
  116955. getLOD(camera: Camera): Nullable<AbstractMesh>;
  116956. /**
  116957. * Returns 0 by default. Implemented by child classes
  116958. * @returns an integer
  116959. */
  116960. getTotalVertices(): number;
  116961. /**
  116962. * Returns a positive integer : the total number of indices in this mesh geometry.
  116963. * @returns the numner of indices or zero if the mesh has no geometry.
  116964. */
  116965. getTotalIndices(): number;
  116966. /**
  116967. * Returns null by default. Implemented by child classes
  116968. * @returns null
  116969. */
  116970. getIndices(): Nullable<IndicesArray>;
  116971. /**
  116972. * Returns the array of the requested vertex data kind. Implemented by child classes
  116973. * @param kind defines the vertex data kind to use
  116974. * @returns null
  116975. */
  116976. getVerticesData(kind: string): Nullable<FloatArray>;
  116977. /**
  116978. * Sets the vertex data of the mesh geometry for the requested `kind`.
  116979. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  116980. * Note that a new underlying VertexBuffer object is created each call.
  116981. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  116982. * @param kind defines vertex data kind:
  116983. * * VertexBuffer.PositionKind
  116984. * * VertexBuffer.UVKind
  116985. * * VertexBuffer.UV2Kind
  116986. * * VertexBuffer.UV3Kind
  116987. * * VertexBuffer.UV4Kind
  116988. * * VertexBuffer.UV5Kind
  116989. * * VertexBuffer.UV6Kind
  116990. * * VertexBuffer.ColorKind
  116991. * * VertexBuffer.MatricesIndicesKind
  116992. * * VertexBuffer.MatricesIndicesExtraKind
  116993. * * VertexBuffer.MatricesWeightsKind
  116994. * * VertexBuffer.MatricesWeightsExtraKind
  116995. * @param data defines the data source
  116996. * @param updatable defines if the data must be flagged as updatable (or static)
  116997. * @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
  116998. * @returns the current mesh
  116999. */
  117000. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  117001. /**
  117002. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  117003. * If the mesh has no geometry, it is simply returned as it is.
  117004. * @param kind defines vertex data kind:
  117005. * * VertexBuffer.PositionKind
  117006. * * VertexBuffer.UVKind
  117007. * * VertexBuffer.UV2Kind
  117008. * * VertexBuffer.UV3Kind
  117009. * * VertexBuffer.UV4Kind
  117010. * * VertexBuffer.UV5Kind
  117011. * * VertexBuffer.UV6Kind
  117012. * * VertexBuffer.ColorKind
  117013. * * VertexBuffer.MatricesIndicesKind
  117014. * * VertexBuffer.MatricesIndicesExtraKind
  117015. * * VertexBuffer.MatricesWeightsKind
  117016. * * VertexBuffer.MatricesWeightsExtraKind
  117017. * @param data defines the data source
  117018. * @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
  117019. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  117020. * @returns the current mesh
  117021. */
  117022. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  117023. /**
  117024. * Sets the mesh indices,
  117025. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  117026. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  117027. * @param totalVertices Defines the total number of vertices
  117028. * @returns the current mesh
  117029. */
  117030. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  117031. /**
  117032. * Gets a boolean indicating if specific vertex data is present
  117033. * @param kind defines the vertex data kind to use
  117034. * @returns true is data kind is present
  117035. */
  117036. isVerticesDataPresent(kind: string): boolean;
  117037. /**
  117038. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  117039. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  117040. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  117041. * @returns a BoundingInfo
  117042. */
  117043. getBoundingInfo(): BoundingInfo;
  117044. /**
  117045. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  117046. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  117047. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  117048. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  117049. * @returns the current mesh
  117050. */
  117051. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  117052. /**
  117053. * Overwrite the current bounding info
  117054. * @param boundingInfo defines the new bounding info
  117055. * @returns the current mesh
  117056. */
  117057. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  117058. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  117059. get useBones(): boolean;
  117060. /** @hidden */
  117061. _preActivate(): void;
  117062. /** @hidden */
  117063. _preActivateForIntermediateRendering(renderId: number): void;
  117064. /** @hidden */
  117065. _activate(renderId: number, intermediateRendering: boolean): boolean;
  117066. /** @hidden */
  117067. _postActivate(): void;
  117068. /** @hidden */
  117069. _freeze(): void;
  117070. /** @hidden */
  117071. _unFreeze(): void;
  117072. /**
  117073. * Gets the current world matrix
  117074. * @returns a Matrix
  117075. */
  117076. getWorldMatrix(): Matrix;
  117077. /** @hidden */
  117078. _getWorldMatrixDeterminant(): number;
  117079. /**
  117080. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  117081. */
  117082. get isAnInstance(): boolean;
  117083. /**
  117084. * Gets a boolean indicating if this mesh has instances
  117085. */
  117086. get hasInstances(): boolean;
  117087. /**
  117088. * Gets a boolean indicating if this mesh has thin instances
  117089. */
  117090. get hasThinInstances(): boolean;
  117091. /**
  117092. * Perform relative position change from the point of view of behind the front of the mesh.
  117093. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117094. * Supports definition of mesh facing forward or backward
  117095. * @param amountRight defines the distance on the right axis
  117096. * @param amountUp defines the distance on the up axis
  117097. * @param amountForward defines the distance on the forward axis
  117098. * @returns the current mesh
  117099. */
  117100. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  117101. /**
  117102. * Calculate relative position change from the point of view of behind the front of the mesh.
  117103. * This is performed taking into account the meshes current rotation, so you do not have to care.
  117104. * Supports definition of mesh facing forward or backward
  117105. * @param amountRight defines the distance on the right axis
  117106. * @param amountUp defines the distance on the up axis
  117107. * @param amountForward defines the distance on the forward axis
  117108. * @returns the new displacement vector
  117109. */
  117110. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  117111. /**
  117112. * Perform relative rotation change from the point of view of behind the front of the mesh.
  117113. * Supports definition of mesh facing forward or backward
  117114. * @param flipBack defines the flip
  117115. * @param twirlClockwise defines the twirl
  117116. * @param tiltRight defines the tilt
  117117. * @returns the current mesh
  117118. */
  117119. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  117120. /**
  117121. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  117122. * Supports definition of mesh facing forward or backward.
  117123. * @param flipBack defines the flip
  117124. * @param twirlClockwise defines the twirl
  117125. * @param tiltRight defines the tilt
  117126. * @returns the new rotation vector
  117127. */
  117128. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  117129. /**
  117130. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  117131. * This means the mesh underlying bounding box and sphere are recomputed.
  117132. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  117133. * @returns the current mesh
  117134. */
  117135. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  117136. /** @hidden */
  117137. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  117138. /** @hidden */
  117139. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  117140. /** @hidden */
  117141. _updateBoundingInfo(): AbstractMesh;
  117142. /** @hidden */
  117143. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  117144. /** @hidden */
  117145. protected _afterComputeWorldMatrix(): void;
  117146. /** @hidden */
  117147. get _effectiveMesh(): AbstractMesh;
  117148. /**
  117149. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  117150. * A mesh is in the frustum if its bounding box intersects the frustum
  117151. * @param frustumPlanes defines the frustum to test
  117152. * @returns true if the mesh is in the frustum planes
  117153. */
  117154. isInFrustum(frustumPlanes: Plane[]): boolean;
  117155. /**
  117156. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  117157. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  117158. * @param frustumPlanes defines the frustum to test
  117159. * @returns true if the mesh is completely in the frustum planes
  117160. */
  117161. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  117162. /**
  117163. * True if the mesh intersects another mesh or a SolidParticle object
  117164. * @param mesh defines a target mesh or SolidParticle to test
  117165. * @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)
  117166. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  117167. * @returns true if there is an intersection
  117168. */
  117169. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  117170. /**
  117171. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  117172. * @param point defines the point to test
  117173. * @returns true if there is an intersection
  117174. */
  117175. intersectsPoint(point: Vector3): boolean;
  117176. /**
  117177. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  117178. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117179. */
  117180. get checkCollisions(): boolean;
  117181. set checkCollisions(collisionEnabled: boolean);
  117182. /**
  117183. * Gets Collider object used to compute collisions (not physics)
  117184. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117185. */
  117186. get collider(): Nullable<Collider>;
  117187. /**
  117188. * Move the mesh using collision engine
  117189. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117190. * @param displacement defines the requested displacement vector
  117191. * @returns the current mesh
  117192. */
  117193. moveWithCollisions(displacement: Vector3): AbstractMesh;
  117194. private _onCollisionPositionChange;
  117195. /** @hidden */
  117196. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  117197. /** @hidden */
  117198. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  117199. /** @hidden */
  117200. _checkCollision(collider: Collider): AbstractMesh;
  117201. /** @hidden */
  117202. _generatePointsArray(): boolean;
  117203. /**
  117204. * Checks if the passed Ray intersects with the mesh
  117205. * @param ray defines the ray to use
  117206. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  117207. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  117208. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  117209. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  117210. * @returns the picking info
  117211. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  117212. */
  117213. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  117214. /**
  117215. * Clones the current mesh
  117216. * @param name defines the mesh name
  117217. * @param newParent defines the new mesh parent
  117218. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  117219. * @returns the new mesh
  117220. */
  117221. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  117222. /**
  117223. * Disposes all the submeshes of the current meshnp
  117224. * @returns the current mesh
  117225. */
  117226. releaseSubMeshes(): AbstractMesh;
  117227. /**
  117228. * Releases resources associated with this abstract mesh.
  117229. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117230. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117231. */
  117232. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117233. /**
  117234. * Adds the passed mesh as a child to the current mesh
  117235. * @param mesh defines the child mesh
  117236. * @returns the current mesh
  117237. */
  117238. addChild(mesh: AbstractMesh): AbstractMesh;
  117239. /**
  117240. * Removes the passed mesh from the current mesh children list
  117241. * @param mesh defines the child mesh
  117242. * @returns the current mesh
  117243. */
  117244. removeChild(mesh: AbstractMesh): AbstractMesh;
  117245. /** @hidden */
  117246. private _initFacetData;
  117247. /**
  117248. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  117249. * This method can be called within the render loop.
  117250. * 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
  117251. * @returns the current mesh
  117252. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117253. */
  117254. updateFacetData(): AbstractMesh;
  117255. /**
  117256. * Returns the facetLocalNormals array.
  117257. * The normals are expressed in the mesh local spac
  117258. * @returns an array of Vector3
  117259. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117260. */
  117261. getFacetLocalNormals(): Vector3[];
  117262. /**
  117263. * Returns the facetLocalPositions array.
  117264. * The facet positions are expressed in the mesh local space
  117265. * @returns an array of Vector3
  117266. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117267. */
  117268. getFacetLocalPositions(): Vector3[];
  117269. /**
  117270. * Returns the facetLocalPartioning array
  117271. * @returns an array of array of numbers
  117272. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117273. */
  117274. getFacetLocalPartitioning(): number[][];
  117275. /**
  117276. * Returns the i-th facet position in the world system.
  117277. * This method allocates a new Vector3 per call
  117278. * @param i defines the facet index
  117279. * @returns a new Vector3
  117280. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117281. */
  117282. getFacetPosition(i: number): Vector3;
  117283. /**
  117284. * Sets the reference Vector3 with the i-th facet position in the world system
  117285. * @param i defines the facet index
  117286. * @param ref defines the target vector
  117287. * @returns the current mesh
  117288. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117289. */
  117290. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  117291. /**
  117292. * Returns the i-th facet normal in the world system.
  117293. * This method allocates a new Vector3 per call
  117294. * @param i defines the facet index
  117295. * @returns a new Vector3
  117296. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117297. */
  117298. getFacetNormal(i: number): Vector3;
  117299. /**
  117300. * Sets the reference Vector3 with the i-th facet normal in the world system
  117301. * @param i defines the facet index
  117302. * @param ref defines the target vector
  117303. * @returns the current mesh
  117304. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117305. */
  117306. getFacetNormalToRef(i: number, ref: Vector3): this;
  117307. /**
  117308. * 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)
  117309. * @param x defines x coordinate
  117310. * @param y defines y coordinate
  117311. * @param z defines z coordinate
  117312. * @returns the array of facet indexes
  117313. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117314. */
  117315. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  117316. /**
  117317. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  117318. * @param projected sets as the (x,y,z) world projection on the facet
  117319. * @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
  117320. * @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
  117321. * @param x defines x coordinate
  117322. * @param y defines y coordinate
  117323. * @param z defines z coordinate
  117324. * @returns the face index if found (or null instead)
  117325. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117326. */
  117327. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117328. /**
  117329. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  117330. * @param projected sets as the (x,y,z) local projection on the facet
  117331. * @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
  117332. * @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
  117333. * @param x defines x coordinate
  117334. * @param y defines y coordinate
  117335. * @param z defines z coordinate
  117336. * @returns the face index if found (or null instead)
  117337. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117338. */
  117339. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  117340. /**
  117341. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  117342. * @returns the parameters
  117343. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117344. */
  117345. getFacetDataParameters(): any;
  117346. /**
  117347. * Disables the feature FacetData and frees the related memory
  117348. * @returns the current mesh
  117349. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  117350. */
  117351. disableFacetData(): AbstractMesh;
  117352. /**
  117353. * Updates the AbstractMesh indices array
  117354. * @param indices defines the data source
  117355. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  117356. * @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)
  117357. * @returns the current mesh
  117358. */
  117359. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  117360. /**
  117361. * Creates new normals data for the mesh
  117362. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  117363. * @returns the current mesh
  117364. */
  117365. createNormals(updatable: boolean): AbstractMesh;
  117366. /**
  117367. * Align the mesh with a normal
  117368. * @param normal defines the normal to use
  117369. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  117370. * @returns the current mesh
  117371. */
  117372. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  117373. /** @hidden */
  117374. _checkOcclusionQuery(): boolean;
  117375. /**
  117376. * Disables the mesh edge rendering mode
  117377. * @returns the currentAbstractMesh
  117378. */
  117379. disableEdgesRendering(): AbstractMesh;
  117380. /**
  117381. * Enables the edge rendering mode on the mesh.
  117382. * This mode makes the mesh edges visible
  117383. * @param epsilon defines the maximal distance between two angles to detect a face
  117384. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  117385. * @returns the currentAbstractMesh
  117386. * @see https://www.babylonjs-playground.com/#19O9TU#0
  117387. */
  117388. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  117389. /**
  117390. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  117391. * @returns an array of particle systems in the scene that use the mesh as an emitter
  117392. */
  117393. getConnectedParticleSystems(): IParticleSystem[];
  117394. }
  117395. }
  117396. declare module BABYLON {
  117397. /**
  117398. * Interface used to define ActionEvent
  117399. */
  117400. export interface IActionEvent {
  117401. /** The mesh or sprite that triggered the action */
  117402. source: any;
  117403. /** The X mouse cursor position at the time of the event */
  117404. pointerX: number;
  117405. /** The Y mouse cursor position at the time of the event */
  117406. pointerY: number;
  117407. /** The mesh that is currently pointed at (can be null) */
  117408. meshUnderPointer: Nullable<AbstractMesh>;
  117409. /** the original (browser) event that triggered the ActionEvent */
  117410. sourceEvent?: any;
  117411. /** additional data for the event */
  117412. additionalData?: any;
  117413. }
  117414. /**
  117415. * ActionEvent is the event being sent when an action is triggered.
  117416. */
  117417. export class ActionEvent implements IActionEvent {
  117418. /** The mesh or sprite that triggered the action */
  117419. source: any;
  117420. /** The X mouse cursor position at the time of the event */
  117421. pointerX: number;
  117422. /** The Y mouse cursor position at the time of the event */
  117423. pointerY: number;
  117424. /** The mesh that is currently pointed at (can be null) */
  117425. meshUnderPointer: Nullable<AbstractMesh>;
  117426. /** the original (browser) event that triggered the ActionEvent */
  117427. sourceEvent?: any;
  117428. /** additional data for the event */
  117429. additionalData?: any;
  117430. /**
  117431. * Creates a new ActionEvent
  117432. * @param source The mesh or sprite that triggered the action
  117433. * @param pointerX The X mouse cursor position at the time of the event
  117434. * @param pointerY The Y mouse cursor position at the time of the event
  117435. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  117436. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  117437. * @param additionalData additional data for the event
  117438. */
  117439. constructor(
  117440. /** The mesh or sprite that triggered the action */
  117441. source: any,
  117442. /** The X mouse cursor position at the time of the event */
  117443. pointerX: number,
  117444. /** The Y mouse cursor position at the time of the event */
  117445. pointerY: number,
  117446. /** The mesh that is currently pointed at (can be null) */
  117447. meshUnderPointer: Nullable<AbstractMesh>,
  117448. /** the original (browser) event that triggered the ActionEvent */
  117449. sourceEvent?: any,
  117450. /** additional data for the event */
  117451. additionalData?: any);
  117452. /**
  117453. * Helper function to auto-create an ActionEvent from a source mesh.
  117454. * @param source The source mesh that triggered the event
  117455. * @param evt The original (browser) event
  117456. * @param additionalData additional data for the event
  117457. * @returns the new ActionEvent
  117458. */
  117459. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  117460. /**
  117461. * Helper function to auto-create an ActionEvent from a source sprite
  117462. * @param source The source sprite that triggered the event
  117463. * @param scene Scene associated with the sprite
  117464. * @param evt The original (browser) event
  117465. * @param additionalData additional data for the event
  117466. * @returns the new ActionEvent
  117467. */
  117468. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  117469. /**
  117470. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  117471. * @param scene the scene where the event occurred
  117472. * @param evt The original (browser) event
  117473. * @returns the new ActionEvent
  117474. */
  117475. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  117476. /**
  117477. * Helper function to auto-create an ActionEvent from a primitive
  117478. * @param prim defines the target primitive
  117479. * @param pointerPos defines the pointer position
  117480. * @param evt The original (browser) event
  117481. * @param additionalData additional data for the event
  117482. * @returns the new ActionEvent
  117483. */
  117484. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  117485. }
  117486. }
  117487. declare module BABYLON {
  117488. /**
  117489. * Abstract class used to decouple action Manager from scene and meshes.
  117490. * Do not instantiate.
  117491. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117492. */
  117493. export abstract class AbstractActionManager implements IDisposable {
  117494. /** Gets the list of active triggers */
  117495. static Triggers: {
  117496. [key: string]: number;
  117497. };
  117498. /** Gets the cursor to use when hovering items */
  117499. hoverCursor: string;
  117500. /** Gets the list of actions */
  117501. actions: IAction[];
  117502. /**
  117503. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  117504. */
  117505. isRecursive: boolean;
  117506. /**
  117507. * Releases all associated resources
  117508. */
  117509. abstract dispose(): void;
  117510. /**
  117511. * Does this action manager has pointer triggers
  117512. */
  117513. abstract get hasPointerTriggers(): boolean;
  117514. /**
  117515. * Does this action manager has pick triggers
  117516. */
  117517. abstract get hasPickTriggers(): boolean;
  117518. /**
  117519. * Process a specific trigger
  117520. * @param trigger defines the trigger to process
  117521. * @param evt defines the event details to be processed
  117522. */
  117523. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  117524. /**
  117525. * Does this action manager handles actions of any of the given triggers
  117526. * @param triggers defines the triggers to be tested
  117527. * @return a boolean indicating whether one (or more) of the triggers is handled
  117528. */
  117529. abstract hasSpecificTriggers(triggers: number[]): boolean;
  117530. /**
  117531. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  117532. * speed.
  117533. * @param triggerA defines the trigger to be tested
  117534. * @param triggerB defines the trigger to be tested
  117535. * @return a boolean indicating whether one (or more) of the triggers is handled
  117536. */
  117537. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  117538. /**
  117539. * Does this action manager handles actions of a given trigger
  117540. * @param trigger defines the trigger to be tested
  117541. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  117542. * @return whether the trigger is handled
  117543. */
  117544. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  117545. /**
  117546. * Serialize this manager to a JSON object
  117547. * @param name defines the property name to store this manager
  117548. * @returns a JSON representation of this manager
  117549. */
  117550. abstract serialize(name: string): any;
  117551. /**
  117552. * Registers an action to this action manager
  117553. * @param action defines the action to be registered
  117554. * @return the action amended (prepared) after registration
  117555. */
  117556. abstract registerAction(action: IAction): Nullable<IAction>;
  117557. /**
  117558. * Unregisters an action to this action manager
  117559. * @param action defines the action to be unregistered
  117560. * @return a boolean indicating whether the action has been unregistered
  117561. */
  117562. abstract unregisterAction(action: IAction): Boolean;
  117563. /**
  117564. * Does exist one action manager with at least one trigger
  117565. **/
  117566. static get HasTriggers(): boolean;
  117567. /**
  117568. * Does exist one action manager with at least one pick trigger
  117569. **/
  117570. static get HasPickTriggers(): boolean;
  117571. /**
  117572. * Does exist one action manager that handles actions of a given trigger
  117573. * @param trigger defines the trigger to be tested
  117574. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  117575. **/
  117576. static HasSpecificTrigger(trigger: number): boolean;
  117577. }
  117578. }
  117579. declare module BABYLON {
  117580. /**
  117581. * Defines how a node can be built from a string name.
  117582. */
  117583. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  117584. /**
  117585. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  117586. */
  117587. export class Node implements IBehaviorAware<Node> {
  117588. /** @hidden */
  117589. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  117590. private static _NodeConstructors;
  117591. /**
  117592. * Add a new node constructor
  117593. * @param type defines the type name of the node to construct
  117594. * @param constructorFunc defines the constructor function
  117595. */
  117596. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  117597. /**
  117598. * Returns a node constructor based on type name
  117599. * @param type defines the type name
  117600. * @param name defines the new node name
  117601. * @param scene defines the hosting scene
  117602. * @param options defines optional options to transmit to constructors
  117603. * @returns the new constructor or null
  117604. */
  117605. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  117606. /**
  117607. * Gets or sets the name of the node
  117608. */
  117609. name: string;
  117610. /**
  117611. * Gets or sets the id of the node
  117612. */
  117613. id: string;
  117614. /**
  117615. * Gets or sets the unique id of the node
  117616. */
  117617. uniqueId: number;
  117618. /**
  117619. * Gets or sets a string used to store user defined state for the node
  117620. */
  117621. state: string;
  117622. /**
  117623. * Gets or sets an object used to store user defined information for the node
  117624. */
  117625. metadata: any;
  117626. /**
  117627. * For internal use only. Please do not use.
  117628. */
  117629. reservedDataStore: any;
  117630. /**
  117631. * List of inspectable custom properties (used by the Inspector)
  117632. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117633. */
  117634. inspectableCustomProperties: IInspectable[];
  117635. private _doNotSerialize;
  117636. /**
  117637. * Gets or sets a boolean used to define if the node must be serialized
  117638. */
  117639. get doNotSerialize(): boolean;
  117640. set doNotSerialize(value: boolean);
  117641. /** @hidden */
  117642. _isDisposed: boolean;
  117643. /**
  117644. * Gets a list of Animations associated with the node
  117645. */
  117646. animations: Animation[];
  117647. protected _ranges: {
  117648. [name: string]: Nullable<AnimationRange>;
  117649. };
  117650. /**
  117651. * Callback raised when the node is ready to be used
  117652. */
  117653. onReady: Nullable<(node: Node) => void>;
  117654. private _isEnabled;
  117655. private _isParentEnabled;
  117656. private _isReady;
  117657. /** @hidden */
  117658. _currentRenderId: number;
  117659. private _parentUpdateId;
  117660. /** @hidden */
  117661. _childUpdateId: number;
  117662. /** @hidden */
  117663. _waitingParentId: Nullable<string>;
  117664. /** @hidden */
  117665. _scene: Scene;
  117666. /** @hidden */
  117667. _cache: any;
  117668. private _parentNode;
  117669. private _children;
  117670. /** @hidden */
  117671. _worldMatrix: Matrix;
  117672. /** @hidden */
  117673. _worldMatrixDeterminant: number;
  117674. /** @hidden */
  117675. _worldMatrixDeterminantIsDirty: boolean;
  117676. /** @hidden */
  117677. private _sceneRootNodesIndex;
  117678. /**
  117679. * Gets a boolean indicating if the node has been disposed
  117680. * @returns true if the node was disposed
  117681. */
  117682. isDisposed(): boolean;
  117683. /**
  117684. * Gets or sets the parent of the node (without keeping the current position in the scene)
  117685. * @see https://doc.babylonjs.com/how_to/parenting
  117686. */
  117687. set parent(parent: Nullable<Node>);
  117688. get parent(): Nullable<Node>;
  117689. /** @hidden */
  117690. _addToSceneRootNodes(): void;
  117691. /** @hidden */
  117692. _removeFromSceneRootNodes(): void;
  117693. private _animationPropertiesOverride;
  117694. /**
  117695. * Gets or sets the animation properties override
  117696. */
  117697. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  117698. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  117699. /**
  117700. * Gets a string identifying the name of the class
  117701. * @returns "Node" string
  117702. */
  117703. getClassName(): string;
  117704. /** @hidden */
  117705. readonly _isNode: boolean;
  117706. /**
  117707. * An event triggered when the mesh is disposed
  117708. */
  117709. onDisposeObservable: Observable<Node>;
  117710. private _onDisposeObserver;
  117711. /**
  117712. * Sets a callback that will be raised when the node will be disposed
  117713. */
  117714. set onDispose(callback: () => void);
  117715. /**
  117716. * Creates a new Node
  117717. * @param name the name and id to be given to this node
  117718. * @param scene the scene this node will be added to
  117719. */
  117720. constructor(name: string, scene?: Nullable<Scene>);
  117721. /**
  117722. * Gets the scene of the node
  117723. * @returns a scene
  117724. */
  117725. getScene(): Scene;
  117726. /**
  117727. * Gets the engine of the node
  117728. * @returns a Engine
  117729. */
  117730. getEngine(): Engine;
  117731. private _behaviors;
  117732. /**
  117733. * Attach a behavior to the node
  117734. * @see https://doc.babylonjs.com/features/behaviour
  117735. * @param behavior defines the behavior to attach
  117736. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  117737. * @returns the current Node
  117738. */
  117739. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  117740. /**
  117741. * Remove an attached behavior
  117742. * @see https://doc.babylonjs.com/features/behaviour
  117743. * @param behavior defines the behavior to attach
  117744. * @returns the current Node
  117745. */
  117746. removeBehavior(behavior: Behavior<Node>): Node;
  117747. /**
  117748. * Gets the list of attached behaviors
  117749. * @see https://doc.babylonjs.com/features/behaviour
  117750. */
  117751. get behaviors(): Behavior<Node>[];
  117752. /**
  117753. * Gets an attached behavior by name
  117754. * @param name defines the name of the behavior to look for
  117755. * @see https://doc.babylonjs.com/features/behaviour
  117756. * @returns null if behavior was not found else the requested behavior
  117757. */
  117758. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  117759. /**
  117760. * Returns the latest update of the World matrix
  117761. * @returns a Matrix
  117762. */
  117763. getWorldMatrix(): Matrix;
  117764. /** @hidden */
  117765. _getWorldMatrixDeterminant(): number;
  117766. /**
  117767. * Returns directly the latest state of the mesh World matrix.
  117768. * A Matrix is returned.
  117769. */
  117770. get worldMatrixFromCache(): Matrix;
  117771. /** @hidden */
  117772. _initCache(): void;
  117773. /** @hidden */
  117774. updateCache(force?: boolean): void;
  117775. /** @hidden */
  117776. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  117777. /** @hidden */
  117778. _updateCache(ignoreParentClass?: boolean): void;
  117779. /** @hidden */
  117780. _isSynchronized(): boolean;
  117781. /** @hidden */
  117782. _markSyncedWithParent(): void;
  117783. /** @hidden */
  117784. isSynchronizedWithParent(): boolean;
  117785. /** @hidden */
  117786. isSynchronized(): boolean;
  117787. /**
  117788. * Is this node ready to be used/rendered
  117789. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  117790. * @return true if the node is ready
  117791. */
  117792. isReady(completeCheck?: boolean): boolean;
  117793. /**
  117794. * Is this node enabled?
  117795. * 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
  117796. * @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
  117797. * @return whether this node (and its parent) is enabled
  117798. */
  117799. isEnabled(checkAncestors?: boolean): boolean;
  117800. /** @hidden */
  117801. protected _syncParentEnabledState(): void;
  117802. /**
  117803. * Set the enabled state of this node
  117804. * @param value defines the new enabled state
  117805. */
  117806. setEnabled(value: boolean): void;
  117807. /**
  117808. * Is this node a descendant of the given node?
  117809. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  117810. * @param ancestor defines the parent node to inspect
  117811. * @returns a boolean indicating if this node is a descendant of the given node
  117812. */
  117813. isDescendantOf(ancestor: Node): boolean;
  117814. /** @hidden */
  117815. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  117816. /**
  117817. * Will return all nodes that have this node as ascendant
  117818. * @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
  117819. * @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
  117820. * @return all children nodes of all types
  117821. */
  117822. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  117823. /**
  117824. * Get all child-meshes of this node
  117825. * @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)
  117826. * @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
  117827. * @returns an array of AbstractMesh
  117828. */
  117829. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  117830. /**
  117831. * Get all direct children of this node
  117832. * @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
  117833. * @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)
  117834. * @returns an array of Node
  117835. */
  117836. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  117837. /** @hidden */
  117838. _setReady(state: boolean): void;
  117839. /**
  117840. * Get an animation by name
  117841. * @param name defines the name of the animation to look for
  117842. * @returns null if not found else the requested animation
  117843. */
  117844. getAnimationByName(name: string): Nullable<Animation>;
  117845. /**
  117846. * Creates an animation range for this node
  117847. * @param name defines the name of the range
  117848. * @param from defines the starting key
  117849. * @param to defines the end key
  117850. */
  117851. createAnimationRange(name: string, from: number, to: number): void;
  117852. /**
  117853. * Delete a specific animation range
  117854. * @param name defines the name of the range to delete
  117855. * @param deleteFrames defines if animation frames from the range must be deleted as well
  117856. */
  117857. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  117858. /**
  117859. * Get an animation range by name
  117860. * @param name defines the name of the animation range to look for
  117861. * @returns null if not found else the requested animation range
  117862. */
  117863. getAnimationRange(name: string): Nullable<AnimationRange>;
  117864. /**
  117865. * Gets the list of all animation ranges defined on this node
  117866. * @returns an array
  117867. */
  117868. getAnimationRanges(): Nullable<AnimationRange>[];
  117869. /**
  117870. * Will start the animation sequence
  117871. * @param name defines the range frames for animation sequence
  117872. * @param loop defines if the animation should loop (false by default)
  117873. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  117874. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  117875. * @returns the object created for this animation. If range does not exist, it will return null
  117876. */
  117877. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  117878. /**
  117879. * Serialize animation ranges into a JSON compatible object
  117880. * @returns serialization object
  117881. */
  117882. serializeAnimationRanges(): any;
  117883. /**
  117884. * Computes the world matrix of the node
  117885. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  117886. * @returns the world matrix
  117887. */
  117888. computeWorldMatrix(force?: boolean): Matrix;
  117889. /**
  117890. * Releases resources associated with this node.
  117891. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  117892. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  117893. */
  117894. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  117895. /**
  117896. * Parse animation range data from a serialization object and store them into a given node
  117897. * @param node defines where to store the animation ranges
  117898. * @param parsedNode defines the serialization object to read data from
  117899. * @param scene defines the hosting scene
  117900. */
  117901. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  117902. /**
  117903. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  117904. * @param includeDescendants Include bounding info from descendants as well (true by default)
  117905. * @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
  117906. * @returns the new bounding vectors
  117907. */
  117908. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  117909. min: Vector3;
  117910. max: Vector3;
  117911. };
  117912. }
  117913. }
  117914. declare module BABYLON {
  117915. /**
  117916. * @hidden
  117917. */
  117918. export class _IAnimationState {
  117919. key: number;
  117920. repeatCount: number;
  117921. workValue?: any;
  117922. loopMode?: number;
  117923. offsetValue?: any;
  117924. highLimitValue?: any;
  117925. }
  117926. /**
  117927. * Class used to store any kind of animation
  117928. */
  117929. export class Animation {
  117930. /**Name of the animation */
  117931. name: string;
  117932. /**Property to animate */
  117933. targetProperty: string;
  117934. /**The frames per second of the animation */
  117935. framePerSecond: number;
  117936. /**The data type of the animation */
  117937. dataType: number;
  117938. /**The loop mode of the animation */
  117939. loopMode?: number | undefined;
  117940. /**Specifies if blending should be enabled */
  117941. enableBlending?: boolean | undefined;
  117942. /**
  117943. * Use matrix interpolation instead of using direct key value when animating matrices
  117944. */
  117945. static AllowMatricesInterpolation: boolean;
  117946. /**
  117947. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  117948. */
  117949. static AllowMatrixDecomposeForInterpolation: boolean;
  117950. /** Define the Url to load snippets */
  117951. static SnippetUrl: string;
  117952. /** Snippet ID if the animation was created from the snippet server */
  117953. snippetId: string;
  117954. /**
  117955. * Stores the key frames of the animation
  117956. */
  117957. private _keys;
  117958. /**
  117959. * Stores the easing function of the animation
  117960. */
  117961. private _easingFunction;
  117962. /**
  117963. * @hidden Internal use only
  117964. */
  117965. _runtimeAnimations: RuntimeAnimation[];
  117966. /**
  117967. * The set of event that will be linked to this animation
  117968. */
  117969. private _events;
  117970. /**
  117971. * Stores an array of target property paths
  117972. */
  117973. targetPropertyPath: string[];
  117974. /**
  117975. * Stores the blending speed of the animation
  117976. */
  117977. blendingSpeed: number;
  117978. /**
  117979. * Stores the animation ranges for the animation
  117980. */
  117981. private _ranges;
  117982. /**
  117983. * @hidden Internal use
  117984. */
  117985. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  117986. /**
  117987. * Sets up an animation
  117988. * @param property The property to animate
  117989. * @param animationType The animation type to apply
  117990. * @param framePerSecond The frames per second of the animation
  117991. * @param easingFunction The easing function used in the animation
  117992. * @returns The created animation
  117993. */
  117994. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  117995. /**
  117996. * Create and start an animation on a node
  117997. * @param name defines the name of the global animation that will be run on all nodes
  117998. * @param node defines the root node where the animation will take place
  117999. * @param targetProperty defines property to animate
  118000. * @param framePerSecond defines the number of frame per second yo use
  118001. * @param totalFrame defines the number of frames in total
  118002. * @param from defines the initial value
  118003. * @param to defines the final value
  118004. * @param loopMode defines which loop mode you want to use (off by default)
  118005. * @param easingFunction defines the easing function to use (linear by default)
  118006. * @param onAnimationEnd defines the callback to call when animation end
  118007. * @returns the animatable created for this animation
  118008. */
  118009. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118010. /**
  118011. * Create and start an animation on a node and its descendants
  118012. * @param name defines the name of the global animation that will be run on all nodes
  118013. * @param node defines the root node where the animation will take place
  118014. * @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
  118015. * @param targetProperty defines property to animate
  118016. * @param framePerSecond defines the number of frame per second to use
  118017. * @param totalFrame defines the number of frames in total
  118018. * @param from defines the initial value
  118019. * @param to defines the final value
  118020. * @param loopMode defines which loop mode you want to use (off by default)
  118021. * @param easingFunction defines the easing function to use (linear by default)
  118022. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  118023. * @returns the list of animatables created for all nodes
  118024. * @example https://www.babylonjs-playground.com/#MH0VLI
  118025. */
  118026. 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[]>;
  118027. /**
  118028. * Creates a new animation, merges it with the existing animations and starts it
  118029. * @param name Name of the animation
  118030. * @param node Node which contains the scene that begins the animations
  118031. * @param targetProperty Specifies which property to animate
  118032. * @param framePerSecond The frames per second of the animation
  118033. * @param totalFrame The total number of frames
  118034. * @param from The frame at the beginning of the animation
  118035. * @param to The frame at the end of the animation
  118036. * @param loopMode Specifies the loop mode of the animation
  118037. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  118038. * @param onAnimationEnd Callback to run once the animation is complete
  118039. * @returns Nullable animation
  118040. */
  118041. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  118042. /**
  118043. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  118044. * @param sourceAnimation defines the Animation containing keyframes to convert
  118045. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  118046. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  118047. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  118048. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  118049. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  118050. */
  118051. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  118052. /**
  118053. * Transition property of an host to the target Value
  118054. * @param property The property to transition
  118055. * @param targetValue The target Value of the property
  118056. * @param host The object where the property to animate belongs
  118057. * @param scene Scene used to run the animation
  118058. * @param frameRate Framerate (in frame/s) to use
  118059. * @param transition The transition type we want to use
  118060. * @param duration The duration of the animation, in milliseconds
  118061. * @param onAnimationEnd Callback trigger at the end of the animation
  118062. * @returns Nullable animation
  118063. */
  118064. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  118065. /**
  118066. * Return the array of runtime animations currently using this animation
  118067. */
  118068. get runtimeAnimations(): RuntimeAnimation[];
  118069. /**
  118070. * Specifies if any of the runtime animations are currently running
  118071. */
  118072. get hasRunningRuntimeAnimations(): boolean;
  118073. /**
  118074. * Initializes the animation
  118075. * @param name Name of the animation
  118076. * @param targetProperty Property to animate
  118077. * @param framePerSecond The frames per second of the animation
  118078. * @param dataType The data type of the animation
  118079. * @param loopMode The loop mode of the animation
  118080. * @param enableBlending Specifies if blending should be enabled
  118081. */
  118082. constructor(
  118083. /**Name of the animation */
  118084. name: string,
  118085. /**Property to animate */
  118086. targetProperty: string,
  118087. /**The frames per second of the animation */
  118088. framePerSecond: number,
  118089. /**The data type of the animation */
  118090. dataType: number,
  118091. /**The loop mode of the animation */
  118092. loopMode?: number | undefined,
  118093. /**Specifies if blending should be enabled */
  118094. enableBlending?: boolean | undefined);
  118095. /**
  118096. * Converts the animation to a string
  118097. * @param fullDetails support for multiple levels of logging within scene loading
  118098. * @returns String form of the animation
  118099. */
  118100. toString(fullDetails?: boolean): string;
  118101. /**
  118102. * Add an event to this animation
  118103. * @param event Event to add
  118104. */
  118105. addEvent(event: AnimationEvent): void;
  118106. /**
  118107. * Remove all events found at the given frame
  118108. * @param frame The frame to remove events from
  118109. */
  118110. removeEvents(frame: number): void;
  118111. /**
  118112. * Retrieves all the events from the animation
  118113. * @returns Events from the animation
  118114. */
  118115. getEvents(): AnimationEvent[];
  118116. /**
  118117. * Creates an animation range
  118118. * @param name Name of the animation range
  118119. * @param from Starting frame of the animation range
  118120. * @param to Ending frame of the animation
  118121. */
  118122. createRange(name: string, from: number, to: number): void;
  118123. /**
  118124. * Deletes an animation range by name
  118125. * @param name Name of the animation range to delete
  118126. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  118127. */
  118128. deleteRange(name: string, deleteFrames?: boolean): void;
  118129. /**
  118130. * Gets the animation range by name, or null if not defined
  118131. * @param name Name of the animation range
  118132. * @returns Nullable animation range
  118133. */
  118134. getRange(name: string): Nullable<AnimationRange>;
  118135. /**
  118136. * Gets the key frames from the animation
  118137. * @returns The key frames of the animation
  118138. */
  118139. getKeys(): Array<IAnimationKey>;
  118140. /**
  118141. * Gets the highest frame rate of the animation
  118142. * @returns Highest frame rate of the animation
  118143. */
  118144. getHighestFrame(): number;
  118145. /**
  118146. * Gets the easing function of the animation
  118147. * @returns Easing function of the animation
  118148. */
  118149. getEasingFunction(): IEasingFunction;
  118150. /**
  118151. * Sets the easing function of the animation
  118152. * @param easingFunction A custom mathematical formula for animation
  118153. */
  118154. setEasingFunction(easingFunction: EasingFunction): void;
  118155. /**
  118156. * Interpolates a scalar linearly
  118157. * @param startValue Start value of the animation curve
  118158. * @param endValue End value of the animation curve
  118159. * @param gradient Scalar amount to interpolate
  118160. * @returns Interpolated scalar value
  118161. */
  118162. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  118163. /**
  118164. * Interpolates a scalar cubically
  118165. * @param startValue Start value of the animation curve
  118166. * @param outTangent End tangent of the animation
  118167. * @param endValue End value of the animation curve
  118168. * @param inTangent Start tangent of the animation curve
  118169. * @param gradient Scalar amount to interpolate
  118170. * @returns Interpolated scalar value
  118171. */
  118172. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  118173. /**
  118174. * Interpolates a quaternion using a spherical linear interpolation
  118175. * @param startValue Start value of the animation curve
  118176. * @param endValue End value of the animation curve
  118177. * @param gradient Scalar amount to interpolate
  118178. * @returns Interpolated quaternion value
  118179. */
  118180. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  118181. /**
  118182. * Interpolates a quaternion cubically
  118183. * @param startValue Start value of the animation curve
  118184. * @param outTangent End tangent of the animation curve
  118185. * @param endValue End value of the animation curve
  118186. * @param inTangent Start tangent of the animation curve
  118187. * @param gradient Scalar amount to interpolate
  118188. * @returns Interpolated quaternion value
  118189. */
  118190. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  118191. /**
  118192. * Interpolates a Vector3 linearl
  118193. * @param startValue Start value of the animation curve
  118194. * @param endValue End value of the animation curve
  118195. * @param gradient Scalar amount to interpolate
  118196. * @returns Interpolated scalar value
  118197. */
  118198. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  118199. /**
  118200. * Interpolates a Vector3 cubically
  118201. * @param startValue Start value of the animation curve
  118202. * @param outTangent End tangent of the animation
  118203. * @param endValue End value of the animation curve
  118204. * @param inTangent Start tangent of the animation curve
  118205. * @param gradient Scalar amount to interpolate
  118206. * @returns InterpolatedVector3 value
  118207. */
  118208. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  118209. /**
  118210. * Interpolates a Vector2 linearly
  118211. * @param startValue Start value of the animation curve
  118212. * @param endValue End value of the animation curve
  118213. * @param gradient Scalar amount to interpolate
  118214. * @returns Interpolated Vector2 value
  118215. */
  118216. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  118217. /**
  118218. * Interpolates a Vector2 cubically
  118219. * @param startValue Start value of the animation curve
  118220. * @param outTangent End tangent of the animation
  118221. * @param endValue End value of the animation curve
  118222. * @param inTangent Start tangent of the animation curve
  118223. * @param gradient Scalar amount to interpolate
  118224. * @returns Interpolated Vector2 value
  118225. */
  118226. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  118227. /**
  118228. * Interpolates a size linearly
  118229. * @param startValue Start value of the animation curve
  118230. * @param endValue End value of the animation curve
  118231. * @param gradient Scalar amount to interpolate
  118232. * @returns Interpolated Size value
  118233. */
  118234. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  118235. /**
  118236. * Interpolates a Color3 linearly
  118237. * @param startValue Start value of the animation curve
  118238. * @param endValue End value of the animation curve
  118239. * @param gradient Scalar amount to interpolate
  118240. * @returns Interpolated Color3 value
  118241. */
  118242. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  118243. /**
  118244. * Interpolates a Color4 linearly
  118245. * @param startValue Start value of the animation curve
  118246. * @param endValue End value of the animation curve
  118247. * @param gradient Scalar amount to interpolate
  118248. * @returns Interpolated Color3 value
  118249. */
  118250. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  118251. /**
  118252. * @hidden Internal use only
  118253. */
  118254. _getKeyValue(value: any): any;
  118255. /**
  118256. * @hidden Internal use only
  118257. */
  118258. _interpolate(currentFrame: number, state: _IAnimationState): any;
  118259. /**
  118260. * Defines the function to use to interpolate matrices
  118261. * @param startValue defines the start matrix
  118262. * @param endValue defines the end matrix
  118263. * @param gradient defines the gradient between both matrices
  118264. * @param result defines an optional target matrix where to store the interpolation
  118265. * @returns the interpolated matrix
  118266. */
  118267. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  118268. /**
  118269. * Makes a copy of the animation
  118270. * @returns Cloned animation
  118271. */
  118272. clone(): Animation;
  118273. /**
  118274. * Sets the key frames of the animation
  118275. * @param values The animation key frames to set
  118276. */
  118277. setKeys(values: Array<IAnimationKey>): void;
  118278. /**
  118279. * Serializes the animation to an object
  118280. * @returns Serialized object
  118281. */
  118282. serialize(): any;
  118283. /**
  118284. * Float animation type
  118285. */
  118286. static readonly ANIMATIONTYPE_FLOAT: number;
  118287. /**
  118288. * Vector3 animation type
  118289. */
  118290. static readonly ANIMATIONTYPE_VECTOR3: number;
  118291. /**
  118292. * Quaternion animation type
  118293. */
  118294. static readonly ANIMATIONTYPE_QUATERNION: number;
  118295. /**
  118296. * Matrix animation type
  118297. */
  118298. static readonly ANIMATIONTYPE_MATRIX: number;
  118299. /**
  118300. * Color3 animation type
  118301. */
  118302. static readonly ANIMATIONTYPE_COLOR3: number;
  118303. /**
  118304. * Color3 animation type
  118305. */
  118306. static readonly ANIMATIONTYPE_COLOR4: number;
  118307. /**
  118308. * Vector2 animation type
  118309. */
  118310. static readonly ANIMATIONTYPE_VECTOR2: number;
  118311. /**
  118312. * Size animation type
  118313. */
  118314. static readonly ANIMATIONTYPE_SIZE: number;
  118315. /**
  118316. * Relative Loop Mode
  118317. */
  118318. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  118319. /**
  118320. * Cycle Loop Mode
  118321. */
  118322. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  118323. /**
  118324. * Constant Loop Mode
  118325. */
  118326. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  118327. /** @hidden */
  118328. static _UniversalLerp(left: any, right: any, amount: number): any;
  118329. /**
  118330. * Parses an animation object and creates an animation
  118331. * @param parsedAnimation Parsed animation object
  118332. * @returns Animation object
  118333. */
  118334. static Parse(parsedAnimation: any): Animation;
  118335. /**
  118336. * Appends the serialized animations from the source animations
  118337. * @param source Source containing the animations
  118338. * @param destination Target to store the animations
  118339. */
  118340. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118341. /**
  118342. * Creates a new animation or an array of animations from a snippet saved in a remote file
  118343. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  118344. * @param url defines the url to load from
  118345. * @returns a promise that will resolve to the new animation or an array of animations
  118346. */
  118347. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  118348. /**
  118349. * Creates an animation or an array of animations from a snippet saved by the Inspector
  118350. * @param snippetId defines the snippet to load
  118351. * @returns a promise that will resolve to the new animation or a new array of animations
  118352. */
  118353. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  118354. }
  118355. }
  118356. declare module BABYLON {
  118357. /**
  118358. * Interface containing an array of animations
  118359. */
  118360. export interface IAnimatable {
  118361. /**
  118362. * Array of animations
  118363. */
  118364. animations: Nullable<Array<Animation>>;
  118365. }
  118366. }
  118367. declare module BABYLON {
  118368. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  118369. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118370. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118371. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118372. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118373. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118374. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118375. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118376. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118377. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118378. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118379. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118380. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118381. /**
  118382. * Decorator used to define property that can be serialized as reference to a camera
  118383. * @param sourceName defines the name of the property to decorate
  118384. */
  118385. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  118386. /**
  118387. * Class used to help serialization objects
  118388. */
  118389. export class SerializationHelper {
  118390. /** @hidden */
  118391. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  118392. /** @hidden */
  118393. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  118394. /** @hidden */
  118395. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  118396. /** @hidden */
  118397. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  118398. /**
  118399. * Appends the serialized animations from the source animations
  118400. * @param source Source containing the animations
  118401. * @param destination Target to store the animations
  118402. */
  118403. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  118404. /**
  118405. * Static function used to serialized a specific entity
  118406. * @param entity defines the entity to serialize
  118407. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  118408. * @returns a JSON compatible object representing the serialization of the entity
  118409. */
  118410. static Serialize<T>(entity: T, serializationObject?: any): any;
  118411. /**
  118412. * Creates a new entity from a serialization data object
  118413. * @param creationFunction defines a function used to instanciated the new entity
  118414. * @param source defines the source serialization data
  118415. * @param scene defines the hosting scene
  118416. * @param rootUrl defines the root url for resources
  118417. * @returns a new entity
  118418. */
  118419. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  118420. /**
  118421. * Clones an object
  118422. * @param creationFunction defines the function used to instanciate the new object
  118423. * @param source defines the source object
  118424. * @returns the cloned object
  118425. */
  118426. static Clone<T>(creationFunction: () => T, source: T): T;
  118427. /**
  118428. * Instanciates a new object based on a source one (some data will be shared between both object)
  118429. * @param creationFunction defines the function used to instanciate the new object
  118430. * @param source defines the source object
  118431. * @returns the new object
  118432. */
  118433. static Instanciate<T>(creationFunction: () => T, source: T): T;
  118434. }
  118435. }
  118436. declare module BABYLON {
  118437. /**
  118438. * Base class of all the textures in babylon.
  118439. * It groups all the common properties the materials, post process, lights... might need
  118440. * in order to make a correct use of the texture.
  118441. */
  118442. export class BaseTexture implements IAnimatable {
  118443. /**
  118444. * Default anisotropic filtering level for the application.
  118445. * It is set to 4 as a good tradeoff between perf and quality.
  118446. */
  118447. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  118448. /**
  118449. * Gets or sets the unique id of the texture
  118450. */
  118451. uniqueId: number;
  118452. /**
  118453. * Define the name of the texture.
  118454. */
  118455. name: string;
  118456. /**
  118457. * Gets or sets an object used to store user defined information.
  118458. */
  118459. metadata: any;
  118460. /**
  118461. * For internal use only. Please do not use.
  118462. */
  118463. reservedDataStore: any;
  118464. private _hasAlpha;
  118465. /**
  118466. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  118467. */
  118468. set hasAlpha(value: boolean);
  118469. get hasAlpha(): boolean;
  118470. /**
  118471. * Defines if the alpha value should be determined via the rgb values.
  118472. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  118473. */
  118474. getAlphaFromRGB: boolean;
  118475. /**
  118476. * Intensity or strength of the texture.
  118477. * It is commonly used by materials to fine tune the intensity of the texture
  118478. */
  118479. level: number;
  118480. /**
  118481. * Define the UV chanel to use starting from 0 and defaulting to 0.
  118482. * This is part of the texture as textures usually maps to one uv set.
  118483. */
  118484. coordinatesIndex: number;
  118485. protected _coordinatesMode: number;
  118486. /**
  118487. * How a texture is mapped.
  118488. *
  118489. * | Value | Type | Description |
  118490. * | ----- | ----------------------------------- | ----------- |
  118491. * | 0 | EXPLICIT_MODE | |
  118492. * | 1 | SPHERICAL_MODE | |
  118493. * | 2 | PLANAR_MODE | |
  118494. * | 3 | CUBIC_MODE | |
  118495. * | 4 | PROJECTION_MODE | |
  118496. * | 5 | SKYBOX_MODE | |
  118497. * | 6 | INVCUBIC_MODE | |
  118498. * | 7 | EQUIRECTANGULAR_MODE | |
  118499. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  118500. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  118501. */
  118502. set coordinatesMode(value: number);
  118503. get coordinatesMode(): number;
  118504. private _wrapU;
  118505. /**
  118506. * | Value | Type | Description |
  118507. * | ----- | ------------------ | ----------- |
  118508. * | 0 | CLAMP_ADDRESSMODE | |
  118509. * | 1 | WRAP_ADDRESSMODE | |
  118510. * | 2 | MIRROR_ADDRESSMODE | |
  118511. */
  118512. get wrapU(): number;
  118513. set wrapU(value: number);
  118514. private _wrapV;
  118515. /**
  118516. * | Value | Type | Description |
  118517. * | ----- | ------------------ | ----------- |
  118518. * | 0 | CLAMP_ADDRESSMODE | |
  118519. * | 1 | WRAP_ADDRESSMODE | |
  118520. * | 2 | MIRROR_ADDRESSMODE | |
  118521. */
  118522. get wrapV(): number;
  118523. set wrapV(value: number);
  118524. /**
  118525. * | Value | Type | Description |
  118526. * | ----- | ------------------ | ----------- |
  118527. * | 0 | CLAMP_ADDRESSMODE | |
  118528. * | 1 | WRAP_ADDRESSMODE | |
  118529. * | 2 | MIRROR_ADDRESSMODE | |
  118530. */
  118531. wrapR: number;
  118532. /**
  118533. * With compliant hardware and browser (supporting anisotropic filtering)
  118534. * this defines the level of anisotropic filtering in the texture.
  118535. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  118536. */
  118537. anisotropicFilteringLevel: number;
  118538. /**
  118539. * Define if the texture is a cube texture or if false a 2d texture.
  118540. */
  118541. get isCube(): boolean;
  118542. set isCube(value: boolean);
  118543. /**
  118544. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  118545. */
  118546. get is3D(): boolean;
  118547. set is3D(value: boolean);
  118548. /**
  118549. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  118550. */
  118551. get is2DArray(): boolean;
  118552. set is2DArray(value: boolean);
  118553. private _gammaSpace;
  118554. /**
  118555. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  118556. * HDR texture are usually stored in linear space.
  118557. * This only impacts the PBR and Background materials
  118558. */
  118559. get gammaSpace(): boolean;
  118560. set gammaSpace(gamma: boolean);
  118561. /**
  118562. * Gets or sets whether or not the texture contains RGBD data.
  118563. */
  118564. get isRGBD(): boolean;
  118565. set isRGBD(value: boolean);
  118566. /**
  118567. * Is Z inverted in the texture (useful in a cube texture).
  118568. */
  118569. invertZ: boolean;
  118570. /**
  118571. * Are mip maps generated for this texture or not.
  118572. */
  118573. get noMipmap(): boolean;
  118574. /**
  118575. * @hidden
  118576. */
  118577. lodLevelInAlpha: boolean;
  118578. /**
  118579. * With prefiltered texture, defined the offset used during the prefiltering steps.
  118580. */
  118581. get lodGenerationOffset(): number;
  118582. set lodGenerationOffset(value: number);
  118583. /**
  118584. * With prefiltered texture, defined the scale used during the prefiltering steps.
  118585. */
  118586. get lodGenerationScale(): number;
  118587. set lodGenerationScale(value: number);
  118588. /**
  118589. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  118590. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  118591. * average roughness values.
  118592. */
  118593. get linearSpecularLOD(): boolean;
  118594. set linearSpecularLOD(value: boolean);
  118595. /**
  118596. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  118597. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  118598. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  118599. */
  118600. get irradianceTexture(): Nullable<BaseTexture>;
  118601. set irradianceTexture(value: Nullable<BaseTexture>);
  118602. /**
  118603. * Define if the texture is a render target.
  118604. */
  118605. isRenderTarget: boolean;
  118606. /**
  118607. * Define the unique id of the texture in the scene.
  118608. */
  118609. get uid(): string;
  118610. /** @hidden */
  118611. _prefiltered: boolean;
  118612. /**
  118613. * Return a string representation of the texture.
  118614. * @returns the texture as a string
  118615. */
  118616. toString(): string;
  118617. /**
  118618. * Get the class name of the texture.
  118619. * @returns "BaseTexture"
  118620. */
  118621. getClassName(): string;
  118622. /**
  118623. * Define the list of animation attached to the texture.
  118624. */
  118625. animations: Animation[];
  118626. /**
  118627. * An event triggered when the texture is disposed.
  118628. */
  118629. onDisposeObservable: Observable<BaseTexture>;
  118630. private _onDisposeObserver;
  118631. /**
  118632. * Callback triggered when the texture has been disposed.
  118633. * Kept for back compatibility, you can use the onDisposeObservable instead.
  118634. */
  118635. set onDispose(callback: () => void);
  118636. /**
  118637. * Define the current state of the loading sequence when in delayed load mode.
  118638. */
  118639. delayLoadState: number;
  118640. protected _scene: Nullable<Scene>;
  118641. protected _engine: Nullable<ThinEngine>;
  118642. /** @hidden */
  118643. _texture: Nullable<InternalTexture>;
  118644. private _uid;
  118645. /**
  118646. * Define if the texture is preventinga material to render or not.
  118647. * If not and the texture is not ready, the engine will use a default black texture instead.
  118648. */
  118649. get isBlocking(): boolean;
  118650. /**
  118651. * Instantiates a new BaseTexture.
  118652. * Base class of all the textures in babylon.
  118653. * It groups all the common properties the materials, post process, lights... might need
  118654. * in order to make a correct use of the texture.
  118655. * @param sceneOrEngine Define the scene or engine the texture blongs to
  118656. */
  118657. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  118658. /**
  118659. * Get the scene the texture belongs to.
  118660. * @returns the scene or null if undefined
  118661. */
  118662. getScene(): Nullable<Scene>;
  118663. /** @hidden */
  118664. protected _getEngine(): Nullable<ThinEngine>;
  118665. /**
  118666. * Checks if the texture has the same transform matrix than another texture
  118667. * @param texture texture to check against
  118668. * @returns true if the transforms are the same, else false
  118669. */
  118670. checkTransformsAreIdentical(texture: Nullable<BaseTexture>): boolean;
  118671. /**
  118672. * Get the texture transform matrix used to offset tile the texture for istance.
  118673. * @returns the transformation matrix
  118674. */
  118675. getTextureMatrix(): Matrix;
  118676. /**
  118677. * Get the texture reflection matrix used to rotate/transform the reflection.
  118678. * @returns the reflection matrix
  118679. */
  118680. getReflectionTextureMatrix(): Matrix;
  118681. /**
  118682. * Get the underlying lower level texture from Babylon.
  118683. * @returns the insternal texture
  118684. */
  118685. getInternalTexture(): Nullable<InternalTexture>;
  118686. /**
  118687. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  118688. * @returns true if ready or not blocking
  118689. */
  118690. isReadyOrNotBlocking(): boolean;
  118691. /**
  118692. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  118693. * @returns true if fully ready
  118694. */
  118695. isReady(): boolean;
  118696. private _cachedSize;
  118697. /**
  118698. * Get the size of the texture.
  118699. * @returns the texture size.
  118700. */
  118701. getSize(): ISize;
  118702. /**
  118703. * Get the base size of the texture.
  118704. * It can be different from the size if the texture has been resized for POT for instance
  118705. * @returns the base size
  118706. */
  118707. getBaseSize(): ISize;
  118708. /**
  118709. * Update the sampling mode of the texture.
  118710. * Default is Trilinear mode.
  118711. *
  118712. * | Value | Type | Description |
  118713. * | ----- | ------------------ | ----------- |
  118714. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  118715. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  118716. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  118717. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  118718. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  118719. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  118720. * | 7 | NEAREST_LINEAR | |
  118721. * | 8 | NEAREST_NEAREST | |
  118722. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  118723. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  118724. * | 11 | LINEAR_LINEAR | |
  118725. * | 12 | LINEAR_NEAREST | |
  118726. *
  118727. * > _mag_: magnification filter (close to the viewer)
  118728. * > _min_: minification filter (far from the viewer)
  118729. * > _mip_: filter used between mip map levels
  118730. *@param samplingMode Define the new sampling mode of the texture
  118731. */
  118732. updateSamplingMode(samplingMode: number): void;
  118733. /**
  118734. * Scales the texture if is `canRescale()`
  118735. * @param ratio the resize factor we want to use to rescale
  118736. */
  118737. scale(ratio: number): void;
  118738. /**
  118739. * Get if the texture can rescale.
  118740. */
  118741. get canRescale(): boolean;
  118742. /** @hidden */
  118743. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  118744. /** @hidden */
  118745. _rebuild(): void;
  118746. /**
  118747. * Triggers the load sequence in delayed load mode.
  118748. */
  118749. delayLoad(): void;
  118750. /**
  118751. * Clones the texture.
  118752. * @returns the cloned texture
  118753. */
  118754. clone(): Nullable<BaseTexture>;
  118755. /**
  118756. * Get the texture underlying type (INT, FLOAT...)
  118757. */
  118758. get textureType(): number;
  118759. /**
  118760. * Get the texture underlying format (RGB, RGBA...)
  118761. */
  118762. get textureFormat(): number;
  118763. /**
  118764. * Indicates that textures need to be re-calculated for all materials
  118765. */
  118766. protected _markAllSubMeshesAsTexturesDirty(): void;
  118767. /**
  118768. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  118769. * This will returns an RGBA array buffer containing either in values (0-255) or
  118770. * float values (0-1) depending of the underlying buffer type.
  118771. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  118772. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  118773. * @param buffer defines a user defined buffer to fill with data (can be null)
  118774. * @returns The Array buffer containing the pixels data.
  118775. */
  118776. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  118777. /**
  118778. * Release and destroy the underlying lower level texture aka internalTexture.
  118779. */
  118780. releaseInternalTexture(): void;
  118781. /** @hidden */
  118782. get _lodTextureHigh(): Nullable<BaseTexture>;
  118783. /** @hidden */
  118784. get _lodTextureMid(): Nullable<BaseTexture>;
  118785. /** @hidden */
  118786. get _lodTextureLow(): Nullable<BaseTexture>;
  118787. /**
  118788. * Dispose the texture and release its associated resources.
  118789. */
  118790. dispose(): void;
  118791. /**
  118792. * Serialize the texture into a JSON representation that can be parsed later on.
  118793. * @returns the JSON representation of the texture
  118794. */
  118795. serialize(): any;
  118796. /**
  118797. * Helper function to be called back once a list of texture contains only ready textures.
  118798. * @param textures Define the list of textures to wait for
  118799. * @param callback Define the callback triggered once the entire list will be ready
  118800. */
  118801. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  118802. private static _isScene;
  118803. }
  118804. }
  118805. declare module BABYLON {
  118806. /**
  118807. * Options to be used when creating an effect.
  118808. */
  118809. export interface IEffectCreationOptions {
  118810. /**
  118811. * Atrributes that will be used in the shader.
  118812. */
  118813. attributes: string[];
  118814. /**
  118815. * Uniform varible names that will be set in the shader.
  118816. */
  118817. uniformsNames: string[];
  118818. /**
  118819. * Uniform buffer variable names that will be set in the shader.
  118820. */
  118821. uniformBuffersNames: string[];
  118822. /**
  118823. * Sampler texture variable names that will be set in the shader.
  118824. */
  118825. samplers: string[];
  118826. /**
  118827. * Define statements that will be set in the shader.
  118828. */
  118829. defines: any;
  118830. /**
  118831. * Possible fallbacks for this effect to improve performance when needed.
  118832. */
  118833. fallbacks: Nullable<IEffectFallbacks>;
  118834. /**
  118835. * Callback that will be called when the shader is compiled.
  118836. */
  118837. onCompiled: Nullable<(effect: Effect) => void>;
  118838. /**
  118839. * Callback that will be called if an error occurs during shader compilation.
  118840. */
  118841. onError: Nullable<(effect: Effect, errors: string) => void>;
  118842. /**
  118843. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118844. */
  118845. indexParameters?: any;
  118846. /**
  118847. * Max number of lights that can be used in the shader.
  118848. */
  118849. maxSimultaneousLights?: number;
  118850. /**
  118851. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  118852. */
  118853. transformFeedbackVaryings?: Nullable<string[]>;
  118854. /**
  118855. * 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
  118856. */
  118857. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  118858. /**
  118859. * Is this effect rendering to several color attachments ?
  118860. */
  118861. multiTarget?: boolean;
  118862. }
  118863. /**
  118864. * Effect containing vertex and fragment shader that can be executed on an object.
  118865. */
  118866. export class Effect implements IDisposable {
  118867. /**
  118868. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  118869. */
  118870. static ShadersRepository: string;
  118871. /**
  118872. * Enable logging of the shader code when a compilation error occurs
  118873. */
  118874. static LogShaderCodeOnCompilationError: boolean;
  118875. /**
  118876. * Name of the effect.
  118877. */
  118878. name: any;
  118879. /**
  118880. * String container all the define statements that should be set on the shader.
  118881. */
  118882. defines: string;
  118883. /**
  118884. * Callback that will be called when the shader is compiled.
  118885. */
  118886. onCompiled: Nullable<(effect: Effect) => void>;
  118887. /**
  118888. * Callback that will be called if an error occurs during shader compilation.
  118889. */
  118890. onError: Nullable<(effect: Effect, errors: string) => void>;
  118891. /**
  118892. * Callback that will be called when effect is bound.
  118893. */
  118894. onBind: Nullable<(effect: Effect) => void>;
  118895. /**
  118896. * Unique ID of the effect.
  118897. */
  118898. uniqueId: number;
  118899. /**
  118900. * Observable that will be called when the shader is compiled.
  118901. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  118902. */
  118903. onCompileObservable: Observable<Effect>;
  118904. /**
  118905. * Observable that will be called if an error occurs during shader compilation.
  118906. */
  118907. onErrorObservable: Observable<Effect>;
  118908. /** @hidden */
  118909. _onBindObservable: Nullable<Observable<Effect>>;
  118910. /**
  118911. * @hidden
  118912. * Specifies if the effect was previously ready
  118913. */
  118914. _wasPreviouslyReady: boolean;
  118915. /**
  118916. * Observable that will be called when effect is bound.
  118917. */
  118918. get onBindObservable(): Observable<Effect>;
  118919. /** @hidden */
  118920. _bonesComputationForcedToCPU: boolean;
  118921. /** @hidden */
  118922. _multiTarget: boolean;
  118923. private static _uniqueIdSeed;
  118924. private _engine;
  118925. private _uniformBuffersNames;
  118926. private _uniformBuffersNamesList;
  118927. private _uniformsNames;
  118928. private _samplerList;
  118929. private _samplers;
  118930. private _isReady;
  118931. private _compilationError;
  118932. private _allFallbacksProcessed;
  118933. private _attributesNames;
  118934. private _attributes;
  118935. private _attributeLocationByName;
  118936. private _uniforms;
  118937. /**
  118938. * Key for the effect.
  118939. * @hidden
  118940. */
  118941. _key: string;
  118942. private _indexParameters;
  118943. private _fallbacks;
  118944. private _vertexSourceCode;
  118945. private _fragmentSourceCode;
  118946. private _vertexSourceCodeOverride;
  118947. private _fragmentSourceCodeOverride;
  118948. private _transformFeedbackVaryings;
  118949. /**
  118950. * Compiled shader to webGL program.
  118951. * @hidden
  118952. */
  118953. _pipelineContext: Nullable<IPipelineContext>;
  118954. private _valueCache;
  118955. private static _baseCache;
  118956. /**
  118957. * Instantiates an effect.
  118958. * An effect can be used to create/manage/execute vertex and fragment shaders.
  118959. * @param baseName Name of the effect.
  118960. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  118961. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  118962. * @param samplers List of sampler variables that will be passed to the shader.
  118963. * @param engine Engine to be used to render the effect
  118964. * @param defines Define statements to be added to the shader.
  118965. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  118966. * @param onCompiled Callback that will be called when the shader is compiled.
  118967. * @param onError Callback that will be called if an error occurs during shader compilation.
  118968. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  118969. */
  118970. 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);
  118971. private _useFinalCode;
  118972. /**
  118973. * Unique key for this effect
  118974. */
  118975. get key(): string;
  118976. /**
  118977. * If the effect has been compiled and prepared.
  118978. * @returns if the effect is compiled and prepared.
  118979. */
  118980. isReady(): boolean;
  118981. private _isReadyInternal;
  118982. /**
  118983. * The engine the effect was initialized with.
  118984. * @returns the engine.
  118985. */
  118986. getEngine(): Engine;
  118987. /**
  118988. * The pipeline context for this effect
  118989. * @returns the associated pipeline context
  118990. */
  118991. getPipelineContext(): Nullable<IPipelineContext>;
  118992. /**
  118993. * The set of names of attribute variables for the shader.
  118994. * @returns An array of attribute names.
  118995. */
  118996. getAttributesNames(): string[];
  118997. /**
  118998. * Returns the attribute at the given index.
  118999. * @param index The index of the attribute.
  119000. * @returns The location of the attribute.
  119001. */
  119002. getAttributeLocation(index: number): number;
  119003. /**
  119004. * Returns the attribute based on the name of the variable.
  119005. * @param name of the attribute to look up.
  119006. * @returns the attribute location.
  119007. */
  119008. getAttributeLocationByName(name: string): number;
  119009. /**
  119010. * The number of attributes.
  119011. * @returns the numnber of attributes.
  119012. */
  119013. getAttributesCount(): number;
  119014. /**
  119015. * Gets the index of a uniform variable.
  119016. * @param uniformName of the uniform to look up.
  119017. * @returns the index.
  119018. */
  119019. getUniformIndex(uniformName: string): number;
  119020. /**
  119021. * Returns the attribute based on the name of the variable.
  119022. * @param uniformName of the uniform to look up.
  119023. * @returns the location of the uniform.
  119024. */
  119025. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  119026. /**
  119027. * Returns an array of sampler variable names
  119028. * @returns The array of sampler variable names.
  119029. */
  119030. getSamplers(): string[];
  119031. /**
  119032. * Returns an array of uniform variable names
  119033. * @returns The array of uniform variable names.
  119034. */
  119035. getUniformNames(): string[];
  119036. /**
  119037. * Returns an array of uniform buffer variable names
  119038. * @returns The array of uniform buffer variable names.
  119039. */
  119040. getUniformBuffersNames(): string[];
  119041. /**
  119042. * Returns the index parameters used to create the effect
  119043. * @returns The index parameters object
  119044. */
  119045. getIndexParameters(): any;
  119046. /**
  119047. * The error from the last compilation.
  119048. * @returns the error string.
  119049. */
  119050. getCompilationError(): string;
  119051. /**
  119052. * Gets a boolean indicating that all fallbacks were used during compilation
  119053. * @returns true if all fallbacks were used
  119054. */
  119055. allFallbacksProcessed(): boolean;
  119056. /**
  119057. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  119058. * @param func The callback to be used.
  119059. */
  119060. executeWhenCompiled(func: (effect: Effect) => void): void;
  119061. private _checkIsReady;
  119062. private _loadShader;
  119063. /**
  119064. * Gets the vertex shader source code of this effect
  119065. */
  119066. get vertexSourceCode(): string;
  119067. /**
  119068. * Gets the fragment shader source code of this effect
  119069. */
  119070. get fragmentSourceCode(): string;
  119071. /**
  119072. * Recompiles the webGL program
  119073. * @param vertexSourceCode The source code for the vertex shader.
  119074. * @param fragmentSourceCode The source code for the fragment shader.
  119075. * @param onCompiled Callback called when completed.
  119076. * @param onError Callback called on error.
  119077. * @hidden
  119078. */
  119079. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  119080. /**
  119081. * Prepares the effect
  119082. * @hidden
  119083. */
  119084. _prepareEffect(): void;
  119085. private _getShaderCodeAndErrorLine;
  119086. private _processCompilationErrors;
  119087. /**
  119088. * Checks if the effect is supported. (Must be called after compilation)
  119089. */
  119090. get isSupported(): boolean;
  119091. /**
  119092. * Binds a texture to the engine to be used as output of the shader.
  119093. * @param channel Name of the output variable.
  119094. * @param texture Texture to bind.
  119095. * @hidden
  119096. */
  119097. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  119098. /**
  119099. * Sets a texture on the engine to be used in the shader.
  119100. * @param channel Name of the sampler variable.
  119101. * @param texture Texture to set.
  119102. */
  119103. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  119104. /**
  119105. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  119106. * @param channel Name of the sampler variable.
  119107. * @param texture Texture to set.
  119108. */
  119109. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  119110. /**
  119111. * Sets an array of textures on the engine to be used in the shader.
  119112. * @param channel Name of the variable.
  119113. * @param textures Textures to set.
  119114. */
  119115. setTextureArray(channel: string, textures: BaseTexture[]): void;
  119116. /**
  119117. * 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)
  119118. * @param channel Name of the sampler variable.
  119119. * @param postProcess Post process to get the input texture from.
  119120. */
  119121. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  119122. /**
  119123. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  119124. * 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)
  119125. * @param channel Name of the sampler variable.
  119126. * @param postProcess Post process to get the output texture from.
  119127. */
  119128. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  119129. /** @hidden */
  119130. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  119131. /** @hidden */
  119132. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  119133. /** @hidden */
  119134. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  119135. /** @hidden */
  119136. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  119137. /**
  119138. * Binds a buffer to a uniform.
  119139. * @param buffer Buffer to bind.
  119140. * @param name Name of the uniform variable to bind to.
  119141. */
  119142. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  119143. /**
  119144. * Binds block to a uniform.
  119145. * @param blockName Name of the block to bind.
  119146. * @param index Index to bind.
  119147. */
  119148. bindUniformBlock(blockName: string, index: number): void;
  119149. /**
  119150. * Sets an interger value on a uniform variable.
  119151. * @param uniformName Name of the variable.
  119152. * @param value Value to be set.
  119153. * @returns this effect.
  119154. */
  119155. setInt(uniformName: string, value: number): Effect;
  119156. /**
  119157. * Sets an int array on a uniform variable.
  119158. * @param uniformName Name of the variable.
  119159. * @param array array to be set.
  119160. * @returns this effect.
  119161. */
  119162. setIntArray(uniformName: string, array: Int32Array): Effect;
  119163. /**
  119164. * 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)
  119165. * @param uniformName Name of the variable.
  119166. * @param array array to be set.
  119167. * @returns this effect.
  119168. */
  119169. setIntArray2(uniformName: string, array: Int32Array): Effect;
  119170. /**
  119171. * 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)
  119172. * @param uniformName Name of the variable.
  119173. * @param array array to be set.
  119174. * @returns this effect.
  119175. */
  119176. setIntArray3(uniformName: string, array: Int32Array): Effect;
  119177. /**
  119178. * 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)
  119179. * @param uniformName Name of the variable.
  119180. * @param array array to be set.
  119181. * @returns this effect.
  119182. */
  119183. setIntArray4(uniformName: string, array: Int32Array): Effect;
  119184. /**
  119185. * Sets an float array on a uniform variable.
  119186. * @param uniformName Name of the variable.
  119187. * @param array array to be set.
  119188. * @returns this effect.
  119189. */
  119190. setFloatArray(uniformName: string, array: Float32Array): Effect;
  119191. /**
  119192. * 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)
  119193. * @param uniformName Name of the variable.
  119194. * @param array array to be set.
  119195. * @returns this effect.
  119196. */
  119197. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  119198. /**
  119199. * 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)
  119200. * @param uniformName Name of the variable.
  119201. * @param array array to be set.
  119202. * @returns this effect.
  119203. */
  119204. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  119205. /**
  119206. * 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)
  119207. * @param uniformName Name of the variable.
  119208. * @param array array to be set.
  119209. * @returns this effect.
  119210. */
  119211. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  119212. /**
  119213. * Sets an array on a uniform variable.
  119214. * @param uniformName Name of the variable.
  119215. * @param array array to be set.
  119216. * @returns this effect.
  119217. */
  119218. setArray(uniformName: string, array: number[]): Effect;
  119219. /**
  119220. * 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)
  119221. * @param uniformName Name of the variable.
  119222. * @param array array to be set.
  119223. * @returns this effect.
  119224. */
  119225. setArray2(uniformName: string, array: number[]): Effect;
  119226. /**
  119227. * 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)
  119228. * @param uniformName Name of the variable.
  119229. * @param array array to be set.
  119230. * @returns this effect.
  119231. */
  119232. setArray3(uniformName: string, array: number[]): Effect;
  119233. /**
  119234. * 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)
  119235. * @param uniformName Name of the variable.
  119236. * @param array array to be set.
  119237. * @returns this effect.
  119238. */
  119239. setArray4(uniformName: string, array: number[]): Effect;
  119240. /**
  119241. * Sets matrices on a uniform variable.
  119242. * @param uniformName Name of the variable.
  119243. * @param matrices matrices to be set.
  119244. * @returns this effect.
  119245. */
  119246. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  119247. /**
  119248. * Sets matrix on a uniform variable.
  119249. * @param uniformName Name of the variable.
  119250. * @param matrix matrix to be set.
  119251. * @returns this effect.
  119252. */
  119253. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  119254. /**
  119255. * 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)
  119256. * @param uniformName Name of the variable.
  119257. * @param matrix matrix to be set.
  119258. * @returns this effect.
  119259. */
  119260. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  119261. /**
  119262. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  119263. * @param uniformName Name of the variable.
  119264. * @param matrix matrix to be set.
  119265. * @returns this effect.
  119266. */
  119267. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  119268. /**
  119269. * Sets a float on a uniform variable.
  119270. * @param uniformName Name of the variable.
  119271. * @param value value to be set.
  119272. * @returns this effect.
  119273. */
  119274. setFloat(uniformName: string, value: number): Effect;
  119275. /**
  119276. * Sets a boolean on a uniform variable.
  119277. * @param uniformName Name of the variable.
  119278. * @param bool value to be set.
  119279. * @returns this effect.
  119280. */
  119281. setBool(uniformName: string, bool: boolean): Effect;
  119282. /**
  119283. * Sets a Vector2 on a uniform variable.
  119284. * @param uniformName Name of the variable.
  119285. * @param vector2 vector2 to be set.
  119286. * @returns this effect.
  119287. */
  119288. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  119289. /**
  119290. * Sets a float2 on a uniform variable.
  119291. * @param uniformName Name of the variable.
  119292. * @param x First float in float2.
  119293. * @param y Second float in float2.
  119294. * @returns this effect.
  119295. */
  119296. setFloat2(uniformName: string, x: number, y: number): Effect;
  119297. /**
  119298. * Sets a Vector3 on a uniform variable.
  119299. * @param uniformName Name of the variable.
  119300. * @param vector3 Value to be set.
  119301. * @returns this effect.
  119302. */
  119303. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  119304. /**
  119305. * Sets a float3 on a uniform variable.
  119306. * @param uniformName Name of the variable.
  119307. * @param x First float in float3.
  119308. * @param y Second float in float3.
  119309. * @param z Third float in float3.
  119310. * @returns this effect.
  119311. */
  119312. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  119313. /**
  119314. * Sets a Vector4 on a uniform variable.
  119315. * @param uniformName Name of the variable.
  119316. * @param vector4 Value to be set.
  119317. * @returns this effect.
  119318. */
  119319. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  119320. /**
  119321. * Sets a float4 on a uniform variable.
  119322. * @param uniformName Name of the variable.
  119323. * @param x First float in float4.
  119324. * @param y Second float in float4.
  119325. * @param z Third float in float4.
  119326. * @param w Fourth float in float4.
  119327. * @returns this effect.
  119328. */
  119329. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  119330. /**
  119331. * Sets a Color3 on a uniform variable.
  119332. * @param uniformName Name of the variable.
  119333. * @param color3 Value to be set.
  119334. * @returns this effect.
  119335. */
  119336. setColor3(uniformName: string, color3: IColor3Like): Effect;
  119337. /**
  119338. * Sets a Color4 on a uniform variable.
  119339. * @param uniformName Name of the variable.
  119340. * @param color3 Value to be set.
  119341. * @param alpha Alpha value to be set.
  119342. * @returns this effect.
  119343. */
  119344. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  119345. /**
  119346. * Sets a Color4 on a uniform variable
  119347. * @param uniformName defines the name of the variable
  119348. * @param color4 defines the value to be set
  119349. * @returns this effect.
  119350. */
  119351. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  119352. /** Release all associated resources */
  119353. dispose(): void;
  119354. /**
  119355. * This function will add a new shader to the shader store
  119356. * @param name the name of the shader
  119357. * @param pixelShader optional pixel shader content
  119358. * @param vertexShader optional vertex shader content
  119359. */
  119360. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  119361. /**
  119362. * Store of each shader (The can be looked up using effect.key)
  119363. */
  119364. static ShadersStore: {
  119365. [key: string]: string;
  119366. };
  119367. /**
  119368. * Store of each included file for a shader (The can be looked up using effect.key)
  119369. */
  119370. static IncludesShadersStore: {
  119371. [key: string]: string;
  119372. };
  119373. /**
  119374. * Resets the cache of effects.
  119375. */
  119376. static ResetCache(): void;
  119377. }
  119378. }
  119379. declare module BABYLON {
  119380. /**
  119381. * Interface used to describe the capabilities of the engine relatively to the current browser
  119382. */
  119383. export interface EngineCapabilities {
  119384. /** Maximum textures units per fragment shader */
  119385. maxTexturesImageUnits: number;
  119386. /** Maximum texture units per vertex shader */
  119387. maxVertexTextureImageUnits: number;
  119388. /** Maximum textures units in the entire pipeline */
  119389. maxCombinedTexturesImageUnits: number;
  119390. /** Maximum texture size */
  119391. maxTextureSize: number;
  119392. /** Maximum texture samples */
  119393. maxSamples?: number;
  119394. /** Maximum cube texture size */
  119395. maxCubemapTextureSize: number;
  119396. /** Maximum render texture size */
  119397. maxRenderTextureSize: number;
  119398. /** Maximum number of vertex attributes */
  119399. maxVertexAttribs: number;
  119400. /** Maximum number of varyings */
  119401. maxVaryingVectors: number;
  119402. /** Maximum number of uniforms per vertex shader */
  119403. maxVertexUniformVectors: number;
  119404. /** Maximum number of uniforms per fragment shader */
  119405. maxFragmentUniformVectors: number;
  119406. /** Defines if standard derivates (dx/dy) are supported */
  119407. standardDerivatives: boolean;
  119408. /** Defines if s3tc texture compression is supported */
  119409. s3tc?: WEBGL_compressed_texture_s3tc;
  119410. /** Defines if pvrtc texture compression is supported */
  119411. pvrtc: any;
  119412. /** Defines if etc1 texture compression is supported */
  119413. etc1: any;
  119414. /** Defines if etc2 texture compression is supported */
  119415. etc2: any;
  119416. /** Defines if astc texture compression is supported */
  119417. astc: any;
  119418. /** Defines if bptc texture compression is supported */
  119419. bptc: any;
  119420. /** Defines if float textures are supported */
  119421. textureFloat: boolean;
  119422. /** Defines if vertex array objects are supported */
  119423. vertexArrayObject: boolean;
  119424. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  119425. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  119426. /** Gets the maximum level of anisotropy supported */
  119427. maxAnisotropy: number;
  119428. /** Defines if instancing is supported */
  119429. instancedArrays: boolean;
  119430. /** Defines if 32 bits indices are supported */
  119431. uintIndices: boolean;
  119432. /** Defines if high precision shaders are supported */
  119433. highPrecisionShaderSupported: boolean;
  119434. /** Defines if depth reading in the fragment shader is supported */
  119435. fragmentDepthSupported: boolean;
  119436. /** Defines if float texture linear filtering is supported*/
  119437. textureFloatLinearFiltering: boolean;
  119438. /** Defines if rendering to float textures is supported */
  119439. textureFloatRender: boolean;
  119440. /** Defines if half float textures are supported*/
  119441. textureHalfFloat: boolean;
  119442. /** Defines if half float texture linear filtering is supported*/
  119443. textureHalfFloatLinearFiltering: boolean;
  119444. /** Defines if rendering to half float textures is supported */
  119445. textureHalfFloatRender: boolean;
  119446. /** Defines if textureLOD shader command is supported */
  119447. textureLOD: boolean;
  119448. /** Defines if draw buffers extension is supported */
  119449. drawBuffersExtension: boolean;
  119450. /** Defines if depth textures are supported */
  119451. depthTextureExtension: boolean;
  119452. /** Defines if float color buffer are supported */
  119453. colorBufferFloat: boolean;
  119454. /** Gets disjoint timer query extension (null if not supported) */
  119455. timerQuery?: EXT_disjoint_timer_query;
  119456. /** Defines if timestamp can be used with timer query */
  119457. canUseTimestampForTimerQuery: boolean;
  119458. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  119459. multiview?: any;
  119460. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  119461. oculusMultiview?: any;
  119462. /** Function used to let the system compiles shaders in background */
  119463. parallelShaderCompile?: {
  119464. COMPLETION_STATUS_KHR: number;
  119465. };
  119466. /** Max number of texture samples for MSAA */
  119467. maxMSAASamples: number;
  119468. /** Defines if the blend min max extension is supported */
  119469. blendMinMax: boolean;
  119470. }
  119471. }
  119472. declare module BABYLON {
  119473. /**
  119474. * @hidden
  119475. **/
  119476. export class DepthCullingState {
  119477. private _isDepthTestDirty;
  119478. private _isDepthMaskDirty;
  119479. private _isDepthFuncDirty;
  119480. private _isCullFaceDirty;
  119481. private _isCullDirty;
  119482. private _isZOffsetDirty;
  119483. private _isFrontFaceDirty;
  119484. private _depthTest;
  119485. private _depthMask;
  119486. private _depthFunc;
  119487. private _cull;
  119488. private _cullFace;
  119489. private _zOffset;
  119490. private _frontFace;
  119491. /**
  119492. * Initializes the state.
  119493. */
  119494. constructor();
  119495. get isDirty(): boolean;
  119496. get zOffset(): number;
  119497. set zOffset(value: number);
  119498. get cullFace(): Nullable<number>;
  119499. set cullFace(value: Nullable<number>);
  119500. get cull(): Nullable<boolean>;
  119501. set cull(value: Nullable<boolean>);
  119502. get depthFunc(): Nullable<number>;
  119503. set depthFunc(value: Nullable<number>);
  119504. get depthMask(): boolean;
  119505. set depthMask(value: boolean);
  119506. get depthTest(): boolean;
  119507. set depthTest(value: boolean);
  119508. get frontFace(): Nullable<number>;
  119509. set frontFace(value: Nullable<number>);
  119510. reset(): void;
  119511. apply(gl: WebGLRenderingContext): void;
  119512. }
  119513. }
  119514. declare module BABYLON {
  119515. /**
  119516. * @hidden
  119517. **/
  119518. export class StencilState {
  119519. /** 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 */
  119520. static readonly ALWAYS: number;
  119521. /** Passed to stencilOperation to specify that stencil value must be kept */
  119522. static readonly KEEP: number;
  119523. /** Passed to stencilOperation to specify that stencil value must be replaced */
  119524. static readonly REPLACE: number;
  119525. private _isStencilTestDirty;
  119526. private _isStencilMaskDirty;
  119527. private _isStencilFuncDirty;
  119528. private _isStencilOpDirty;
  119529. private _stencilTest;
  119530. private _stencilMask;
  119531. private _stencilFunc;
  119532. private _stencilFuncRef;
  119533. private _stencilFuncMask;
  119534. private _stencilOpStencilFail;
  119535. private _stencilOpDepthFail;
  119536. private _stencilOpStencilDepthPass;
  119537. get isDirty(): boolean;
  119538. get stencilFunc(): number;
  119539. set stencilFunc(value: number);
  119540. get stencilFuncRef(): number;
  119541. set stencilFuncRef(value: number);
  119542. get stencilFuncMask(): number;
  119543. set stencilFuncMask(value: number);
  119544. get stencilOpStencilFail(): number;
  119545. set stencilOpStencilFail(value: number);
  119546. get stencilOpDepthFail(): number;
  119547. set stencilOpDepthFail(value: number);
  119548. get stencilOpStencilDepthPass(): number;
  119549. set stencilOpStencilDepthPass(value: number);
  119550. get stencilMask(): number;
  119551. set stencilMask(value: number);
  119552. get stencilTest(): boolean;
  119553. set stencilTest(value: boolean);
  119554. constructor();
  119555. reset(): void;
  119556. apply(gl: WebGLRenderingContext): void;
  119557. }
  119558. }
  119559. declare module BABYLON {
  119560. /**
  119561. * @hidden
  119562. **/
  119563. export class AlphaState {
  119564. private _isAlphaBlendDirty;
  119565. private _isBlendFunctionParametersDirty;
  119566. private _isBlendEquationParametersDirty;
  119567. private _isBlendConstantsDirty;
  119568. private _alphaBlend;
  119569. private _blendFunctionParameters;
  119570. private _blendEquationParameters;
  119571. private _blendConstants;
  119572. /**
  119573. * Initializes the state.
  119574. */
  119575. constructor();
  119576. get isDirty(): boolean;
  119577. get alphaBlend(): boolean;
  119578. set alphaBlend(value: boolean);
  119579. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  119580. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  119581. setAlphaEquationParameters(rgb: number, alpha: number): void;
  119582. reset(): void;
  119583. apply(gl: WebGLRenderingContext): void;
  119584. }
  119585. }
  119586. declare module BABYLON {
  119587. /** @hidden */
  119588. export class WebGLShaderProcessor implements IShaderProcessor {
  119589. postProcessor(code: string, defines: string[], isFragment: boolean, engine: ThinEngine): string;
  119590. }
  119591. }
  119592. declare module BABYLON {
  119593. /** @hidden */
  119594. export class WebGL2ShaderProcessor implements IShaderProcessor {
  119595. attributeProcessor(attribute: string): string;
  119596. varyingProcessor(varying: string, isFragment: boolean): string;
  119597. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  119598. }
  119599. }
  119600. declare module BABYLON {
  119601. /**
  119602. * Interface for attribute information associated with buffer instanciation
  119603. */
  119604. export interface InstancingAttributeInfo {
  119605. /**
  119606. * Name of the GLSL attribute
  119607. * if attribute index is not specified, this is used to retrieve the index from the effect
  119608. */
  119609. attributeName: string;
  119610. /**
  119611. * Index/offset of the attribute in the vertex shader
  119612. * if not specified, this will be computes from the name.
  119613. */
  119614. index?: number;
  119615. /**
  119616. * size of the attribute, 1, 2, 3 or 4
  119617. */
  119618. attributeSize: number;
  119619. /**
  119620. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  119621. */
  119622. offset: number;
  119623. /**
  119624. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  119625. * default to 1
  119626. */
  119627. divisor?: number;
  119628. /**
  119629. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  119630. * default is FLOAT
  119631. */
  119632. attributeType?: number;
  119633. /**
  119634. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  119635. */
  119636. normalized?: boolean;
  119637. }
  119638. }
  119639. declare module BABYLON {
  119640. interface ThinEngine {
  119641. /**
  119642. * Update a video texture
  119643. * @param texture defines the texture to update
  119644. * @param video defines the video element to use
  119645. * @param invertY defines if data must be stored with Y axis inverted
  119646. */
  119647. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  119648. }
  119649. }
  119650. declare module BABYLON {
  119651. interface ThinEngine {
  119652. /**
  119653. * Creates a dynamic texture
  119654. * @param width defines the width of the texture
  119655. * @param height defines the height of the texture
  119656. * @param generateMipMaps defines if the engine should generate the mip levels
  119657. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  119658. * @returns the dynamic texture inside an InternalTexture
  119659. */
  119660. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  119661. /**
  119662. * Update the content of a dynamic texture
  119663. * @param texture defines the texture to update
  119664. * @param canvas defines the canvas containing the source
  119665. * @param invertY defines if data must be stored with Y axis inverted
  119666. * @param premulAlpha defines if alpha is stored as premultiplied
  119667. * @param format defines the format of the data
  119668. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119669. */
  119670. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  119671. }
  119672. }
  119673. declare module BABYLON {
  119674. /**
  119675. * Settings for finer control over video usage
  119676. */
  119677. export interface VideoTextureSettings {
  119678. /**
  119679. * Applies `autoplay` to video, if specified
  119680. */
  119681. autoPlay?: boolean;
  119682. /**
  119683. * Applies `muted` to video, if specified
  119684. */
  119685. muted?: boolean;
  119686. /**
  119687. * Applies `loop` to video, if specified
  119688. */
  119689. loop?: boolean;
  119690. /**
  119691. * Automatically updates internal texture from video at every frame in the render loop
  119692. */
  119693. autoUpdateTexture: boolean;
  119694. /**
  119695. * Image src displayed during the video loading or until the user interacts with the video.
  119696. */
  119697. poster?: string;
  119698. }
  119699. /**
  119700. * If you want to display a video in your scene, this is the special texture for that.
  119701. * This special texture works similar to other textures, with the exception of a few parameters.
  119702. * @see https://doc.babylonjs.com/how_to/video_texture
  119703. */
  119704. export class VideoTexture extends Texture {
  119705. /**
  119706. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  119707. */
  119708. readonly autoUpdateTexture: boolean;
  119709. /**
  119710. * The video instance used by the texture internally
  119711. */
  119712. readonly video: HTMLVideoElement;
  119713. private _onUserActionRequestedObservable;
  119714. /**
  119715. * Event triggerd when a dom action is required by the user to play the video.
  119716. * This happens due to recent changes in browser policies preventing video to auto start.
  119717. */
  119718. get onUserActionRequestedObservable(): Observable<Texture>;
  119719. private _generateMipMaps;
  119720. private _stillImageCaptured;
  119721. private _displayingPosterTexture;
  119722. private _settings;
  119723. private _createInternalTextureOnEvent;
  119724. private _frameId;
  119725. private _currentSrc;
  119726. /**
  119727. * Creates a video texture.
  119728. * If you want to display a video in your scene, this is the special texture for that.
  119729. * This special texture works similar to other textures, with the exception of a few parameters.
  119730. * @see https://doc.babylonjs.com/how_to/video_texture
  119731. * @param name optional name, will detect from video source, if not defined
  119732. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  119733. * @param scene is obviously the current scene.
  119734. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  119735. * @param invertY is false by default but can be used to invert video on Y axis
  119736. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  119737. * @param settings allows finer control over video usage
  119738. */
  119739. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  119740. private _getName;
  119741. private _getVideo;
  119742. private _createInternalTexture;
  119743. private reset;
  119744. /**
  119745. * @hidden Internal method to initiate `update`.
  119746. */
  119747. _rebuild(): void;
  119748. /**
  119749. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  119750. */
  119751. update(): void;
  119752. /**
  119753. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  119754. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  119755. */
  119756. updateTexture(isVisible: boolean): void;
  119757. protected _updateInternalTexture: () => void;
  119758. /**
  119759. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  119760. * @param url New url.
  119761. */
  119762. updateURL(url: string): void;
  119763. /**
  119764. * Clones the texture.
  119765. * @returns the cloned texture
  119766. */
  119767. clone(): VideoTexture;
  119768. /**
  119769. * Dispose the texture and release its associated resources.
  119770. */
  119771. dispose(): void;
  119772. /**
  119773. * Creates a video texture straight from a stream.
  119774. * @param scene Define the scene the texture should be created in
  119775. * @param stream Define the stream the texture should be created from
  119776. * @returns The created video texture as a promise
  119777. */
  119778. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  119779. /**
  119780. * Creates a video texture straight from your WebCam video feed.
  119781. * @param scene Define the scene the texture should be created in
  119782. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119783. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119784. * @returns The created video texture as a promise
  119785. */
  119786. static CreateFromWebCamAsync(scene: Scene, constraints: {
  119787. minWidth: number;
  119788. maxWidth: number;
  119789. minHeight: number;
  119790. maxHeight: number;
  119791. deviceId: string;
  119792. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  119793. /**
  119794. * Creates a video texture straight from your WebCam video feed.
  119795. * @param scene Define the scene the texture should be created in
  119796. * @param onReady Define a callback to triggered once the texture will be ready
  119797. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  119798. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  119799. */
  119800. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  119801. minWidth: number;
  119802. maxWidth: number;
  119803. minHeight: number;
  119804. maxHeight: number;
  119805. deviceId: string;
  119806. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  119807. }
  119808. }
  119809. declare module BABYLON {
  119810. /**
  119811. * Defines the interface used by objects working like Scene
  119812. * @hidden
  119813. */
  119814. export interface ISceneLike {
  119815. _addPendingData(data: any): void;
  119816. _removePendingData(data: any): void;
  119817. offlineProvider: IOfflineProvider;
  119818. }
  119819. /**
  119820. * Information about the current host
  119821. */
  119822. export interface HostInformation {
  119823. /**
  119824. * Defines if the current host is a mobile
  119825. */
  119826. isMobile: boolean;
  119827. }
  119828. /** Interface defining initialization parameters for Engine class */
  119829. export interface EngineOptions extends WebGLContextAttributes {
  119830. /**
  119831. * Defines if the engine should no exceed a specified device ratio
  119832. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  119833. */
  119834. limitDeviceRatio?: number;
  119835. /**
  119836. * Defines if webvr should be enabled automatically
  119837. * @see https://doc.babylonjs.com/how_to/webvr_camera
  119838. */
  119839. autoEnableWebVR?: boolean;
  119840. /**
  119841. * Defines if webgl2 should be turned off even if supported
  119842. * @see https://doc.babylonjs.com/features/webgl2
  119843. */
  119844. disableWebGL2Support?: boolean;
  119845. /**
  119846. * Defines if webaudio should be initialized as well
  119847. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119848. */
  119849. audioEngine?: boolean;
  119850. /**
  119851. * Defines if animations should run using a deterministic lock step
  119852. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119853. */
  119854. deterministicLockstep?: boolean;
  119855. /** Defines the maximum steps to use with deterministic lock step mode */
  119856. lockstepMaxSteps?: number;
  119857. /** Defines the seconds between each deterministic lock step */
  119858. timeStep?: number;
  119859. /**
  119860. * Defines that engine should ignore context lost events
  119861. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  119862. */
  119863. doNotHandleContextLost?: boolean;
  119864. /**
  119865. * Defines that engine should ignore modifying touch action attribute and style
  119866. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  119867. */
  119868. doNotHandleTouchAction?: boolean;
  119869. /**
  119870. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  119871. */
  119872. useHighPrecisionFloats?: boolean;
  119873. /**
  119874. * Make the canvas XR Compatible for XR sessions
  119875. */
  119876. xrCompatible?: boolean;
  119877. /**
  119878. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  119879. */
  119880. useHighPrecisionMatrix?: boolean;
  119881. /**
  119882. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  119883. */
  119884. failIfMajorPerformanceCaveat?: boolean;
  119885. }
  119886. /**
  119887. * The base engine class (root of all engines)
  119888. */
  119889. export class ThinEngine {
  119890. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  119891. static ExceptionList: ({
  119892. key: string;
  119893. capture: string;
  119894. captureConstraint: number;
  119895. targets: string[];
  119896. } | {
  119897. key: string;
  119898. capture: null;
  119899. captureConstraint: null;
  119900. targets: string[];
  119901. })[];
  119902. /** @hidden */
  119903. static _TextureLoaders: IInternalTextureLoader[];
  119904. /**
  119905. * Returns the current npm package of the sdk
  119906. */
  119907. static get NpmPackage(): string;
  119908. /**
  119909. * Returns the current version of the framework
  119910. */
  119911. static get Version(): string;
  119912. /**
  119913. * Returns a string describing the current engine
  119914. */
  119915. get description(): string;
  119916. /**
  119917. * Gets or sets the epsilon value used by collision engine
  119918. */
  119919. static CollisionsEpsilon: number;
  119920. /**
  119921. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  119922. */
  119923. static get ShadersRepository(): string;
  119924. static set ShadersRepository(value: string);
  119925. /** @hidden */
  119926. _shaderProcessor: IShaderProcessor;
  119927. /**
  119928. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  119929. */
  119930. forcePOTTextures: boolean;
  119931. /**
  119932. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  119933. */
  119934. isFullscreen: boolean;
  119935. /**
  119936. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  119937. */
  119938. cullBackFaces: boolean;
  119939. /**
  119940. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  119941. */
  119942. renderEvenInBackground: boolean;
  119943. /**
  119944. * Gets or sets a boolean indicating that cache can be kept between frames
  119945. */
  119946. preventCacheWipeBetweenFrames: boolean;
  119947. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  119948. validateShaderPrograms: boolean;
  119949. /**
  119950. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  119951. * This can provide greater z depth for distant objects.
  119952. */
  119953. useReverseDepthBuffer: boolean;
  119954. /**
  119955. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  119956. */
  119957. disableUniformBuffers: boolean;
  119958. /** @hidden */
  119959. _uniformBuffers: UniformBuffer[];
  119960. /**
  119961. * Gets a boolean indicating that the engine supports uniform buffers
  119962. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  119963. */
  119964. get supportsUniformBuffers(): boolean;
  119965. /** @hidden */
  119966. _gl: WebGLRenderingContext;
  119967. /** @hidden */
  119968. _webGLVersion: number;
  119969. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  119970. protected _windowIsBackground: boolean;
  119971. protected _creationOptions: EngineOptions;
  119972. protected _highPrecisionShadersAllowed: boolean;
  119973. /** @hidden */
  119974. get _shouldUseHighPrecisionShader(): boolean;
  119975. /**
  119976. * Gets a boolean indicating that only power of 2 textures are supported
  119977. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  119978. */
  119979. get needPOTTextures(): boolean;
  119980. /** @hidden */
  119981. _badOS: boolean;
  119982. /** @hidden */
  119983. _badDesktopOS: boolean;
  119984. private _hardwareScalingLevel;
  119985. /** @hidden */
  119986. _caps: EngineCapabilities;
  119987. private _isStencilEnable;
  119988. private _glVersion;
  119989. private _glRenderer;
  119990. private _glVendor;
  119991. /** @hidden */
  119992. _videoTextureSupported: boolean;
  119993. protected _renderingQueueLaunched: boolean;
  119994. protected _activeRenderLoops: (() => void)[];
  119995. /**
  119996. * Observable signaled when a context lost event is raised
  119997. */
  119998. onContextLostObservable: Observable<ThinEngine>;
  119999. /**
  120000. * Observable signaled when a context restored event is raised
  120001. */
  120002. onContextRestoredObservable: Observable<ThinEngine>;
  120003. private _onContextLost;
  120004. private _onContextRestored;
  120005. protected _contextWasLost: boolean;
  120006. /** @hidden */
  120007. _doNotHandleContextLost: boolean;
  120008. /**
  120009. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  120010. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  120011. */
  120012. get doNotHandleContextLost(): boolean;
  120013. set doNotHandleContextLost(value: boolean);
  120014. /**
  120015. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  120016. */
  120017. disableVertexArrayObjects: boolean;
  120018. /** @hidden */
  120019. protected _colorWrite: boolean;
  120020. /** @hidden */
  120021. protected _colorWriteChanged: boolean;
  120022. /** @hidden */
  120023. protected _depthCullingState: DepthCullingState;
  120024. /** @hidden */
  120025. protected _stencilState: StencilState;
  120026. /** @hidden */
  120027. _alphaState: AlphaState;
  120028. /** @hidden */
  120029. _alphaMode: number;
  120030. /** @hidden */
  120031. _alphaEquation: number;
  120032. /** @hidden */
  120033. _internalTexturesCache: InternalTexture[];
  120034. /** @hidden */
  120035. protected _activeChannel: number;
  120036. private _currentTextureChannel;
  120037. /** @hidden */
  120038. protected _boundTexturesCache: {
  120039. [key: string]: Nullable<InternalTexture>;
  120040. };
  120041. /** @hidden */
  120042. protected _currentEffect: Nullable<Effect>;
  120043. /** @hidden */
  120044. protected _currentProgram: Nullable<WebGLProgram>;
  120045. private _compiledEffects;
  120046. private _vertexAttribArraysEnabled;
  120047. /** @hidden */
  120048. protected _cachedViewport: Nullable<IViewportLike>;
  120049. private _cachedVertexArrayObject;
  120050. /** @hidden */
  120051. protected _cachedVertexBuffers: any;
  120052. /** @hidden */
  120053. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  120054. /** @hidden */
  120055. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  120056. /** @hidden */
  120057. _currentRenderTarget: Nullable<InternalTexture>;
  120058. private _uintIndicesCurrentlySet;
  120059. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  120060. /** @hidden */
  120061. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  120062. /** @hidden */
  120063. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  120064. private _currentBufferPointers;
  120065. private _currentInstanceLocations;
  120066. private _currentInstanceBuffers;
  120067. private _textureUnits;
  120068. /** @hidden */
  120069. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  120070. /** @hidden */
  120071. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  120072. /** @hidden */
  120073. _boundRenderFunction: any;
  120074. private _vaoRecordInProgress;
  120075. private _mustWipeVertexAttributes;
  120076. private _emptyTexture;
  120077. private _emptyCubeTexture;
  120078. private _emptyTexture3D;
  120079. private _emptyTexture2DArray;
  120080. /** @hidden */
  120081. _frameHandler: number;
  120082. private _nextFreeTextureSlots;
  120083. private _maxSimultaneousTextures;
  120084. private _activeRequests;
  120085. /** @hidden */
  120086. _transformTextureUrl: Nullable<(url: string) => string>;
  120087. /**
  120088. * Gets information about the current host
  120089. */
  120090. hostInformation: HostInformation;
  120091. protected get _supportsHardwareTextureRescaling(): boolean;
  120092. private _framebufferDimensionsObject;
  120093. /**
  120094. * sets the object from which width and height will be taken from when getting render width and height
  120095. * Will fallback to the gl object
  120096. * @param dimensions the framebuffer width and height that will be used.
  120097. */
  120098. set framebufferDimensionsObject(dimensions: Nullable<{
  120099. framebufferWidth: number;
  120100. framebufferHeight: number;
  120101. }>);
  120102. /**
  120103. * Gets the current viewport
  120104. */
  120105. get currentViewport(): Nullable<IViewportLike>;
  120106. /**
  120107. * Gets the default empty texture
  120108. */
  120109. get emptyTexture(): InternalTexture;
  120110. /**
  120111. * Gets the default empty 3D texture
  120112. */
  120113. get emptyTexture3D(): InternalTexture;
  120114. /**
  120115. * Gets the default empty 2D array texture
  120116. */
  120117. get emptyTexture2DArray(): InternalTexture;
  120118. /**
  120119. * Gets the default empty cube texture
  120120. */
  120121. get emptyCubeTexture(): InternalTexture;
  120122. /**
  120123. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  120124. */
  120125. readonly premultipliedAlpha: boolean;
  120126. /**
  120127. * Observable event triggered before each texture is initialized
  120128. */
  120129. onBeforeTextureInitObservable: Observable<Texture>;
  120130. /**
  120131. * Creates a new engine
  120132. * @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
  120133. * @param antialias defines enable antialiasing (default: false)
  120134. * @param options defines further options to be sent to the getContext() function
  120135. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  120136. */
  120137. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  120138. private _rebuildInternalTextures;
  120139. private _rebuildEffects;
  120140. /**
  120141. * Gets a boolean indicating if all created effects are ready
  120142. * @returns true if all effects are ready
  120143. */
  120144. areAllEffectsReady(): boolean;
  120145. protected _rebuildBuffers(): void;
  120146. protected _initGLContext(): void;
  120147. /**
  120148. * Gets version of the current webGL context
  120149. */
  120150. get webGLVersion(): number;
  120151. /**
  120152. * Gets a string identifying the name of the class
  120153. * @returns "Engine" string
  120154. */
  120155. getClassName(): string;
  120156. /**
  120157. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  120158. */
  120159. get isStencilEnable(): boolean;
  120160. /** @hidden */
  120161. _prepareWorkingCanvas(): void;
  120162. /**
  120163. * Reset the texture cache to empty state
  120164. */
  120165. resetTextureCache(): void;
  120166. /**
  120167. * Gets an object containing information about the current webGL context
  120168. * @returns an object containing the vender, the renderer and the version of the current webGL context
  120169. */
  120170. getGlInfo(): {
  120171. vendor: string;
  120172. renderer: string;
  120173. version: string;
  120174. };
  120175. /**
  120176. * Defines the hardware scaling level.
  120177. * By default the hardware scaling level is computed from the window device ratio.
  120178. * 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.
  120179. * @param level defines the level to use
  120180. */
  120181. setHardwareScalingLevel(level: number): void;
  120182. /**
  120183. * Gets the current hardware scaling level.
  120184. * By default the hardware scaling level is computed from the window device ratio.
  120185. * 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.
  120186. * @returns a number indicating the current hardware scaling level
  120187. */
  120188. getHardwareScalingLevel(): number;
  120189. /**
  120190. * Gets the list of loaded textures
  120191. * @returns an array containing all loaded textures
  120192. */
  120193. getLoadedTexturesCache(): InternalTexture[];
  120194. /**
  120195. * Gets the object containing all engine capabilities
  120196. * @returns the EngineCapabilities object
  120197. */
  120198. getCaps(): EngineCapabilities;
  120199. /**
  120200. * stop executing a render loop function and remove it from the execution array
  120201. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  120202. */
  120203. stopRenderLoop(renderFunction?: () => void): void;
  120204. /** @hidden */
  120205. _renderLoop(): void;
  120206. /**
  120207. * Gets the HTML canvas attached with the current webGL context
  120208. * @returns a HTML canvas
  120209. */
  120210. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  120211. /**
  120212. * Gets host window
  120213. * @returns the host window object
  120214. */
  120215. getHostWindow(): Nullable<Window>;
  120216. /**
  120217. * Gets the current render width
  120218. * @param useScreen defines if screen size must be used (or the current render target if any)
  120219. * @returns a number defining the current render width
  120220. */
  120221. getRenderWidth(useScreen?: boolean): number;
  120222. /**
  120223. * Gets the current render height
  120224. * @param useScreen defines if screen size must be used (or the current render target if any)
  120225. * @returns a number defining the current render height
  120226. */
  120227. getRenderHeight(useScreen?: boolean): number;
  120228. /**
  120229. * Can be used to override the current requestAnimationFrame requester.
  120230. * @hidden
  120231. */
  120232. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120233. /**
  120234. * Register and execute a render loop. The engine can have more than one render function
  120235. * @param renderFunction defines the function to continuously execute
  120236. */
  120237. runRenderLoop(renderFunction: () => void): void;
  120238. /**
  120239. * Clear the current render buffer or the current render target (if any is set up)
  120240. * @param color defines the color to use
  120241. * @param backBuffer defines if the back buffer must be cleared
  120242. * @param depth defines if the depth buffer must be cleared
  120243. * @param stencil defines if the stencil buffer must be cleared
  120244. */
  120245. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120246. private _viewportCached;
  120247. /** @hidden */
  120248. _viewport(x: number, y: number, width: number, height: number): void;
  120249. /**
  120250. * Set the WebGL's viewport
  120251. * @param viewport defines the viewport element to be used
  120252. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  120253. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  120254. */
  120255. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  120256. /**
  120257. * Begin a new frame
  120258. */
  120259. beginFrame(): void;
  120260. /**
  120261. * Enf the current frame
  120262. */
  120263. endFrame(): void;
  120264. /**
  120265. * Resize the view according to the canvas' size
  120266. */
  120267. resize(): void;
  120268. /**
  120269. * Force a specific size of the canvas
  120270. * @param width defines the new canvas' width
  120271. * @param height defines the new canvas' height
  120272. * @returns true if the size was changed
  120273. */
  120274. setSize(width: number, height: number): boolean;
  120275. /**
  120276. * Binds the frame buffer to the specified texture.
  120277. * @param texture The texture to render to or null for the default canvas
  120278. * @param faceIndex The face of the texture to render to in case of cube texture
  120279. * @param requiredWidth The width of the target to render to
  120280. * @param requiredHeight The height of the target to render to
  120281. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120282. * @param lodLevel defines the lod level to bind to the frame buffer
  120283. * @param layer defines the 2d array index to bind to frame buffer to
  120284. */
  120285. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  120286. /** @hidden */
  120287. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120288. /**
  120289. * Unbind the current render target texture from the webGL context
  120290. * @param texture defines the render target texture to unbind
  120291. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120292. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120293. */
  120294. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120295. /**
  120296. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  120297. */
  120298. flushFramebuffer(): void;
  120299. /**
  120300. * Unbind the current render target and bind the default framebuffer
  120301. */
  120302. restoreDefaultFramebuffer(): void;
  120303. /** @hidden */
  120304. protected _resetVertexBufferBinding(): void;
  120305. /**
  120306. * Creates a vertex buffer
  120307. * @param data the data for the vertex buffer
  120308. * @returns the new WebGL static buffer
  120309. */
  120310. createVertexBuffer(data: DataArray): DataBuffer;
  120311. private _createVertexBuffer;
  120312. /**
  120313. * Creates a dynamic vertex buffer
  120314. * @param data the data for the dynamic vertex buffer
  120315. * @returns the new WebGL dynamic buffer
  120316. */
  120317. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120318. protected _resetIndexBufferBinding(): void;
  120319. /**
  120320. * Creates a new index buffer
  120321. * @param indices defines the content of the index buffer
  120322. * @param updatable defines if the index buffer must be updatable
  120323. * @returns a new webGL buffer
  120324. */
  120325. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  120326. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  120327. /**
  120328. * Bind a webGL buffer to the webGL context
  120329. * @param buffer defines the buffer to bind
  120330. */
  120331. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  120332. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  120333. private bindBuffer;
  120334. /**
  120335. * update the bound buffer with the given data
  120336. * @param data defines the data to update
  120337. */
  120338. updateArrayBuffer(data: Float32Array): void;
  120339. private _vertexAttribPointer;
  120340. /** @hidden */
  120341. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  120342. private _bindVertexBuffersAttributes;
  120343. /**
  120344. * Records a vertex array object
  120345. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  120346. * @param vertexBuffers defines the list of vertex buffers to store
  120347. * @param indexBuffer defines the index buffer to store
  120348. * @param effect defines the effect to store
  120349. * @returns the new vertex array object
  120350. */
  120351. recordVertexArrayObject(vertexBuffers: {
  120352. [key: string]: VertexBuffer;
  120353. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120354. /**
  120355. * Bind a specific vertex array object
  120356. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  120357. * @param vertexArrayObject defines the vertex array object to bind
  120358. * @param indexBuffer defines the index buffer to bind
  120359. */
  120360. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  120361. /**
  120362. * Bind webGl buffers directly to the webGL context
  120363. * @param vertexBuffer defines the vertex buffer to bind
  120364. * @param indexBuffer defines the index buffer to bind
  120365. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120366. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120367. * @param effect defines the effect associated with the vertex buffer
  120368. */
  120369. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  120370. private _unbindVertexArrayObject;
  120371. /**
  120372. * Bind a list of vertex buffers to the webGL context
  120373. * @param vertexBuffers defines the list of vertex buffers to bind
  120374. * @param indexBuffer defines the index buffer to bind
  120375. * @param effect defines the effect associated with the vertex buffers
  120376. */
  120377. bindBuffers(vertexBuffers: {
  120378. [key: string]: Nullable<VertexBuffer>;
  120379. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  120380. /**
  120381. * Unbind all instance attributes
  120382. */
  120383. unbindInstanceAttributes(): void;
  120384. /**
  120385. * Release and free the memory of a vertex array object
  120386. * @param vao defines the vertex array object to delete
  120387. */
  120388. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  120389. /** @hidden */
  120390. _releaseBuffer(buffer: DataBuffer): boolean;
  120391. protected _deleteBuffer(buffer: DataBuffer): void;
  120392. /**
  120393. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  120394. * @param instancesBuffer defines the webGL buffer to update and bind
  120395. * @param data defines the data to store in the buffer
  120396. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  120397. */
  120398. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  120399. /**
  120400. * Bind the content of a webGL buffer used with instantiation
  120401. * @param instancesBuffer defines the webGL buffer to bind
  120402. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  120403. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  120404. */
  120405. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  120406. /**
  120407. * Disable the instance attribute corresponding to the name in parameter
  120408. * @param name defines the name of the attribute to disable
  120409. */
  120410. disableInstanceAttributeByName(name: string): void;
  120411. /**
  120412. * Disable the instance attribute corresponding to the location in parameter
  120413. * @param attributeLocation defines the attribute location of the attribute to disable
  120414. */
  120415. disableInstanceAttribute(attributeLocation: number): void;
  120416. /**
  120417. * Disable the attribute corresponding to the location in parameter
  120418. * @param attributeLocation defines the attribute location of the attribute to disable
  120419. */
  120420. disableAttributeByIndex(attributeLocation: number): void;
  120421. /**
  120422. * Send a draw order
  120423. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120424. * @param indexStart defines the starting index
  120425. * @param indexCount defines the number of index to draw
  120426. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120427. */
  120428. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120429. /**
  120430. * Draw a list of points
  120431. * @param verticesStart defines the index of first vertex to draw
  120432. * @param verticesCount defines the count of vertices to draw
  120433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120434. */
  120435. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120436. /**
  120437. * Draw a list of unindexed primitives
  120438. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120439. * @param verticesStart defines the index of first vertex to draw
  120440. * @param verticesCount defines the count of vertices to draw
  120441. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120442. */
  120443. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120444. /**
  120445. * Draw a list of indexed primitives
  120446. * @param fillMode defines the primitive to use
  120447. * @param indexStart defines the starting index
  120448. * @param indexCount defines the number of index to draw
  120449. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120450. */
  120451. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120452. /**
  120453. * Draw a list of unindexed primitives
  120454. * @param fillMode defines the primitive to use
  120455. * @param verticesStart defines the index of first vertex to draw
  120456. * @param verticesCount defines the count of vertices to draw
  120457. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120458. */
  120459. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120460. private _drawMode;
  120461. /** @hidden */
  120462. protected _reportDrawCall(): void;
  120463. /** @hidden */
  120464. _releaseEffect(effect: Effect): void;
  120465. /** @hidden */
  120466. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120467. /**
  120468. * Create a new effect (used to store vertex/fragment shaders)
  120469. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  120470. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  120471. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  120472. * @param samplers defines an array of string used to represent textures
  120473. * @param defines defines the string containing the defines to use to compile the shaders
  120474. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  120475. * @param onCompiled defines a function to call when the effect creation is successful
  120476. * @param onError defines a function to call when the effect creation has failed
  120477. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  120478. * @returns the new Effect
  120479. */
  120480. 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;
  120481. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  120482. private _compileShader;
  120483. private _compileRawShader;
  120484. /** @hidden */
  120485. _getShaderSource(shader: WebGLShader): Nullable<string>;
  120486. /**
  120487. * Directly creates a webGL program
  120488. * @param pipelineContext defines the pipeline context to attach to
  120489. * @param vertexCode defines the vertex shader code to use
  120490. * @param fragmentCode defines the fragment shader code to use
  120491. * @param context defines the webGL context to use (if not set, the current one will be used)
  120492. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  120493. * @returns the new webGL program
  120494. */
  120495. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  120496. /**
  120497. * Creates a webGL program
  120498. * @param pipelineContext defines the pipeline context to attach to
  120499. * @param vertexCode defines the vertex shader code to use
  120500. * @param fragmentCode defines the fragment shader code to use
  120501. * @param defines defines the string containing the defines to use to compile the shaders
  120502. * @param context defines the webGL context to use (if not set, the current one will be used)
  120503. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  120504. * @returns the new webGL program
  120505. */
  120506. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  120507. /**
  120508. * Creates a new pipeline context
  120509. * @returns the new pipeline
  120510. */
  120511. createPipelineContext(): IPipelineContext;
  120512. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  120513. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  120514. /** @hidden */
  120515. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120516. /** @hidden */
  120517. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120518. /** @hidden */
  120519. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120520. /**
  120521. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  120522. * @param pipelineContext defines the pipeline context to use
  120523. * @param uniformsNames defines the list of uniform names
  120524. * @returns an array of webGL uniform locations
  120525. */
  120526. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  120527. /**
  120528. * Gets the lsit of active attributes for a given webGL program
  120529. * @param pipelineContext defines the pipeline context to use
  120530. * @param attributesNames defines the list of attribute names to get
  120531. * @returns an array of indices indicating the offset of each attribute
  120532. */
  120533. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120534. /**
  120535. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  120536. * @param effect defines the effect to activate
  120537. */
  120538. enableEffect(effect: Nullable<Effect>): void;
  120539. /**
  120540. * Set the value of an uniform to a number (int)
  120541. * @param uniform defines the webGL uniform location where to store the value
  120542. * @param value defines the int number to store
  120543. * @returns true if the value was set
  120544. */
  120545. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  120546. /**
  120547. * Set the value of an uniform to an array of int32
  120548. * @param uniform defines the webGL uniform location where to store the value
  120549. * @param array defines the array of int32 to store
  120550. * @returns true if the value was set
  120551. */
  120552. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120553. /**
  120554. * Set the value of an uniform to an array of int32 (stored as vec2)
  120555. * @param uniform defines the webGL uniform location where to store the value
  120556. * @param array defines the array of int32 to store
  120557. * @returns true if the value was set
  120558. */
  120559. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120560. /**
  120561. * Set the value of an uniform to an array of int32 (stored as vec3)
  120562. * @param uniform defines the webGL uniform location where to store the value
  120563. * @param array defines the array of int32 to store
  120564. * @returns true if the value was set
  120565. */
  120566. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120567. /**
  120568. * Set the value of an uniform to an array of int32 (stored as vec4)
  120569. * @param uniform defines the webGL uniform location where to store the value
  120570. * @param array defines the array of int32 to store
  120571. * @returns true if the value was set
  120572. */
  120573. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  120574. /**
  120575. * Set the value of an uniform to an array of number
  120576. * @param uniform defines the webGL uniform location where to store the value
  120577. * @param array defines the array of number to store
  120578. * @returns true if the value was set
  120579. */
  120580. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120581. /**
  120582. * Set the value of an uniform to an array of number (stored as vec2)
  120583. * @param uniform defines the webGL uniform location where to store the value
  120584. * @param array defines the array of number to store
  120585. * @returns true if the value was set
  120586. */
  120587. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120588. /**
  120589. * Set the value of an uniform to an array of number (stored as vec3)
  120590. * @param uniform defines the webGL uniform location where to store the value
  120591. * @param array defines the array of number to store
  120592. * @returns true if the value was set
  120593. */
  120594. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120595. /**
  120596. * Set the value of an uniform to an array of number (stored as vec4)
  120597. * @param uniform defines the webGL uniform location where to store the value
  120598. * @param array defines the array of number to store
  120599. * @returns true if the value was set
  120600. */
  120601. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  120602. /**
  120603. * Set the value of an uniform to an array of float32 (stored as matrices)
  120604. * @param uniform defines the webGL uniform location where to store the value
  120605. * @param matrices defines the array of float32 to store
  120606. * @returns true if the value was set
  120607. */
  120608. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  120609. /**
  120610. * Set the value of an uniform to a matrix (3x3)
  120611. * @param uniform defines the webGL uniform location where to store the value
  120612. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  120613. * @returns true if the value was set
  120614. */
  120615. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  120616. /**
  120617. * Set the value of an uniform to a matrix (2x2)
  120618. * @param uniform defines the webGL uniform location where to store the value
  120619. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  120620. * @returns true if the value was set
  120621. */
  120622. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  120623. /**
  120624. * Set the value of an uniform to a number (float)
  120625. * @param uniform defines the webGL uniform location where to store the value
  120626. * @param value defines the float number to store
  120627. * @returns true if the value was transfered
  120628. */
  120629. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  120630. /**
  120631. * Set the value of an uniform to a vec2
  120632. * @param uniform defines the webGL uniform location where to store the value
  120633. * @param x defines the 1st component of the value
  120634. * @param y defines the 2nd component of the value
  120635. * @returns true if the value was set
  120636. */
  120637. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  120638. /**
  120639. * Set the value of an uniform to a vec3
  120640. * @param uniform defines the webGL uniform location where to store the value
  120641. * @param x defines the 1st component of the value
  120642. * @param y defines the 2nd component of the value
  120643. * @param z defines the 3rd component of the value
  120644. * @returns true if the value was set
  120645. */
  120646. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  120647. /**
  120648. * Set the value of an uniform to a vec4
  120649. * @param uniform defines the webGL uniform location where to store the value
  120650. * @param x defines the 1st component of the value
  120651. * @param y defines the 2nd component of the value
  120652. * @param z defines the 3rd component of the value
  120653. * @param w defines the 4th component of the value
  120654. * @returns true if the value was set
  120655. */
  120656. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  120657. /**
  120658. * Apply all cached states (depth, culling, stencil and alpha)
  120659. */
  120660. applyStates(): void;
  120661. /**
  120662. * Enable or disable color writing
  120663. * @param enable defines the state to set
  120664. */
  120665. setColorWrite(enable: boolean): void;
  120666. /**
  120667. * Gets a boolean indicating if color writing is enabled
  120668. * @returns the current color writing state
  120669. */
  120670. getColorWrite(): boolean;
  120671. /**
  120672. * Gets the depth culling state manager
  120673. */
  120674. get depthCullingState(): DepthCullingState;
  120675. /**
  120676. * Gets the alpha state manager
  120677. */
  120678. get alphaState(): AlphaState;
  120679. /**
  120680. * Gets the stencil state manager
  120681. */
  120682. get stencilState(): StencilState;
  120683. /**
  120684. * Clears the list of texture accessible through engine.
  120685. * This can help preventing texture load conflict due to name collision.
  120686. */
  120687. clearInternalTexturesCache(): void;
  120688. /**
  120689. * Force the entire cache to be cleared
  120690. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120691. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120692. */
  120693. wipeCaches(bruteForce?: boolean): void;
  120694. /** @hidden */
  120695. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  120696. min: number;
  120697. mag: number;
  120698. };
  120699. /** @hidden */
  120700. _createTexture(): WebGLTexture;
  120701. /**
  120702. * Usually called from Texture.ts.
  120703. * Passed information to create a WebGLTexture
  120704. * @param url defines a value which contains one of the following:
  120705. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120706. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120707. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120708. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120709. * @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)
  120710. * @param scene needed for loading to the correct scene
  120711. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120712. * @param onLoad optional callback to be called upon successful completion
  120713. * @param onError optional callback to be called upon failure
  120714. * @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
  120715. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120716. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120717. * @param forcedExtension defines the extension to use to pick the right loader
  120718. * @param mimeType defines an optional mime type
  120719. * @param loaderOptions options to be passed to the loader
  120720. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120721. */
  120722. 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;
  120723. /**
  120724. * Loads an image as an HTMLImageElement.
  120725. * @param input url string, ArrayBuffer, or Blob to load
  120726. * @param onLoad callback called when the image successfully loads
  120727. * @param onError callback called when the image fails to load
  120728. * @param offlineProvider offline provider for caching
  120729. * @param mimeType optional mime type
  120730. * @returns the HTMLImageElement of the loaded image
  120731. * @hidden
  120732. */
  120733. 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>;
  120734. /**
  120735. * @hidden
  120736. */
  120737. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  120738. private _unpackFlipYCached;
  120739. /**
  120740. * In case you are sharing the context with other applications, it might
  120741. * be interested to not cache the unpack flip y state to ensure a consistent
  120742. * value would be set.
  120743. */
  120744. enableUnpackFlipYCached: boolean;
  120745. /** @hidden */
  120746. _unpackFlipY(value: boolean): void;
  120747. /** @hidden */
  120748. _getUnpackAlignement(): number;
  120749. private _getTextureTarget;
  120750. /**
  120751. * Update the sampling mode of a given texture
  120752. * @param samplingMode defines the required sampling mode
  120753. * @param texture defines the texture to update
  120754. * @param generateMipMaps defines whether to generate mipmaps for the texture
  120755. */
  120756. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  120757. /**
  120758. * Update the sampling mode of a given texture
  120759. * @param texture defines the texture to update
  120760. * @param wrapU defines the texture wrap mode of the u coordinates
  120761. * @param wrapV defines the texture wrap mode of the v coordinates
  120762. * @param wrapR defines the texture wrap mode of the r coordinates
  120763. */
  120764. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  120765. /** @hidden */
  120766. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  120767. width: number;
  120768. height: number;
  120769. layers?: number;
  120770. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  120771. /** @hidden */
  120772. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120773. /** @hidden */
  120774. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  120775. /**
  120776. * Update a portion of an internal texture
  120777. * @param texture defines the texture to update
  120778. * @param imageData defines the data to store into the texture
  120779. * @param xOffset defines the x coordinates of the update rectangle
  120780. * @param yOffset defines the y coordinates of the update rectangle
  120781. * @param width defines the width of the update rectangle
  120782. * @param height defines the height of the update rectangle
  120783. * @param faceIndex defines the face index if texture is a cube (0 by default)
  120784. * @param lod defines the lod level to update (0 by default)
  120785. */
  120786. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  120787. /** @hidden */
  120788. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120789. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  120790. private _prepareWebGLTexture;
  120791. /** @hidden */
  120792. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  120793. private _getDepthStencilBuffer;
  120794. /** @hidden */
  120795. _releaseFramebufferObjects(texture: InternalTexture): void;
  120796. /** @hidden */
  120797. _releaseTexture(texture: InternalTexture): void;
  120798. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120799. protected _setProgram(program: WebGLProgram): void;
  120800. protected _boundUniforms: {
  120801. [key: number]: WebGLUniformLocation;
  120802. };
  120803. /**
  120804. * Binds an effect to the webGL context
  120805. * @param effect defines the effect to bind
  120806. */
  120807. bindSamplers(effect: Effect): void;
  120808. private _activateCurrentTexture;
  120809. /** @hidden */
  120810. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  120811. /** @hidden */
  120812. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  120813. /**
  120814. * Unbind all textures from the webGL context
  120815. */
  120816. unbindAllTextures(): void;
  120817. /**
  120818. * Sets a texture to the according uniform.
  120819. * @param channel The texture channel
  120820. * @param uniform The uniform to set
  120821. * @param texture The texture to apply
  120822. */
  120823. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  120824. private _bindSamplerUniformToChannel;
  120825. private _getTextureWrapMode;
  120826. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120827. /**
  120828. * Sets an array of texture to the webGL context
  120829. * @param channel defines the channel where the texture array must be set
  120830. * @param uniform defines the associated uniform location
  120831. * @param textures defines the array of textures to bind
  120832. */
  120833. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  120834. /** @hidden */
  120835. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  120836. private _setTextureParameterFloat;
  120837. private _setTextureParameterInteger;
  120838. /**
  120839. * Unbind all vertex attributes from the webGL context
  120840. */
  120841. unbindAllAttributes(): void;
  120842. /**
  120843. * 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
  120844. */
  120845. releaseEffects(): void;
  120846. /**
  120847. * Dispose and release all associated resources
  120848. */
  120849. dispose(): void;
  120850. /**
  120851. * Attach a new callback raised when context lost event is fired
  120852. * @param callback defines the callback to call
  120853. */
  120854. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120855. /**
  120856. * Attach a new callback raised when context restored event is fired
  120857. * @param callback defines the callback to call
  120858. */
  120859. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  120860. /**
  120861. * Get the current error code of the webGL context
  120862. * @returns the error code
  120863. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120864. */
  120865. getError(): number;
  120866. private _canRenderToFloatFramebuffer;
  120867. private _canRenderToHalfFloatFramebuffer;
  120868. private _canRenderToFramebuffer;
  120869. /** @hidden */
  120870. _getWebGLTextureType(type: number): number;
  120871. /** @hidden */
  120872. _getInternalFormat(format: number): number;
  120873. /** @hidden */
  120874. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  120875. /** @hidden */
  120876. _getRGBAMultiSampleBufferFormat(type: number): number;
  120877. /** @hidden */
  120878. _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;
  120879. /**
  120880. * Loads a file from a url
  120881. * @param url url to load
  120882. * @param onSuccess callback called when the file successfully loads
  120883. * @param onProgress callback called while file is loading (if the server supports this mode)
  120884. * @param offlineProvider defines the offline provider for caching
  120885. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  120886. * @param onError callback called when the file fails to load
  120887. * @returns a file request object
  120888. * @hidden
  120889. */
  120890. 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;
  120891. /**
  120892. * Reads pixels from the current frame buffer. Please note that this function can be slow
  120893. * @param x defines the x coordinate of the rectangle where pixels must be read
  120894. * @param y defines the y coordinate of the rectangle where pixels must be read
  120895. * @param width defines the width of the rectangle where pixels must be read
  120896. * @param height defines the height of the rectangle where pixels must be read
  120897. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  120898. * @returns a Uint8Array containing RGBA colors
  120899. */
  120900. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  120901. private static _IsSupported;
  120902. private static _HasMajorPerformanceCaveat;
  120903. /**
  120904. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120905. */
  120906. static get IsSupported(): boolean;
  120907. /**
  120908. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  120909. * @returns true if the engine can be created
  120910. * @ignorenaming
  120911. */
  120912. static isSupported(): boolean;
  120913. /**
  120914. * 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)
  120915. */
  120916. static get HasMajorPerformanceCaveat(): boolean;
  120917. /**
  120918. * Find the next highest power of two.
  120919. * @param x Number to start search from.
  120920. * @return Next highest power of two.
  120921. */
  120922. static CeilingPOT(x: number): number;
  120923. /**
  120924. * Find the next lowest power of two.
  120925. * @param x Number to start search from.
  120926. * @return Next lowest power of two.
  120927. */
  120928. static FloorPOT(x: number): number;
  120929. /**
  120930. * Find the nearest power of two.
  120931. * @param x Number to start search from.
  120932. * @return Next nearest power of two.
  120933. */
  120934. static NearestPOT(x: number): number;
  120935. /**
  120936. * Get the closest exponent of two
  120937. * @param value defines the value to approximate
  120938. * @param max defines the maximum value to return
  120939. * @param mode defines how to define the closest value
  120940. * @returns closest exponent of two of the given value
  120941. */
  120942. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  120943. /**
  120944. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  120945. * @param func - the function to be called
  120946. * @param requester - the object that will request the next frame. Falls back to window.
  120947. * @returns frame number
  120948. */
  120949. static QueueNewFrame(func: () => void, requester?: any): number;
  120950. /**
  120951. * Gets host document
  120952. * @returns the host document object
  120953. */
  120954. getHostDocument(): Nullable<Document>;
  120955. }
  120956. }
  120957. declare module BABYLON {
  120958. /**
  120959. * Defines the source of the internal texture
  120960. */
  120961. export enum InternalTextureSource {
  120962. /**
  120963. * The source of the texture data is unknown
  120964. */
  120965. Unknown = 0,
  120966. /**
  120967. * Texture data comes from an URL
  120968. */
  120969. Url = 1,
  120970. /**
  120971. * Texture data is only used for temporary storage
  120972. */
  120973. Temp = 2,
  120974. /**
  120975. * Texture data comes from raw data (ArrayBuffer)
  120976. */
  120977. Raw = 3,
  120978. /**
  120979. * Texture content is dynamic (video or dynamic texture)
  120980. */
  120981. Dynamic = 4,
  120982. /**
  120983. * Texture content is generated by rendering to it
  120984. */
  120985. RenderTarget = 5,
  120986. /**
  120987. * Texture content is part of a multi render target process
  120988. */
  120989. MultiRenderTarget = 6,
  120990. /**
  120991. * Texture data comes from a cube data file
  120992. */
  120993. Cube = 7,
  120994. /**
  120995. * Texture data comes from a raw cube data
  120996. */
  120997. CubeRaw = 8,
  120998. /**
  120999. * Texture data come from a prefiltered cube data file
  121000. */
  121001. CubePrefiltered = 9,
  121002. /**
  121003. * Texture content is raw 3D data
  121004. */
  121005. Raw3D = 10,
  121006. /**
  121007. * Texture content is raw 2D array data
  121008. */
  121009. Raw2DArray = 11,
  121010. /**
  121011. * Texture content is a depth texture
  121012. */
  121013. Depth = 12,
  121014. /**
  121015. * Texture data comes from a raw cube data encoded with RGBD
  121016. */
  121017. CubeRawRGBD = 13
  121018. }
  121019. /**
  121020. * Class used to store data associated with WebGL texture data for the engine
  121021. * This class should not be used directly
  121022. */
  121023. export class InternalTexture {
  121024. /** @hidden */
  121025. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  121026. /**
  121027. * Defines if the texture is ready
  121028. */
  121029. isReady: boolean;
  121030. /**
  121031. * Defines if the texture is a cube texture
  121032. */
  121033. isCube: boolean;
  121034. /**
  121035. * Defines if the texture contains 3D data
  121036. */
  121037. is3D: boolean;
  121038. /**
  121039. * Defines if the texture contains 2D array data
  121040. */
  121041. is2DArray: boolean;
  121042. /**
  121043. * Defines if the texture contains multiview data
  121044. */
  121045. isMultiview: boolean;
  121046. /**
  121047. * Gets the URL used to load this texture
  121048. */
  121049. url: string;
  121050. /**
  121051. * Gets the sampling mode of the texture
  121052. */
  121053. samplingMode: number;
  121054. /**
  121055. * Gets a boolean indicating if the texture needs mipmaps generation
  121056. */
  121057. generateMipMaps: boolean;
  121058. /**
  121059. * Gets the number of samples used by the texture (WebGL2+ only)
  121060. */
  121061. samples: number;
  121062. /**
  121063. * Gets the type of the texture (int, float...)
  121064. */
  121065. type: number;
  121066. /**
  121067. * Gets the format of the texture (RGB, RGBA...)
  121068. */
  121069. format: number;
  121070. /**
  121071. * Observable called when the texture is loaded
  121072. */
  121073. onLoadedObservable: Observable<InternalTexture>;
  121074. /**
  121075. * Gets the width of the texture
  121076. */
  121077. width: number;
  121078. /**
  121079. * Gets the height of the texture
  121080. */
  121081. height: number;
  121082. /**
  121083. * Gets the depth of the texture
  121084. */
  121085. depth: number;
  121086. /**
  121087. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  121088. */
  121089. baseWidth: number;
  121090. /**
  121091. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  121092. */
  121093. baseHeight: number;
  121094. /**
  121095. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  121096. */
  121097. baseDepth: number;
  121098. /**
  121099. * Gets a boolean indicating if the texture is inverted on Y axis
  121100. */
  121101. invertY: boolean;
  121102. /** @hidden */
  121103. _invertVScale: boolean;
  121104. /** @hidden */
  121105. _associatedChannel: number;
  121106. /** @hidden */
  121107. _source: InternalTextureSource;
  121108. /** @hidden */
  121109. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  121110. /** @hidden */
  121111. _bufferView: Nullable<ArrayBufferView>;
  121112. /** @hidden */
  121113. _bufferViewArray: Nullable<ArrayBufferView[]>;
  121114. /** @hidden */
  121115. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  121116. /** @hidden */
  121117. _size: number;
  121118. /** @hidden */
  121119. _extension: string;
  121120. /** @hidden */
  121121. _files: Nullable<string[]>;
  121122. /** @hidden */
  121123. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  121124. /** @hidden */
  121125. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  121126. /** @hidden */
  121127. _framebuffer: Nullable<WebGLFramebuffer>;
  121128. /** @hidden */
  121129. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  121130. /** @hidden */
  121131. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  121132. /** @hidden */
  121133. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  121134. /** @hidden */
  121135. _attachments: Nullable<number[]>;
  121136. /** @hidden */
  121137. _textureArray: Nullable<InternalTexture[]>;
  121138. /** @hidden */
  121139. _cachedCoordinatesMode: Nullable<number>;
  121140. /** @hidden */
  121141. _cachedWrapU: Nullable<number>;
  121142. /** @hidden */
  121143. _cachedWrapV: Nullable<number>;
  121144. /** @hidden */
  121145. _cachedWrapR: Nullable<number>;
  121146. /** @hidden */
  121147. _cachedAnisotropicFilteringLevel: Nullable<number>;
  121148. /** @hidden */
  121149. _isDisabled: boolean;
  121150. /** @hidden */
  121151. _compression: Nullable<string>;
  121152. /** @hidden */
  121153. _generateStencilBuffer: boolean;
  121154. /** @hidden */
  121155. _generateDepthBuffer: boolean;
  121156. /** @hidden */
  121157. _comparisonFunction: number;
  121158. /** @hidden */
  121159. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  121160. /** @hidden */
  121161. _lodGenerationScale: number;
  121162. /** @hidden */
  121163. _lodGenerationOffset: number;
  121164. /** @hidden */
  121165. _depthStencilTexture: Nullable<InternalTexture>;
  121166. /** @hidden */
  121167. _colorTextureArray: Nullable<WebGLTexture>;
  121168. /** @hidden */
  121169. _depthStencilTextureArray: Nullable<WebGLTexture>;
  121170. /** @hidden */
  121171. _lodTextureHigh: Nullable<BaseTexture>;
  121172. /** @hidden */
  121173. _lodTextureMid: Nullable<BaseTexture>;
  121174. /** @hidden */
  121175. _lodTextureLow: Nullable<BaseTexture>;
  121176. /** @hidden */
  121177. _isRGBD: boolean;
  121178. /** @hidden */
  121179. _linearSpecularLOD: boolean;
  121180. /** @hidden */
  121181. _irradianceTexture: Nullable<BaseTexture>;
  121182. /** @hidden */
  121183. _webGLTexture: Nullable<WebGLTexture>;
  121184. /** @hidden */
  121185. _references: number;
  121186. /** @hidden */
  121187. _gammaSpace: Nullable<boolean>;
  121188. private _engine;
  121189. /**
  121190. * Gets the Engine the texture belongs to.
  121191. * @returns The babylon engine
  121192. */
  121193. getEngine(): ThinEngine;
  121194. /**
  121195. * Gets the data source type of the texture
  121196. */
  121197. get source(): InternalTextureSource;
  121198. /**
  121199. * Creates a new InternalTexture
  121200. * @param engine defines the engine to use
  121201. * @param source defines the type of data that will be used
  121202. * @param delayAllocation if the texture allocation should be delayed (default: false)
  121203. */
  121204. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  121205. /**
  121206. * Increments the number of references (ie. the number of Texture that point to it)
  121207. */
  121208. incrementReferences(): void;
  121209. /**
  121210. * Change the size of the texture (not the size of the content)
  121211. * @param width defines the new width
  121212. * @param height defines the new height
  121213. * @param depth defines the new depth (1 by default)
  121214. */
  121215. updateSize(width: int, height: int, depth?: int): void;
  121216. /** @hidden */
  121217. _rebuild(): void;
  121218. /** @hidden */
  121219. _swapAndDie(target: InternalTexture): void;
  121220. /**
  121221. * Dispose the current allocated resources
  121222. */
  121223. dispose(): void;
  121224. }
  121225. }
  121226. declare module BABYLON {
  121227. /**
  121228. * Class used to work with sound analyzer using fast fourier transform (FFT)
  121229. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121230. */
  121231. export class Analyser {
  121232. /**
  121233. * Gets or sets the smoothing
  121234. * @ignorenaming
  121235. */
  121236. SMOOTHING: number;
  121237. /**
  121238. * Gets or sets the FFT table size
  121239. * @ignorenaming
  121240. */
  121241. FFT_SIZE: number;
  121242. /**
  121243. * Gets or sets the bar graph amplitude
  121244. * @ignorenaming
  121245. */
  121246. BARGRAPHAMPLITUDE: number;
  121247. /**
  121248. * Gets or sets the position of the debug canvas
  121249. * @ignorenaming
  121250. */
  121251. DEBUGCANVASPOS: {
  121252. x: number;
  121253. y: number;
  121254. };
  121255. /**
  121256. * Gets or sets the debug canvas size
  121257. * @ignorenaming
  121258. */
  121259. DEBUGCANVASSIZE: {
  121260. width: number;
  121261. height: number;
  121262. };
  121263. private _byteFreqs;
  121264. private _byteTime;
  121265. private _floatFreqs;
  121266. private _webAudioAnalyser;
  121267. private _debugCanvas;
  121268. private _debugCanvasContext;
  121269. private _scene;
  121270. private _registerFunc;
  121271. private _audioEngine;
  121272. /**
  121273. * Creates a new analyser
  121274. * @param scene defines hosting scene
  121275. */
  121276. constructor(scene: Scene);
  121277. /**
  121278. * Get the number of data values you will have to play with for the visualization
  121279. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  121280. * @returns a number
  121281. */
  121282. getFrequencyBinCount(): number;
  121283. /**
  121284. * Gets the current frequency data as a byte array
  121285. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  121286. * @returns a Uint8Array
  121287. */
  121288. getByteFrequencyData(): Uint8Array;
  121289. /**
  121290. * Gets the current waveform as a byte array
  121291. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  121292. * @returns a Uint8Array
  121293. */
  121294. getByteTimeDomainData(): Uint8Array;
  121295. /**
  121296. * Gets the current frequency data as a float array
  121297. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  121298. * @returns a Float32Array
  121299. */
  121300. getFloatFrequencyData(): Float32Array;
  121301. /**
  121302. * Renders the debug canvas
  121303. */
  121304. drawDebugCanvas(): void;
  121305. /**
  121306. * Stops rendering the debug canvas and removes it
  121307. */
  121308. stopDebugCanvas(): void;
  121309. /**
  121310. * Connects two audio nodes
  121311. * @param inputAudioNode defines first node to connect
  121312. * @param outputAudioNode defines second node to connect
  121313. */
  121314. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  121315. /**
  121316. * Releases all associated resources
  121317. */
  121318. dispose(): void;
  121319. }
  121320. }
  121321. declare module BABYLON {
  121322. /**
  121323. * This represents an audio engine and it is responsible
  121324. * to play, synchronize and analyse sounds throughout the application.
  121325. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121326. */
  121327. export interface IAudioEngine extends IDisposable {
  121328. /**
  121329. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  121330. */
  121331. readonly canUseWebAudio: boolean;
  121332. /**
  121333. * Gets the current AudioContext if available.
  121334. */
  121335. readonly audioContext: Nullable<AudioContext>;
  121336. /**
  121337. * The master gain node defines the global audio volume of your audio engine.
  121338. */
  121339. readonly masterGain: GainNode;
  121340. /**
  121341. * Gets whether or not mp3 are supported by your browser.
  121342. */
  121343. readonly isMP3supported: boolean;
  121344. /**
  121345. * Gets whether or not ogg are supported by your browser.
  121346. */
  121347. readonly isOGGsupported: boolean;
  121348. /**
  121349. * Defines if Babylon should emit a warning if WebAudio is not supported.
  121350. * @ignoreNaming
  121351. */
  121352. WarnedWebAudioUnsupported: boolean;
  121353. /**
  121354. * Defines if the audio engine relies on a custom unlocked button.
  121355. * In this case, the embedded button will not be displayed.
  121356. */
  121357. useCustomUnlockedButton: boolean;
  121358. /**
  121359. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  121360. */
  121361. readonly unlocked: boolean;
  121362. /**
  121363. * Event raised when audio has been unlocked on the browser.
  121364. */
  121365. onAudioUnlockedObservable: Observable<AudioEngine>;
  121366. /**
  121367. * Event raised when audio has been locked on the browser.
  121368. */
  121369. onAudioLockedObservable: Observable<AudioEngine>;
  121370. /**
  121371. * Flags the audio engine in Locked state.
  121372. * This happens due to new browser policies preventing audio to autoplay.
  121373. */
  121374. lock(): void;
  121375. /**
  121376. * Unlocks the audio engine once a user action has been done on the dom.
  121377. * This is helpful to resume play once browser policies have been satisfied.
  121378. */
  121379. unlock(): void;
  121380. /**
  121381. * Gets the global volume sets on the master gain.
  121382. * @returns the global volume if set or -1 otherwise
  121383. */
  121384. getGlobalVolume(): number;
  121385. /**
  121386. * Sets the global volume of your experience (sets on the master gain).
  121387. * @param newVolume Defines the new global volume of the application
  121388. */
  121389. setGlobalVolume(newVolume: number): void;
  121390. /**
  121391. * Connect the audio engine to an audio analyser allowing some amazing
  121392. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  121393. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  121394. * @param analyser The analyser to connect to the engine
  121395. */
  121396. connectToAnalyser(analyser: Analyser): void;
  121397. }
  121398. /**
  121399. * This represents the default audio engine used in babylon.
  121400. * It is responsible to play, synchronize and analyse sounds throughout the application.
  121401. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121402. */
  121403. export class AudioEngine implements IAudioEngine {
  121404. private _audioContext;
  121405. private _audioContextInitialized;
  121406. private _muteButton;
  121407. private _hostElement;
  121408. /**
  121409. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  121410. */
  121411. canUseWebAudio: boolean;
  121412. /**
  121413. * The master gain node defines the global audio volume of your audio engine.
  121414. */
  121415. masterGain: GainNode;
  121416. /**
  121417. * Defines if Babylon should emit a warning if WebAudio is not supported.
  121418. * @ignoreNaming
  121419. */
  121420. WarnedWebAudioUnsupported: boolean;
  121421. /**
  121422. * Gets whether or not mp3 are supported by your browser.
  121423. */
  121424. isMP3supported: boolean;
  121425. /**
  121426. * Gets whether or not ogg are supported by your browser.
  121427. */
  121428. isOGGsupported: boolean;
  121429. /**
  121430. * Gets whether audio has been unlocked on the device.
  121431. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  121432. * a user interaction has happened.
  121433. */
  121434. unlocked: boolean;
  121435. /**
  121436. * Defines if the audio engine relies on a custom unlocked button.
  121437. * In this case, the embedded button will not be displayed.
  121438. */
  121439. useCustomUnlockedButton: boolean;
  121440. /**
  121441. * Event raised when audio has been unlocked on the browser.
  121442. */
  121443. onAudioUnlockedObservable: Observable<AudioEngine>;
  121444. /**
  121445. * Event raised when audio has been locked on the browser.
  121446. */
  121447. onAudioLockedObservable: Observable<AudioEngine>;
  121448. /**
  121449. * Gets the current AudioContext if available.
  121450. */
  121451. get audioContext(): Nullable<AudioContext>;
  121452. private _connectedAnalyser;
  121453. /**
  121454. * Instantiates a new audio engine.
  121455. *
  121456. * There should be only one per page as some browsers restrict the number
  121457. * of audio contexts you can create.
  121458. * @param hostElement defines the host element where to display the mute icon if necessary
  121459. */
  121460. constructor(hostElement?: Nullable<HTMLElement>);
  121461. /**
  121462. * Flags the audio engine in Locked state.
  121463. * This happens due to new browser policies preventing audio to autoplay.
  121464. */
  121465. lock(): void;
  121466. /**
  121467. * Unlocks the audio engine once a user action has been done on the dom.
  121468. * This is helpful to resume play once browser policies have been satisfied.
  121469. */
  121470. unlock(): void;
  121471. private _resumeAudioContext;
  121472. private _initializeAudioContext;
  121473. private _tryToRun;
  121474. private _triggerRunningState;
  121475. private _triggerSuspendedState;
  121476. private _displayMuteButton;
  121477. private _moveButtonToTopLeft;
  121478. private _onResize;
  121479. private _hideMuteButton;
  121480. /**
  121481. * Destroy and release the resources associated with the audio ccontext.
  121482. */
  121483. dispose(): void;
  121484. /**
  121485. * Gets the global volume sets on the master gain.
  121486. * @returns the global volume if set or -1 otherwise
  121487. */
  121488. getGlobalVolume(): number;
  121489. /**
  121490. * Sets the global volume of your experience (sets on the master gain).
  121491. * @param newVolume Defines the new global volume of the application
  121492. */
  121493. setGlobalVolume(newVolume: number): void;
  121494. /**
  121495. * Connect the audio engine to an audio analyser allowing some amazing
  121496. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  121497. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  121498. * @param analyser The analyser to connect to the engine
  121499. */
  121500. connectToAnalyser(analyser: Analyser): void;
  121501. }
  121502. }
  121503. declare module BABYLON {
  121504. /**
  121505. * Interface used to present a loading screen while loading a scene
  121506. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121507. */
  121508. export interface ILoadingScreen {
  121509. /**
  121510. * Function called to display the loading screen
  121511. */
  121512. displayLoadingUI: () => void;
  121513. /**
  121514. * Function called to hide the loading screen
  121515. */
  121516. hideLoadingUI: () => void;
  121517. /**
  121518. * Gets or sets the color to use for the background
  121519. */
  121520. loadingUIBackgroundColor: string;
  121521. /**
  121522. * Gets or sets the text to display while loading
  121523. */
  121524. loadingUIText: string;
  121525. }
  121526. /**
  121527. * Class used for the default loading screen
  121528. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  121529. */
  121530. export class DefaultLoadingScreen implements ILoadingScreen {
  121531. private _renderingCanvas;
  121532. private _loadingText;
  121533. private _loadingDivBackgroundColor;
  121534. private _loadingDiv;
  121535. private _loadingTextDiv;
  121536. /** Gets or sets the logo url to use for the default loading screen */
  121537. static DefaultLogoUrl: string;
  121538. /** Gets or sets the spinner url to use for the default loading screen */
  121539. static DefaultSpinnerUrl: string;
  121540. /**
  121541. * Creates a new default loading screen
  121542. * @param _renderingCanvas defines the canvas used to render the scene
  121543. * @param _loadingText defines the default text to display
  121544. * @param _loadingDivBackgroundColor defines the default background color
  121545. */
  121546. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  121547. /**
  121548. * Function called to display the loading screen
  121549. */
  121550. displayLoadingUI(): void;
  121551. /**
  121552. * Function called to hide the loading screen
  121553. */
  121554. hideLoadingUI(): void;
  121555. /**
  121556. * Gets or sets the text to display while loading
  121557. */
  121558. set loadingUIText(text: string);
  121559. get loadingUIText(): string;
  121560. /**
  121561. * Gets or sets the color to use for the background
  121562. */
  121563. get loadingUIBackgroundColor(): string;
  121564. set loadingUIBackgroundColor(color: string);
  121565. private _resizeLoadingUI;
  121566. }
  121567. }
  121568. declare module BABYLON {
  121569. /**
  121570. * Interface for any object that can request an animation frame
  121571. */
  121572. export interface ICustomAnimationFrameRequester {
  121573. /**
  121574. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  121575. */
  121576. renderFunction?: Function;
  121577. /**
  121578. * Called to request the next frame to render to
  121579. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  121580. */
  121581. requestAnimationFrame: Function;
  121582. /**
  121583. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  121584. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  121585. */
  121586. requestID?: number;
  121587. }
  121588. }
  121589. declare module BABYLON {
  121590. /**
  121591. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  121592. */
  121593. export class PerformanceMonitor {
  121594. private _enabled;
  121595. private _rollingFrameTime;
  121596. private _lastFrameTimeMs;
  121597. /**
  121598. * constructor
  121599. * @param frameSampleSize The number of samples required to saturate the sliding window
  121600. */
  121601. constructor(frameSampleSize?: number);
  121602. /**
  121603. * Samples current frame
  121604. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  121605. */
  121606. sampleFrame(timeMs?: number): void;
  121607. /**
  121608. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121609. */
  121610. get averageFrameTime(): number;
  121611. /**
  121612. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  121613. */
  121614. get averageFrameTimeVariance(): number;
  121615. /**
  121616. * Returns the frame time of the most recent frame
  121617. */
  121618. get instantaneousFrameTime(): number;
  121619. /**
  121620. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  121621. */
  121622. get averageFPS(): number;
  121623. /**
  121624. * Returns the average framerate in frames per second using the most recent frame time
  121625. */
  121626. get instantaneousFPS(): number;
  121627. /**
  121628. * Returns true if enough samples have been taken to completely fill the sliding window
  121629. */
  121630. get isSaturated(): boolean;
  121631. /**
  121632. * Enables contributions to the sliding window sample set
  121633. */
  121634. enable(): void;
  121635. /**
  121636. * Disables contributions to the sliding window sample set
  121637. * Samples will not be interpolated over the disabled period
  121638. */
  121639. disable(): void;
  121640. /**
  121641. * Returns true if sampling is enabled
  121642. */
  121643. get isEnabled(): boolean;
  121644. /**
  121645. * Resets performance monitor
  121646. */
  121647. reset(): void;
  121648. }
  121649. /**
  121650. * RollingAverage
  121651. *
  121652. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  121653. */
  121654. export class RollingAverage {
  121655. /**
  121656. * Current average
  121657. */
  121658. average: number;
  121659. /**
  121660. * Current variance
  121661. */
  121662. variance: number;
  121663. protected _samples: Array<number>;
  121664. protected _sampleCount: number;
  121665. protected _pos: number;
  121666. protected _m2: number;
  121667. /**
  121668. * constructor
  121669. * @param length The number of samples required to saturate the sliding window
  121670. */
  121671. constructor(length: number);
  121672. /**
  121673. * Adds a sample to the sample set
  121674. * @param v The sample value
  121675. */
  121676. add(v: number): void;
  121677. /**
  121678. * Returns previously added values or null if outside of history or outside the sliding window domain
  121679. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  121680. * @return Value previously recorded with add() or null if outside of range
  121681. */
  121682. history(i: number): number;
  121683. /**
  121684. * Returns true if enough samples have been taken to completely fill the sliding window
  121685. * @return true if sample-set saturated
  121686. */
  121687. isSaturated(): boolean;
  121688. /**
  121689. * Resets the rolling average (equivalent to 0 samples taken so far)
  121690. */
  121691. reset(): void;
  121692. /**
  121693. * Wraps a value around the sample range boundaries
  121694. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  121695. * @return Wrapped position in sample range
  121696. */
  121697. protected _wrapPosition(i: number): number;
  121698. }
  121699. }
  121700. declare module BABYLON {
  121701. /**
  121702. * This class is used to track a performance counter which is number based.
  121703. * The user has access to many properties which give statistics of different nature.
  121704. *
  121705. * The implementer can track two kinds of Performance Counter: time and count.
  121706. * 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.
  121707. * 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.
  121708. */
  121709. export class PerfCounter {
  121710. /**
  121711. * Gets or sets a global boolean to turn on and off all the counters
  121712. */
  121713. static Enabled: boolean;
  121714. /**
  121715. * Returns the smallest value ever
  121716. */
  121717. get min(): number;
  121718. /**
  121719. * Returns the biggest value ever
  121720. */
  121721. get max(): number;
  121722. /**
  121723. * Returns the average value since the performance counter is running
  121724. */
  121725. get average(): number;
  121726. /**
  121727. * Returns the average value of the last second the counter was monitored
  121728. */
  121729. get lastSecAverage(): number;
  121730. /**
  121731. * Returns the current value
  121732. */
  121733. get current(): number;
  121734. /**
  121735. * Gets the accumulated total
  121736. */
  121737. get total(): number;
  121738. /**
  121739. * Gets the total value count
  121740. */
  121741. get count(): number;
  121742. /**
  121743. * Creates a new counter
  121744. */
  121745. constructor();
  121746. /**
  121747. * Call this method to start monitoring a new frame.
  121748. * 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.
  121749. */
  121750. fetchNewFrame(): void;
  121751. /**
  121752. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  121753. * @param newCount the count value to add to the monitored count
  121754. * @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.
  121755. */
  121756. addCount(newCount: number, fetchResult: boolean): void;
  121757. /**
  121758. * Start monitoring this performance counter
  121759. */
  121760. beginMonitoring(): void;
  121761. /**
  121762. * Compute the time lapsed since the previous beginMonitoring() call.
  121763. * @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
  121764. */
  121765. endMonitoring(newFrame?: boolean): void;
  121766. private _fetchResult;
  121767. private _startMonitoringTime;
  121768. private _min;
  121769. private _max;
  121770. private _average;
  121771. private _current;
  121772. private _totalValueCount;
  121773. private _totalAccumulated;
  121774. private _lastSecAverage;
  121775. private _lastSecAccumulated;
  121776. private _lastSecTime;
  121777. private _lastSecValueCount;
  121778. }
  121779. }
  121780. declare module BABYLON {
  121781. interface ThinEngine {
  121782. /** @hidden */
  121783. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  121784. }
  121785. }
  121786. declare module BABYLON {
  121787. /**
  121788. * Defines the interface used by display changed events
  121789. */
  121790. export interface IDisplayChangedEventArgs {
  121791. /** Gets the vrDisplay object (if any) */
  121792. vrDisplay: Nullable<any>;
  121793. /** Gets a boolean indicating if webVR is supported */
  121794. vrSupported: boolean;
  121795. }
  121796. /**
  121797. * Defines the interface used by objects containing a viewport (like a camera)
  121798. */
  121799. interface IViewportOwnerLike {
  121800. /**
  121801. * Gets or sets the viewport
  121802. */
  121803. viewport: IViewportLike;
  121804. }
  121805. /**
  121806. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  121807. */
  121808. export class Engine extends ThinEngine {
  121809. /** Defines that alpha blending is disabled */
  121810. static readonly ALPHA_DISABLE: number;
  121811. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  121812. static readonly ALPHA_ADD: number;
  121813. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  121814. static readonly ALPHA_COMBINE: number;
  121815. /** Defines that alpha blending to DEST - SRC * DEST */
  121816. static readonly ALPHA_SUBTRACT: number;
  121817. /** Defines that alpha blending to SRC * DEST */
  121818. static readonly ALPHA_MULTIPLY: number;
  121819. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  121820. static readonly ALPHA_MAXIMIZED: number;
  121821. /** Defines that alpha blending to SRC + DEST */
  121822. static readonly ALPHA_ONEONE: number;
  121823. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  121824. static readonly ALPHA_PREMULTIPLIED: number;
  121825. /**
  121826. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  121827. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  121828. */
  121829. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  121830. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  121831. static readonly ALPHA_INTERPOLATE: number;
  121832. /**
  121833. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  121834. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  121835. */
  121836. static readonly ALPHA_SCREENMODE: number;
  121837. /** Defines that the ressource is not delayed*/
  121838. static readonly DELAYLOADSTATE_NONE: number;
  121839. /** Defines that the ressource was successfully delay loaded */
  121840. static readonly DELAYLOADSTATE_LOADED: number;
  121841. /** Defines that the ressource is currently delay loading */
  121842. static readonly DELAYLOADSTATE_LOADING: number;
  121843. /** Defines that the ressource is delayed and has not started loading */
  121844. static readonly DELAYLOADSTATE_NOTLOADED: number;
  121845. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  121846. static readonly NEVER: number;
  121847. /** 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 */
  121848. static readonly ALWAYS: number;
  121849. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  121850. static readonly LESS: number;
  121851. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  121852. static readonly EQUAL: number;
  121853. /** 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 */
  121854. static readonly LEQUAL: number;
  121855. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  121856. static readonly GREATER: number;
  121857. /** 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 */
  121858. static readonly GEQUAL: number;
  121859. /** 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 */
  121860. static readonly NOTEQUAL: number;
  121861. /** Passed to stencilOperation to specify that stencil value must be kept */
  121862. static readonly KEEP: number;
  121863. /** Passed to stencilOperation to specify that stencil value must be replaced */
  121864. static readonly REPLACE: number;
  121865. /** Passed to stencilOperation to specify that stencil value must be incremented */
  121866. static readonly INCR: number;
  121867. /** Passed to stencilOperation to specify that stencil value must be decremented */
  121868. static readonly DECR: number;
  121869. /** Passed to stencilOperation to specify that stencil value must be inverted */
  121870. static readonly INVERT: number;
  121871. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  121872. static readonly INCR_WRAP: number;
  121873. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  121874. static readonly DECR_WRAP: number;
  121875. /** Texture is not repeating outside of 0..1 UVs */
  121876. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  121877. /** Texture is repeating outside of 0..1 UVs */
  121878. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  121879. /** Texture is repeating and mirrored */
  121880. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  121881. /** ALPHA */
  121882. static readonly TEXTUREFORMAT_ALPHA: number;
  121883. /** LUMINANCE */
  121884. static readonly TEXTUREFORMAT_LUMINANCE: number;
  121885. /** LUMINANCE_ALPHA */
  121886. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  121887. /** RGB */
  121888. static readonly TEXTUREFORMAT_RGB: number;
  121889. /** RGBA */
  121890. static readonly TEXTUREFORMAT_RGBA: number;
  121891. /** RED */
  121892. static readonly TEXTUREFORMAT_RED: number;
  121893. /** RED (2nd reference) */
  121894. static readonly TEXTUREFORMAT_R: number;
  121895. /** RG */
  121896. static readonly TEXTUREFORMAT_RG: number;
  121897. /** RED_INTEGER */
  121898. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  121899. /** RED_INTEGER (2nd reference) */
  121900. static readonly TEXTUREFORMAT_R_INTEGER: number;
  121901. /** RG_INTEGER */
  121902. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  121903. /** RGB_INTEGER */
  121904. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  121905. /** RGBA_INTEGER */
  121906. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  121907. /** UNSIGNED_BYTE */
  121908. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  121909. /** UNSIGNED_BYTE (2nd reference) */
  121910. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  121911. /** FLOAT */
  121912. static readonly TEXTURETYPE_FLOAT: number;
  121913. /** HALF_FLOAT */
  121914. static readonly TEXTURETYPE_HALF_FLOAT: number;
  121915. /** BYTE */
  121916. static readonly TEXTURETYPE_BYTE: number;
  121917. /** SHORT */
  121918. static readonly TEXTURETYPE_SHORT: number;
  121919. /** UNSIGNED_SHORT */
  121920. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  121921. /** INT */
  121922. static readonly TEXTURETYPE_INT: number;
  121923. /** UNSIGNED_INT */
  121924. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  121925. /** UNSIGNED_SHORT_4_4_4_4 */
  121926. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  121927. /** UNSIGNED_SHORT_5_5_5_1 */
  121928. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  121929. /** UNSIGNED_SHORT_5_6_5 */
  121930. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  121931. /** UNSIGNED_INT_2_10_10_10_REV */
  121932. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  121933. /** UNSIGNED_INT_24_8 */
  121934. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  121935. /** UNSIGNED_INT_10F_11F_11F_REV */
  121936. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  121937. /** UNSIGNED_INT_5_9_9_9_REV */
  121938. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  121939. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  121940. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  121941. /** nearest is mag = nearest and min = nearest and mip = linear */
  121942. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  121943. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121944. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  121945. /** Trilinear is mag = linear and min = linear and mip = linear */
  121946. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  121947. /** nearest is mag = nearest and min = nearest and mip = linear */
  121948. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  121949. /** Bilinear is mag = linear and min = linear and mip = nearest */
  121950. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  121951. /** Trilinear is mag = linear and min = linear and mip = linear */
  121952. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  121953. /** mag = nearest and min = nearest and mip = nearest */
  121954. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  121955. /** mag = nearest and min = linear and mip = nearest */
  121956. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  121957. /** mag = nearest and min = linear and mip = linear */
  121958. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  121959. /** mag = nearest and min = linear and mip = none */
  121960. static readonly TEXTURE_NEAREST_LINEAR: number;
  121961. /** mag = nearest and min = nearest and mip = none */
  121962. static readonly TEXTURE_NEAREST_NEAREST: number;
  121963. /** mag = linear and min = nearest and mip = nearest */
  121964. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  121965. /** mag = linear and min = nearest and mip = linear */
  121966. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  121967. /** mag = linear and min = linear and mip = none */
  121968. static readonly TEXTURE_LINEAR_LINEAR: number;
  121969. /** mag = linear and min = nearest and mip = none */
  121970. static readonly TEXTURE_LINEAR_NEAREST: number;
  121971. /** Explicit coordinates mode */
  121972. static readonly TEXTURE_EXPLICIT_MODE: number;
  121973. /** Spherical coordinates mode */
  121974. static readonly TEXTURE_SPHERICAL_MODE: number;
  121975. /** Planar coordinates mode */
  121976. static readonly TEXTURE_PLANAR_MODE: number;
  121977. /** Cubic coordinates mode */
  121978. static readonly TEXTURE_CUBIC_MODE: number;
  121979. /** Projection coordinates mode */
  121980. static readonly TEXTURE_PROJECTION_MODE: number;
  121981. /** Skybox coordinates mode */
  121982. static readonly TEXTURE_SKYBOX_MODE: number;
  121983. /** Inverse Cubic coordinates mode */
  121984. static readonly TEXTURE_INVCUBIC_MODE: number;
  121985. /** Equirectangular coordinates mode */
  121986. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  121987. /** Equirectangular Fixed coordinates mode */
  121988. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  121989. /** Equirectangular Fixed Mirrored coordinates mode */
  121990. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  121991. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  121992. static readonly SCALEMODE_FLOOR: number;
  121993. /** Defines that texture rescaling will look for the nearest power of 2 size */
  121994. static readonly SCALEMODE_NEAREST: number;
  121995. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  121996. static readonly SCALEMODE_CEILING: number;
  121997. /**
  121998. * Returns the current npm package of the sdk
  121999. */
  122000. static get NpmPackage(): string;
  122001. /**
  122002. * Returns the current version of the framework
  122003. */
  122004. static get Version(): string;
  122005. /** Gets the list of created engines */
  122006. static get Instances(): Engine[];
  122007. /**
  122008. * Gets the latest created engine
  122009. */
  122010. static get LastCreatedEngine(): Nullable<Engine>;
  122011. /**
  122012. * Gets the latest created scene
  122013. */
  122014. static get LastCreatedScene(): Nullable<Scene>;
  122015. /**
  122016. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  122017. * @param flag defines which part of the materials must be marked as dirty
  122018. * @param predicate defines a predicate used to filter which materials should be affected
  122019. */
  122020. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  122021. /**
  122022. * Method called to create the default loading screen.
  122023. * This can be overriden in your own app.
  122024. * @param canvas The rendering canvas element
  122025. * @returns The loading screen
  122026. */
  122027. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  122028. /**
  122029. * Method called to create the default rescale post process on each engine.
  122030. */
  122031. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  122032. /**
  122033. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  122034. **/
  122035. enableOfflineSupport: boolean;
  122036. /**
  122037. * 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)
  122038. **/
  122039. disableManifestCheck: boolean;
  122040. /**
  122041. * Gets the list of created scenes
  122042. */
  122043. scenes: Scene[];
  122044. /**
  122045. * Event raised when a new scene is created
  122046. */
  122047. onNewSceneAddedObservable: Observable<Scene>;
  122048. /**
  122049. * Gets the list of created postprocesses
  122050. */
  122051. postProcesses: PostProcess[];
  122052. /**
  122053. * Gets a boolean indicating if the pointer is currently locked
  122054. */
  122055. isPointerLock: boolean;
  122056. /**
  122057. * Observable event triggered each time the rendering canvas is resized
  122058. */
  122059. onResizeObservable: Observable<Engine>;
  122060. /**
  122061. * Observable event triggered each time the canvas loses focus
  122062. */
  122063. onCanvasBlurObservable: Observable<Engine>;
  122064. /**
  122065. * Observable event triggered each time the canvas gains focus
  122066. */
  122067. onCanvasFocusObservable: Observable<Engine>;
  122068. /**
  122069. * Observable event triggered each time the canvas receives pointerout event
  122070. */
  122071. onCanvasPointerOutObservable: Observable<PointerEvent>;
  122072. /**
  122073. * Observable raised when the engine begins a new frame
  122074. */
  122075. onBeginFrameObservable: Observable<Engine>;
  122076. /**
  122077. * If set, will be used to request the next animation frame for the render loop
  122078. */
  122079. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  122080. /**
  122081. * Observable raised when the engine ends the current frame
  122082. */
  122083. onEndFrameObservable: Observable<Engine>;
  122084. /**
  122085. * Observable raised when the engine is about to compile a shader
  122086. */
  122087. onBeforeShaderCompilationObservable: Observable<Engine>;
  122088. /**
  122089. * Observable raised when the engine has jsut compiled a shader
  122090. */
  122091. onAfterShaderCompilationObservable: Observable<Engine>;
  122092. /**
  122093. * Gets the audio engine
  122094. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122095. * @ignorenaming
  122096. */
  122097. static audioEngine: IAudioEngine;
  122098. /**
  122099. * Default AudioEngine factory responsible of creating the Audio Engine.
  122100. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  122101. */
  122102. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  122103. /**
  122104. * Default offline support factory responsible of creating a tool used to store data locally.
  122105. * By default, this will create a Database object if the workload has been embedded.
  122106. */
  122107. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  122108. private _loadingScreen;
  122109. private _pointerLockRequested;
  122110. private _rescalePostProcess;
  122111. private _deterministicLockstep;
  122112. private _lockstepMaxSteps;
  122113. private _timeStep;
  122114. protected get _supportsHardwareTextureRescaling(): boolean;
  122115. private _fps;
  122116. private _deltaTime;
  122117. /** @hidden */
  122118. _drawCalls: PerfCounter;
  122119. /** 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 */
  122120. canvasTabIndex: number;
  122121. /**
  122122. * Turn this value on if you want to pause FPS computation when in background
  122123. */
  122124. disablePerformanceMonitorInBackground: boolean;
  122125. private _performanceMonitor;
  122126. /**
  122127. * Gets the performance monitor attached to this engine
  122128. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  122129. */
  122130. get performanceMonitor(): PerformanceMonitor;
  122131. private _onFocus;
  122132. private _onBlur;
  122133. private _onCanvasPointerOut;
  122134. private _onCanvasBlur;
  122135. private _onCanvasFocus;
  122136. private _onFullscreenChange;
  122137. private _onPointerLockChange;
  122138. /**
  122139. * Gets the HTML element used to attach event listeners
  122140. * @returns a HTML element
  122141. */
  122142. getInputElement(): Nullable<HTMLElement>;
  122143. /**
  122144. * Creates a new engine
  122145. * @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
  122146. * @param antialias defines enable antialiasing (default: false)
  122147. * @param options defines further options to be sent to the getContext() function
  122148. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  122149. */
  122150. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  122151. /**
  122152. * Gets current aspect ratio
  122153. * @param viewportOwner defines the camera to use to get the aspect ratio
  122154. * @param useScreen defines if screen size must be used (or the current render target if any)
  122155. * @returns a number defining the aspect ratio
  122156. */
  122157. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  122158. /**
  122159. * Gets current screen aspect ratio
  122160. * @returns a number defining the aspect ratio
  122161. */
  122162. getScreenAspectRatio(): number;
  122163. /**
  122164. * Gets the client rect of the HTML canvas attached with the current webGL context
  122165. * @returns a client rectanglee
  122166. */
  122167. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  122168. /**
  122169. * Gets the client rect of the HTML element used for events
  122170. * @returns a client rectanglee
  122171. */
  122172. getInputElementClientRect(): Nullable<ClientRect>;
  122173. /**
  122174. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  122175. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122176. * @returns true if engine is in deterministic lock step mode
  122177. */
  122178. isDeterministicLockStep(): boolean;
  122179. /**
  122180. * Gets the max steps when engine is running in deterministic lock step
  122181. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  122182. * @returns the max steps
  122183. */
  122184. getLockstepMaxSteps(): number;
  122185. /**
  122186. * Returns the time in ms between steps when using deterministic lock step.
  122187. * @returns time step in (ms)
  122188. */
  122189. getTimeStep(): number;
  122190. /**
  122191. * Force the mipmap generation for the given render target texture
  122192. * @param texture defines the render target texture to use
  122193. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  122194. */
  122195. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  122196. /** States */
  122197. /**
  122198. * Set various states to the webGL context
  122199. * @param culling defines backface culling state
  122200. * @param zOffset defines the value to apply to zOffset (0 by default)
  122201. * @param force defines if states must be applied even if cache is up to date
  122202. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  122203. */
  122204. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122205. /**
  122206. * Set the z offset to apply to current rendering
  122207. * @param value defines the offset to apply
  122208. */
  122209. setZOffset(value: number): void;
  122210. /**
  122211. * Gets the current value of the zOffset
  122212. * @returns the current zOffset state
  122213. */
  122214. getZOffset(): number;
  122215. /**
  122216. * Enable or disable depth buffering
  122217. * @param enable defines the state to set
  122218. */
  122219. setDepthBuffer(enable: boolean): void;
  122220. /**
  122221. * Gets a boolean indicating if depth writing is enabled
  122222. * @returns the current depth writing state
  122223. */
  122224. getDepthWrite(): boolean;
  122225. /**
  122226. * Enable or disable depth writing
  122227. * @param enable defines the state to set
  122228. */
  122229. setDepthWrite(enable: boolean): void;
  122230. /**
  122231. * Gets a boolean indicating if stencil buffer is enabled
  122232. * @returns the current stencil buffer state
  122233. */
  122234. getStencilBuffer(): boolean;
  122235. /**
  122236. * Enable or disable the stencil buffer
  122237. * @param enable defines if the stencil buffer must be enabled or disabled
  122238. */
  122239. setStencilBuffer(enable: boolean): void;
  122240. /**
  122241. * Gets the current stencil mask
  122242. * @returns a number defining the new stencil mask to use
  122243. */
  122244. getStencilMask(): number;
  122245. /**
  122246. * Sets the current stencil mask
  122247. * @param mask defines the new stencil mask to use
  122248. */
  122249. setStencilMask(mask: number): void;
  122250. /**
  122251. * Gets the current stencil function
  122252. * @returns a number defining the stencil function to use
  122253. */
  122254. getStencilFunction(): number;
  122255. /**
  122256. * Gets the current stencil reference value
  122257. * @returns a number defining the stencil reference value to use
  122258. */
  122259. getStencilFunctionReference(): number;
  122260. /**
  122261. * Gets the current stencil mask
  122262. * @returns a number defining the stencil mask to use
  122263. */
  122264. getStencilFunctionMask(): number;
  122265. /**
  122266. * Sets the current stencil function
  122267. * @param stencilFunc defines the new stencil function to use
  122268. */
  122269. setStencilFunction(stencilFunc: number): void;
  122270. /**
  122271. * Sets the current stencil reference
  122272. * @param reference defines the new stencil reference to use
  122273. */
  122274. setStencilFunctionReference(reference: number): void;
  122275. /**
  122276. * Sets the current stencil mask
  122277. * @param mask defines the new stencil mask to use
  122278. */
  122279. setStencilFunctionMask(mask: number): void;
  122280. /**
  122281. * Gets the current stencil operation when stencil fails
  122282. * @returns a number defining stencil operation to use when stencil fails
  122283. */
  122284. getStencilOperationFail(): number;
  122285. /**
  122286. * Gets the current stencil operation when depth fails
  122287. * @returns a number defining stencil operation to use when depth fails
  122288. */
  122289. getStencilOperationDepthFail(): number;
  122290. /**
  122291. * Gets the current stencil operation when stencil passes
  122292. * @returns a number defining stencil operation to use when stencil passes
  122293. */
  122294. getStencilOperationPass(): number;
  122295. /**
  122296. * Sets the stencil operation to use when stencil fails
  122297. * @param operation defines the stencil operation to use when stencil fails
  122298. */
  122299. setStencilOperationFail(operation: number): void;
  122300. /**
  122301. * Sets the stencil operation to use when depth fails
  122302. * @param operation defines the stencil operation to use when depth fails
  122303. */
  122304. setStencilOperationDepthFail(operation: number): void;
  122305. /**
  122306. * Sets the stencil operation to use when stencil passes
  122307. * @param operation defines the stencil operation to use when stencil passes
  122308. */
  122309. setStencilOperationPass(operation: number): void;
  122310. /**
  122311. * Sets a boolean indicating if the dithering state is enabled or disabled
  122312. * @param value defines the dithering state
  122313. */
  122314. setDitheringState(value: boolean): void;
  122315. /**
  122316. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  122317. * @param value defines the rasterizer state
  122318. */
  122319. setRasterizerState(value: boolean): void;
  122320. /**
  122321. * Gets the current depth function
  122322. * @returns a number defining the depth function
  122323. */
  122324. getDepthFunction(): Nullable<number>;
  122325. /**
  122326. * Sets the current depth function
  122327. * @param depthFunc defines the function to use
  122328. */
  122329. setDepthFunction(depthFunc: number): void;
  122330. /**
  122331. * Sets the current depth function to GREATER
  122332. */
  122333. setDepthFunctionToGreater(): void;
  122334. /**
  122335. * Sets the current depth function to GEQUAL
  122336. */
  122337. setDepthFunctionToGreaterOrEqual(): void;
  122338. /**
  122339. * Sets the current depth function to LESS
  122340. */
  122341. setDepthFunctionToLess(): void;
  122342. /**
  122343. * Sets the current depth function to LEQUAL
  122344. */
  122345. setDepthFunctionToLessOrEqual(): void;
  122346. private _cachedStencilBuffer;
  122347. private _cachedStencilFunction;
  122348. private _cachedStencilMask;
  122349. private _cachedStencilOperationPass;
  122350. private _cachedStencilOperationFail;
  122351. private _cachedStencilOperationDepthFail;
  122352. private _cachedStencilReference;
  122353. /**
  122354. * Caches the the state of the stencil buffer
  122355. */
  122356. cacheStencilState(): void;
  122357. /**
  122358. * Restores the state of the stencil buffer
  122359. */
  122360. restoreStencilState(): void;
  122361. /**
  122362. * Directly set the WebGL Viewport
  122363. * @param x defines the x coordinate of the viewport (in screen space)
  122364. * @param y defines the y coordinate of the viewport (in screen space)
  122365. * @param width defines the width of the viewport (in screen space)
  122366. * @param height defines the height of the viewport (in screen space)
  122367. * @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
  122368. */
  122369. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  122370. /**
  122371. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  122372. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  122373. * @param y defines the y-coordinate of the corner of the clear rectangle
  122374. * @param width defines the width of the clear rectangle
  122375. * @param height defines the height of the clear rectangle
  122376. * @param clearColor defines the clear color
  122377. */
  122378. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  122379. /**
  122380. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  122381. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  122382. * @param y defines the y-coordinate of the corner of the clear rectangle
  122383. * @param width defines the width of the clear rectangle
  122384. * @param height defines the height of the clear rectangle
  122385. */
  122386. enableScissor(x: number, y: number, width: number, height: number): void;
  122387. /**
  122388. * Disable previously set scissor test rectangle
  122389. */
  122390. disableScissor(): void;
  122391. protected _reportDrawCall(): void;
  122392. /**
  122393. * Initializes a webVR display and starts listening to display change events
  122394. * The onVRDisplayChangedObservable will be notified upon these changes
  122395. * @returns The onVRDisplayChangedObservable
  122396. */
  122397. initWebVR(): Observable<IDisplayChangedEventArgs>;
  122398. /** @hidden */
  122399. _prepareVRComponent(): void;
  122400. /** @hidden */
  122401. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  122402. /** @hidden */
  122403. _submitVRFrame(): void;
  122404. /**
  122405. * Call this function to leave webVR mode
  122406. * Will do nothing if webVR is not supported or if there is no webVR device
  122407. * @see https://doc.babylonjs.com/how_to/webvr_camera
  122408. */
  122409. disableVR(): void;
  122410. /**
  122411. * Gets a boolean indicating that the system is in VR mode and is presenting
  122412. * @returns true if VR mode is engaged
  122413. */
  122414. isVRPresenting(): boolean;
  122415. /** @hidden */
  122416. _requestVRFrame(): void;
  122417. /** @hidden */
  122418. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  122419. /**
  122420. * Gets the source code of the vertex shader associated with a specific webGL program
  122421. * @param program defines the program to use
  122422. * @returns a string containing the source code of the vertex shader associated with the program
  122423. */
  122424. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  122425. /**
  122426. * Gets the source code of the fragment shader associated with a specific webGL program
  122427. * @param program defines the program to use
  122428. * @returns a string containing the source code of the fragment shader associated with the program
  122429. */
  122430. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  122431. /**
  122432. * Sets a depth stencil texture from a render target to the according uniform.
  122433. * @param channel The texture channel
  122434. * @param uniform The uniform to set
  122435. * @param texture The render target texture containing the depth stencil texture to apply
  122436. */
  122437. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  122438. /**
  122439. * Sets a texture to the webGL context from a postprocess
  122440. * @param channel defines the channel to use
  122441. * @param postProcess defines the source postprocess
  122442. */
  122443. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  122444. /**
  122445. * Binds the output of the passed in post process to the texture channel specified
  122446. * @param channel The channel the texture should be bound to
  122447. * @param postProcess The post process which's output should be bound
  122448. */
  122449. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  122450. protected _rebuildBuffers(): void;
  122451. /** @hidden */
  122452. _renderFrame(): void;
  122453. _renderLoop(): void;
  122454. /** @hidden */
  122455. _renderViews(): boolean;
  122456. /**
  122457. * Toggle full screen mode
  122458. * @param requestPointerLock defines if a pointer lock should be requested from the user
  122459. */
  122460. switchFullscreen(requestPointerLock: boolean): void;
  122461. /**
  122462. * Enters full screen mode
  122463. * @param requestPointerLock defines if a pointer lock should be requested from the user
  122464. */
  122465. enterFullscreen(requestPointerLock: boolean): void;
  122466. /**
  122467. * Exits full screen mode
  122468. */
  122469. exitFullscreen(): void;
  122470. /**
  122471. * Enters Pointerlock mode
  122472. */
  122473. enterPointerlock(): void;
  122474. /**
  122475. * Exits Pointerlock mode
  122476. */
  122477. exitPointerlock(): void;
  122478. /**
  122479. * Begin a new frame
  122480. */
  122481. beginFrame(): void;
  122482. /**
  122483. * Enf the current frame
  122484. */
  122485. endFrame(): void;
  122486. resize(): void;
  122487. /**
  122488. * Force a specific size of the canvas
  122489. * @param width defines the new canvas' width
  122490. * @param height defines the new canvas' height
  122491. * @returns true if the size was changed
  122492. */
  122493. setSize(width: number, height: number): boolean;
  122494. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  122495. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  122496. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  122497. _releaseTexture(texture: InternalTexture): void;
  122498. /**
  122499. * @hidden
  122500. * Rescales a texture
  122501. * @param source input texutre
  122502. * @param destination destination texture
  122503. * @param scene scene to use to render the resize
  122504. * @param internalFormat format to use when resizing
  122505. * @param onComplete callback to be called when resize has completed
  122506. */
  122507. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  122508. /**
  122509. * Gets the current framerate
  122510. * @returns a number representing the framerate
  122511. */
  122512. getFps(): number;
  122513. /**
  122514. * Gets the time spent between current and previous frame
  122515. * @returns a number representing the delta time in ms
  122516. */
  122517. getDeltaTime(): number;
  122518. private _measureFps;
  122519. /** @hidden */
  122520. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  122521. /**
  122522. * Updates the sample count of a render target texture
  122523. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  122524. * @param texture defines the texture to update
  122525. * @param samples defines the sample count to set
  122526. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  122527. */
  122528. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  122529. /**
  122530. * Updates a depth texture Comparison Mode and Function.
  122531. * If the comparison Function is equal to 0, the mode will be set to none.
  122532. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  122533. * @param texture The texture to set the comparison function for
  122534. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  122535. */
  122536. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  122537. /**
  122538. * Creates a webGL buffer to use with instanciation
  122539. * @param capacity defines the size of the buffer
  122540. * @returns the webGL buffer
  122541. */
  122542. createInstancesBuffer(capacity: number): DataBuffer;
  122543. /**
  122544. * Delete a webGL buffer used with instanciation
  122545. * @param buffer defines the webGL buffer to delete
  122546. */
  122547. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  122548. private _clientWaitAsync;
  122549. /** @hidden */
  122550. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  122551. dispose(): void;
  122552. private _disableTouchAction;
  122553. /**
  122554. * Display the loading screen
  122555. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122556. */
  122557. displayLoadingUI(): void;
  122558. /**
  122559. * Hide the loading screen
  122560. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122561. */
  122562. hideLoadingUI(): void;
  122563. /**
  122564. * Gets the current loading screen object
  122565. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122566. */
  122567. get loadingScreen(): ILoadingScreen;
  122568. /**
  122569. * Sets the current loading screen object
  122570. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122571. */
  122572. set loadingScreen(loadingScreen: ILoadingScreen);
  122573. /**
  122574. * Sets the current loading screen text
  122575. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122576. */
  122577. set loadingUIText(text: string);
  122578. /**
  122579. * Sets the current loading screen background color
  122580. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  122581. */
  122582. set loadingUIBackgroundColor(color: string);
  122583. /** Pointerlock and fullscreen */
  122584. /**
  122585. * Ask the browser to promote the current element to pointerlock mode
  122586. * @param element defines the DOM element to promote
  122587. */
  122588. static _RequestPointerlock(element: HTMLElement): void;
  122589. /**
  122590. * Asks the browser to exit pointerlock mode
  122591. */
  122592. static _ExitPointerlock(): void;
  122593. /**
  122594. * Ask the browser to promote the current element to fullscreen rendering mode
  122595. * @param element defines the DOM element to promote
  122596. */
  122597. static _RequestFullscreen(element: HTMLElement): void;
  122598. /**
  122599. * Asks the browser to exit fullscreen mode
  122600. */
  122601. static _ExitFullscreen(): void;
  122602. }
  122603. }
  122604. declare module BABYLON {
  122605. /**
  122606. * The engine store class is responsible to hold all the instances of Engine and Scene created
  122607. * during the life time of the application.
  122608. */
  122609. export class EngineStore {
  122610. /** Gets the list of created engines */
  122611. static Instances: Engine[];
  122612. /** @hidden */
  122613. static _LastCreatedScene: Nullable<Scene>;
  122614. /**
  122615. * Gets the latest created engine
  122616. */
  122617. static get LastCreatedEngine(): Nullable<Engine>;
  122618. /**
  122619. * Gets the latest created scene
  122620. */
  122621. static get LastCreatedScene(): Nullable<Scene>;
  122622. /**
  122623. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  122624. * @ignorenaming
  122625. */
  122626. static UseFallbackTexture: boolean;
  122627. /**
  122628. * Texture content used if a texture cannot loaded
  122629. * @ignorenaming
  122630. */
  122631. static FallbackTexture: string;
  122632. }
  122633. }
  122634. declare module BABYLON {
  122635. /**
  122636. * Helper class that provides a small promise polyfill
  122637. */
  122638. export class PromisePolyfill {
  122639. /**
  122640. * Static function used to check if the polyfill is required
  122641. * If this is the case then the function will inject the polyfill to window.Promise
  122642. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  122643. */
  122644. static Apply(force?: boolean): void;
  122645. }
  122646. }
  122647. declare module BABYLON {
  122648. /**
  122649. * Interface for screenshot methods with describe argument called `size` as object with options
  122650. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  122651. */
  122652. export interface IScreenshotSize {
  122653. /**
  122654. * number in pixels for canvas height
  122655. */
  122656. height?: number;
  122657. /**
  122658. * multiplier allowing render at a higher or lower resolution
  122659. * If value is defined then height and width will be ignored and taken from camera
  122660. */
  122661. precision?: number;
  122662. /**
  122663. * number in pixels for canvas width
  122664. */
  122665. width?: number;
  122666. }
  122667. }
  122668. declare module BABYLON {
  122669. interface IColor4Like {
  122670. r: float;
  122671. g: float;
  122672. b: float;
  122673. a: float;
  122674. }
  122675. /**
  122676. * Class containing a set of static utilities functions
  122677. */
  122678. export class Tools {
  122679. /**
  122680. * Gets or sets the base URL to use to load assets
  122681. */
  122682. static get BaseUrl(): string;
  122683. static set BaseUrl(value: string);
  122684. /**
  122685. * Enable/Disable Custom HTTP Request Headers globally.
  122686. * default = false
  122687. * @see CustomRequestHeaders
  122688. */
  122689. static UseCustomRequestHeaders: boolean;
  122690. /**
  122691. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  122692. * i.e. when loading files, where the server/service expects an Authorization header
  122693. */
  122694. static CustomRequestHeaders: {
  122695. [key: string]: string;
  122696. };
  122697. /**
  122698. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  122699. */
  122700. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  122701. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  122702. /**
  122703. * Default behaviour for cors in the application.
  122704. * It can be a string if the expected behavior is identical in the entire app.
  122705. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  122706. */
  122707. static get CorsBehavior(): string | ((url: string | string[]) => string);
  122708. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  122709. /**
  122710. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  122711. * @ignorenaming
  122712. */
  122713. static get UseFallbackTexture(): boolean;
  122714. static set UseFallbackTexture(value: boolean);
  122715. /**
  122716. * Use this object to register external classes like custom textures or material
  122717. * to allow the laoders to instantiate them
  122718. */
  122719. static get RegisteredExternalClasses(): {
  122720. [key: string]: Object;
  122721. };
  122722. static set RegisteredExternalClasses(classes: {
  122723. [key: string]: Object;
  122724. });
  122725. /**
  122726. * Texture content used if a texture cannot loaded
  122727. * @ignorenaming
  122728. */
  122729. static get fallbackTexture(): string;
  122730. static set fallbackTexture(value: string);
  122731. /**
  122732. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  122733. * @param u defines the coordinate on X axis
  122734. * @param v defines the coordinate on Y axis
  122735. * @param width defines the width of the source data
  122736. * @param height defines the height of the source data
  122737. * @param pixels defines the source byte array
  122738. * @param color defines the output color
  122739. */
  122740. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  122741. /**
  122742. * Interpolates between a and b via alpha
  122743. * @param a The lower value (returned when alpha = 0)
  122744. * @param b The upper value (returned when alpha = 1)
  122745. * @param alpha The interpolation-factor
  122746. * @return The mixed value
  122747. */
  122748. static Mix(a: number, b: number, alpha: number): number;
  122749. /**
  122750. * Tries to instantiate a new object from a given class name
  122751. * @param className defines the class name to instantiate
  122752. * @returns the new object or null if the system was not able to do the instantiation
  122753. */
  122754. static Instantiate(className: string): any;
  122755. /**
  122756. * Provides a slice function that will work even on IE
  122757. * @param data defines the array to slice
  122758. * @param start defines the start of the data (optional)
  122759. * @param end defines the end of the data (optional)
  122760. * @returns the new sliced array
  122761. */
  122762. static Slice<T>(data: T, start?: number, end?: number): T;
  122763. /**
  122764. * Provides a slice function that will work even on IE
  122765. * The difference between this and Slice is that this will force-convert to array
  122766. * @param data defines the array to slice
  122767. * @param start defines the start of the data (optional)
  122768. * @param end defines the end of the data (optional)
  122769. * @returns the new sliced array
  122770. */
  122771. static SliceToArray<T, P>(data: T, start?: number, end?: number): Array<P>;
  122772. /**
  122773. * Polyfill for setImmediate
  122774. * @param action defines the action to execute after the current execution block
  122775. */
  122776. static SetImmediate(action: () => void): void;
  122777. /**
  122778. * Function indicating if a number is an exponent of 2
  122779. * @param value defines the value to test
  122780. * @returns true if the value is an exponent of 2
  122781. */
  122782. static IsExponentOfTwo(value: number): boolean;
  122783. private static _tmpFloatArray;
  122784. /**
  122785. * Returns the nearest 32-bit single precision float representation of a Number
  122786. * @param value A Number. If the parameter is of a different type, it will get converted
  122787. * to a number or to NaN if it cannot be converted
  122788. * @returns number
  122789. */
  122790. static FloatRound(value: number): number;
  122791. /**
  122792. * Extracts the filename from a path
  122793. * @param path defines the path to use
  122794. * @returns the filename
  122795. */
  122796. static GetFilename(path: string): string;
  122797. /**
  122798. * Extracts the "folder" part of a path (everything before the filename).
  122799. * @param uri The URI to extract the info from
  122800. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  122801. * @returns The "folder" part of the path
  122802. */
  122803. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  122804. /**
  122805. * Extracts text content from a DOM element hierarchy
  122806. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  122807. */
  122808. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  122809. /**
  122810. * Convert an angle in radians to degrees
  122811. * @param angle defines the angle to convert
  122812. * @returns the angle in degrees
  122813. */
  122814. static ToDegrees(angle: number): number;
  122815. /**
  122816. * Convert an angle in degrees to radians
  122817. * @param angle defines the angle to convert
  122818. * @returns the angle in radians
  122819. */
  122820. static ToRadians(angle: number): number;
  122821. /**
  122822. * Returns an array if obj is not an array
  122823. * @param obj defines the object to evaluate as an array
  122824. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  122825. * @returns either obj directly if obj is an array or a new array containing obj
  122826. */
  122827. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  122828. /**
  122829. * Gets the pointer prefix to use
  122830. * @param engine defines the engine we are finding the prefix for
  122831. * @returns "pointer" if touch is enabled. Else returns "mouse"
  122832. */
  122833. static GetPointerPrefix(engine: Engine): string;
  122834. /**
  122835. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  122836. * @param url define the url we are trying
  122837. * @param element define the dom element where to configure the cors policy
  122838. */
  122839. static SetCorsBehavior(url: string | string[], element: {
  122840. crossOrigin: string | null;
  122841. }): void;
  122842. /**
  122843. * Removes unwanted characters from an url
  122844. * @param url defines the url to clean
  122845. * @returns the cleaned url
  122846. */
  122847. static CleanUrl(url: string): string;
  122848. /**
  122849. * Gets or sets a function used to pre-process url before using them to load assets
  122850. */
  122851. static get PreprocessUrl(): (url: string) => string;
  122852. static set PreprocessUrl(processor: (url: string) => string);
  122853. /**
  122854. * Loads an image as an HTMLImageElement.
  122855. * @param input url string, ArrayBuffer, or Blob to load
  122856. * @param onLoad callback called when the image successfully loads
  122857. * @param onError callback called when the image fails to load
  122858. * @param offlineProvider offline provider for caching
  122859. * @param mimeType optional mime type
  122860. * @returns the HTMLImageElement of the loaded image
  122861. */
  122862. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  122863. /**
  122864. * Loads a file from a url
  122865. * @param url url string, ArrayBuffer, or Blob to load
  122866. * @param onSuccess callback called when the file successfully loads
  122867. * @param onProgress callback called while file is loading (if the server supports this mode)
  122868. * @param offlineProvider defines the offline provider for caching
  122869. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122870. * @param onError callback called when the file fails to load
  122871. * @returns a file request object
  122872. */
  122873. 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;
  122874. /**
  122875. * Loads a file from a url
  122876. * @param url the file url to load
  122877. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  122878. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  122879. */
  122880. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  122881. /**
  122882. * Load a script (identified by an url). When the url returns, the
  122883. * content of this file is added into a new script element, attached to the DOM (body element)
  122884. * @param scriptUrl defines the url of the script to laod
  122885. * @param onSuccess defines the callback called when the script is loaded
  122886. * @param onError defines the callback to call if an error occurs
  122887. * @param scriptId defines the id of the script element
  122888. */
  122889. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  122890. /**
  122891. * Load an asynchronous script (identified by an url). When the url returns, the
  122892. * content of this file is added into a new script element, attached to the DOM (body element)
  122893. * @param scriptUrl defines the url of the script to laod
  122894. * @param scriptId defines the id of the script element
  122895. * @returns a promise request object
  122896. */
  122897. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  122898. /**
  122899. * Loads a file from a blob
  122900. * @param fileToLoad defines the blob to use
  122901. * @param callback defines the callback to call when data is loaded
  122902. * @param progressCallback defines the callback to call during loading process
  122903. * @returns a file request object
  122904. */
  122905. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  122906. /**
  122907. * Reads a file from a File object
  122908. * @param file defines the file to load
  122909. * @param onSuccess defines the callback to call when data is loaded
  122910. * @param onProgress defines the callback to call during loading process
  122911. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  122912. * @param onError defines the callback to call when an error occurs
  122913. * @returns a file request object
  122914. */
  122915. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  122916. /**
  122917. * Creates a data url from a given string content
  122918. * @param content defines the content to convert
  122919. * @returns the new data url link
  122920. */
  122921. static FileAsURL(content: string): string;
  122922. /**
  122923. * Format the given number to a specific decimal format
  122924. * @param value defines the number to format
  122925. * @param decimals defines the number of decimals to use
  122926. * @returns the formatted string
  122927. */
  122928. static Format(value: number, decimals?: number): string;
  122929. /**
  122930. * Tries to copy an object by duplicating every property
  122931. * @param source defines the source object
  122932. * @param destination defines the target object
  122933. * @param doNotCopyList defines a list of properties to avoid
  122934. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  122935. */
  122936. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  122937. /**
  122938. * Gets a boolean indicating if the given object has no own property
  122939. * @param obj defines the object to test
  122940. * @returns true if object has no own property
  122941. */
  122942. static IsEmpty(obj: any): boolean;
  122943. /**
  122944. * Function used to register events at window level
  122945. * @param windowElement defines the Window object to use
  122946. * @param events defines the events to register
  122947. */
  122948. static RegisterTopRootEvents(windowElement: Window, events: {
  122949. name: string;
  122950. handler: Nullable<(e: FocusEvent) => any>;
  122951. }[]): void;
  122952. /**
  122953. * Function used to unregister events from window level
  122954. * @param windowElement defines the Window object to use
  122955. * @param events defines the events to unregister
  122956. */
  122957. static UnregisterTopRootEvents(windowElement: Window, events: {
  122958. name: string;
  122959. handler: Nullable<(e: FocusEvent) => any>;
  122960. }[]): void;
  122961. /**
  122962. * @ignore
  122963. */
  122964. static _ScreenshotCanvas: HTMLCanvasElement;
  122965. /**
  122966. * Dumps the current bound framebuffer
  122967. * @param width defines the rendering width
  122968. * @param height defines the rendering height
  122969. * @param engine defines the hosting engine
  122970. * @param successCallback defines the callback triggered once the data are available
  122971. * @param mimeType defines the mime type of the result
  122972. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  122973. */
  122974. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122975. /**
  122976. * Converts the canvas data to blob.
  122977. * This acts as a polyfill for browsers not supporting the to blob function.
  122978. * @param canvas Defines the canvas to extract the data from
  122979. * @param successCallback Defines the callback triggered once the data are available
  122980. * @param mimeType Defines the mime type of the result
  122981. */
  122982. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  122983. /**
  122984. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  122985. * @param successCallback defines the callback triggered once the data are available
  122986. * @param mimeType defines the mime type of the result
  122987. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  122988. */
  122989. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  122990. /**
  122991. * Downloads a blob in the browser
  122992. * @param blob defines the blob to download
  122993. * @param fileName defines the name of the downloaded file
  122994. */
  122995. static Download(blob: Blob, fileName: string): void;
  122996. /**
  122997. * Captures a screenshot of the current rendering
  122998. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  122999. * @param engine defines the rendering engine
  123000. * @param camera defines the source camera
  123001. * @param size This parameter can be set to a single number or to an object with the
  123002. * following (optional) properties: precision, width, height. If a single number is passed,
  123003. * it will be used for both width and height. If an object is passed, the screenshot size
  123004. * will be derived from the parameters. The precision property is a multiplier allowing
  123005. * rendering at a higher or lower resolution
  123006. * @param successCallback defines the callback receives a single parameter which contains the
  123007. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123008. * src parameter of an <img> to display it
  123009. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123010. * Check your browser for supported MIME types
  123011. */
  123012. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  123013. /**
  123014. * Captures a screenshot of the current rendering
  123015. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123016. * @param engine defines the rendering engine
  123017. * @param camera defines the source camera
  123018. * @param size This parameter can be set to a single number or to an object with the
  123019. * following (optional) properties: precision, width, height. If a single number is passed,
  123020. * it will be used for both width and height. If an object is passed, the screenshot size
  123021. * will be derived from the parameters. The precision property is a multiplier allowing
  123022. * rendering at a higher or lower resolution
  123023. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  123024. * Check your browser for supported MIME types
  123025. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123026. * to the src parameter of an <img> to display it
  123027. */
  123028. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  123029. /**
  123030. * Generates an image screenshot from the specified camera.
  123031. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123032. * @param engine The engine to use for rendering
  123033. * @param camera The camera to use for rendering
  123034. * @param size This parameter can be set to a single number or to an object with the
  123035. * following (optional) properties: precision, width, height. If a single number is passed,
  123036. * it will be used for both width and height. If an object is passed, the screenshot size
  123037. * will be derived from the parameters. The precision property is a multiplier allowing
  123038. * rendering at a higher or lower resolution
  123039. * @param successCallback The callback receives a single parameter which contains the
  123040. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  123041. * src parameter of an <img> to display it
  123042. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123043. * Check your browser for supported MIME types
  123044. * @param samples Texture samples (default: 1)
  123045. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123046. * @param fileName A name for for the downloaded file.
  123047. */
  123048. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  123049. /**
  123050. * Generates an image screenshot from the specified camera.
  123051. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  123052. * @param engine The engine to use for rendering
  123053. * @param camera The camera to use for rendering
  123054. * @param size This parameter can be set to a single number or to an object with the
  123055. * following (optional) properties: precision, width, height. If a single number is passed,
  123056. * it will be used for both width and height. If an object is passed, the screenshot size
  123057. * will be derived from the parameters. The precision property is a multiplier allowing
  123058. * rendering at a higher or lower resolution
  123059. * @param mimeType The MIME type of the screenshot image (default: image/png).
  123060. * Check your browser for supported MIME types
  123061. * @param samples Texture samples (default: 1)
  123062. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  123063. * @param fileName A name for for the downloaded file.
  123064. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  123065. * to the src parameter of an <img> to display it
  123066. */
  123067. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  123068. /**
  123069. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  123070. * Be aware Math.random() could cause collisions, but:
  123071. * "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"
  123072. * @returns a pseudo random id
  123073. */
  123074. static RandomId(): string;
  123075. /**
  123076. * Test if the given uri is a base64 string
  123077. * @param uri The uri to test
  123078. * @return True if the uri is a base64 string or false otherwise
  123079. */
  123080. static IsBase64(uri: string): boolean;
  123081. /**
  123082. * Decode the given base64 uri.
  123083. * @param uri The uri to decode
  123084. * @return The decoded base64 data.
  123085. */
  123086. static DecodeBase64(uri: string): ArrayBuffer;
  123087. /**
  123088. * Gets the absolute url.
  123089. * @param url the input url
  123090. * @return the absolute url
  123091. */
  123092. static GetAbsoluteUrl(url: string): string;
  123093. /**
  123094. * No log
  123095. */
  123096. static readonly NoneLogLevel: number;
  123097. /**
  123098. * Only message logs
  123099. */
  123100. static readonly MessageLogLevel: number;
  123101. /**
  123102. * Only warning logs
  123103. */
  123104. static readonly WarningLogLevel: number;
  123105. /**
  123106. * Only error logs
  123107. */
  123108. static readonly ErrorLogLevel: number;
  123109. /**
  123110. * All logs
  123111. */
  123112. static readonly AllLogLevel: number;
  123113. /**
  123114. * Gets a value indicating the number of loading errors
  123115. * @ignorenaming
  123116. */
  123117. static get errorsCount(): number;
  123118. /**
  123119. * Callback called when a new log is added
  123120. */
  123121. static OnNewCacheEntry: (entry: string) => void;
  123122. /**
  123123. * Log a message to the console
  123124. * @param message defines the message to log
  123125. */
  123126. static Log(message: string): void;
  123127. /**
  123128. * Write a warning message to the console
  123129. * @param message defines the message to log
  123130. */
  123131. static Warn(message: string): void;
  123132. /**
  123133. * Write an error message to the console
  123134. * @param message defines the message to log
  123135. */
  123136. static Error(message: string): void;
  123137. /**
  123138. * Gets current log cache (list of logs)
  123139. */
  123140. static get LogCache(): string;
  123141. /**
  123142. * Clears the log cache
  123143. */
  123144. static ClearLogCache(): void;
  123145. /**
  123146. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  123147. */
  123148. static set LogLevels(level: number);
  123149. /**
  123150. * Checks if the window object exists
  123151. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  123152. */
  123153. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  123154. /**
  123155. * No performance log
  123156. */
  123157. static readonly PerformanceNoneLogLevel: number;
  123158. /**
  123159. * Use user marks to log performance
  123160. */
  123161. static readonly PerformanceUserMarkLogLevel: number;
  123162. /**
  123163. * Log performance to the console
  123164. */
  123165. static readonly PerformanceConsoleLogLevel: number;
  123166. private static _performance;
  123167. /**
  123168. * Sets the current performance log level
  123169. */
  123170. static set PerformanceLogLevel(level: number);
  123171. private static _StartPerformanceCounterDisabled;
  123172. private static _EndPerformanceCounterDisabled;
  123173. private static _StartUserMark;
  123174. private static _EndUserMark;
  123175. private static _StartPerformanceConsole;
  123176. private static _EndPerformanceConsole;
  123177. /**
  123178. * Starts a performance counter
  123179. */
  123180. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123181. /**
  123182. * Ends a specific performance coutner
  123183. */
  123184. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  123185. /**
  123186. * Gets either window.performance.now() if supported or Date.now() else
  123187. */
  123188. static get Now(): number;
  123189. /**
  123190. * This method will return the name of the class used to create the instance of the given object.
  123191. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  123192. * @param object the object to get the class name from
  123193. * @param isType defines if the object is actually a type
  123194. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  123195. */
  123196. static GetClassName(object: any, isType?: boolean): string;
  123197. /**
  123198. * Gets the first element of an array satisfying a given predicate
  123199. * @param array defines the array to browse
  123200. * @param predicate defines the predicate to use
  123201. * @returns null if not found or the element
  123202. */
  123203. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  123204. /**
  123205. * This method will return the name of the full name of the class, including its owning module (if any).
  123206. * 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).
  123207. * @param object the object to get the class name from
  123208. * @param isType defines if the object is actually a type
  123209. * @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.
  123210. * @ignorenaming
  123211. */
  123212. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  123213. /**
  123214. * Returns a promise that resolves after the given amount of time.
  123215. * @param delay Number of milliseconds to delay
  123216. * @returns Promise that resolves after the given amount of time
  123217. */
  123218. static DelayAsync(delay: number): Promise<void>;
  123219. /**
  123220. * Utility function to detect if the current user agent is Safari
  123221. * @returns whether or not the current user agent is safari
  123222. */
  123223. static IsSafari(): boolean;
  123224. }
  123225. /**
  123226. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  123227. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  123228. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  123229. * @param name The name of the class, case should be preserved
  123230. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  123231. */
  123232. export function className(name: string, module?: string): (target: Object) => void;
  123233. /**
  123234. * An implementation of a loop for asynchronous functions.
  123235. */
  123236. export class AsyncLoop {
  123237. /**
  123238. * Defines the number of iterations for the loop
  123239. */
  123240. iterations: number;
  123241. /**
  123242. * Defines the current index of the loop.
  123243. */
  123244. index: number;
  123245. private _done;
  123246. private _fn;
  123247. private _successCallback;
  123248. /**
  123249. * Constructor.
  123250. * @param iterations the number of iterations.
  123251. * @param func the function to run each iteration
  123252. * @param successCallback the callback that will be called upon succesful execution
  123253. * @param offset starting offset.
  123254. */
  123255. constructor(
  123256. /**
  123257. * Defines the number of iterations for the loop
  123258. */
  123259. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  123260. /**
  123261. * Execute the next iteration. Must be called after the last iteration was finished.
  123262. */
  123263. executeNext(): void;
  123264. /**
  123265. * Break the loop and run the success callback.
  123266. */
  123267. breakLoop(): void;
  123268. /**
  123269. * Create and run an async loop.
  123270. * @param iterations the number of iterations.
  123271. * @param fn the function to run each iteration
  123272. * @param successCallback the callback that will be called upon succesful execution
  123273. * @param offset starting offset.
  123274. * @returns the created async loop object
  123275. */
  123276. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  123277. /**
  123278. * A for-loop that will run a given number of iterations synchronous and the rest async.
  123279. * @param iterations total number of iterations
  123280. * @param syncedIterations number of synchronous iterations in each async iteration.
  123281. * @param fn the function to call each iteration.
  123282. * @param callback a success call back that will be called when iterating stops.
  123283. * @param breakFunction a break condition (optional)
  123284. * @param timeout timeout settings for the setTimeout function. default - 0.
  123285. * @returns the created async loop object
  123286. */
  123287. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  123288. }
  123289. }
  123290. declare module BABYLON {
  123291. /**
  123292. * This class implement a typical dictionary using a string as key and the generic type T as value.
  123293. * The underlying implementation relies on an associative array to ensure the best performances.
  123294. * The value can be anything including 'null' but except 'undefined'
  123295. */
  123296. export class StringDictionary<T> {
  123297. /**
  123298. * This will clear this dictionary and copy the content from the 'source' one.
  123299. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  123300. * @param source the dictionary to take the content from and copy to this dictionary
  123301. */
  123302. copyFrom(source: StringDictionary<T>): void;
  123303. /**
  123304. * Get a value based from its key
  123305. * @param key the given key to get the matching value from
  123306. * @return the value if found, otherwise undefined is returned
  123307. */
  123308. get(key: string): T | undefined;
  123309. /**
  123310. * Get a value from its key or add it if it doesn't exist.
  123311. * This method will ensure you that a given key/data will be present in the dictionary.
  123312. * @param key the given key to get the matching value from
  123313. * @param factory the factory that will create the value if the key is not present in the dictionary.
  123314. * The factory will only be invoked if there's no data for the given key.
  123315. * @return the value corresponding to the key.
  123316. */
  123317. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  123318. /**
  123319. * Get a value from its key if present in the dictionary otherwise add it
  123320. * @param key the key to get the value from
  123321. * @param val if there's no such key/value pair in the dictionary add it with this value
  123322. * @return the value corresponding to the key
  123323. */
  123324. getOrAdd(key: string, val: T): T;
  123325. /**
  123326. * Check if there's a given key in the dictionary
  123327. * @param key the key to check for
  123328. * @return true if the key is present, false otherwise
  123329. */
  123330. contains(key: string): boolean;
  123331. /**
  123332. * Add a new key and its corresponding value
  123333. * @param key the key to add
  123334. * @param value the value corresponding to the key
  123335. * @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
  123336. */
  123337. add(key: string, value: T): boolean;
  123338. /**
  123339. * Update a specific value associated to a key
  123340. * @param key defines the key to use
  123341. * @param value defines the value to store
  123342. * @returns true if the value was updated (or false if the key was not found)
  123343. */
  123344. set(key: string, value: T): boolean;
  123345. /**
  123346. * Get the element of the given key and remove it from the dictionary
  123347. * @param key defines the key to search
  123348. * @returns the value associated with the key or null if not found
  123349. */
  123350. getAndRemove(key: string): Nullable<T>;
  123351. /**
  123352. * Remove a key/value from the dictionary.
  123353. * @param key the key to remove
  123354. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  123355. */
  123356. remove(key: string): boolean;
  123357. /**
  123358. * Clear the whole content of the dictionary
  123359. */
  123360. clear(): void;
  123361. /**
  123362. * Gets the current count
  123363. */
  123364. get count(): number;
  123365. /**
  123366. * Execute a callback on each key/val of the dictionary.
  123367. * Note that you can remove any element in this dictionary in the callback implementation
  123368. * @param callback the callback to execute on a given key/value pair
  123369. */
  123370. forEach(callback: (key: string, val: T) => void): void;
  123371. /**
  123372. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  123373. * If the callback returns null or undefined the method will iterate to the next key/value pair
  123374. * Note that you can remove any element in this dictionary in the callback implementation
  123375. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  123376. * @returns the first item
  123377. */
  123378. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  123379. private _count;
  123380. private _data;
  123381. }
  123382. }
  123383. declare module BABYLON {
  123384. /** @hidden */
  123385. export interface ICollisionCoordinator {
  123386. createCollider(): Collider;
  123387. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  123388. init(scene: Scene): void;
  123389. }
  123390. /** @hidden */
  123391. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  123392. private _scene;
  123393. private _scaledPosition;
  123394. private _scaledVelocity;
  123395. private _finalPosition;
  123396. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  123397. createCollider(): Collider;
  123398. init(scene: Scene): void;
  123399. private _collideWithWorld;
  123400. }
  123401. }
  123402. declare module BABYLON {
  123403. /**
  123404. * Class used to manage all inputs for the scene.
  123405. */
  123406. export class InputManager {
  123407. /** The distance in pixel that you have to move to prevent some events */
  123408. static DragMovementThreshold: number;
  123409. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  123410. static LongPressDelay: number;
  123411. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  123412. static DoubleClickDelay: number;
  123413. /** If you need to check double click without raising a single click at first click, enable this flag */
  123414. static ExclusiveDoubleClickMode: boolean;
  123415. /** 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. */
  123416. private _alreadyAttached;
  123417. private _alreadyAttachedTo;
  123418. private _wheelEventName;
  123419. private _onPointerMove;
  123420. private _onPointerDown;
  123421. private _onPointerUp;
  123422. private _initClickEvent;
  123423. private _initActionManager;
  123424. private _delayedSimpleClick;
  123425. private _delayedSimpleClickTimeout;
  123426. private _previousDelayedSimpleClickTimeout;
  123427. private _meshPickProceed;
  123428. private _previousButtonPressed;
  123429. private _currentPickResult;
  123430. private _previousPickResult;
  123431. private _totalPointersPressed;
  123432. private _doubleClickOccured;
  123433. private _pointerOverMesh;
  123434. private _pickedDownMesh;
  123435. private _pickedUpMesh;
  123436. private _pointerX;
  123437. private _pointerY;
  123438. private _unTranslatedPointerX;
  123439. private _unTranslatedPointerY;
  123440. private _startingPointerPosition;
  123441. private _previousStartingPointerPosition;
  123442. private _startingPointerTime;
  123443. private _previousStartingPointerTime;
  123444. private _pointerCaptures;
  123445. private _meshUnderPointerId;
  123446. private _onKeyDown;
  123447. private _onKeyUp;
  123448. private _keyboardIsAttached;
  123449. private _onCanvasFocusObserver;
  123450. private _onCanvasBlurObserver;
  123451. private _scene;
  123452. /**
  123453. * Creates a new InputManager
  123454. * @param scene defines the hosting scene
  123455. */
  123456. constructor(scene: Scene);
  123457. /**
  123458. * Gets the mesh that is currently under the pointer
  123459. */
  123460. get meshUnderPointer(): Nullable<AbstractMesh>;
  123461. /**
  123462. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  123463. * @param pointerId the pointer id to use
  123464. * @returns The mesh under this pointer id or null if not found
  123465. */
  123466. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  123467. /**
  123468. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  123469. */
  123470. get unTranslatedPointer(): Vector2;
  123471. /**
  123472. * Gets or sets the current on-screen X position of the pointer
  123473. */
  123474. get pointerX(): number;
  123475. set pointerX(value: number);
  123476. /**
  123477. * Gets or sets the current on-screen Y position of the pointer
  123478. */
  123479. get pointerY(): number;
  123480. set pointerY(value: number);
  123481. private _updatePointerPosition;
  123482. private _processPointerMove;
  123483. private _setRayOnPointerInfo;
  123484. private _checkPrePointerObservable;
  123485. /**
  123486. * Use this method to simulate a pointer move on a mesh
  123487. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123488. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123489. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123490. */
  123491. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  123492. /**
  123493. * Use this method to simulate a pointer down on a mesh
  123494. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123495. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123496. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123497. */
  123498. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  123499. private _processPointerDown;
  123500. /** @hidden */
  123501. _isPointerSwiping(): boolean;
  123502. /**
  123503. * Use this method to simulate a pointer up on a mesh
  123504. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  123505. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  123506. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  123507. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  123508. */
  123509. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  123510. private _processPointerUp;
  123511. /**
  123512. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  123513. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  123514. * @returns true if the pointer was captured
  123515. */
  123516. isPointerCaptured(pointerId?: number): boolean;
  123517. /**
  123518. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  123519. * @param attachUp defines if you want to attach events to pointerup
  123520. * @param attachDown defines if you want to attach events to pointerdown
  123521. * @param attachMove defines if you want to attach events to pointermove
  123522. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  123523. */
  123524. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  123525. /**
  123526. * Detaches all event handlers
  123527. */
  123528. detachControl(): void;
  123529. /**
  123530. * Force the value of meshUnderPointer
  123531. * @param mesh defines the mesh to use
  123532. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  123533. */
  123534. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  123535. /**
  123536. * Gets the mesh under the pointer
  123537. * @returns a Mesh or null if no mesh is under the pointer
  123538. */
  123539. getPointerOverMesh(): Nullable<AbstractMesh>;
  123540. }
  123541. }
  123542. declare module BABYLON {
  123543. /**
  123544. * This class defines the direct association between an animation and a target
  123545. */
  123546. export class TargetedAnimation {
  123547. /**
  123548. * Animation to perform
  123549. */
  123550. animation: Animation;
  123551. /**
  123552. * Target to animate
  123553. */
  123554. target: any;
  123555. /**
  123556. * Returns the string "TargetedAnimation"
  123557. * @returns "TargetedAnimation"
  123558. */
  123559. getClassName(): string;
  123560. /**
  123561. * Serialize the object
  123562. * @returns the JSON object representing the current entity
  123563. */
  123564. serialize(): any;
  123565. }
  123566. /**
  123567. * Use this class to create coordinated animations on multiple targets
  123568. */
  123569. export class AnimationGroup implements IDisposable {
  123570. /** The name of the animation group */
  123571. name: string;
  123572. private _scene;
  123573. private _targetedAnimations;
  123574. private _animatables;
  123575. private _from;
  123576. private _to;
  123577. private _isStarted;
  123578. private _isPaused;
  123579. private _speedRatio;
  123580. private _loopAnimation;
  123581. private _isAdditive;
  123582. /**
  123583. * Gets or sets the unique id of the node
  123584. */
  123585. uniqueId: number;
  123586. /**
  123587. * This observable will notify when one animation have ended
  123588. */
  123589. onAnimationEndObservable: Observable<TargetedAnimation>;
  123590. /**
  123591. * Observer raised when one animation loops
  123592. */
  123593. onAnimationLoopObservable: Observable<TargetedAnimation>;
  123594. /**
  123595. * Observer raised when all animations have looped
  123596. */
  123597. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  123598. /**
  123599. * This observable will notify when all animations have ended.
  123600. */
  123601. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  123602. /**
  123603. * This observable will notify when all animations have paused.
  123604. */
  123605. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  123606. /**
  123607. * This observable will notify when all animations are playing.
  123608. */
  123609. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  123610. /**
  123611. * Gets the first frame
  123612. */
  123613. get from(): number;
  123614. /**
  123615. * Gets the last frame
  123616. */
  123617. get to(): number;
  123618. /**
  123619. * Define if the animations are started
  123620. */
  123621. get isStarted(): boolean;
  123622. /**
  123623. * Gets a value indicating that the current group is playing
  123624. */
  123625. get isPlaying(): boolean;
  123626. /**
  123627. * Gets or sets the speed ratio to use for all animations
  123628. */
  123629. get speedRatio(): number;
  123630. /**
  123631. * Gets or sets the speed ratio to use for all animations
  123632. */
  123633. set speedRatio(value: number);
  123634. /**
  123635. * Gets or sets if all animations should loop or not
  123636. */
  123637. get loopAnimation(): boolean;
  123638. set loopAnimation(value: boolean);
  123639. /**
  123640. * Gets or sets if all animations should be evaluated additively
  123641. */
  123642. get isAdditive(): boolean;
  123643. set isAdditive(value: boolean);
  123644. /**
  123645. * Gets the targeted animations for this animation group
  123646. */
  123647. get targetedAnimations(): Array<TargetedAnimation>;
  123648. /**
  123649. * returning the list of animatables controlled by this animation group.
  123650. */
  123651. get animatables(): Array<Animatable>;
  123652. /**
  123653. * Gets the list of target animations
  123654. */
  123655. get children(): TargetedAnimation[];
  123656. /**
  123657. * Instantiates a new Animation Group.
  123658. * This helps managing several animations at once.
  123659. * @see https://doc.babylonjs.com/how_to/group
  123660. * @param name Defines the name of the group
  123661. * @param scene Defines the scene the group belongs to
  123662. */
  123663. constructor(
  123664. /** The name of the animation group */
  123665. name: string, scene?: Nullable<Scene>);
  123666. /**
  123667. * Add an animation (with its target) in the group
  123668. * @param animation defines the animation we want to add
  123669. * @param target defines the target of the animation
  123670. * @returns the TargetedAnimation object
  123671. */
  123672. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  123673. /**
  123674. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  123675. * It can add constant keys at begin or end
  123676. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  123677. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  123678. * @returns the animation group
  123679. */
  123680. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  123681. private _animationLoopCount;
  123682. private _animationLoopFlags;
  123683. private _processLoop;
  123684. /**
  123685. * Start all animations on given targets
  123686. * @param loop defines if animations must loop
  123687. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  123688. * @param from defines the from key (optional)
  123689. * @param to defines the to key (optional)
  123690. * @param isAdditive defines the additive state for the resulting animatables (optional)
  123691. * @returns the current animation group
  123692. */
  123693. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  123694. /**
  123695. * Pause all animations
  123696. * @returns the animation group
  123697. */
  123698. pause(): AnimationGroup;
  123699. /**
  123700. * Play all animations to initial state
  123701. * This function will start() the animations if they were not started or will restart() them if they were paused
  123702. * @param loop defines if animations must loop
  123703. * @returns the animation group
  123704. */
  123705. play(loop?: boolean): AnimationGroup;
  123706. /**
  123707. * Reset all animations to initial state
  123708. * @returns the animation group
  123709. */
  123710. reset(): AnimationGroup;
  123711. /**
  123712. * Restart animations from key 0
  123713. * @returns the animation group
  123714. */
  123715. restart(): AnimationGroup;
  123716. /**
  123717. * Stop all animations
  123718. * @returns the animation group
  123719. */
  123720. stop(): AnimationGroup;
  123721. /**
  123722. * Set animation weight for all animatables
  123723. * @param weight defines the weight to use
  123724. * @return the animationGroup
  123725. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123726. */
  123727. setWeightForAllAnimatables(weight: number): AnimationGroup;
  123728. /**
  123729. * Synchronize and normalize all animatables with a source animatable
  123730. * @param root defines the root animatable to synchronize with
  123731. * @return the animationGroup
  123732. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  123733. */
  123734. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  123735. /**
  123736. * Goes to a specific frame in this animation group
  123737. * @param frame the frame number to go to
  123738. * @return the animationGroup
  123739. */
  123740. goToFrame(frame: number): AnimationGroup;
  123741. /**
  123742. * Dispose all associated resources
  123743. */
  123744. dispose(): void;
  123745. private _checkAnimationGroupEnded;
  123746. /**
  123747. * Clone the current animation group and returns a copy
  123748. * @param newName defines the name of the new group
  123749. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  123750. * @returns the new aniamtion group
  123751. */
  123752. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  123753. /**
  123754. * Serializes the animationGroup to an object
  123755. * @returns Serialized object
  123756. */
  123757. serialize(): any;
  123758. /**
  123759. * Returns a new AnimationGroup object parsed from the source provided.
  123760. * @param parsedAnimationGroup defines the source
  123761. * @param scene defines the scene that will receive the animationGroup
  123762. * @returns a new AnimationGroup
  123763. */
  123764. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  123765. /**
  123766. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  123767. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  123768. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  123769. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  123770. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  123771. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  123772. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  123773. */
  123774. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  123775. /**
  123776. * Returns the string "AnimationGroup"
  123777. * @returns "AnimationGroup"
  123778. */
  123779. getClassName(): string;
  123780. /**
  123781. * Creates a detailled string about the object
  123782. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  123783. * @returns a string representing the object
  123784. */
  123785. toString(fullDetails?: boolean): string;
  123786. }
  123787. }
  123788. declare module BABYLON {
  123789. /**
  123790. * Define an interface for all classes that will hold resources
  123791. */
  123792. export interface IDisposable {
  123793. /**
  123794. * Releases all held resources
  123795. */
  123796. dispose(): void;
  123797. }
  123798. /** Interface defining initialization parameters for Scene class */
  123799. export interface SceneOptions {
  123800. /**
  123801. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  123802. * It will improve performance when the number of geometries becomes important.
  123803. */
  123804. useGeometryUniqueIdsMap?: boolean;
  123805. /**
  123806. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  123807. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123808. */
  123809. useMaterialMeshMap?: boolean;
  123810. /**
  123811. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  123812. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  123813. */
  123814. useClonedMeshMap?: boolean;
  123815. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  123816. virtual?: boolean;
  123817. }
  123818. /**
  123819. * Represents a scene to be rendered by the engine.
  123820. * @see https://doc.babylonjs.com/features/scene
  123821. */
  123822. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  123823. /** The fog is deactivated */
  123824. static readonly FOGMODE_NONE: number;
  123825. /** The fog density is following an exponential function */
  123826. static readonly FOGMODE_EXP: number;
  123827. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  123828. static readonly FOGMODE_EXP2: number;
  123829. /** The fog density is following a linear function. */
  123830. static readonly FOGMODE_LINEAR: number;
  123831. /**
  123832. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  123833. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123834. */
  123835. static MinDeltaTime: number;
  123836. /**
  123837. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  123838. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  123839. */
  123840. static MaxDeltaTime: number;
  123841. /**
  123842. * Factory used to create the default material.
  123843. * @param name The name of the material to create
  123844. * @param scene The scene to create the material for
  123845. * @returns The default material
  123846. */
  123847. static DefaultMaterialFactory(scene: Scene): Material;
  123848. /**
  123849. * Factory used to create the a collision coordinator.
  123850. * @returns The collision coordinator
  123851. */
  123852. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  123853. /** @hidden */
  123854. _inputManager: InputManager;
  123855. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  123856. cameraToUseForPointers: Nullable<Camera>;
  123857. /** @hidden */
  123858. readonly _isScene: boolean;
  123859. /** @hidden */
  123860. _blockEntityCollection: boolean;
  123861. /**
  123862. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  123863. */
  123864. autoClear: boolean;
  123865. /**
  123866. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  123867. */
  123868. autoClearDepthAndStencil: boolean;
  123869. /**
  123870. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  123871. */
  123872. clearColor: Color4;
  123873. /**
  123874. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  123875. */
  123876. ambientColor: Color3;
  123877. /**
  123878. * This is use to store the default BRDF lookup for PBR materials in your scene.
  123879. * It should only be one of the following (if not the default embedded one):
  123880. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  123881. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  123882. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  123883. * The material properties need to be setup according to the type of texture in use.
  123884. */
  123885. environmentBRDFTexture: BaseTexture;
  123886. /**
  123887. * Texture used in all pbr material as the reflection texture.
  123888. * As in the majority of the scene they are the same (exception for multi room and so on),
  123889. * this is easier to reference from here than from all the materials.
  123890. */
  123891. get environmentTexture(): Nullable<BaseTexture>;
  123892. /**
  123893. * Texture used in all pbr material as the reflection texture.
  123894. * As in the majority of the scene they are the same (exception for multi room and so on),
  123895. * this is easier to set here than in all the materials.
  123896. */
  123897. set environmentTexture(value: Nullable<BaseTexture>);
  123898. /** @hidden */
  123899. protected _environmentIntensity: number;
  123900. /**
  123901. * Intensity of the environment in all pbr material.
  123902. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123903. * As in the majority of the scene they are the same (exception for multi room and so on),
  123904. * this is easier to reference from here than from all the materials.
  123905. */
  123906. get environmentIntensity(): number;
  123907. /**
  123908. * Intensity of the environment in all pbr material.
  123909. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  123910. * As in the majority of the scene they are the same (exception for multi room and so on),
  123911. * this is easier to set here than in all the materials.
  123912. */
  123913. set environmentIntensity(value: number);
  123914. /** @hidden */
  123915. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  123916. /**
  123917. * Default image processing configuration used either in the rendering
  123918. * Forward main pass or through the imageProcessingPostProcess if present.
  123919. * As in the majority of the scene they are the same (exception for multi camera),
  123920. * this is easier to reference from here than from all the materials and post process.
  123921. *
  123922. * No setter as we it is a shared configuration, you can set the values instead.
  123923. */
  123924. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  123925. private _forceWireframe;
  123926. /**
  123927. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  123928. */
  123929. set forceWireframe(value: boolean);
  123930. get forceWireframe(): boolean;
  123931. private _skipFrustumClipping;
  123932. /**
  123933. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  123934. */
  123935. set skipFrustumClipping(value: boolean);
  123936. get skipFrustumClipping(): boolean;
  123937. private _forcePointsCloud;
  123938. /**
  123939. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  123940. */
  123941. set forcePointsCloud(value: boolean);
  123942. get forcePointsCloud(): boolean;
  123943. /**
  123944. * Gets or sets the active clipplane 1
  123945. */
  123946. clipPlane: Nullable<Plane>;
  123947. /**
  123948. * Gets or sets the active clipplane 2
  123949. */
  123950. clipPlane2: Nullable<Plane>;
  123951. /**
  123952. * Gets or sets the active clipplane 3
  123953. */
  123954. clipPlane3: Nullable<Plane>;
  123955. /**
  123956. * Gets or sets the active clipplane 4
  123957. */
  123958. clipPlane4: Nullable<Plane>;
  123959. /**
  123960. * Gets or sets the active clipplane 5
  123961. */
  123962. clipPlane5: Nullable<Plane>;
  123963. /**
  123964. * Gets or sets the active clipplane 6
  123965. */
  123966. clipPlane6: Nullable<Plane>;
  123967. /**
  123968. * Gets or sets a boolean indicating if animations are enabled
  123969. */
  123970. animationsEnabled: boolean;
  123971. private _animationPropertiesOverride;
  123972. /**
  123973. * Gets or sets the animation properties override
  123974. */
  123975. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  123976. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  123977. /**
  123978. * Gets or sets a boolean indicating if a constant deltatime has to be used
  123979. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  123980. */
  123981. useConstantAnimationDeltaTime: boolean;
  123982. /**
  123983. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  123984. * Please note that it requires to run a ray cast through the scene on every frame
  123985. */
  123986. constantlyUpdateMeshUnderPointer: boolean;
  123987. /**
  123988. * Defines the HTML cursor to use when hovering over interactive elements
  123989. */
  123990. hoverCursor: string;
  123991. /**
  123992. * Defines the HTML default cursor to use (empty by default)
  123993. */
  123994. defaultCursor: string;
  123995. /**
  123996. * Defines whether cursors are handled by the scene.
  123997. */
  123998. doNotHandleCursors: boolean;
  123999. /**
  124000. * This is used to call preventDefault() on pointer down
  124001. * in order to block unwanted artifacts like system double clicks
  124002. */
  124003. preventDefaultOnPointerDown: boolean;
  124004. /**
  124005. * This is used to call preventDefault() on pointer up
  124006. * in order to block unwanted artifacts like system double clicks
  124007. */
  124008. preventDefaultOnPointerUp: boolean;
  124009. /**
  124010. * Gets or sets user defined metadata
  124011. */
  124012. metadata: any;
  124013. /**
  124014. * For internal use only. Please do not use.
  124015. */
  124016. reservedDataStore: any;
  124017. /**
  124018. * Gets the name of the plugin used to load this scene (null by default)
  124019. */
  124020. loadingPluginName: string;
  124021. /**
  124022. * Use this array to add regular expressions used to disable offline support for specific urls
  124023. */
  124024. disableOfflineSupportExceptionRules: RegExp[];
  124025. /**
  124026. * An event triggered when the scene is disposed.
  124027. */
  124028. onDisposeObservable: Observable<Scene>;
  124029. private _onDisposeObserver;
  124030. /** Sets a function to be executed when this scene is disposed. */
  124031. set onDispose(callback: () => void);
  124032. /**
  124033. * An event triggered before rendering the scene (right after animations and physics)
  124034. */
  124035. onBeforeRenderObservable: Observable<Scene>;
  124036. private _onBeforeRenderObserver;
  124037. /** Sets a function to be executed before rendering this scene */
  124038. set beforeRender(callback: Nullable<() => void>);
  124039. /**
  124040. * An event triggered after rendering the scene
  124041. */
  124042. onAfterRenderObservable: Observable<Scene>;
  124043. /**
  124044. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  124045. */
  124046. onAfterRenderCameraObservable: Observable<Camera>;
  124047. private _onAfterRenderObserver;
  124048. /** Sets a function to be executed after rendering this scene */
  124049. set afterRender(callback: Nullable<() => void>);
  124050. /**
  124051. * An event triggered before animating the scene
  124052. */
  124053. onBeforeAnimationsObservable: Observable<Scene>;
  124054. /**
  124055. * An event triggered after animations processing
  124056. */
  124057. onAfterAnimationsObservable: Observable<Scene>;
  124058. /**
  124059. * An event triggered before draw calls are ready to be sent
  124060. */
  124061. onBeforeDrawPhaseObservable: Observable<Scene>;
  124062. /**
  124063. * An event triggered after draw calls have been sent
  124064. */
  124065. onAfterDrawPhaseObservable: Observable<Scene>;
  124066. /**
  124067. * An event triggered when the scene is ready
  124068. */
  124069. onReadyObservable: Observable<Scene>;
  124070. /**
  124071. * An event triggered before rendering a camera
  124072. */
  124073. onBeforeCameraRenderObservable: Observable<Camera>;
  124074. private _onBeforeCameraRenderObserver;
  124075. /** Sets a function to be executed before rendering a camera*/
  124076. set beforeCameraRender(callback: () => void);
  124077. /**
  124078. * An event triggered after rendering a camera
  124079. */
  124080. onAfterCameraRenderObservable: Observable<Camera>;
  124081. private _onAfterCameraRenderObserver;
  124082. /** Sets a function to be executed after rendering a camera*/
  124083. set afterCameraRender(callback: () => void);
  124084. /**
  124085. * An event triggered when active meshes evaluation is about to start
  124086. */
  124087. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  124088. /**
  124089. * An event triggered when active meshes evaluation is done
  124090. */
  124091. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  124092. /**
  124093. * An event triggered when particles rendering is about to start
  124094. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124095. */
  124096. onBeforeParticlesRenderingObservable: Observable<Scene>;
  124097. /**
  124098. * An event triggered when particles rendering is done
  124099. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  124100. */
  124101. onAfterParticlesRenderingObservable: Observable<Scene>;
  124102. /**
  124103. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  124104. */
  124105. onDataLoadedObservable: Observable<Scene>;
  124106. /**
  124107. * An event triggered when a camera is created
  124108. */
  124109. onNewCameraAddedObservable: Observable<Camera>;
  124110. /**
  124111. * An event triggered when a camera is removed
  124112. */
  124113. onCameraRemovedObservable: Observable<Camera>;
  124114. /**
  124115. * An event triggered when a light is created
  124116. */
  124117. onNewLightAddedObservable: Observable<Light>;
  124118. /**
  124119. * An event triggered when a light is removed
  124120. */
  124121. onLightRemovedObservable: Observable<Light>;
  124122. /**
  124123. * An event triggered when a geometry is created
  124124. */
  124125. onNewGeometryAddedObservable: Observable<Geometry>;
  124126. /**
  124127. * An event triggered when a geometry is removed
  124128. */
  124129. onGeometryRemovedObservable: Observable<Geometry>;
  124130. /**
  124131. * An event triggered when a transform node is created
  124132. */
  124133. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  124134. /**
  124135. * An event triggered when a transform node is removed
  124136. */
  124137. onTransformNodeRemovedObservable: Observable<TransformNode>;
  124138. /**
  124139. * An event triggered when a mesh is created
  124140. */
  124141. onNewMeshAddedObservable: Observable<AbstractMesh>;
  124142. /**
  124143. * An event triggered when a mesh is removed
  124144. */
  124145. onMeshRemovedObservable: Observable<AbstractMesh>;
  124146. /**
  124147. * An event triggered when a skeleton is created
  124148. */
  124149. onNewSkeletonAddedObservable: Observable<Skeleton>;
  124150. /**
  124151. * An event triggered when a skeleton is removed
  124152. */
  124153. onSkeletonRemovedObservable: Observable<Skeleton>;
  124154. /**
  124155. * An event triggered when a material is created
  124156. */
  124157. onNewMaterialAddedObservable: Observable<Material>;
  124158. /**
  124159. * An event triggered when a material is removed
  124160. */
  124161. onMaterialRemovedObservable: Observable<Material>;
  124162. /**
  124163. * An event triggered when a texture is created
  124164. */
  124165. onNewTextureAddedObservable: Observable<BaseTexture>;
  124166. /**
  124167. * An event triggered when a texture is removed
  124168. */
  124169. onTextureRemovedObservable: Observable<BaseTexture>;
  124170. /**
  124171. * An event triggered when render targets are about to be rendered
  124172. * Can happen multiple times per frame.
  124173. */
  124174. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  124175. /**
  124176. * An event triggered when render targets were rendered.
  124177. * Can happen multiple times per frame.
  124178. */
  124179. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  124180. /**
  124181. * An event triggered before calculating deterministic simulation step
  124182. */
  124183. onBeforeStepObservable: Observable<Scene>;
  124184. /**
  124185. * An event triggered after calculating deterministic simulation step
  124186. */
  124187. onAfterStepObservable: Observable<Scene>;
  124188. /**
  124189. * An event triggered when the activeCamera property is updated
  124190. */
  124191. onActiveCameraChanged: Observable<Scene>;
  124192. /**
  124193. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  124194. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124195. * 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)
  124196. */
  124197. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124198. /**
  124199. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  124200. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  124201. * 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)
  124202. */
  124203. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  124204. /**
  124205. * This Observable will when a mesh has been imported into the scene.
  124206. */
  124207. onMeshImportedObservable: Observable<AbstractMesh>;
  124208. /**
  124209. * This Observable will when an animation file has been imported into the scene.
  124210. */
  124211. onAnimationFileImportedObservable: Observable<Scene>;
  124212. /**
  124213. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  124214. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  124215. */
  124216. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  124217. /** @hidden */
  124218. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  124219. /**
  124220. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  124221. */
  124222. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  124223. /**
  124224. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  124225. */
  124226. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  124227. /**
  124228. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  124229. */
  124230. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  124231. /** Callback called when a pointer move is detected */
  124232. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124233. /** Callback called when a pointer down is detected */
  124234. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  124235. /** Callback called when a pointer up is detected */
  124236. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  124237. /** Callback called when a pointer pick is detected */
  124238. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  124239. /**
  124240. * 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).
  124241. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  124242. */
  124243. onPrePointerObservable: Observable<PointerInfoPre>;
  124244. /**
  124245. * Observable event triggered each time an input event is received from the rendering canvas
  124246. */
  124247. onPointerObservable: Observable<PointerInfo>;
  124248. /**
  124249. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  124250. */
  124251. get unTranslatedPointer(): Vector2;
  124252. /**
  124253. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  124254. */
  124255. static get DragMovementThreshold(): number;
  124256. static set DragMovementThreshold(value: number);
  124257. /**
  124258. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  124259. */
  124260. static get LongPressDelay(): number;
  124261. static set LongPressDelay(value: number);
  124262. /**
  124263. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  124264. */
  124265. static get DoubleClickDelay(): number;
  124266. static set DoubleClickDelay(value: number);
  124267. /** If you need to check double click without raising a single click at first click, enable this flag */
  124268. static get ExclusiveDoubleClickMode(): boolean;
  124269. static set ExclusiveDoubleClickMode(value: boolean);
  124270. /** @hidden */
  124271. _mirroredCameraPosition: Nullable<Vector3>;
  124272. /**
  124273. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  124274. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  124275. */
  124276. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  124277. /**
  124278. * Observable event triggered each time an keyboard event is received from the hosting window
  124279. */
  124280. onKeyboardObservable: Observable<KeyboardInfo>;
  124281. private _useRightHandedSystem;
  124282. /**
  124283. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  124284. */
  124285. set useRightHandedSystem(value: boolean);
  124286. get useRightHandedSystem(): boolean;
  124287. private _timeAccumulator;
  124288. private _currentStepId;
  124289. private _currentInternalStep;
  124290. /**
  124291. * Sets the step Id used by deterministic lock step
  124292. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124293. * @param newStepId defines the step Id
  124294. */
  124295. setStepId(newStepId: number): void;
  124296. /**
  124297. * Gets the step Id used by deterministic lock step
  124298. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124299. * @returns the step Id
  124300. */
  124301. getStepId(): number;
  124302. /**
  124303. * Gets the internal step used by deterministic lock step
  124304. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  124305. * @returns the internal step
  124306. */
  124307. getInternalStep(): number;
  124308. private _fogEnabled;
  124309. /**
  124310. * Gets or sets a boolean indicating if fog is enabled on this scene
  124311. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124312. * (Default is true)
  124313. */
  124314. set fogEnabled(value: boolean);
  124315. get fogEnabled(): boolean;
  124316. private _fogMode;
  124317. /**
  124318. * Gets or sets the fog mode to use
  124319. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124320. * | mode | value |
  124321. * | --- | --- |
  124322. * | FOGMODE_NONE | 0 |
  124323. * | FOGMODE_EXP | 1 |
  124324. * | FOGMODE_EXP2 | 2 |
  124325. * | FOGMODE_LINEAR | 3 |
  124326. */
  124327. set fogMode(value: number);
  124328. get fogMode(): number;
  124329. /**
  124330. * Gets or sets the fog color to use
  124331. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124332. * (Default is Color3(0.2, 0.2, 0.3))
  124333. */
  124334. fogColor: Color3;
  124335. /**
  124336. * Gets or sets the fog density to use
  124337. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124338. * (Default is 0.1)
  124339. */
  124340. fogDensity: number;
  124341. /**
  124342. * Gets or sets the fog start distance to use
  124343. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124344. * (Default is 0)
  124345. */
  124346. fogStart: number;
  124347. /**
  124348. * Gets or sets the fog end distance to use
  124349. * @see https://doc.babylonjs.com/babylon101/environment#fog
  124350. * (Default is 1000)
  124351. */
  124352. fogEnd: number;
  124353. /**
  124354. * Flag indicating that the frame buffer binding is handled by another component
  124355. */
  124356. prePass: boolean;
  124357. private _shadowsEnabled;
  124358. /**
  124359. * Gets or sets a boolean indicating if shadows are enabled on this scene
  124360. */
  124361. set shadowsEnabled(value: boolean);
  124362. get shadowsEnabled(): boolean;
  124363. private _lightsEnabled;
  124364. /**
  124365. * Gets or sets a boolean indicating if lights are enabled on this scene
  124366. */
  124367. set lightsEnabled(value: boolean);
  124368. get lightsEnabled(): boolean;
  124369. /** All of the active cameras added to this scene. */
  124370. activeCameras: Camera[];
  124371. /** @hidden */
  124372. _activeCamera: Nullable<Camera>;
  124373. /** Gets or sets the current active camera */
  124374. get activeCamera(): Nullable<Camera>;
  124375. set activeCamera(value: Nullable<Camera>);
  124376. private _defaultMaterial;
  124377. /** The default material used on meshes when no material is affected */
  124378. get defaultMaterial(): Material;
  124379. /** The default material used on meshes when no material is affected */
  124380. set defaultMaterial(value: Material);
  124381. private _texturesEnabled;
  124382. /**
  124383. * Gets or sets a boolean indicating if textures are enabled on this scene
  124384. */
  124385. set texturesEnabled(value: boolean);
  124386. get texturesEnabled(): boolean;
  124387. /**
  124388. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  124389. */
  124390. physicsEnabled: boolean;
  124391. /**
  124392. * Gets or sets a boolean indicating if particles are enabled on this scene
  124393. */
  124394. particlesEnabled: boolean;
  124395. /**
  124396. * Gets or sets a boolean indicating if sprites are enabled on this scene
  124397. */
  124398. spritesEnabled: boolean;
  124399. private _skeletonsEnabled;
  124400. /**
  124401. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  124402. */
  124403. set skeletonsEnabled(value: boolean);
  124404. get skeletonsEnabled(): boolean;
  124405. /**
  124406. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  124407. */
  124408. lensFlaresEnabled: boolean;
  124409. /**
  124410. * Gets or sets a boolean indicating if collisions are enabled on this scene
  124411. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  124412. */
  124413. collisionsEnabled: boolean;
  124414. private _collisionCoordinator;
  124415. /** @hidden */
  124416. get collisionCoordinator(): ICollisionCoordinator;
  124417. /**
  124418. * Defines the gravity applied to this scene (used only for collisions)
  124419. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  124420. */
  124421. gravity: Vector3;
  124422. /**
  124423. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  124424. */
  124425. postProcessesEnabled: boolean;
  124426. /**
  124427. * Gets the current postprocess manager
  124428. */
  124429. postProcessManager: PostProcessManager;
  124430. /**
  124431. * Gets or sets a boolean indicating if render targets are enabled on this scene
  124432. */
  124433. renderTargetsEnabled: boolean;
  124434. /**
  124435. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  124436. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  124437. */
  124438. dumpNextRenderTargets: boolean;
  124439. /**
  124440. * The list of user defined render targets added to the scene
  124441. */
  124442. customRenderTargets: RenderTargetTexture[];
  124443. /**
  124444. * Defines if texture loading must be delayed
  124445. * If true, textures will only be loaded when they need to be rendered
  124446. */
  124447. useDelayedTextureLoading: boolean;
  124448. /**
  124449. * Gets the list of meshes imported to the scene through SceneLoader
  124450. */
  124451. importedMeshesFiles: String[];
  124452. /**
  124453. * Gets or sets a boolean indicating if probes are enabled on this scene
  124454. */
  124455. probesEnabled: boolean;
  124456. /**
  124457. * Gets or sets the current offline provider to use to store scene data
  124458. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124459. */
  124460. offlineProvider: IOfflineProvider;
  124461. /**
  124462. * Gets or sets the action manager associated with the scene
  124463. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  124464. */
  124465. actionManager: AbstractActionManager;
  124466. private _meshesForIntersections;
  124467. /**
  124468. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  124469. */
  124470. proceduralTexturesEnabled: boolean;
  124471. private _engine;
  124472. private _totalVertices;
  124473. /** @hidden */
  124474. _activeIndices: PerfCounter;
  124475. /** @hidden */
  124476. _activeParticles: PerfCounter;
  124477. /** @hidden */
  124478. _activeBones: PerfCounter;
  124479. private _animationRatio;
  124480. /** @hidden */
  124481. _animationTimeLast: number;
  124482. /** @hidden */
  124483. _animationTime: number;
  124484. /**
  124485. * Gets or sets a general scale for animation speed
  124486. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  124487. */
  124488. animationTimeScale: number;
  124489. /** @hidden */
  124490. _cachedMaterial: Nullable<Material>;
  124491. /** @hidden */
  124492. _cachedEffect: Nullable<Effect>;
  124493. /** @hidden */
  124494. _cachedVisibility: Nullable<number>;
  124495. private _renderId;
  124496. private _frameId;
  124497. private _executeWhenReadyTimeoutId;
  124498. private _intermediateRendering;
  124499. private _viewUpdateFlag;
  124500. private _projectionUpdateFlag;
  124501. /** @hidden */
  124502. _toBeDisposed: Nullable<IDisposable>[];
  124503. private _activeRequests;
  124504. /** @hidden */
  124505. _pendingData: any[];
  124506. private _isDisposed;
  124507. /**
  124508. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  124509. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  124510. */
  124511. dispatchAllSubMeshesOfActiveMeshes: boolean;
  124512. private _activeMeshes;
  124513. private _processedMaterials;
  124514. private _renderTargets;
  124515. /** @hidden */
  124516. _activeParticleSystems: SmartArray<IParticleSystem>;
  124517. private _activeSkeletons;
  124518. private _softwareSkinnedMeshes;
  124519. private _renderingManager;
  124520. /** @hidden */
  124521. _activeAnimatables: Animatable[];
  124522. private _transformMatrix;
  124523. private _sceneUbo;
  124524. /** @hidden */
  124525. _viewMatrix: Matrix;
  124526. private _projectionMatrix;
  124527. /** @hidden */
  124528. _forcedViewPosition: Nullable<Vector3>;
  124529. /** @hidden */
  124530. _frustumPlanes: Plane[];
  124531. /**
  124532. * Gets the list of frustum planes (built from the active camera)
  124533. */
  124534. get frustumPlanes(): Plane[];
  124535. /**
  124536. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  124537. * This is useful if there are more lights that the maximum simulteanous authorized
  124538. */
  124539. requireLightSorting: boolean;
  124540. /** @hidden */
  124541. readonly useMaterialMeshMap: boolean;
  124542. /** @hidden */
  124543. readonly useClonedMeshMap: boolean;
  124544. private _externalData;
  124545. private _uid;
  124546. /**
  124547. * @hidden
  124548. * Backing store of defined scene components.
  124549. */
  124550. _components: ISceneComponent[];
  124551. /**
  124552. * @hidden
  124553. * Backing store of defined scene components.
  124554. */
  124555. _serializableComponents: ISceneSerializableComponent[];
  124556. /**
  124557. * List of components to register on the next registration step.
  124558. */
  124559. private _transientComponents;
  124560. /**
  124561. * Registers the transient components if needed.
  124562. */
  124563. private _registerTransientComponents;
  124564. /**
  124565. * @hidden
  124566. * Add a component to the scene.
  124567. * Note that the ccomponent could be registered on th next frame if this is called after
  124568. * the register component stage.
  124569. * @param component Defines the component to add to the scene
  124570. */
  124571. _addComponent(component: ISceneComponent): void;
  124572. /**
  124573. * @hidden
  124574. * Gets a component from the scene.
  124575. * @param name defines the name of the component to retrieve
  124576. * @returns the component or null if not present
  124577. */
  124578. _getComponent(name: string): Nullable<ISceneComponent>;
  124579. /**
  124580. * @hidden
  124581. * Defines the actions happening before camera updates.
  124582. */
  124583. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  124584. /**
  124585. * @hidden
  124586. * Defines the actions happening before clear the canvas.
  124587. */
  124588. _beforeClearStage: Stage<SimpleStageAction>;
  124589. /**
  124590. * @hidden
  124591. * Defines the actions when collecting render targets for the frame.
  124592. */
  124593. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  124594. /**
  124595. * @hidden
  124596. * Defines the actions happening for one camera in the frame.
  124597. */
  124598. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  124599. /**
  124600. * @hidden
  124601. * Defines the actions happening during the per mesh ready checks.
  124602. */
  124603. _isReadyForMeshStage: Stage<MeshStageAction>;
  124604. /**
  124605. * @hidden
  124606. * Defines the actions happening before evaluate active mesh checks.
  124607. */
  124608. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  124609. /**
  124610. * @hidden
  124611. * Defines the actions happening during the evaluate sub mesh checks.
  124612. */
  124613. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  124614. /**
  124615. * @hidden
  124616. * Defines the actions happening during the active mesh stage.
  124617. */
  124618. _preActiveMeshStage: Stage<PreActiveMeshStageAction>;
  124619. /**
  124620. * @hidden
  124621. * Defines the actions happening during the per camera render target step.
  124622. */
  124623. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  124624. /**
  124625. * @hidden
  124626. * Defines the actions happening just before the active camera is drawing.
  124627. */
  124628. _beforeCameraDrawStage: Stage<CameraStageAction>;
  124629. /**
  124630. * @hidden
  124631. * Defines the actions happening just before a render target is drawing.
  124632. */
  124633. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  124634. /**
  124635. * @hidden
  124636. * Defines the actions happening just before a rendering group is drawing.
  124637. */
  124638. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  124639. /**
  124640. * @hidden
  124641. * Defines the actions happening just before a mesh is drawing.
  124642. */
  124643. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  124644. /**
  124645. * @hidden
  124646. * Defines the actions happening just after a mesh has been drawn.
  124647. */
  124648. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  124649. /**
  124650. * @hidden
  124651. * Defines the actions happening just after a rendering group has been drawn.
  124652. */
  124653. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  124654. /**
  124655. * @hidden
  124656. * Defines the actions happening just after the active camera has been drawn.
  124657. */
  124658. _afterCameraDrawStage: Stage<CameraStageAction>;
  124659. /**
  124660. * @hidden
  124661. * Defines the actions happening just after a render target has been drawn.
  124662. */
  124663. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  124664. /**
  124665. * @hidden
  124666. * Defines the actions happening just after rendering all cameras and computing intersections.
  124667. */
  124668. _afterRenderStage: Stage<SimpleStageAction>;
  124669. /**
  124670. * @hidden
  124671. * Defines the actions happening when a pointer move event happens.
  124672. */
  124673. _pointerMoveStage: Stage<PointerMoveStageAction>;
  124674. /**
  124675. * @hidden
  124676. * Defines the actions happening when a pointer down event happens.
  124677. */
  124678. _pointerDownStage: Stage<PointerUpDownStageAction>;
  124679. /**
  124680. * @hidden
  124681. * Defines the actions happening when a pointer up event happens.
  124682. */
  124683. _pointerUpStage: Stage<PointerUpDownStageAction>;
  124684. /**
  124685. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  124686. */
  124687. private geometriesByUniqueId;
  124688. /**
  124689. * Creates a new Scene
  124690. * @param engine defines the engine to use to render this scene
  124691. * @param options defines the scene options
  124692. */
  124693. constructor(engine: Engine, options?: SceneOptions);
  124694. /**
  124695. * Gets a string identifying the name of the class
  124696. * @returns "Scene" string
  124697. */
  124698. getClassName(): string;
  124699. private _defaultMeshCandidates;
  124700. /**
  124701. * @hidden
  124702. */
  124703. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  124704. private _defaultSubMeshCandidates;
  124705. /**
  124706. * @hidden
  124707. */
  124708. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  124709. /**
  124710. * Sets the default candidate providers for the scene.
  124711. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  124712. * and getCollidingSubMeshCandidates to their default function
  124713. */
  124714. setDefaultCandidateProviders(): void;
  124715. /**
  124716. * Gets the mesh that is currently under the pointer
  124717. */
  124718. get meshUnderPointer(): Nullable<AbstractMesh>;
  124719. /**
  124720. * Gets or sets the current on-screen X position of the pointer
  124721. */
  124722. get pointerX(): number;
  124723. set pointerX(value: number);
  124724. /**
  124725. * Gets or sets the current on-screen Y position of the pointer
  124726. */
  124727. get pointerY(): number;
  124728. set pointerY(value: number);
  124729. /**
  124730. * Gets the cached material (ie. the latest rendered one)
  124731. * @returns the cached material
  124732. */
  124733. getCachedMaterial(): Nullable<Material>;
  124734. /**
  124735. * Gets the cached effect (ie. the latest rendered one)
  124736. * @returns the cached effect
  124737. */
  124738. getCachedEffect(): Nullable<Effect>;
  124739. /**
  124740. * Gets the cached visibility state (ie. the latest rendered one)
  124741. * @returns the cached visibility state
  124742. */
  124743. getCachedVisibility(): Nullable<number>;
  124744. /**
  124745. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  124746. * @param material defines the current material
  124747. * @param effect defines the current effect
  124748. * @param visibility defines the current visibility state
  124749. * @returns true if one parameter is not cached
  124750. */
  124751. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  124752. /**
  124753. * Gets the engine associated with the scene
  124754. * @returns an Engine
  124755. */
  124756. getEngine(): Engine;
  124757. /**
  124758. * Gets the total number of vertices rendered per frame
  124759. * @returns the total number of vertices rendered per frame
  124760. */
  124761. getTotalVertices(): number;
  124762. /**
  124763. * Gets the performance counter for total vertices
  124764. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124765. */
  124766. get totalVerticesPerfCounter(): PerfCounter;
  124767. /**
  124768. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  124769. * @returns the total number of active indices rendered per frame
  124770. */
  124771. getActiveIndices(): number;
  124772. /**
  124773. * Gets the performance counter for active indices
  124774. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124775. */
  124776. get totalActiveIndicesPerfCounter(): PerfCounter;
  124777. /**
  124778. * Gets the total number of active particles rendered per frame
  124779. * @returns the total number of active particles rendered per frame
  124780. */
  124781. getActiveParticles(): number;
  124782. /**
  124783. * Gets the performance counter for active particles
  124784. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124785. */
  124786. get activeParticlesPerfCounter(): PerfCounter;
  124787. /**
  124788. * Gets the total number of active bones rendered per frame
  124789. * @returns the total number of active bones rendered per frame
  124790. */
  124791. getActiveBones(): number;
  124792. /**
  124793. * Gets the performance counter for active bones
  124794. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  124795. */
  124796. get activeBonesPerfCounter(): PerfCounter;
  124797. /**
  124798. * Gets the array of active meshes
  124799. * @returns an array of AbstractMesh
  124800. */
  124801. getActiveMeshes(): SmartArray<AbstractMesh>;
  124802. /**
  124803. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  124804. * @returns a number
  124805. */
  124806. getAnimationRatio(): number;
  124807. /**
  124808. * Gets an unique Id for the current render phase
  124809. * @returns a number
  124810. */
  124811. getRenderId(): number;
  124812. /**
  124813. * Gets an unique Id for the current frame
  124814. * @returns a number
  124815. */
  124816. getFrameId(): number;
  124817. /** Call this function if you want to manually increment the render Id*/
  124818. incrementRenderId(): void;
  124819. private _createUbo;
  124820. /**
  124821. * Use this method to simulate a pointer move on a mesh
  124822. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124823. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124824. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124825. * @returns the current scene
  124826. */
  124827. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124828. /**
  124829. * Use this method to simulate a pointer down on a mesh
  124830. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124831. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124832. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124833. * @returns the current scene
  124834. */
  124835. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  124836. /**
  124837. * Use this method to simulate a pointer up on a mesh
  124838. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  124839. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  124840. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  124841. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  124842. * @returns the current scene
  124843. */
  124844. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  124845. /**
  124846. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  124847. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  124848. * @returns true if the pointer was captured
  124849. */
  124850. isPointerCaptured(pointerId?: number): boolean;
  124851. /**
  124852. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  124853. * @param attachUp defines if you want to attach events to pointerup
  124854. * @param attachDown defines if you want to attach events to pointerdown
  124855. * @param attachMove defines if you want to attach events to pointermove
  124856. */
  124857. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  124858. /** Detaches all event handlers*/
  124859. detachControl(): void;
  124860. /**
  124861. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  124862. * Delay loaded resources are not taking in account
  124863. * @return true if all required resources are ready
  124864. */
  124865. isReady(): boolean;
  124866. /** Resets all cached information relative to material (including effect and visibility) */
  124867. resetCachedMaterial(): void;
  124868. /**
  124869. * Registers a function to be called before every frame render
  124870. * @param func defines the function to register
  124871. */
  124872. registerBeforeRender(func: () => void): void;
  124873. /**
  124874. * Unregisters a function called before every frame render
  124875. * @param func defines the function to unregister
  124876. */
  124877. unregisterBeforeRender(func: () => void): void;
  124878. /**
  124879. * Registers a function to be called after every frame render
  124880. * @param func defines the function to register
  124881. */
  124882. registerAfterRender(func: () => void): void;
  124883. /**
  124884. * Unregisters a function called after every frame render
  124885. * @param func defines the function to unregister
  124886. */
  124887. unregisterAfterRender(func: () => void): void;
  124888. private _executeOnceBeforeRender;
  124889. /**
  124890. * The provided function will run before render once and will be disposed afterwards.
  124891. * A timeout delay can be provided so that the function will be executed in N ms.
  124892. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  124893. * @param func The function to be executed.
  124894. * @param timeout optional delay in ms
  124895. */
  124896. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  124897. /** @hidden */
  124898. _addPendingData(data: any): void;
  124899. /** @hidden */
  124900. _removePendingData(data: any): void;
  124901. /**
  124902. * Returns the number of items waiting to be loaded
  124903. * @returns the number of items waiting to be loaded
  124904. */
  124905. getWaitingItemsCount(): number;
  124906. /**
  124907. * Returns a boolean indicating if the scene is still loading data
  124908. */
  124909. get isLoading(): boolean;
  124910. /**
  124911. * Registers a function to be executed when the scene is ready
  124912. * @param {Function} func - the function to be executed
  124913. */
  124914. executeWhenReady(func: () => void): void;
  124915. /**
  124916. * Returns a promise that resolves when the scene is ready
  124917. * @returns A promise that resolves when the scene is ready
  124918. */
  124919. whenReadyAsync(): Promise<void>;
  124920. /** @hidden */
  124921. _checkIsReady(): void;
  124922. /**
  124923. * Gets all animatable attached to the scene
  124924. */
  124925. get animatables(): Animatable[];
  124926. /**
  124927. * Resets the last animation time frame.
  124928. * Useful to override when animations start running when loading a scene for the first time.
  124929. */
  124930. resetLastAnimationTimeFrame(): void;
  124931. /**
  124932. * Gets the current view matrix
  124933. * @returns a Matrix
  124934. */
  124935. getViewMatrix(): Matrix;
  124936. /**
  124937. * Gets the current projection matrix
  124938. * @returns a Matrix
  124939. */
  124940. getProjectionMatrix(): Matrix;
  124941. /**
  124942. * Gets the current transform matrix
  124943. * @returns a Matrix made of View * Projection
  124944. */
  124945. getTransformMatrix(): Matrix;
  124946. /**
  124947. * Sets the current transform matrix
  124948. * @param viewL defines the View matrix to use
  124949. * @param projectionL defines the Projection matrix to use
  124950. * @param viewR defines the right View matrix to use (if provided)
  124951. * @param projectionR defines the right Projection matrix to use (if provided)
  124952. */
  124953. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  124954. /**
  124955. * Gets the uniform buffer used to store scene data
  124956. * @returns a UniformBuffer
  124957. */
  124958. getSceneUniformBuffer(): UniformBuffer;
  124959. /**
  124960. * Gets an unique (relatively to the current scene) Id
  124961. * @returns an unique number for the scene
  124962. */
  124963. getUniqueId(): number;
  124964. /**
  124965. * Add a mesh to the list of scene's meshes
  124966. * @param newMesh defines the mesh to add
  124967. * @param recursive if all child meshes should also be added to the scene
  124968. */
  124969. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  124970. /**
  124971. * Remove a mesh for the list of scene's meshes
  124972. * @param toRemove defines the mesh to remove
  124973. * @param recursive if all child meshes should also be removed from the scene
  124974. * @returns the index where the mesh was in the mesh list
  124975. */
  124976. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  124977. /**
  124978. * Add a transform node to the list of scene's transform nodes
  124979. * @param newTransformNode defines the transform node to add
  124980. */
  124981. addTransformNode(newTransformNode: TransformNode): void;
  124982. /**
  124983. * Remove a transform node for the list of scene's transform nodes
  124984. * @param toRemove defines the transform node to remove
  124985. * @returns the index where the transform node was in the transform node list
  124986. */
  124987. removeTransformNode(toRemove: TransformNode): number;
  124988. /**
  124989. * Remove a skeleton for the list of scene's skeletons
  124990. * @param toRemove defines the skeleton to remove
  124991. * @returns the index where the skeleton was in the skeleton list
  124992. */
  124993. removeSkeleton(toRemove: Skeleton): number;
  124994. /**
  124995. * Remove a morph target for the list of scene's morph targets
  124996. * @param toRemove defines the morph target to remove
  124997. * @returns the index where the morph target was in the morph target list
  124998. */
  124999. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  125000. /**
  125001. * Remove a light for the list of scene's lights
  125002. * @param toRemove defines the light to remove
  125003. * @returns the index where the light was in the light list
  125004. */
  125005. removeLight(toRemove: Light): number;
  125006. /**
  125007. * Remove a camera for the list of scene's cameras
  125008. * @param toRemove defines the camera to remove
  125009. * @returns the index where the camera was in the camera list
  125010. */
  125011. removeCamera(toRemove: Camera): number;
  125012. /**
  125013. * Remove a particle system for the list of scene's particle systems
  125014. * @param toRemove defines the particle system to remove
  125015. * @returns the index where the particle system was in the particle system list
  125016. */
  125017. removeParticleSystem(toRemove: IParticleSystem): number;
  125018. /**
  125019. * Remove a animation for the list of scene's animations
  125020. * @param toRemove defines the animation to remove
  125021. * @returns the index where the animation was in the animation list
  125022. */
  125023. removeAnimation(toRemove: Animation): number;
  125024. /**
  125025. * Will stop the animation of the given target
  125026. * @param target - the target
  125027. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  125028. * @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)
  125029. */
  125030. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  125031. /**
  125032. * Removes the given animation group from this scene.
  125033. * @param toRemove The animation group to remove
  125034. * @returns The index of the removed animation group
  125035. */
  125036. removeAnimationGroup(toRemove: AnimationGroup): number;
  125037. /**
  125038. * Removes the given multi-material from this scene.
  125039. * @param toRemove The multi-material to remove
  125040. * @returns The index of the removed multi-material
  125041. */
  125042. removeMultiMaterial(toRemove: MultiMaterial): number;
  125043. /**
  125044. * Removes the given material from this scene.
  125045. * @param toRemove The material to remove
  125046. * @returns The index of the removed material
  125047. */
  125048. removeMaterial(toRemove: Material): number;
  125049. /**
  125050. * Removes the given action manager from this scene.
  125051. * @param toRemove The action manager to remove
  125052. * @returns The index of the removed action manager
  125053. */
  125054. removeActionManager(toRemove: AbstractActionManager): number;
  125055. /**
  125056. * Removes the given texture from this scene.
  125057. * @param toRemove The texture to remove
  125058. * @returns The index of the removed texture
  125059. */
  125060. removeTexture(toRemove: BaseTexture): number;
  125061. /**
  125062. * Adds the given light to this scene
  125063. * @param newLight The light to add
  125064. */
  125065. addLight(newLight: Light): void;
  125066. /**
  125067. * Sorts the list list based on light priorities
  125068. */
  125069. sortLightsByPriority(): void;
  125070. /**
  125071. * Adds the given camera to this scene
  125072. * @param newCamera The camera to add
  125073. */
  125074. addCamera(newCamera: Camera): void;
  125075. /**
  125076. * Adds the given skeleton to this scene
  125077. * @param newSkeleton The skeleton to add
  125078. */
  125079. addSkeleton(newSkeleton: Skeleton): void;
  125080. /**
  125081. * Adds the given particle system to this scene
  125082. * @param newParticleSystem The particle system to add
  125083. */
  125084. addParticleSystem(newParticleSystem: IParticleSystem): void;
  125085. /**
  125086. * Adds the given animation to this scene
  125087. * @param newAnimation The animation to add
  125088. */
  125089. addAnimation(newAnimation: Animation): void;
  125090. /**
  125091. * Adds the given animation group to this scene.
  125092. * @param newAnimationGroup The animation group to add
  125093. */
  125094. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  125095. /**
  125096. * Adds the given multi-material to this scene
  125097. * @param newMultiMaterial The multi-material to add
  125098. */
  125099. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  125100. /**
  125101. * Adds the given material to this scene
  125102. * @param newMaterial The material to add
  125103. */
  125104. addMaterial(newMaterial: Material): void;
  125105. /**
  125106. * Adds the given morph target to this scene
  125107. * @param newMorphTargetManager The morph target to add
  125108. */
  125109. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  125110. /**
  125111. * Adds the given geometry to this scene
  125112. * @param newGeometry The geometry to add
  125113. */
  125114. addGeometry(newGeometry: Geometry): void;
  125115. /**
  125116. * Adds the given action manager to this scene
  125117. * @param newActionManager The action manager to add
  125118. */
  125119. addActionManager(newActionManager: AbstractActionManager): void;
  125120. /**
  125121. * Adds the given texture to this scene.
  125122. * @param newTexture The texture to add
  125123. */
  125124. addTexture(newTexture: BaseTexture): void;
  125125. /**
  125126. * Switch active camera
  125127. * @param newCamera defines the new active camera
  125128. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  125129. */
  125130. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  125131. /**
  125132. * sets the active camera of the scene using its ID
  125133. * @param id defines the camera's ID
  125134. * @return the new active camera or null if none found.
  125135. */
  125136. setActiveCameraByID(id: string): Nullable<Camera>;
  125137. /**
  125138. * sets the active camera of the scene using its name
  125139. * @param name defines the camera's name
  125140. * @returns the new active camera or null if none found.
  125141. */
  125142. setActiveCameraByName(name: string): Nullable<Camera>;
  125143. /**
  125144. * get an animation group using its name
  125145. * @param name defines the material's name
  125146. * @return the animation group or null if none found.
  125147. */
  125148. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  125149. /**
  125150. * Get a material using its unique id
  125151. * @param uniqueId defines the material's unique id
  125152. * @return the material or null if none found.
  125153. */
  125154. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  125155. /**
  125156. * get a material using its id
  125157. * @param id defines the material's ID
  125158. * @return the material or null if none found.
  125159. */
  125160. getMaterialByID(id: string): Nullable<Material>;
  125161. /**
  125162. * Gets a the last added material using a given id
  125163. * @param id defines the material's ID
  125164. * @return the last material with the given id or null if none found.
  125165. */
  125166. getLastMaterialByID(id: string): Nullable<Material>;
  125167. /**
  125168. * Gets a material using its name
  125169. * @param name defines the material's name
  125170. * @return the material or null if none found.
  125171. */
  125172. getMaterialByName(name: string): Nullable<Material>;
  125173. /**
  125174. * Get a texture using its unique id
  125175. * @param uniqueId defines the texture's unique id
  125176. * @return the texture or null if none found.
  125177. */
  125178. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  125179. /**
  125180. * Gets a camera using its id
  125181. * @param id defines the id to look for
  125182. * @returns the camera or null if not found
  125183. */
  125184. getCameraByID(id: string): Nullable<Camera>;
  125185. /**
  125186. * Gets a camera using its unique id
  125187. * @param uniqueId defines the unique id to look for
  125188. * @returns the camera or null if not found
  125189. */
  125190. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  125191. /**
  125192. * Gets a camera using its name
  125193. * @param name defines the camera's name
  125194. * @return the camera or null if none found.
  125195. */
  125196. getCameraByName(name: string): Nullable<Camera>;
  125197. /**
  125198. * Gets a bone using its id
  125199. * @param id defines the bone's id
  125200. * @return the bone or null if not found
  125201. */
  125202. getBoneByID(id: string): Nullable<Bone>;
  125203. /**
  125204. * Gets a bone using its id
  125205. * @param name defines the bone's name
  125206. * @return the bone or null if not found
  125207. */
  125208. getBoneByName(name: string): Nullable<Bone>;
  125209. /**
  125210. * Gets a light node using its name
  125211. * @param name defines the the light's name
  125212. * @return the light or null if none found.
  125213. */
  125214. getLightByName(name: string): Nullable<Light>;
  125215. /**
  125216. * Gets a light node using its id
  125217. * @param id defines the light's id
  125218. * @return the light or null if none found.
  125219. */
  125220. getLightByID(id: string): Nullable<Light>;
  125221. /**
  125222. * Gets a light node using its scene-generated unique ID
  125223. * @param uniqueId defines the light's unique id
  125224. * @return the light or null if none found.
  125225. */
  125226. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  125227. /**
  125228. * Gets a particle system by id
  125229. * @param id defines the particle system id
  125230. * @return the corresponding system or null if none found
  125231. */
  125232. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  125233. /**
  125234. * Gets a geometry using its ID
  125235. * @param id defines the geometry's id
  125236. * @return the geometry or null if none found.
  125237. */
  125238. getGeometryByID(id: string): Nullable<Geometry>;
  125239. private _getGeometryByUniqueID;
  125240. /**
  125241. * Add a new geometry to this scene
  125242. * @param geometry defines the geometry to be added to the scene.
  125243. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  125244. * @return a boolean defining if the geometry was added or not
  125245. */
  125246. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  125247. /**
  125248. * Removes an existing geometry
  125249. * @param geometry defines the geometry to be removed from the scene
  125250. * @return a boolean defining if the geometry was removed or not
  125251. */
  125252. removeGeometry(geometry: Geometry): boolean;
  125253. /**
  125254. * Gets the list of geometries attached to the scene
  125255. * @returns an array of Geometry
  125256. */
  125257. getGeometries(): Geometry[];
  125258. /**
  125259. * Gets the first added mesh found of a given ID
  125260. * @param id defines the id to search for
  125261. * @return the mesh found or null if not found at all
  125262. */
  125263. getMeshByID(id: string): Nullable<AbstractMesh>;
  125264. /**
  125265. * Gets a list of meshes using their id
  125266. * @param id defines the id to search for
  125267. * @returns a list of meshes
  125268. */
  125269. getMeshesByID(id: string): Array<AbstractMesh>;
  125270. /**
  125271. * Gets the first added transform node found of a given ID
  125272. * @param id defines the id to search for
  125273. * @return the found transform node or null if not found at all.
  125274. */
  125275. getTransformNodeByID(id: string): Nullable<TransformNode>;
  125276. /**
  125277. * Gets a transform node with its auto-generated unique id
  125278. * @param uniqueId efines the unique id to search for
  125279. * @return the found transform node or null if not found at all.
  125280. */
  125281. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  125282. /**
  125283. * Gets a list of transform nodes using their id
  125284. * @param id defines the id to search for
  125285. * @returns a list of transform nodes
  125286. */
  125287. getTransformNodesByID(id: string): Array<TransformNode>;
  125288. /**
  125289. * Gets a mesh with its auto-generated unique id
  125290. * @param uniqueId defines the unique id to search for
  125291. * @return the found mesh or null if not found at all.
  125292. */
  125293. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  125294. /**
  125295. * Gets a the last added mesh using a given id
  125296. * @param id defines the id to search for
  125297. * @return the found mesh or null if not found at all.
  125298. */
  125299. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  125300. /**
  125301. * Gets a the last added node (Mesh, Camera, Light) using a given id
  125302. * @param id defines the id to search for
  125303. * @return the found node or null if not found at all
  125304. */
  125305. getLastEntryByID(id: string): Nullable<Node>;
  125306. /**
  125307. * Gets a node (Mesh, Camera, Light) using a given id
  125308. * @param id defines the id to search for
  125309. * @return the found node or null if not found at all
  125310. */
  125311. getNodeByID(id: string): Nullable<Node>;
  125312. /**
  125313. * Gets a node (Mesh, Camera, Light) using a given name
  125314. * @param name defines the name to search for
  125315. * @return the found node or null if not found at all.
  125316. */
  125317. getNodeByName(name: string): Nullable<Node>;
  125318. /**
  125319. * Gets a mesh using a given name
  125320. * @param name defines the name to search for
  125321. * @return the found mesh or null if not found at all.
  125322. */
  125323. getMeshByName(name: string): Nullable<AbstractMesh>;
  125324. /**
  125325. * Gets a transform node using a given name
  125326. * @param name defines the name to search for
  125327. * @return the found transform node or null if not found at all.
  125328. */
  125329. getTransformNodeByName(name: string): Nullable<TransformNode>;
  125330. /**
  125331. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  125332. * @param id defines the id to search for
  125333. * @return the found skeleton or null if not found at all.
  125334. */
  125335. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  125336. /**
  125337. * Gets a skeleton using a given auto generated unique id
  125338. * @param uniqueId defines the unique id to search for
  125339. * @return the found skeleton or null if not found at all.
  125340. */
  125341. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  125342. /**
  125343. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  125344. * @param id defines the id to search for
  125345. * @return the found skeleton or null if not found at all.
  125346. */
  125347. getSkeletonById(id: string): Nullable<Skeleton>;
  125348. /**
  125349. * Gets a skeleton using a given name
  125350. * @param name defines the name to search for
  125351. * @return the found skeleton or null if not found at all.
  125352. */
  125353. getSkeletonByName(name: string): Nullable<Skeleton>;
  125354. /**
  125355. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  125356. * @param id defines the id to search for
  125357. * @return the found morph target manager or null if not found at all.
  125358. */
  125359. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  125360. /**
  125361. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  125362. * @param id defines the id to search for
  125363. * @return the found morph target or null if not found at all.
  125364. */
  125365. getMorphTargetById(id: string): Nullable<MorphTarget>;
  125366. /**
  125367. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  125368. * @param name defines the name to search for
  125369. * @return the found morph target or null if not found at all.
  125370. */
  125371. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  125372. /**
  125373. * Gets a post process using a given name (if many are found, this function will pick the first one)
  125374. * @param name defines the name to search for
  125375. * @return the found post process or null if not found at all.
  125376. */
  125377. getPostProcessByName(name: string): Nullable<PostProcess>;
  125378. /**
  125379. * Gets a boolean indicating if the given mesh is active
  125380. * @param mesh defines the mesh to look for
  125381. * @returns true if the mesh is in the active list
  125382. */
  125383. isActiveMesh(mesh: AbstractMesh): boolean;
  125384. /**
  125385. * Return a unique id as a string which can serve as an identifier for the scene
  125386. */
  125387. get uid(): string;
  125388. /**
  125389. * Add an externaly attached data from its key.
  125390. * This method call will fail and return false, if such key already exists.
  125391. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  125392. * @param key the unique key that identifies the data
  125393. * @param data the data object to associate to the key for this Engine instance
  125394. * @return true if no such key were already present and the data was added successfully, false otherwise
  125395. */
  125396. addExternalData<T>(key: string, data: T): boolean;
  125397. /**
  125398. * Get an externaly attached data from its key
  125399. * @param key the unique key that identifies the data
  125400. * @return the associated data, if present (can be null), or undefined if not present
  125401. */
  125402. getExternalData<T>(key: string): Nullable<T>;
  125403. /**
  125404. * Get an externaly attached data from its key, create it using a factory if it's not already present
  125405. * @param key the unique key that identifies the data
  125406. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  125407. * @return the associated data, can be null if the factory returned null.
  125408. */
  125409. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  125410. /**
  125411. * Remove an externaly attached data from the Engine instance
  125412. * @param key the unique key that identifies the data
  125413. * @return true if the data was successfully removed, false if it doesn't exist
  125414. */
  125415. removeExternalData(key: string): boolean;
  125416. private _evaluateSubMesh;
  125417. /**
  125418. * Clear the processed materials smart array preventing retention point in material dispose.
  125419. */
  125420. freeProcessedMaterials(): void;
  125421. private _preventFreeActiveMeshesAndRenderingGroups;
  125422. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  125423. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  125424. * when disposing several meshes in a row or a hierarchy of meshes.
  125425. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  125426. */
  125427. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  125428. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  125429. /**
  125430. * Clear the active meshes smart array preventing retention point in mesh dispose.
  125431. */
  125432. freeActiveMeshes(): void;
  125433. /**
  125434. * Clear the info related to rendering groups preventing retention points during dispose.
  125435. */
  125436. freeRenderingGroups(): void;
  125437. /** @hidden */
  125438. _isInIntermediateRendering(): boolean;
  125439. /**
  125440. * Lambda returning the list of potentially active meshes.
  125441. */
  125442. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  125443. /**
  125444. * Lambda returning the list of potentially active sub meshes.
  125445. */
  125446. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  125447. /**
  125448. * Lambda returning the list of potentially intersecting sub meshes.
  125449. */
  125450. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  125451. /**
  125452. * Lambda returning the list of potentially colliding sub meshes.
  125453. */
  125454. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  125455. private _activeMeshesFrozen;
  125456. private _skipEvaluateActiveMeshesCompletely;
  125457. /**
  125458. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  125459. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  125460. * @param onSuccess optional success callback
  125461. * @param onError optional error callback
  125462. * @returns the current scene
  125463. */
  125464. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  125465. /**
  125466. * Use this function to restart evaluating active meshes on every frame
  125467. * @returns the current scene
  125468. */
  125469. unfreezeActiveMeshes(): Scene;
  125470. private _evaluateActiveMeshes;
  125471. private _activeMesh;
  125472. /**
  125473. * Update the transform matrix to update from the current active camera
  125474. * @param force defines a boolean used to force the update even if cache is up to date
  125475. */
  125476. updateTransformMatrix(force?: boolean): void;
  125477. private _bindFrameBuffer;
  125478. /** @hidden */
  125479. _allowPostProcessClearColor: boolean;
  125480. /** @hidden */
  125481. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  125482. private _processSubCameras;
  125483. private _checkIntersections;
  125484. /** @hidden */
  125485. _advancePhysicsEngineStep(step: number): void;
  125486. /**
  125487. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  125488. */
  125489. getDeterministicFrameTime: () => number;
  125490. /** @hidden */
  125491. _animate(): void;
  125492. /** Execute all animations (for a frame) */
  125493. animate(): void;
  125494. /**
  125495. * Render the scene
  125496. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  125497. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  125498. */
  125499. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  125500. /**
  125501. * Freeze all materials
  125502. * A frozen material will not be updatable but should be faster to render
  125503. */
  125504. freezeMaterials(): void;
  125505. /**
  125506. * Unfreeze all materials
  125507. * A frozen material will not be updatable but should be faster to render
  125508. */
  125509. unfreezeMaterials(): void;
  125510. /**
  125511. * Releases all held ressources
  125512. */
  125513. dispose(): void;
  125514. /**
  125515. * Gets if the scene is already disposed
  125516. */
  125517. get isDisposed(): boolean;
  125518. /**
  125519. * Call this function to reduce memory footprint of the scene.
  125520. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  125521. */
  125522. clearCachedVertexData(): void;
  125523. /**
  125524. * This function will remove the local cached buffer data from texture.
  125525. * It will save memory but will prevent the texture from being rebuilt
  125526. */
  125527. cleanCachedTextureBuffer(): void;
  125528. /**
  125529. * Get the world extend vectors with an optional filter
  125530. *
  125531. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  125532. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  125533. */
  125534. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  125535. min: Vector3;
  125536. max: Vector3;
  125537. };
  125538. /**
  125539. * Creates a ray that can be used to pick in the scene
  125540. * @param x defines the x coordinate of the origin (on-screen)
  125541. * @param y defines the y coordinate of the origin (on-screen)
  125542. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  125543. * @param camera defines the camera to use for the picking
  125544. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  125545. * @returns a Ray
  125546. */
  125547. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  125548. /**
  125549. * Creates a ray that can be used to pick in the scene
  125550. * @param x defines the x coordinate of the origin (on-screen)
  125551. * @param y defines the y coordinate of the origin (on-screen)
  125552. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  125553. * @param result defines the ray where to store the picking ray
  125554. * @param camera defines the camera to use for the picking
  125555. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  125556. * @returns the current scene
  125557. */
  125558. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  125559. /**
  125560. * Creates a ray that can be used to pick in the scene
  125561. * @param x defines the x coordinate of the origin (on-screen)
  125562. * @param y defines the y coordinate of the origin (on-screen)
  125563. * @param camera defines the camera to use for the picking
  125564. * @returns a Ray
  125565. */
  125566. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  125567. /**
  125568. * Creates a ray that can be used to pick in the scene
  125569. * @param x defines the x coordinate of the origin (on-screen)
  125570. * @param y defines the y coordinate of the origin (on-screen)
  125571. * @param result defines the ray where to store the picking ray
  125572. * @param camera defines the camera to use for the picking
  125573. * @returns the current scene
  125574. */
  125575. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  125576. /** Launch a ray to try to pick a mesh in the scene
  125577. * @param x position on screen
  125578. * @param y position on screen
  125579. * @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
  125580. * @param fastCheck defines if the first intersection will be used (and not the closest)
  125581. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  125582. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125583. * @returns a PickingInfo
  125584. */
  125585. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  125586. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  125587. * @param x position on screen
  125588. * @param y position on screen
  125589. * @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
  125590. * @param fastCheck defines if the first intersection will be used (and not the closest)
  125591. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  125592. * @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)
  125593. */
  125594. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  125595. /** Use the given ray to pick a mesh in the scene
  125596. * @param ray The ray to use to pick meshes
  125597. * @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
  125598. * @param fastCheck defines if the first intersection will be used (and not the closest)
  125599. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125600. * @returns a PickingInfo
  125601. */
  125602. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  125603. /**
  125604. * Launch a ray to try to pick a mesh in the scene
  125605. * @param x X position on screen
  125606. * @param y Y position on screen
  125607. * @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
  125608. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  125609. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125610. * @returns an array of PickingInfo
  125611. */
  125612. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  125613. /**
  125614. * Launch a ray to try to pick a mesh in the scene
  125615. * @param ray Ray to use
  125616. * @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
  125617. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  125618. * @returns an array of PickingInfo
  125619. */
  125620. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  125621. /**
  125622. * Force the value of meshUnderPointer
  125623. * @param mesh defines the mesh to use
  125624. * @param pointerId optional pointer id when using more than one pointer
  125625. */
  125626. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  125627. /**
  125628. * Gets the mesh under the pointer
  125629. * @returns a Mesh or null if no mesh is under the pointer
  125630. */
  125631. getPointerOverMesh(): Nullable<AbstractMesh>;
  125632. /** @hidden */
  125633. _rebuildGeometries(): void;
  125634. /** @hidden */
  125635. _rebuildTextures(): void;
  125636. private _getByTags;
  125637. /**
  125638. * Get a list of meshes by tags
  125639. * @param tagsQuery defines the tags query to use
  125640. * @param forEach defines a predicate used to filter results
  125641. * @returns an array of Mesh
  125642. */
  125643. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  125644. /**
  125645. * Get a list of cameras by tags
  125646. * @param tagsQuery defines the tags query to use
  125647. * @param forEach defines a predicate used to filter results
  125648. * @returns an array of Camera
  125649. */
  125650. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  125651. /**
  125652. * Get a list of lights by tags
  125653. * @param tagsQuery defines the tags query to use
  125654. * @param forEach defines a predicate used to filter results
  125655. * @returns an array of Light
  125656. */
  125657. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  125658. /**
  125659. * Get a list of materials by tags
  125660. * @param tagsQuery defines the tags query to use
  125661. * @param forEach defines a predicate used to filter results
  125662. * @returns an array of Material
  125663. */
  125664. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  125665. /**
  125666. * Get a list of transform nodes by tags
  125667. * @param tagsQuery defines the tags query to use
  125668. * @param forEach defines a predicate used to filter results
  125669. * @returns an array of TransformNode
  125670. */
  125671. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  125672. /**
  125673. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  125674. * This allowed control for front to back rendering or reversly depending of the special needs.
  125675. *
  125676. * @param renderingGroupId The rendering group id corresponding to its index
  125677. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  125678. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  125679. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  125680. */
  125681. 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;
  125682. /**
  125683. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  125684. *
  125685. * @param renderingGroupId The rendering group id corresponding to its index
  125686. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  125687. * @param depth Automatically clears depth between groups if true and autoClear is true.
  125688. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  125689. */
  125690. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  125691. /**
  125692. * Gets the current auto clear configuration for one rendering group of the rendering
  125693. * manager.
  125694. * @param index the rendering group index to get the information for
  125695. * @returns The auto clear setup for the requested rendering group
  125696. */
  125697. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  125698. private _blockMaterialDirtyMechanism;
  125699. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  125700. get blockMaterialDirtyMechanism(): boolean;
  125701. set blockMaterialDirtyMechanism(value: boolean);
  125702. /**
  125703. * Will flag all materials as dirty to trigger new shader compilation
  125704. * @param flag defines the flag used to specify which material part must be marked as dirty
  125705. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  125706. */
  125707. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  125708. /** @hidden */
  125709. _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;
  125710. /** @hidden */
  125711. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125712. /** @hidden */
  125713. _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;
  125714. /** @hidden */
  125715. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  125716. /** @hidden */
  125717. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  125718. /** @hidden */
  125719. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  125720. }
  125721. }
  125722. declare module BABYLON {
  125723. /**
  125724. * Set of assets to keep when moving a scene into an asset container.
  125725. */
  125726. export class KeepAssets extends AbstractScene {
  125727. }
  125728. /**
  125729. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  125730. */
  125731. export class InstantiatedEntries {
  125732. /**
  125733. * List of new root nodes (eg. nodes with no parent)
  125734. */
  125735. rootNodes: TransformNode[];
  125736. /**
  125737. * List of new skeletons
  125738. */
  125739. skeletons: Skeleton[];
  125740. /**
  125741. * List of new animation groups
  125742. */
  125743. animationGroups: AnimationGroup[];
  125744. }
  125745. /**
  125746. * Container with a set of assets that can be added or removed from a scene.
  125747. */
  125748. export class AssetContainer extends AbstractScene {
  125749. private _wasAddedToScene;
  125750. /**
  125751. * The scene the AssetContainer belongs to.
  125752. */
  125753. scene: Scene;
  125754. /**
  125755. * Instantiates an AssetContainer.
  125756. * @param scene The scene the AssetContainer belongs to.
  125757. */
  125758. constructor(scene: Scene);
  125759. /**
  125760. * Instantiate or clone all meshes and add the new ones to the scene.
  125761. * Skeletons and animation groups will all be cloned
  125762. * @param nameFunction defines an optional function used to get new names for clones
  125763. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  125764. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  125765. */
  125766. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  125767. /**
  125768. * Adds all the assets from the container to the scene.
  125769. */
  125770. addAllToScene(): void;
  125771. /**
  125772. * Removes all the assets in the container from the scene
  125773. */
  125774. removeAllFromScene(): void;
  125775. /**
  125776. * Disposes all the assets in the container
  125777. */
  125778. dispose(): void;
  125779. private _moveAssets;
  125780. /**
  125781. * Removes all the assets contained in the scene and adds them to the container.
  125782. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  125783. */
  125784. moveAllFromScene(keepAssets?: KeepAssets): void;
  125785. /**
  125786. * 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.
  125787. * @returns the root mesh
  125788. */
  125789. createRootMesh(): Mesh;
  125790. /**
  125791. * Merge animations (direct and animation groups) from this asset container into a scene
  125792. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125793. * @param animatables set of animatables to retarget to a node from the scene
  125794. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  125795. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  125796. */
  125797. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  125798. }
  125799. }
  125800. declare module BABYLON {
  125801. /**
  125802. * Defines how the parser contract is defined.
  125803. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  125804. */
  125805. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  125806. /**
  125807. * Defines how the individual parser contract is defined.
  125808. * These parser can parse an individual asset
  125809. */
  125810. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  125811. /**
  125812. * Base class of the scene acting as a container for the different elements composing a scene.
  125813. * This class is dynamically extended by the different components of the scene increasing
  125814. * flexibility and reducing coupling
  125815. */
  125816. export abstract class AbstractScene {
  125817. /**
  125818. * Stores the list of available parsers in the application.
  125819. */
  125820. private static _BabylonFileParsers;
  125821. /**
  125822. * Stores the list of available individual parsers in the application.
  125823. */
  125824. private static _IndividualBabylonFileParsers;
  125825. /**
  125826. * Adds a parser in the list of available ones
  125827. * @param name Defines the name of the parser
  125828. * @param parser Defines the parser to add
  125829. */
  125830. static AddParser(name: string, parser: BabylonFileParser): void;
  125831. /**
  125832. * Gets a general parser from the list of avaialble ones
  125833. * @param name Defines the name of the parser
  125834. * @returns the requested parser or null
  125835. */
  125836. static GetParser(name: string): Nullable<BabylonFileParser>;
  125837. /**
  125838. * Adds n individual parser in the list of available ones
  125839. * @param name Defines the name of the parser
  125840. * @param parser Defines the parser to add
  125841. */
  125842. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  125843. /**
  125844. * Gets an individual parser from the list of avaialble ones
  125845. * @param name Defines the name of the parser
  125846. * @returns the requested parser or null
  125847. */
  125848. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  125849. /**
  125850. * Parser json data and populate both a scene and its associated container object
  125851. * @param jsonData Defines the data to parse
  125852. * @param scene Defines the scene to parse the data for
  125853. * @param container Defines the container attached to the parsing sequence
  125854. * @param rootUrl Defines the root url of the data
  125855. */
  125856. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  125857. /**
  125858. * Gets the list of root nodes (ie. nodes with no parent)
  125859. */
  125860. rootNodes: Node[];
  125861. /** All of the cameras added to this scene
  125862. * @see https://doc.babylonjs.com/babylon101/cameras
  125863. */
  125864. cameras: Camera[];
  125865. /**
  125866. * All of the lights added to this scene
  125867. * @see https://doc.babylonjs.com/babylon101/lights
  125868. */
  125869. lights: Light[];
  125870. /**
  125871. * All of the (abstract) meshes added to this scene
  125872. */
  125873. meshes: AbstractMesh[];
  125874. /**
  125875. * The list of skeletons added to the scene
  125876. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  125877. */
  125878. skeletons: Skeleton[];
  125879. /**
  125880. * All of the particle systems added to this scene
  125881. * @see https://doc.babylonjs.com/babylon101/particles
  125882. */
  125883. particleSystems: IParticleSystem[];
  125884. /**
  125885. * Gets a list of Animations associated with the scene
  125886. */
  125887. animations: Animation[];
  125888. /**
  125889. * All of the animation groups added to this scene
  125890. * @see https://doc.babylonjs.com/how_to/group
  125891. */
  125892. animationGroups: AnimationGroup[];
  125893. /**
  125894. * All of the multi-materials added to this scene
  125895. * @see https://doc.babylonjs.com/how_to/multi_materials
  125896. */
  125897. multiMaterials: MultiMaterial[];
  125898. /**
  125899. * All of the materials added to this scene
  125900. * In the context of a Scene, it is not supposed to be modified manually.
  125901. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  125902. * Note also that the order of the Material within the array is not significant and might change.
  125903. * @see https://doc.babylonjs.com/babylon101/materials
  125904. */
  125905. materials: Material[];
  125906. /**
  125907. * The list of morph target managers added to the scene
  125908. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  125909. */
  125910. morphTargetManagers: MorphTargetManager[];
  125911. /**
  125912. * The list of geometries used in the scene.
  125913. */
  125914. geometries: Geometry[];
  125915. /**
  125916. * All of the tranform nodes added to this scene
  125917. * In the context of a Scene, it is not supposed to be modified manually.
  125918. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  125919. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  125920. * @see https://doc.babylonjs.com/how_to/transformnode
  125921. */
  125922. transformNodes: TransformNode[];
  125923. /**
  125924. * ActionManagers available on the scene.
  125925. */
  125926. actionManagers: AbstractActionManager[];
  125927. /**
  125928. * Textures to keep.
  125929. */
  125930. textures: BaseTexture[];
  125931. /** @hidden */
  125932. protected _environmentTexture: Nullable<BaseTexture>;
  125933. /**
  125934. * Texture used in all pbr material as the reflection texture.
  125935. * As in the majority of the scene they are the same (exception for multi room and so on),
  125936. * this is easier to reference from here than from all the materials.
  125937. */
  125938. get environmentTexture(): Nullable<BaseTexture>;
  125939. set environmentTexture(value: Nullable<BaseTexture>);
  125940. /**
  125941. * The list of postprocesses added to the scene
  125942. */
  125943. postProcesses: PostProcess[];
  125944. /**
  125945. * @returns all meshes, lights, cameras, transformNodes and bones
  125946. */
  125947. getNodes(): Array<Node>;
  125948. }
  125949. }
  125950. declare module BABYLON {
  125951. /**
  125952. * Interface used to define options for Sound class
  125953. */
  125954. export interface ISoundOptions {
  125955. /**
  125956. * Does the sound autoplay once loaded.
  125957. */
  125958. autoplay?: boolean;
  125959. /**
  125960. * Does the sound loop after it finishes playing once.
  125961. */
  125962. loop?: boolean;
  125963. /**
  125964. * Sound's volume
  125965. */
  125966. volume?: number;
  125967. /**
  125968. * Is it a spatial sound?
  125969. */
  125970. spatialSound?: boolean;
  125971. /**
  125972. * Maximum distance to hear that sound
  125973. */
  125974. maxDistance?: number;
  125975. /**
  125976. * Uses user defined attenuation function
  125977. */
  125978. useCustomAttenuation?: boolean;
  125979. /**
  125980. * Define the roll off factor of spatial sounds.
  125981. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125982. */
  125983. rolloffFactor?: number;
  125984. /**
  125985. * Define the reference distance the sound should be heard perfectly.
  125986. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125987. */
  125988. refDistance?: number;
  125989. /**
  125990. * Define the distance attenuation model the sound will follow.
  125991. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  125992. */
  125993. distanceModel?: string;
  125994. /**
  125995. * Defines the playback speed (1 by default)
  125996. */
  125997. playbackRate?: number;
  125998. /**
  125999. * Defines if the sound is from a streaming source
  126000. */
  126001. streaming?: boolean;
  126002. /**
  126003. * Defines an optional length (in seconds) inside the sound file
  126004. */
  126005. length?: number;
  126006. /**
  126007. * Defines an optional offset (in seconds) inside the sound file
  126008. */
  126009. offset?: number;
  126010. /**
  126011. * If true, URLs will not be required to state the audio file codec to use.
  126012. */
  126013. skipCodecCheck?: boolean;
  126014. }
  126015. /**
  126016. * Defines a sound that can be played in the application.
  126017. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  126018. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126019. */
  126020. export class Sound {
  126021. /**
  126022. * The name of the sound in the scene.
  126023. */
  126024. name: string;
  126025. /**
  126026. * Does the sound autoplay once loaded.
  126027. */
  126028. autoplay: boolean;
  126029. /**
  126030. * Does the sound loop after it finishes playing once.
  126031. */
  126032. loop: boolean;
  126033. /**
  126034. * Does the sound use a custom attenuation curve to simulate the falloff
  126035. * happening when the source gets further away from the camera.
  126036. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126037. */
  126038. useCustomAttenuation: boolean;
  126039. /**
  126040. * The sound track id this sound belongs to.
  126041. */
  126042. soundTrackId: number;
  126043. /**
  126044. * Is this sound currently played.
  126045. */
  126046. isPlaying: boolean;
  126047. /**
  126048. * Is this sound currently paused.
  126049. */
  126050. isPaused: boolean;
  126051. /**
  126052. * Does this sound enables spatial sound.
  126053. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126054. */
  126055. spatialSound: boolean;
  126056. /**
  126057. * Define the reference distance the sound should be heard perfectly.
  126058. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126059. */
  126060. refDistance: number;
  126061. /**
  126062. * Define the roll off factor of spatial sounds.
  126063. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126064. */
  126065. rolloffFactor: number;
  126066. /**
  126067. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  126068. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126069. */
  126070. maxDistance: number;
  126071. /**
  126072. * Define the distance attenuation model the sound will follow.
  126073. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126074. */
  126075. distanceModel: string;
  126076. /**
  126077. * @hidden
  126078. * Back Compat
  126079. **/
  126080. onended: () => any;
  126081. /**
  126082. * Gets or sets an object used to store user defined information for the sound.
  126083. */
  126084. metadata: any;
  126085. /**
  126086. * Observable event when the current playing sound finishes.
  126087. */
  126088. onEndedObservable: Observable<Sound>;
  126089. private _panningModel;
  126090. private _playbackRate;
  126091. private _streaming;
  126092. private _startTime;
  126093. private _startOffset;
  126094. private _position;
  126095. /** @hidden */
  126096. _positionInEmitterSpace: boolean;
  126097. private _localDirection;
  126098. private _volume;
  126099. private _isReadyToPlay;
  126100. private _isDirectional;
  126101. private _readyToPlayCallback;
  126102. private _audioBuffer;
  126103. private _soundSource;
  126104. private _streamingSource;
  126105. private _soundPanner;
  126106. private _soundGain;
  126107. private _inputAudioNode;
  126108. private _outputAudioNode;
  126109. private _coneInnerAngle;
  126110. private _coneOuterAngle;
  126111. private _coneOuterGain;
  126112. private _scene;
  126113. private _connectedTransformNode;
  126114. private _customAttenuationFunction;
  126115. private _registerFunc;
  126116. private _isOutputConnected;
  126117. private _htmlAudioElement;
  126118. private _urlType;
  126119. private _length?;
  126120. private _offset?;
  126121. /** @hidden */
  126122. static _SceneComponentInitialization: (scene: Scene) => void;
  126123. /**
  126124. * Create a sound and attach it to a scene
  126125. * @param name Name of your sound
  126126. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  126127. * @param scene defines the scene the sound belongs to
  126128. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  126129. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  126130. */
  126131. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  126132. /**
  126133. * Release the sound and its associated resources
  126134. */
  126135. dispose(): void;
  126136. /**
  126137. * Gets if the sounds is ready to be played or not.
  126138. * @returns true if ready, otherwise false
  126139. */
  126140. isReady(): boolean;
  126141. private _soundLoaded;
  126142. /**
  126143. * Sets the data of the sound from an audiobuffer
  126144. * @param audioBuffer The audioBuffer containing the data
  126145. */
  126146. setAudioBuffer(audioBuffer: AudioBuffer): void;
  126147. /**
  126148. * Updates the current sounds options such as maxdistance, loop...
  126149. * @param options A JSON object containing values named as the object properties
  126150. */
  126151. updateOptions(options: ISoundOptions): void;
  126152. private _createSpatialParameters;
  126153. private _updateSpatialParameters;
  126154. /**
  126155. * Switch the panning model to HRTF:
  126156. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  126157. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126158. */
  126159. switchPanningModelToHRTF(): void;
  126160. /**
  126161. * Switch the panning model to Equal Power:
  126162. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  126163. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126164. */
  126165. switchPanningModelToEqualPower(): void;
  126166. private _switchPanningModel;
  126167. /**
  126168. * Connect this sound to a sound track audio node like gain...
  126169. * @param soundTrackAudioNode the sound track audio node to connect to
  126170. */
  126171. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  126172. /**
  126173. * Transform this sound into a directional source
  126174. * @param coneInnerAngle Size of the inner cone in degree
  126175. * @param coneOuterAngle Size of the outer cone in degree
  126176. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  126177. */
  126178. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  126179. /**
  126180. * Gets or sets the inner angle for the directional cone.
  126181. */
  126182. get directionalConeInnerAngle(): number;
  126183. /**
  126184. * Gets or sets the inner angle for the directional cone.
  126185. */
  126186. set directionalConeInnerAngle(value: number);
  126187. /**
  126188. * Gets or sets the outer angle for the directional cone.
  126189. */
  126190. get directionalConeOuterAngle(): number;
  126191. /**
  126192. * Gets or sets the outer angle for the directional cone.
  126193. */
  126194. set directionalConeOuterAngle(value: number);
  126195. /**
  126196. * Sets the position of the emitter if spatial sound is enabled
  126197. * @param newPosition Defines the new posisiton
  126198. */
  126199. setPosition(newPosition: Vector3): void;
  126200. /**
  126201. * Sets the local direction of the emitter if spatial sound is enabled
  126202. * @param newLocalDirection Defines the new local direction
  126203. */
  126204. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  126205. private _updateDirection;
  126206. /** @hidden */
  126207. updateDistanceFromListener(): void;
  126208. /**
  126209. * Sets a new custom attenuation function for the sound.
  126210. * @param callback Defines the function used for the attenuation
  126211. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  126212. */
  126213. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  126214. /**
  126215. * Play the sound
  126216. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  126217. * @param offset (optional) Start the sound at a specific time in seconds
  126218. * @param length (optional) Sound duration (in seconds)
  126219. */
  126220. play(time?: number, offset?: number, length?: number): void;
  126221. private _onended;
  126222. /**
  126223. * Stop the sound
  126224. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  126225. */
  126226. stop(time?: number): void;
  126227. /**
  126228. * Put the sound in pause
  126229. */
  126230. pause(): void;
  126231. /**
  126232. * Sets a dedicated volume for this sounds
  126233. * @param newVolume Define the new volume of the sound
  126234. * @param time Define time for gradual change to new volume
  126235. */
  126236. setVolume(newVolume: number, time?: number): void;
  126237. /**
  126238. * Set the sound play back rate
  126239. * @param newPlaybackRate Define the playback rate the sound should be played at
  126240. */
  126241. setPlaybackRate(newPlaybackRate: number): void;
  126242. /**
  126243. * Gets the volume of the sound.
  126244. * @returns the volume of the sound
  126245. */
  126246. getVolume(): number;
  126247. /**
  126248. * Attach the sound to a dedicated mesh
  126249. * @param transformNode The transform node to connect the sound with
  126250. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126251. */
  126252. attachToMesh(transformNode: TransformNode): void;
  126253. /**
  126254. * Detach the sound from the previously attached mesh
  126255. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  126256. */
  126257. detachFromMesh(): void;
  126258. private _onRegisterAfterWorldMatrixUpdate;
  126259. /**
  126260. * Clone the current sound in the scene.
  126261. * @returns the new sound clone
  126262. */
  126263. clone(): Nullable<Sound>;
  126264. /**
  126265. * Gets the current underlying audio buffer containing the data
  126266. * @returns the audio buffer
  126267. */
  126268. getAudioBuffer(): Nullable<AudioBuffer>;
  126269. /**
  126270. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  126271. * @returns the source node
  126272. */
  126273. getSoundSource(): Nullable<AudioBufferSourceNode>;
  126274. /**
  126275. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  126276. * @returns the gain node
  126277. */
  126278. getSoundGain(): Nullable<GainNode>;
  126279. /**
  126280. * Serializes the Sound in a JSON representation
  126281. * @returns the JSON representation of the sound
  126282. */
  126283. serialize(): any;
  126284. /**
  126285. * Parse a JSON representation of a sound to innstantiate in a given scene
  126286. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  126287. * @param scene Define the scene the new parsed sound should be created in
  126288. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  126289. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  126290. * @returns the newly parsed sound
  126291. */
  126292. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  126293. }
  126294. }
  126295. declare module BABYLON {
  126296. /**
  126297. * This defines an action helpful to play a defined sound on a triggered action.
  126298. */
  126299. export class PlaySoundAction extends Action {
  126300. private _sound;
  126301. /**
  126302. * Instantiate the action
  126303. * @param triggerOptions defines the trigger options
  126304. * @param sound defines the sound to play
  126305. * @param condition defines the trigger related conditions
  126306. */
  126307. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  126308. /** @hidden */
  126309. _prepare(): void;
  126310. /**
  126311. * Execute the action and play the sound.
  126312. */
  126313. execute(): void;
  126314. /**
  126315. * Serializes the actions and its related information.
  126316. * @param parent defines the object to serialize in
  126317. * @returns the serialized object
  126318. */
  126319. serialize(parent: any): any;
  126320. }
  126321. /**
  126322. * This defines an action helpful to stop a defined sound on a triggered action.
  126323. */
  126324. export class StopSoundAction extends Action {
  126325. private _sound;
  126326. /**
  126327. * Instantiate the action
  126328. * @param triggerOptions defines the trigger options
  126329. * @param sound defines the sound to stop
  126330. * @param condition defines the trigger related conditions
  126331. */
  126332. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  126333. /** @hidden */
  126334. _prepare(): void;
  126335. /**
  126336. * Execute the action and stop the sound.
  126337. */
  126338. execute(): void;
  126339. /**
  126340. * Serializes the actions and its related information.
  126341. * @param parent defines the object to serialize in
  126342. * @returns the serialized object
  126343. */
  126344. serialize(parent: any): any;
  126345. }
  126346. }
  126347. declare module BABYLON {
  126348. /**
  126349. * This defines an action responsible to change the value of a property
  126350. * by interpolating between its current value and the newly set one once triggered.
  126351. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  126352. */
  126353. export class InterpolateValueAction extends Action {
  126354. /**
  126355. * Defines the path of the property where the value should be interpolated
  126356. */
  126357. propertyPath: string;
  126358. /**
  126359. * Defines the target value at the end of the interpolation.
  126360. */
  126361. value: any;
  126362. /**
  126363. * Defines the time it will take for the property to interpolate to the value.
  126364. */
  126365. duration: number;
  126366. /**
  126367. * Defines if the other scene animations should be stopped when the action has been triggered
  126368. */
  126369. stopOtherAnimations?: boolean;
  126370. /**
  126371. * Defines a callback raised once the interpolation animation has been done.
  126372. */
  126373. onInterpolationDone?: () => void;
  126374. /**
  126375. * Observable triggered once the interpolation animation has been done.
  126376. */
  126377. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  126378. private _target;
  126379. private _effectiveTarget;
  126380. private _property;
  126381. /**
  126382. * Instantiate the action
  126383. * @param triggerOptions defines the trigger options
  126384. * @param target defines the object containing the value to interpolate
  126385. * @param propertyPath defines the path to the property in the target object
  126386. * @param value defines the target value at the end of the interpolation
  126387. * @param duration deines the time it will take for the property to interpolate to the value.
  126388. * @param condition defines the trigger related conditions
  126389. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  126390. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  126391. */
  126392. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  126393. /** @hidden */
  126394. _prepare(): void;
  126395. /**
  126396. * Execute the action starts the value interpolation.
  126397. */
  126398. execute(): void;
  126399. /**
  126400. * Serializes the actions and its related information.
  126401. * @param parent defines the object to serialize in
  126402. * @returns the serialized object
  126403. */
  126404. serialize(parent: any): any;
  126405. }
  126406. }
  126407. declare module BABYLON {
  126408. /**
  126409. * Options allowed during the creation of a sound track.
  126410. */
  126411. export interface ISoundTrackOptions {
  126412. /**
  126413. * The volume the sound track should take during creation
  126414. */
  126415. volume?: number;
  126416. /**
  126417. * Define if the sound track is the main sound track of the scene
  126418. */
  126419. mainTrack?: boolean;
  126420. }
  126421. /**
  126422. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  126423. * It will be also used in a future release to apply effects on a specific track.
  126424. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  126425. */
  126426. export class SoundTrack {
  126427. /**
  126428. * The unique identifier of the sound track in the scene.
  126429. */
  126430. id: number;
  126431. /**
  126432. * The list of sounds included in the sound track.
  126433. */
  126434. soundCollection: Array<Sound>;
  126435. private _outputAudioNode;
  126436. private _scene;
  126437. private _connectedAnalyser;
  126438. private _options;
  126439. private _isInitialized;
  126440. /**
  126441. * Creates a new sound track.
  126442. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  126443. * @param scene Define the scene the sound track belongs to
  126444. * @param options
  126445. */
  126446. constructor(scene: Scene, options?: ISoundTrackOptions);
  126447. private _initializeSoundTrackAudioGraph;
  126448. /**
  126449. * Release the sound track and its associated resources
  126450. */
  126451. dispose(): void;
  126452. /**
  126453. * Adds a sound to this sound track
  126454. * @param sound define the cound to add
  126455. * @ignoreNaming
  126456. */
  126457. AddSound(sound: Sound): void;
  126458. /**
  126459. * Removes a sound to this sound track
  126460. * @param sound define the cound to remove
  126461. * @ignoreNaming
  126462. */
  126463. RemoveSound(sound: Sound): void;
  126464. /**
  126465. * Set a global volume for the full sound track.
  126466. * @param newVolume Define the new volume of the sound track
  126467. */
  126468. setVolume(newVolume: number): void;
  126469. /**
  126470. * Switch the panning model to HRTF:
  126471. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  126472. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126473. */
  126474. switchPanningModelToHRTF(): void;
  126475. /**
  126476. * Switch the panning model to Equal Power:
  126477. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  126478. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  126479. */
  126480. switchPanningModelToEqualPower(): void;
  126481. /**
  126482. * Connect the sound track to an audio analyser allowing some amazing
  126483. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  126484. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  126485. * @param analyser The analyser to connect to the engine
  126486. */
  126487. connectToAnalyser(analyser: Analyser): void;
  126488. }
  126489. }
  126490. declare module BABYLON {
  126491. interface AbstractScene {
  126492. /**
  126493. * The list of sounds used in the scene.
  126494. */
  126495. sounds: Nullable<Array<Sound>>;
  126496. }
  126497. interface Scene {
  126498. /**
  126499. * @hidden
  126500. * Backing field
  126501. */
  126502. _mainSoundTrack: SoundTrack;
  126503. /**
  126504. * The main sound track played by the scene.
  126505. * It cotains your primary collection of sounds.
  126506. */
  126507. mainSoundTrack: SoundTrack;
  126508. /**
  126509. * The list of sound tracks added to the scene
  126510. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126511. */
  126512. soundTracks: Nullable<Array<SoundTrack>>;
  126513. /**
  126514. * Gets a sound using a given name
  126515. * @param name defines the name to search for
  126516. * @return the found sound or null if not found at all.
  126517. */
  126518. getSoundByName(name: string): Nullable<Sound>;
  126519. /**
  126520. * Gets or sets if audio support is enabled
  126521. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126522. */
  126523. audioEnabled: boolean;
  126524. /**
  126525. * Gets or sets if audio will be output to headphones
  126526. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126527. */
  126528. headphone: boolean;
  126529. /**
  126530. * Gets or sets custom audio listener position provider
  126531. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  126532. */
  126533. audioListenerPositionProvider: Nullable<() => Vector3>;
  126534. /**
  126535. * Gets or sets a refresh rate when using 3D audio positioning
  126536. */
  126537. audioPositioningRefreshRate: number;
  126538. }
  126539. /**
  126540. * Defines the sound scene component responsible to manage any sounds
  126541. * in a given scene.
  126542. */
  126543. export class AudioSceneComponent implements ISceneSerializableComponent {
  126544. private static _CameraDirectionLH;
  126545. private static _CameraDirectionRH;
  126546. /**
  126547. * The component name helpfull to identify the component in the list of scene components.
  126548. */
  126549. readonly name: string;
  126550. /**
  126551. * The scene the component belongs to.
  126552. */
  126553. scene: Scene;
  126554. private _audioEnabled;
  126555. /**
  126556. * Gets whether audio is enabled or not.
  126557. * Please use related enable/disable method to switch state.
  126558. */
  126559. get audioEnabled(): boolean;
  126560. private _headphone;
  126561. /**
  126562. * Gets whether audio is outputing to headphone or not.
  126563. * Please use the according Switch methods to change output.
  126564. */
  126565. get headphone(): boolean;
  126566. /**
  126567. * Gets or sets a refresh rate when using 3D audio positioning
  126568. */
  126569. audioPositioningRefreshRate: number;
  126570. private _audioListenerPositionProvider;
  126571. /**
  126572. * Gets the current audio listener position provider
  126573. */
  126574. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  126575. /**
  126576. * Sets a custom listener position for all sounds in the scene
  126577. * By default, this is the position of the first active camera
  126578. */
  126579. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  126580. /**
  126581. * Creates a new instance of the component for the given scene
  126582. * @param scene Defines the scene to register the component in
  126583. */
  126584. constructor(scene: Scene);
  126585. /**
  126586. * Registers the component in a given scene
  126587. */
  126588. register(): void;
  126589. /**
  126590. * Rebuilds the elements related to this component in case of
  126591. * context lost for instance.
  126592. */
  126593. rebuild(): void;
  126594. /**
  126595. * Serializes the component data to the specified json object
  126596. * @param serializationObject The object to serialize to
  126597. */
  126598. serialize(serializationObject: any): void;
  126599. /**
  126600. * Adds all the elements from the container to the scene
  126601. * @param container the container holding the elements
  126602. */
  126603. addFromContainer(container: AbstractScene): void;
  126604. /**
  126605. * Removes all the elements in the container from the scene
  126606. * @param container contains the elements to remove
  126607. * @param dispose if the removed element should be disposed (default: false)
  126608. */
  126609. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126610. /**
  126611. * Disposes the component and the associated ressources.
  126612. */
  126613. dispose(): void;
  126614. /**
  126615. * Disables audio in the associated scene.
  126616. */
  126617. disableAudio(): void;
  126618. /**
  126619. * Enables audio in the associated scene.
  126620. */
  126621. enableAudio(): void;
  126622. /**
  126623. * Switch audio to headphone output.
  126624. */
  126625. switchAudioModeForHeadphones(): void;
  126626. /**
  126627. * Switch audio to normal speakers.
  126628. */
  126629. switchAudioModeForNormalSpeakers(): void;
  126630. private _cachedCameraDirection;
  126631. private _cachedCameraPosition;
  126632. private _lastCheck;
  126633. private _afterRender;
  126634. }
  126635. }
  126636. declare module BABYLON {
  126637. /**
  126638. * Wraps one or more Sound objects and selects one with random weight for playback.
  126639. */
  126640. export class WeightedSound {
  126641. /** When true a Sound will be selected and played when the current playing Sound completes. */
  126642. loop: boolean;
  126643. private _coneInnerAngle;
  126644. private _coneOuterAngle;
  126645. private _volume;
  126646. /** A Sound is currently playing. */
  126647. isPlaying: boolean;
  126648. /** A Sound is currently paused. */
  126649. isPaused: boolean;
  126650. private _sounds;
  126651. private _weights;
  126652. private _currentIndex?;
  126653. /**
  126654. * Creates a new WeightedSound from the list of sounds given.
  126655. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  126656. * @param sounds Array of Sounds that will be selected from.
  126657. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  126658. */
  126659. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  126660. /**
  126661. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  126662. */
  126663. get directionalConeInnerAngle(): number;
  126664. /**
  126665. * The size of cone in degress for a directional sound in which there will be no attenuation.
  126666. */
  126667. set directionalConeInnerAngle(value: number);
  126668. /**
  126669. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126670. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126671. */
  126672. get directionalConeOuterAngle(): number;
  126673. /**
  126674. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  126675. * Listener angles between innerAngle and outerAngle will falloff linearly.
  126676. */
  126677. set directionalConeOuterAngle(value: number);
  126678. /**
  126679. * Playback volume.
  126680. */
  126681. get volume(): number;
  126682. /**
  126683. * Playback volume.
  126684. */
  126685. set volume(value: number);
  126686. private _onended;
  126687. /**
  126688. * Suspend playback
  126689. */
  126690. pause(): void;
  126691. /**
  126692. * Stop playback
  126693. */
  126694. stop(): void;
  126695. /**
  126696. * Start playback.
  126697. * @param startOffset Position the clip head at a specific time in seconds.
  126698. */
  126699. play(startOffset?: number): void;
  126700. }
  126701. }
  126702. declare module BABYLON {
  126703. /**
  126704. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  126705. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  126706. */
  126707. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  126708. /**
  126709. * Gets the name of the behavior.
  126710. */
  126711. get name(): string;
  126712. /**
  126713. * The easing function used by animations
  126714. */
  126715. static EasingFunction: BackEase;
  126716. /**
  126717. * The easing mode used by animations
  126718. */
  126719. static EasingMode: number;
  126720. /**
  126721. * The duration of the animation, in milliseconds
  126722. */
  126723. transitionDuration: number;
  126724. /**
  126725. * Length of the distance animated by the transition when lower radius is reached
  126726. */
  126727. lowerRadiusTransitionRange: number;
  126728. /**
  126729. * Length of the distance animated by the transition when upper radius is reached
  126730. */
  126731. upperRadiusTransitionRange: number;
  126732. private _autoTransitionRange;
  126733. /**
  126734. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126735. */
  126736. get autoTransitionRange(): boolean;
  126737. /**
  126738. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  126739. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  126740. */
  126741. set autoTransitionRange(value: boolean);
  126742. private _attachedCamera;
  126743. private _onAfterCheckInputsObserver;
  126744. private _onMeshTargetChangedObserver;
  126745. /**
  126746. * Initializes the behavior.
  126747. */
  126748. init(): void;
  126749. /**
  126750. * Attaches the behavior to its arc rotate camera.
  126751. * @param camera Defines the camera to attach the behavior to
  126752. */
  126753. attach(camera: ArcRotateCamera): void;
  126754. /**
  126755. * Detaches the behavior from its current arc rotate camera.
  126756. */
  126757. detach(): void;
  126758. private _radiusIsAnimating;
  126759. private _radiusBounceTransition;
  126760. private _animatables;
  126761. private _cachedWheelPrecision;
  126762. /**
  126763. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  126764. * @param radiusLimit The limit to check against.
  126765. * @return Bool to indicate if at limit.
  126766. */
  126767. private _isRadiusAtLimit;
  126768. /**
  126769. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  126770. * @param radiusDelta The delta by which to animate to. Can be negative.
  126771. */
  126772. private _applyBoundRadiusAnimation;
  126773. /**
  126774. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  126775. */
  126776. protected _clearAnimationLocks(): void;
  126777. /**
  126778. * Stops and removes all animations that have been applied to the camera
  126779. */
  126780. stopAllAnimations(): void;
  126781. }
  126782. }
  126783. declare module BABYLON {
  126784. /**
  126785. * 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.
  126786. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  126787. */
  126788. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  126789. /**
  126790. * Gets the name of the behavior.
  126791. */
  126792. get name(): string;
  126793. private _mode;
  126794. private _radiusScale;
  126795. private _positionScale;
  126796. private _defaultElevation;
  126797. private _elevationReturnTime;
  126798. private _elevationReturnWaitTime;
  126799. private _zoomStopsAnimation;
  126800. private _framingTime;
  126801. /**
  126802. * The easing function used by animations
  126803. */
  126804. static EasingFunction: ExponentialEase;
  126805. /**
  126806. * The easing mode used by animations
  126807. */
  126808. static EasingMode: number;
  126809. /**
  126810. * Sets the current mode used by the behavior
  126811. */
  126812. set mode(mode: number);
  126813. /**
  126814. * Gets current mode used by the behavior.
  126815. */
  126816. get mode(): number;
  126817. /**
  126818. * Sets the scale applied to the radius (1 by default)
  126819. */
  126820. set radiusScale(radius: number);
  126821. /**
  126822. * Gets the scale applied to the radius
  126823. */
  126824. get radiusScale(): number;
  126825. /**
  126826. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126827. */
  126828. set positionScale(scale: number);
  126829. /**
  126830. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  126831. */
  126832. get positionScale(): number;
  126833. /**
  126834. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126835. * behaviour is triggered, in radians.
  126836. */
  126837. set defaultElevation(elevation: number);
  126838. /**
  126839. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  126840. * behaviour is triggered, in radians.
  126841. */
  126842. get defaultElevation(): number;
  126843. /**
  126844. * Sets the time (in milliseconds) taken to return to the default beta position.
  126845. * Negative value indicates camera should not return to default.
  126846. */
  126847. set elevationReturnTime(speed: number);
  126848. /**
  126849. * Gets the time (in milliseconds) taken to return to the default beta position.
  126850. * Negative value indicates camera should not return to default.
  126851. */
  126852. get elevationReturnTime(): number;
  126853. /**
  126854. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126855. */
  126856. set elevationReturnWaitTime(time: number);
  126857. /**
  126858. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  126859. */
  126860. get elevationReturnWaitTime(): number;
  126861. /**
  126862. * Sets the flag that indicates if user zooming should stop animation.
  126863. */
  126864. set zoomStopsAnimation(flag: boolean);
  126865. /**
  126866. * Gets the flag that indicates if user zooming should stop animation.
  126867. */
  126868. get zoomStopsAnimation(): boolean;
  126869. /**
  126870. * Sets the transition time when framing the mesh, in milliseconds
  126871. */
  126872. set framingTime(time: number);
  126873. /**
  126874. * Gets the transition time when framing the mesh, in milliseconds
  126875. */
  126876. get framingTime(): number;
  126877. /**
  126878. * Define if the behavior should automatically change the configured
  126879. * camera limits and sensibilities.
  126880. */
  126881. autoCorrectCameraLimitsAndSensibility: boolean;
  126882. private _onPrePointerObservableObserver;
  126883. private _onAfterCheckInputsObserver;
  126884. private _onMeshTargetChangedObserver;
  126885. private _attachedCamera;
  126886. private _isPointerDown;
  126887. private _lastInteractionTime;
  126888. /**
  126889. * Initializes the behavior.
  126890. */
  126891. init(): void;
  126892. /**
  126893. * Attaches the behavior to its arc rotate camera.
  126894. * @param camera Defines the camera to attach the behavior to
  126895. */
  126896. attach(camera: ArcRotateCamera): void;
  126897. /**
  126898. * Detaches the behavior from its current arc rotate camera.
  126899. */
  126900. detach(): void;
  126901. private _animatables;
  126902. private _betaIsAnimating;
  126903. private _betaTransition;
  126904. private _radiusTransition;
  126905. private _vectorTransition;
  126906. /**
  126907. * Targets the given mesh and updates zoom level accordingly.
  126908. * @param mesh The mesh to target.
  126909. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126910. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126911. */
  126912. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126913. /**
  126914. * Targets the given mesh with its children and updates zoom level accordingly.
  126915. * @param mesh The mesh to target.
  126916. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126917. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126918. */
  126919. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126920. /**
  126921. * Targets the given meshes with their children and updates zoom level accordingly.
  126922. * @param meshes The mesh to target.
  126923. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126924. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126925. */
  126926. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126927. /**
  126928. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  126929. * @param minimumWorld Determines the smaller position of the bounding box extend
  126930. * @param maximumWorld Determines the bigger position of the bounding box extend
  126931. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  126932. * @param onAnimationEnd Callback triggered at the end of the framing animation
  126933. */
  126934. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  126935. /**
  126936. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  126937. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  126938. * frustum width.
  126939. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  126940. * to fully enclose the mesh in the viewing frustum.
  126941. */
  126942. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  126943. /**
  126944. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  126945. * is automatically returned to its default position (expected to be above ground plane).
  126946. */
  126947. private _maintainCameraAboveGround;
  126948. /**
  126949. * Returns the frustum slope based on the canvas ratio and camera FOV
  126950. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  126951. */
  126952. private _getFrustumSlope;
  126953. /**
  126954. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  126955. */
  126956. private _clearAnimationLocks;
  126957. /**
  126958. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  126959. */
  126960. private _applyUserInteraction;
  126961. /**
  126962. * Stops and removes all animations that have been applied to the camera
  126963. */
  126964. stopAllAnimations(): void;
  126965. /**
  126966. * Gets a value indicating if the user is moving the camera
  126967. */
  126968. get isUserIsMoving(): boolean;
  126969. /**
  126970. * The camera can move all the way towards the mesh.
  126971. */
  126972. static IgnoreBoundsSizeMode: number;
  126973. /**
  126974. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  126975. */
  126976. static FitFrustumSidesMode: number;
  126977. }
  126978. }
  126979. declare module BABYLON {
  126980. /**
  126981. * Base class for Camera Pointer Inputs.
  126982. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  126983. * for example usage.
  126984. */
  126985. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  126986. /**
  126987. * Defines the camera the input is attached to.
  126988. */
  126989. abstract camera: Camera;
  126990. /**
  126991. * Whether keyboard modifier keys are pressed at time of last mouse event.
  126992. */
  126993. protected _altKey: boolean;
  126994. protected _ctrlKey: boolean;
  126995. protected _metaKey: boolean;
  126996. protected _shiftKey: boolean;
  126997. /**
  126998. * Which mouse buttons were pressed at time of last mouse event.
  126999. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  127000. */
  127001. protected _buttonsPressed: number;
  127002. /**
  127003. * Defines the buttons associated with the input to handle camera move.
  127004. */
  127005. buttons: number[];
  127006. /**
  127007. * Attach the input controls to a specific dom element to get the input from.
  127008. * @param element Defines the element the controls should be listened from
  127009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127010. */
  127011. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127012. /**
  127013. * Detach the current controls from the specified dom element.
  127014. * @param element Defines the element to stop listening the inputs from
  127015. */
  127016. detachControl(element: Nullable<HTMLElement>): void;
  127017. /**
  127018. * Gets the class name of the current input.
  127019. * @returns the class name
  127020. */
  127021. getClassName(): string;
  127022. /**
  127023. * Get the friendly name associated with the input class.
  127024. * @returns the input friendly name
  127025. */
  127026. getSimpleName(): string;
  127027. /**
  127028. * Called on pointer POINTERDOUBLETAP event.
  127029. * Override this method to provide functionality on POINTERDOUBLETAP event.
  127030. */
  127031. protected onDoubleTap(type: string): void;
  127032. /**
  127033. * Called on pointer POINTERMOVE event if only a single touch is active.
  127034. * Override this method to provide functionality.
  127035. */
  127036. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127037. /**
  127038. * Called on pointer POINTERMOVE event if multiple touches are active.
  127039. * Override this method to provide functionality.
  127040. */
  127041. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127042. /**
  127043. * Called on JS contextmenu event.
  127044. * Override this method to provide functionality.
  127045. */
  127046. protected onContextMenu(evt: PointerEvent): void;
  127047. /**
  127048. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127049. * press.
  127050. * Override this method to provide functionality.
  127051. */
  127052. protected onButtonDown(evt: PointerEvent): void;
  127053. /**
  127054. * Called each time a new POINTERUP event occurs. Ie, for each button
  127055. * release.
  127056. * Override this method to provide functionality.
  127057. */
  127058. protected onButtonUp(evt: PointerEvent): void;
  127059. /**
  127060. * Called when window becomes inactive.
  127061. * Override this method to provide functionality.
  127062. */
  127063. protected onLostFocus(): void;
  127064. private _pointerInput;
  127065. private _observer;
  127066. private _onLostFocus;
  127067. private pointA;
  127068. private pointB;
  127069. }
  127070. }
  127071. declare module BABYLON {
  127072. /**
  127073. * Manage the pointers inputs to control an arc rotate camera.
  127074. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127075. */
  127076. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  127077. /**
  127078. * Defines the camera the input is attached to.
  127079. */
  127080. camera: ArcRotateCamera;
  127081. /**
  127082. * Gets the class name of the current input.
  127083. * @returns the class name
  127084. */
  127085. getClassName(): string;
  127086. /**
  127087. * Defines the buttons associated with the input to handle camera move.
  127088. */
  127089. buttons: number[];
  127090. /**
  127091. * Defines the pointer angular sensibility along the X axis or how fast is
  127092. * the camera rotating.
  127093. */
  127094. angularSensibilityX: number;
  127095. /**
  127096. * Defines the pointer angular sensibility along the Y axis or how fast is
  127097. * the camera rotating.
  127098. */
  127099. angularSensibilityY: number;
  127100. /**
  127101. * Defines the pointer pinch precision or how fast is the camera zooming.
  127102. */
  127103. pinchPrecision: number;
  127104. /**
  127105. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  127106. * from 0.
  127107. * It defines the percentage of current camera.radius to use as delta when
  127108. * pinch zoom is used.
  127109. */
  127110. pinchDeltaPercentage: number;
  127111. /**
  127112. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  127113. * that any object in the plane at the camera's target point will scale
  127114. * perfectly with finger motion.
  127115. * Overrides pinchDeltaPercentage and pinchPrecision.
  127116. */
  127117. useNaturalPinchZoom: boolean;
  127118. /**
  127119. * Defines the pointer panning sensibility or how fast is the camera moving.
  127120. */
  127121. panningSensibility: number;
  127122. /**
  127123. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  127124. */
  127125. multiTouchPanning: boolean;
  127126. /**
  127127. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  127128. * zoom (pinch) through multitouch.
  127129. */
  127130. multiTouchPanAndZoom: boolean;
  127131. /**
  127132. * Revers pinch action direction.
  127133. */
  127134. pinchInwards: boolean;
  127135. private _isPanClick;
  127136. private _twoFingerActivityCount;
  127137. private _isPinching;
  127138. /**
  127139. * Called on pointer POINTERMOVE event if only a single touch is active.
  127140. */
  127141. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  127142. /**
  127143. * Called on pointer POINTERDOUBLETAP event.
  127144. */
  127145. protected onDoubleTap(type: string): void;
  127146. /**
  127147. * Called on pointer POINTERMOVE event if multiple touches are active.
  127148. */
  127149. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  127150. /**
  127151. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  127152. * press.
  127153. */
  127154. protected onButtonDown(evt: PointerEvent): void;
  127155. /**
  127156. * Called each time a new POINTERUP event occurs. Ie, for each button
  127157. * release.
  127158. */
  127159. protected onButtonUp(evt: PointerEvent): void;
  127160. /**
  127161. * Called when window becomes inactive.
  127162. */
  127163. protected onLostFocus(): void;
  127164. }
  127165. }
  127166. declare module BABYLON {
  127167. /**
  127168. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  127169. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127170. */
  127171. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  127172. /**
  127173. * Defines the camera the input is attached to.
  127174. */
  127175. camera: ArcRotateCamera;
  127176. /**
  127177. * Defines the list of key codes associated with the up action (increase alpha)
  127178. */
  127179. keysUp: number[];
  127180. /**
  127181. * Defines the list of key codes associated with the down action (decrease alpha)
  127182. */
  127183. keysDown: number[];
  127184. /**
  127185. * Defines the list of key codes associated with the left action (increase beta)
  127186. */
  127187. keysLeft: number[];
  127188. /**
  127189. * Defines the list of key codes associated with the right action (decrease beta)
  127190. */
  127191. keysRight: number[];
  127192. /**
  127193. * Defines the list of key codes associated with the reset action.
  127194. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  127195. */
  127196. keysReset: number[];
  127197. /**
  127198. * Defines the panning sensibility of the inputs.
  127199. * (How fast is the camera panning)
  127200. */
  127201. panningSensibility: number;
  127202. /**
  127203. * Defines the zooming sensibility of the inputs.
  127204. * (How fast is the camera zooming)
  127205. */
  127206. zoomingSensibility: number;
  127207. /**
  127208. * Defines whether maintaining the alt key down switch the movement mode from
  127209. * orientation to zoom.
  127210. */
  127211. useAltToZoom: boolean;
  127212. /**
  127213. * Rotation speed of the camera
  127214. */
  127215. angularSpeed: number;
  127216. private _keys;
  127217. private _ctrlPressed;
  127218. private _altPressed;
  127219. private _onCanvasBlurObserver;
  127220. private _onKeyboardObserver;
  127221. private _engine;
  127222. private _scene;
  127223. /**
  127224. * Attach the input controls to a specific dom element to get the input from.
  127225. * @param element Defines the element the controls should be listened from
  127226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127227. */
  127228. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127229. /**
  127230. * Detach the current controls from the specified dom element.
  127231. * @param element Defines the element to stop listening the inputs from
  127232. */
  127233. detachControl(element: Nullable<HTMLElement>): void;
  127234. /**
  127235. * Update the current camera state depending on the inputs that have been used this frame.
  127236. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  127237. */
  127238. checkInputs(): void;
  127239. /**
  127240. * Gets the class name of the current intput.
  127241. * @returns the class name
  127242. */
  127243. getClassName(): string;
  127244. /**
  127245. * Get the friendly name associated with the input class.
  127246. * @returns the input friendly name
  127247. */
  127248. getSimpleName(): string;
  127249. }
  127250. }
  127251. declare module BABYLON {
  127252. /**
  127253. * Manage the mouse wheel inputs to control an arc rotate camera.
  127254. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127255. */
  127256. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  127257. /**
  127258. * Defines the camera the input is attached to.
  127259. */
  127260. camera: ArcRotateCamera;
  127261. /**
  127262. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  127263. */
  127264. wheelPrecision: number;
  127265. /**
  127266. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  127267. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  127268. */
  127269. wheelDeltaPercentage: number;
  127270. private _wheel;
  127271. private _observer;
  127272. private computeDeltaFromMouseWheelLegacyEvent;
  127273. /**
  127274. * Attach the input controls to a specific dom element to get the input from.
  127275. * @param element Defines the element the controls should be listened from
  127276. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127277. */
  127278. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  127279. /**
  127280. * Detach the current controls from the specified dom element.
  127281. * @param element Defines the element to stop listening the inputs from
  127282. */
  127283. detachControl(element: Nullable<HTMLElement>): void;
  127284. /**
  127285. * Gets the class name of the current intput.
  127286. * @returns the class name
  127287. */
  127288. getClassName(): string;
  127289. /**
  127290. * Get the friendly name associated with the input class.
  127291. * @returns the input friendly name
  127292. */
  127293. getSimpleName(): string;
  127294. }
  127295. }
  127296. declare module BABYLON {
  127297. /**
  127298. * Default Inputs manager for the ArcRotateCamera.
  127299. * It groups all the default supported inputs for ease of use.
  127300. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  127301. */
  127302. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  127303. /**
  127304. * Instantiates a new ArcRotateCameraInputsManager.
  127305. * @param camera Defines the camera the inputs belong to
  127306. */
  127307. constructor(camera: ArcRotateCamera);
  127308. /**
  127309. * Add mouse wheel input support to the input manager.
  127310. * @returns the current input manager
  127311. */
  127312. addMouseWheel(): ArcRotateCameraInputsManager;
  127313. /**
  127314. * Add pointers input support to the input manager.
  127315. * @returns the current input manager
  127316. */
  127317. addPointers(): ArcRotateCameraInputsManager;
  127318. /**
  127319. * Add keyboard input support to the input manager.
  127320. * @returns the current input manager
  127321. */
  127322. addKeyboard(): ArcRotateCameraInputsManager;
  127323. }
  127324. }
  127325. declare module BABYLON {
  127326. /**
  127327. * This represents an orbital type of camera.
  127328. *
  127329. * 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.
  127330. * 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.
  127331. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  127332. */
  127333. export class ArcRotateCamera extends TargetCamera {
  127334. /**
  127335. * Defines the rotation angle of the camera along the longitudinal axis.
  127336. */
  127337. alpha: number;
  127338. /**
  127339. * Defines the rotation angle of the camera along the latitudinal axis.
  127340. */
  127341. beta: number;
  127342. /**
  127343. * Defines the radius of the camera from it s target point.
  127344. */
  127345. radius: number;
  127346. protected _target: Vector3;
  127347. protected _targetHost: Nullable<AbstractMesh>;
  127348. /**
  127349. * Defines the target point of the camera.
  127350. * The camera looks towards it form the radius distance.
  127351. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  127352. */
  127353. get target(): Vector3;
  127354. set target(value: Vector3);
  127355. /**
  127356. * Define the current local position of the camera in the scene
  127357. */
  127358. get position(): Vector3;
  127359. set position(newPosition: Vector3);
  127360. protected _upToYMatrix: Matrix;
  127361. protected _YToUpMatrix: Matrix;
  127362. /**
  127363. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  127364. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  127365. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  127366. */
  127367. set upVector(vec: Vector3);
  127368. get upVector(): Vector3;
  127369. /**
  127370. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  127371. */
  127372. setMatUp(): void;
  127373. /**
  127374. * Current inertia value on the longitudinal axis.
  127375. * The bigger this number the longer it will take for the camera to stop.
  127376. */
  127377. inertialAlphaOffset: number;
  127378. /**
  127379. * Current inertia value on the latitudinal axis.
  127380. * The bigger this number the longer it will take for the camera to stop.
  127381. */
  127382. inertialBetaOffset: number;
  127383. /**
  127384. * Current inertia value on the radius axis.
  127385. * The bigger this number the longer it will take for the camera to stop.
  127386. */
  127387. inertialRadiusOffset: number;
  127388. /**
  127389. * Minimum allowed angle on the longitudinal axis.
  127390. * This can help limiting how the Camera is able to move in the scene.
  127391. */
  127392. lowerAlphaLimit: Nullable<number>;
  127393. /**
  127394. * Maximum allowed angle on the longitudinal axis.
  127395. * This can help limiting how the Camera is able to move in the scene.
  127396. */
  127397. upperAlphaLimit: Nullable<number>;
  127398. /**
  127399. * Minimum allowed angle on the latitudinal axis.
  127400. * This can help limiting how the Camera is able to move in the scene.
  127401. */
  127402. lowerBetaLimit: number;
  127403. /**
  127404. * Maximum allowed angle on the latitudinal axis.
  127405. * This can help limiting how the Camera is able to move in the scene.
  127406. */
  127407. upperBetaLimit: number;
  127408. /**
  127409. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  127410. * This can help limiting how the Camera is able to move in the scene.
  127411. */
  127412. lowerRadiusLimit: Nullable<number>;
  127413. /**
  127414. * Maximum allowed distance of the camera to the target (The camera can not get further).
  127415. * This can help limiting how the Camera is able to move in the scene.
  127416. */
  127417. upperRadiusLimit: Nullable<number>;
  127418. /**
  127419. * Defines the current inertia value used during panning of the camera along the X axis.
  127420. */
  127421. inertialPanningX: number;
  127422. /**
  127423. * Defines the current inertia value used during panning of the camera along the Y axis.
  127424. */
  127425. inertialPanningY: number;
  127426. /**
  127427. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  127428. * Basically if your fingers moves away from more than this distance you will be considered
  127429. * in pinch mode.
  127430. */
  127431. pinchToPanMaxDistance: number;
  127432. /**
  127433. * Defines the maximum distance the camera can pan.
  127434. * This could help keeping the cammera always in your scene.
  127435. */
  127436. panningDistanceLimit: Nullable<number>;
  127437. /**
  127438. * Defines the target of the camera before paning.
  127439. */
  127440. panningOriginTarget: Vector3;
  127441. /**
  127442. * Defines the value of the inertia used during panning.
  127443. * 0 would mean stop inertia and one would mean no decelleration at all.
  127444. */
  127445. panningInertia: number;
  127446. /**
  127447. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  127448. */
  127449. get angularSensibilityX(): number;
  127450. set angularSensibilityX(value: number);
  127451. /**
  127452. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  127453. */
  127454. get angularSensibilityY(): number;
  127455. set angularSensibilityY(value: number);
  127456. /**
  127457. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  127458. */
  127459. get pinchPrecision(): number;
  127460. set pinchPrecision(value: number);
  127461. /**
  127462. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  127463. * It will be used instead of pinchDeltaPrecision if different from 0.
  127464. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  127465. */
  127466. get pinchDeltaPercentage(): number;
  127467. set pinchDeltaPercentage(value: number);
  127468. /**
  127469. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  127470. * and pinch delta percentage.
  127471. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  127472. * that any object in the plane at the camera's target point will scale
  127473. * perfectly with finger motion.
  127474. */
  127475. get useNaturalPinchZoom(): boolean;
  127476. set useNaturalPinchZoom(value: boolean);
  127477. /**
  127478. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  127479. */
  127480. get panningSensibility(): number;
  127481. set panningSensibility(value: number);
  127482. /**
  127483. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  127484. */
  127485. get keysUp(): number[];
  127486. set keysUp(value: number[]);
  127487. /**
  127488. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  127489. */
  127490. get keysDown(): number[];
  127491. set keysDown(value: number[]);
  127492. /**
  127493. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  127494. */
  127495. get keysLeft(): number[];
  127496. set keysLeft(value: number[]);
  127497. /**
  127498. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  127499. */
  127500. get keysRight(): number[];
  127501. set keysRight(value: number[]);
  127502. /**
  127503. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  127504. */
  127505. get wheelPrecision(): number;
  127506. set wheelPrecision(value: number);
  127507. /**
  127508. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  127509. * It will be used instead of pinchDeltaPrecision if different from 0.
  127510. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  127511. */
  127512. get wheelDeltaPercentage(): number;
  127513. set wheelDeltaPercentage(value: number);
  127514. /**
  127515. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  127516. */
  127517. zoomOnFactor: number;
  127518. /**
  127519. * Defines a screen offset for the camera position.
  127520. */
  127521. targetScreenOffset: Vector2;
  127522. /**
  127523. * Allows the camera to be completely reversed.
  127524. * If false the camera can not arrive upside down.
  127525. */
  127526. allowUpsideDown: boolean;
  127527. /**
  127528. * Define if double tap/click is used to restore the previously saved state of the camera.
  127529. */
  127530. useInputToRestoreState: boolean;
  127531. /** @hidden */
  127532. _viewMatrix: Matrix;
  127533. /** @hidden */
  127534. _useCtrlForPanning: boolean;
  127535. /** @hidden */
  127536. _panningMouseButton: number;
  127537. /**
  127538. * Defines the input associated to the camera.
  127539. */
  127540. inputs: ArcRotateCameraInputsManager;
  127541. /** @hidden */
  127542. _reset: () => void;
  127543. /**
  127544. * Defines the allowed panning axis.
  127545. */
  127546. panningAxis: Vector3;
  127547. protected _localDirection: Vector3;
  127548. protected _transformedDirection: Vector3;
  127549. private _bouncingBehavior;
  127550. /**
  127551. * Gets the bouncing behavior of the camera if it has been enabled.
  127552. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  127553. */
  127554. get bouncingBehavior(): Nullable<BouncingBehavior>;
  127555. /**
  127556. * Defines if the bouncing behavior of the camera is enabled on the camera.
  127557. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  127558. */
  127559. get useBouncingBehavior(): boolean;
  127560. set useBouncingBehavior(value: boolean);
  127561. private _framingBehavior;
  127562. /**
  127563. * Gets the framing behavior of the camera if it has been enabled.
  127564. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  127565. */
  127566. get framingBehavior(): Nullable<FramingBehavior>;
  127567. /**
  127568. * Defines if the framing behavior of the camera is enabled on the camera.
  127569. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  127570. */
  127571. get useFramingBehavior(): boolean;
  127572. set useFramingBehavior(value: boolean);
  127573. private _autoRotationBehavior;
  127574. /**
  127575. * Gets the auto rotation behavior of the camera if it has been enabled.
  127576. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127577. */
  127578. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  127579. /**
  127580. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  127581. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127582. */
  127583. get useAutoRotationBehavior(): boolean;
  127584. set useAutoRotationBehavior(value: boolean);
  127585. /**
  127586. * Observable triggered when the mesh target has been changed on the camera.
  127587. */
  127588. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  127589. /**
  127590. * Event raised when the camera is colliding with a mesh.
  127591. */
  127592. onCollide: (collidedMesh: AbstractMesh) => void;
  127593. /**
  127594. * Defines whether the camera should check collision with the objects oh the scene.
  127595. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  127596. */
  127597. checkCollisions: boolean;
  127598. /**
  127599. * Defines the collision radius of the camera.
  127600. * This simulates a sphere around the camera.
  127601. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  127602. */
  127603. collisionRadius: Vector3;
  127604. protected _collider: Collider;
  127605. protected _previousPosition: Vector3;
  127606. protected _collisionVelocity: Vector3;
  127607. protected _newPosition: Vector3;
  127608. protected _previousAlpha: number;
  127609. protected _previousBeta: number;
  127610. protected _previousRadius: number;
  127611. protected _collisionTriggered: boolean;
  127612. protected _targetBoundingCenter: Nullable<Vector3>;
  127613. private _computationVector;
  127614. /**
  127615. * Instantiates a new ArcRotateCamera in a given scene
  127616. * @param name Defines the name of the camera
  127617. * @param alpha Defines the camera rotation along the logitudinal axis
  127618. * @param beta Defines the camera rotation along the latitudinal axis
  127619. * @param radius Defines the camera distance from its target
  127620. * @param target Defines the camera target
  127621. * @param scene Defines the scene the camera belongs to
  127622. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  127623. */
  127624. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  127625. /** @hidden */
  127626. _initCache(): void;
  127627. /** @hidden */
  127628. _updateCache(ignoreParentClass?: boolean): void;
  127629. protected _getTargetPosition(): Vector3;
  127630. private _storedAlpha;
  127631. private _storedBeta;
  127632. private _storedRadius;
  127633. private _storedTarget;
  127634. private _storedTargetScreenOffset;
  127635. /**
  127636. * Stores the current state of the camera (alpha, beta, radius and target)
  127637. * @returns the camera itself
  127638. */
  127639. storeState(): Camera;
  127640. /**
  127641. * @hidden
  127642. * Restored camera state. You must call storeState() first
  127643. */
  127644. _restoreStateValues(): boolean;
  127645. /** @hidden */
  127646. _isSynchronizedViewMatrix(): boolean;
  127647. /**
  127648. * Attached controls to the current camera.
  127649. * @param element Defines the element the controls should be listened from
  127650. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  127651. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  127652. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  127653. */
  127654. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  127655. /**
  127656. * Detach the current controls from the camera.
  127657. * The camera will stop reacting to inputs.
  127658. * @param element Defines the element to stop listening the inputs from
  127659. */
  127660. detachControl(element: HTMLElement): void;
  127661. /** @hidden */
  127662. _checkInputs(): void;
  127663. protected _checkLimits(): void;
  127664. /**
  127665. * Rebuilds angles (alpha, beta) and radius from the give position and target
  127666. */
  127667. rebuildAnglesAndRadius(): void;
  127668. /**
  127669. * Use a position to define the current camera related information like alpha, beta and radius
  127670. * @param position Defines the position to set the camera at
  127671. */
  127672. setPosition(position: Vector3): void;
  127673. /**
  127674. * Defines the target the camera should look at.
  127675. * This will automatically adapt alpha beta and radius to fit within the new target.
  127676. * @param target Defines the new target as a Vector or a mesh
  127677. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  127678. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  127679. */
  127680. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  127681. /** @hidden */
  127682. _getViewMatrix(): Matrix;
  127683. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  127684. /**
  127685. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  127686. * @param meshes Defines the mesh to zoom on
  127687. * @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)
  127688. */
  127689. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  127690. /**
  127691. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  127692. * The target will be changed but the radius
  127693. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  127694. * @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)
  127695. */
  127696. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  127697. min: Vector3;
  127698. max: Vector3;
  127699. distance: number;
  127700. }, doNotUpdateMaxZ?: boolean): void;
  127701. /**
  127702. * @override
  127703. * Override Camera.createRigCamera
  127704. */
  127705. createRigCamera(name: string, cameraIndex: number): Camera;
  127706. /**
  127707. * @hidden
  127708. * @override
  127709. * Override Camera._updateRigCameras
  127710. */
  127711. _updateRigCameras(): void;
  127712. /**
  127713. * Destroy the camera and release the current resources hold by it.
  127714. */
  127715. dispose(): void;
  127716. /**
  127717. * Gets the current object class name.
  127718. * @return the class name
  127719. */
  127720. getClassName(): string;
  127721. }
  127722. }
  127723. declare module BABYLON {
  127724. /**
  127725. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  127726. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  127727. */
  127728. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  127729. /**
  127730. * Gets the name of the behavior.
  127731. */
  127732. get name(): string;
  127733. private _zoomStopsAnimation;
  127734. private _idleRotationSpeed;
  127735. private _idleRotationWaitTime;
  127736. private _idleRotationSpinupTime;
  127737. /**
  127738. * Sets the flag that indicates if user zooming should stop animation.
  127739. */
  127740. set zoomStopsAnimation(flag: boolean);
  127741. /**
  127742. * Gets the flag that indicates if user zooming should stop animation.
  127743. */
  127744. get zoomStopsAnimation(): boolean;
  127745. /**
  127746. * Sets the default speed at which the camera rotates around the model.
  127747. */
  127748. set idleRotationSpeed(speed: number);
  127749. /**
  127750. * Gets the default speed at which the camera rotates around the model.
  127751. */
  127752. get idleRotationSpeed(): number;
  127753. /**
  127754. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  127755. */
  127756. set idleRotationWaitTime(time: number);
  127757. /**
  127758. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  127759. */
  127760. get idleRotationWaitTime(): number;
  127761. /**
  127762. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127763. */
  127764. set idleRotationSpinupTime(time: number);
  127765. /**
  127766. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  127767. */
  127768. get idleRotationSpinupTime(): number;
  127769. /**
  127770. * Gets a value indicating if the camera is currently rotating because of this behavior
  127771. */
  127772. get rotationInProgress(): boolean;
  127773. private _onPrePointerObservableObserver;
  127774. private _onAfterCheckInputsObserver;
  127775. private _attachedCamera;
  127776. private _isPointerDown;
  127777. private _lastFrameTime;
  127778. private _lastInteractionTime;
  127779. private _cameraRotationSpeed;
  127780. /**
  127781. * Initializes the behavior.
  127782. */
  127783. init(): void;
  127784. /**
  127785. * Attaches the behavior to its arc rotate camera.
  127786. * @param camera Defines the camera to attach the behavior to
  127787. */
  127788. attach(camera: ArcRotateCamera): void;
  127789. /**
  127790. * Detaches the behavior from its current arc rotate camera.
  127791. */
  127792. detach(): void;
  127793. /**
  127794. * Returns true if user is scrolling.
  127795. * @return true if user is scrolling.
  127796. */
  127797. private _userIsZooming;
  127798. private _lastFrameRadius;
  127799. private _shouldAnimationStopForInteraction;
  127800. /**
  127801. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  127802. */
  127803. private _applyUserInteraction;
  127804. private _userIsMoving;
  127805. }
  127806. }
  127807. declare module BABYLON {
  127808. /**
  127809. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  127810. */
  127811. export class AttachToBoxBehavior implements Behavior<Mesh> {
  127812. private ui;
  127813. /**
  127814. * The name of the behavior
  127815. */
  127816. name: string;
  127817. /**
  127818. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  127819. */
  127820. distanceAwayFromFace: number;
  127821. /**
  127822. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  127823. */
  127824. distanceAwayFromBottomOfFace: number;
  127825. private _faceVectors;
  127826. private _target;
  127827. private _scene;
  127828. private _onRenderObserver;
  127829. private _tmpMatrix;
  127830. private _tmpVector;
  127831. /**
  127832. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  127833. * @param ui The transform node that should be attched to the mesh
  127834. */
  127835. constructor(ui: TransformNode);
  127836. /**
  127837. * Initializes the behavior
  127838. */
  127839. init(): void;
  127840. private _closestFace;
  127841. private _zeroVector;
  127842. private _lookAtTmpMatrix;
  127843. private _lookAtToRef;
  127844. /**
  127845. * Attaches the AttachToBoxBehavior to the passed in mesh
  127846. * @param target The mesh that the specified node will be attached to
  127847. */
  127848. attach(target: Mesh): void;
  127849. /**
  127850. * Detaches the behavior from the mesh
  127851. */
  127852. detach(): void;
  127853. }
  127854. }
  127855. declare module BABYLON {
  127856. /**
  127857. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  127858. */
  127859. export class FadeInOutBehavior implements Behavior<Mesh> {
  127860. /**
  127861. * Time in milliseconds to delay before fading in (Default: 0)
  127862. */
  127863. delay: number;
  127864. /**
  127865. * Time in milliseconds for the mesh to fade in (Default: 300)
  127866. */
  127867. fadeInTime: number;
  127868. private _millisecondsPerFrame;
  127869. private _hovered;
  127870. private _hoverValue;
  127871. private _ownerNode;
  127872. /**
  127873. * Instatiates the FadeInOutBehavior
  127874. */
  127875. constructor();
  127876. /**
  127877. * The name of the behavior
  127878. */
  127879. get name(): string;
  127880. /**
  127881. * Initializes the behavior
  127882. */
  127883. init(): void;
  127884. /**
  127885. * Attaches the fade behavior on the passed in mesh
  127886. * @param ownerNode The mesh that will be faded in/out once attached
  127887. */
  127888. attach(ownerNode: Mesh): void;
  127889. /**
  127890. * Detaches the behavior from the mesh
  127891. */
  127892. detach(): void;
  127893. /**
  127894. * Triggers the mesh to begin fading in or out
  127895. * @param value if the object should fade in or out (true to fade in)
  127896. */
  127897. fadeIn(value: boolean): void;
  127898. private _update;
  127899. private _setAllVisibility;
  127900. }
  127901. }
  127902. declare module BABYLON {
  127903. /**
  127904. * Class containing a set of static utilities functions for managing Pivots
  127905. * @hidden
  127906. */
  127907. export class PivotTools {
  127908. private static _PivotCached;
  127909. private static _OldPivotPoint;
  127910. private static _PivotTranslation;
  127911. private static _PivotTmpVector;
  127912. private static _PivotPostMultiplyPivotMatrix;
  127913. /** @hidden */
  127914. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  127915. /** @hidden */
  127916. static _RestorePivotPoint(mesh: AbstractMesh): void;
  127917. }
  127918. }
  127919. declare module BABYLON {
  127920. /**
  127921. * Class containing static functions to help procedurally build meshes
  127922. */
  127923. export class PlaneBuilder {
  127924. /**
  127925. * Creates a plane mesh
  127926. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  127927. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  127928. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  127929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127930. * * 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
  127931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127932. * @param name defines the name of the mesh
  127933. * @param options defines the options used to create the mesh
  127934. * @param scene defines the hosting scene
  127935. * @returns the plane mesh
  127936. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  127937. */
  127938. static CreatePlane(name: string, options: {
  127939. size?: number;
  127940. width?: number;
  127941. height?: number;
  127942. sideOrientation?: number;
  127943. frontUVs?: Vector4;
  127944. backUVs?: Vector4;
  127945. updatable?: boolean;
  127946. sourcePlane?: Plane;
  127947. }, scene?: Nullable<Scene>): Mesh;
  127948. }
  127949. }
  127950. declare module BABYLON {
  127951. /**
  127952. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  127953. */
  127954. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  127955. private static _AnyMouseID;
  127956. /**
  127957. * Abstract mesh the behavior is set on
  127958. */
  127959. attachedNode: AbstractMesh;
  127960. private _dragPlane;
  127961. private _scene;
  127962. private _pointerObserver;
  127963. private _beforeRenderObserver;
  127964. private static _planeScene;
  127965. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  127966. /**
  127967. * 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)
  127968. */
  127969. maxDragAngle: number;
  127970. /**
  127971. * @hidden
  127972. */
  127973. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  127974. /**
  127975. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  127976. */
  127977. currentDraggingPointerID: number;
  127978. /**
  127979. * The last position where the pointer hit the drag plane in world space
  127980. */
  127981. lastDragPosition: Vector3;
  127982. /**
  127983. * If the behavior is currently in a dragging state
  127984. */
  127985. dragging: boolean;
  127986. /**
  127987. * 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)
  127988. */
  127989. dragDeltaRatio: number;
  127990. /**
  127991. * If the drag plane orientation should be updated during the dragging (Default: true)
  127992. */
  127993. updateDragPlane: boolean;
  127994. private _debugMode;
  127995. private _moving;
  127996. /**
  127997. * Fires each time the attached mesh is dragged with the pointer
  127998. * * delta between last drag position and current drag position in world space
  127999. * * dragDistance along the drag axis
  128000. * * dragPlaneNormal normal of the current drag plane used during the drag
  128001. * * dragPlanePoint in world space where the drag intersects the drag plane
  128002. */
  128003. onDragObservable: Observable<{
  128004. delta: Vector3;
  128005. dragPlanePoint: Vector3;
  128006. dragPlaneNormal: Vector3;
  128007. dragDistance: number;
  128008. pointerId: number;
  128009. }>;
  128010. /**
  128011. * Fires each time a drag begins (eg. mouse down on mesh)
  128012. */
  128013. onDragStartObservable: Observable<{
  128014. dragPlanePoint: Vector3;
  128015. pointerId: number;
  128016. }>;
  128017. /**
  128018. * Fires each time a drag ends (eg. mouse release after drag)
  128019. */
  128020. onDragEndObservable: Observable<{
  128021. dragPlanePoint: Vector3;
  128022. pointerId: number;
  128023. }>;
  128024. /**
  128025. * If the attached mesh should be moved when dragged
  128026. */
  128027. moveAttached: boolean;
  128028. /**
  128029. * If the drag behavior will react to drag events (Default: true)
  128030. */
  128031. enabled: boolean;
  128032. /**
  128033. * If pointer events should start and release the drag (Default: true)
  128034. */
  128035. startAndReleaseDragOnPointerEvents: boolean;
  128036. /**
  128037. * If camera controls should be detached during the drag
  128038. */
  128039. detachCameraControls: boolean;
  128040. /**
  128041. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  128042. */
  128043. useObjectOrientationForDragging: boolean;
  128044. private _options;
  128045. /**
  128046. * Gets the options used by the behavior
  128047. */
  128048. get options(): {
  128049. dragAxis?: Vector3;
  128050. dragPlaneNormal?: Vector3;
  128051. };
  128052. /**
  128053. * Sets the options used by the behavior
  128054. */
  128055. set options(options: {
  128056. dragAxis?: Vector3;
  128057. dragPlaneNormal?: Vector3;
  128058. });
  128059. /**
  128060. * Creates a pointer drag behavior that can be attached to a mesh
  128061. * @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)
  128062. */
  128063. constructor(options?: {
  128064. dragAxis?: Vector3;
  128065. dragPlaneNormal?: Vector3;
  128066. });
  128067. /**
  128068. * Predicate to determine if it is valid to move the object to a new position when it is moved
  128069. */
  128070. validateDrag: (targetPosition: Vector3) => boolean;
  128071. /**
  128072. * The name of the behavior
  128073. */
  128074. get name(): string;
  128075. /**
  128076. * Initializes the behavior
  128077. */
  128078. init(): void;
  128079. private _tmpVector;
  128080. private _alternatePickedPoint;
  128081. private _worldDragAxis;
  128082. private _targetPosition;
  128083. private _attachedElement;
  128084. /**
  128085. * Attaches the drag behavior the passed in mesh
  128086. * @param ownerNode The mesh that will be dragged around once attached
  128087. * @param predicate Predicate to use for pick filtering
  128088. */
  128089. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  128090. /**
  128091. * Force relase the drag action by code.
  128092. */
  128093. releaseDrag(): void;
  128094. private _startDragRay;
  128095. private _lastPointerRay;
  128096. /**
  128097. * Simulates the start of a pointer drag event on the behavior
  128098. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  128099. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  128100. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  128101. */
  128102. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128103. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  128104. private _dragDelta;
  128105. protected _moveDrag(ray: Ray): void;
  128106. private _pickWithRayOnDragPlane;
  128107. private _pointA;
  128108. private _pointC;
  128109. private _localAxis;
  128110. private _lookAt;
  128111. private _updateDragPlanePosition;
  128112. /**
  128113. * Detaches the behavior from the mesh
  128114. */
  128115. detach(): void;
  128116. }
  128117. }
  128118. declare module BABYLON {
  128119. /**
  128120. * A behavior that when attached to a mesh will allow the mesh to be scaled
  128121. */
  128122. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  128123. private _dragBehaviorA;
  128124. private _dragBehaviorB;
  128125. private _startDistance;
  128126. private _initialScale;
  128127. private _targetScale;
  128128. private _ownerNode;
  128129. private _sceneRenderObserver;
  128130. /**
  128131. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  128132. */
  128133. constructor();
  128134. /**
  128135. * The name of the behavior
  128136. */
  128137. get name(): string;
  128138. /**
  128139. * Initializes the behavior
  128140. */
  128141. init(): void;
  128142. private _getCurrentDistance;
  128143. /**
  128144. * Attaches the scale behavior the passed in mesh
  128145. * @param ownerNode The mesh that will be scaled around once attached
  128146. */
  128147. attach(ownerNode: Mesh): void;
  128148. /**
  128149. * Detaches the behavior from the mesh
  128150. */
  128151. detach(): void;
  128152. }
  128153. }
  128154. declare module BABYLON {
  128155. /**
  128156. * 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
  128157. */
  128158. export class SixDofDragBehavior implements Behavior<Mesh> {
  128159. private static _virtualScene;
  128160. private _ownerNode;
  128161. private _sceneRenderObserver;
  128162. private _scene;
  128163. private _targetPosition;
  128164. private _virtualOriginMesh;
  128165. private _virtualDragMesh;
  128166. private _pointerObserver;
  128167. private _moving;
  128168. private _startingOrientation;
  128169. private _attachedElement;
  128170. /**
  128171. * 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)
  128172. */
  128173. private zDragFactor;
  128174. /**
  128175. * If the object should rotate to face the drag origin
  128176. */
  128177. rotateDraggedObject: boolean;
  128178. /**
  128179. * If the behavior is currently in a dragging state
  128180. */
  128181. dragging: boolean;
  128182. /**
  128183. * 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)
  128184. */
  128185. dragDeltaRatio: number;
  128186. /**
  128187. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  128188. */
  128189. currentDraggingPointerID: number;
  128190. /**
  128191. * If camera controls should be detached during the drag
  128192. */
  128193. detachCameraControls: boolean;
  128194. /**
  128195. * Fires each time a drag starts
  128196. */
  128197. onDragStartObservable: Observable<{}>;
  128198. /**
  128199. * Fires each time a drag ends (eg. mouse release after drag)
  128200. */
  128201. onDragEndObservable: Observable<{}>;
  128202. /**
  128203. * 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
  128204. */
  128205. constructor();
  128206. /**
  128207. * The name of the behavior
  128208. */
  128209. get name(): string;
  128210. /**
  128211. * Initializes the behavior
  128212. */
  128213. init(): void;
  128214. /**
  128215. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  128216. */
  128217. private get _pointerCamera();
  128218. /**
  128219. * Attaches the scale behavior the passed in mesh
  128220. * @param ownerNode The mesh that will be scaled around once attached
  128221. */
  128222. attach(ownerNode: Mesh): void;
  128223. /**
  128224. * Detaches the behavior from the mesh
  128225. */
  128226. detach(): void;
  128227. }
  128228. }
  128229. declare module BABYLON {
  128230. /**
  128231. * Class used to apply inverse kinematics to bones
  128232. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  128233. */
  128234. export class BoneIKController {
  128235. private static _tmpVecs;
  128236. private static _tmpQuat;
  128237. private static _tmpMats;
  128238. /**
  128239. * Gets or sets the target mesh
  128240. */
  128241. targetMesh: AbstractMesh;
  128242. /** Gets or sets the mesh used as pole */
  128243. poleTargetMesh: AbstractMesh;
  128244. /**
  128245. * Gets or sets the bone used as pole
  128246. */
  128247. poleTargetBone: Nullable<Bone>;
  128248. /**
  128249. * Gets or sets the target position
  128250. */
  128251. targetPosition: Vector3;
  128252. /**
  128253. * Gets or sets the pole target position
  128254. */
  128255. poleTargetPosition: Vector3;
  128256. /**
  128257. * Gets or sets the pole target local offset
  128258. */
  128259. poleTargetLocalOffset: Vector3;
  128260. /**
  128261. * Gets or sets the pole angle
  128262. */
  128263. poleAngle: number;
  128264. /**
  128265. * Gets or sets the mesh associated with the controller
  128266. */
  128267. mesh: AbstractMesh;
  128268. /**
  128269. * 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)
  128270. */
  128271. slerpAmount: number;
  128272. private _bone1Quat;
  128273. private _bone1Mat;
  128274. private _bone2Ang;
  128275. private _bone1;
  128276. private _bone2;
  128277. private _bone1Length;
  128278. private _bone2Length;
  128279. private _maxAngle;
  128280. private _maxReach;
  128281. private _rightHandedSystem;
  128282. private _bendAxis;
  128283. private _slerping;
  128284. private _adjustRoll;
  128285. /**
  128286. * Gets or sets maximum allowed angle
  128287. */
  128288. get maxAngle(): number;
  128289. set maxAngle(value: number);
  128290. /**
  128291. * Creates a new BoneIKController
  128292. * @param mesh defines the mesh to control
  128293. * @param bone defines the bone to control
  128294. * @param options defines options to set up the controller
  128295. */
  128296. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  128297. targetMesh?: AbstractMesh;
  128298. poleTargetMesh?: AbstractMesh;
  128299. poleTargetBone?: Bone;
  128300. poleTargetLocalOffset?: Vector3;
  128301. poleAngle?: number;
  128302. bendAxis?: Vector3;
  128303. maxAngle?: number;
  128304. slerpAmount?: number;
  128305. });
  128306. private _setMaxAngle;
  128307. /**
  128308. * Force the controller to update the bones
  128309. */
  128310. update(): void;
  128311. }
  128312. }
  128313. declare module BABYLON {
  128314. /**
  128315. * Class used to make a bone look toward a point in space
  128316. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  128317. */
  128318. export class BoneLookController {
  128319. private static _tmpVecs;
  128320. private static _tmpQuat;
  128321. private static _tmpMats;
  128322. /**
  128323. * The target Vector3 that the bone will look at
  128324. */
  128325. target: Vector3;
  128326. /**
  128327. * The mesh that the bone is attached to
  128328. */
  128329. mesh: AbstractMesh;
  128330. /**
  128331. * The bone that will be looking to the target
  128332. */
  128333. bone: Bone;
  128334. /**
  128335. * The up axis of the coordinate system that is used when the bone is rotated
  128336. */
  128337. upAxis: Vector3;
  128338. /**
  128339. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  128340. */
  128341. upAxisSpace: Space;
  128342. /**
  128343. * Used to make an adjustment to the yaw of the bone
  128344. */
  128345. adjustYaw: number;
  128346. /**
  128347. * Used to make an adjustment to the pitch of the bone
  128348. */
  128349. adjustPitch: number;
  128350. /**
  128351. * Used to make an adjustment to the roll of the bone
  128352. */
  128353. adjustRoll: number;
  128354. /**
  128355. * 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)
  128356. */
  128357. slerpAmount: number;
  128358. private _minYaw;
  128359. private _maxYaw;
  128360. private _minPitch;
  128361. private _maxPitch;
  128362. private _minYawSin;
  128363. private _minYawCos;
  128364. private _maxYawSin;
  128365. private _maxYawCos;
  128366. private _midYawConstraint;
  128367. private _minPitchTan;
  128368. private _maxPitchTan;
  128369. private _boneQuat;
  128370. private _slerping;
  128371. private _transformYawPitch;
  128372. private _transformYawPitchInv;
  128373. private _firstFrameSkipped;
  128374. private _yawRange;
  128375. private _fowardAxis;
  128376. /**
  128377. * Gets or sets the minimum yaw angle that the bone can look to
  128378. */
  128379. get minYaw(): number;
  128380. set minYaw(value: number);
  128381. /**
  128382. * Gets or sets the maximum yaw angle that the bone can look to
  128383. */
  128384. get maxYaw(): number;
  128385. set maxYaw(value: number);
  128386. /**
  128387. * Gets or sets the minimum pitch angle that the bone can look to
  128388. */
  128389. get minPitch(): number;
  128390. set minPitch(value: number);
  128391. /**
  128392. * Gets or sets the maximum pitch angle that the bone can look to
  128393. */
  128394. get maxPitch(): number;
  128395. set maxPitch(value: number);
  128396. /**
  128397. * Create a BoneLookController
  128398. * @param mesh the mesh that the bone belongs to
  128399. * @param bone the bone that will be looking to the target
  128400. * @param target the target Vector3 to look at
  128401. * @param options optional settings:
  128402. * * maxYaw: the maximum angle the bone will yaw to
  128403. * * minYaw: the minimum angle the bone will yaw to
  128404. * * maxPitch: the maximum angle the bone will pitch to
  128405. * * minPitch: the minimum angle the bone will yaw to
  128406. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  128407. * * upAxis: the up axis of the coordinate system
  128408. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  128409. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  128410. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  128411. * * adjustYaw: used to make an adjustment to the yaw of the bone
  128412. * * adjustPitch: used to make an adjustment to the pitch of the bone
  128413. * * adjustRoll: used to make an adjustment to the roll of the bone
  128414. **/
  128415. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  128416. maxYaw?: number;
  128417. minYaw?: number;
  128418. maxPitch?: number;
  128419. minPitch?: number;
  128420. slerpAmount?: number;
  128421. upAxis?: Vector3;
  128422. upAxisSpace?: Space;
  128423. yawAxis?: Vector3;
  128424. pitchAxis?: Vector3;
  128425. adjustYaw?: number;
  128426. adjustPitch?: number;
  128427. adjustRoll?: number;
  128428. });
  128429. /**
  128430. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  128431. */
  128432. update(): void;
  128433. private _getAngleDiff;
  128434. private _getAngleBetween;
  128435. private _isAngleBetween;
  128436. }
  128437. }
  128438. declare module BABYLON {
  128439. /**
  128440. * Manage the gamepad inputs to control an arc rotate camera.
  128441. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128442. */
  128443. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  128444. /**
  128445. * Defines the camera the input is attached to.
  128446. */
  128447. camera: ArcRotateCamera;
  128448. /**
  128449. * Defines the gamepad the input is gathering event from.
  128450. */
  128451. gamepad: Nullable<Gamepad>;
  128452. /**
  128453. * Defines the gamepad rotation sensiblity.
  128454. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  128455. */
  128456. gamepadRotationSensibility: number;
  128457. /**
  128458. * Defines the gamepad move sensiblity.
  128459. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  128460. */
  128461. gamepadMoveSensibility: number;
  128462. private _yAxisScale;
  128463. /**
  128464. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  128465. */
  128466. get invertYAxis(): boolean;
  128467. set invertYAxis(value: boolean);
  128468. private _onGamepadConnectedObserver;
  128469. private _onGamepadDisconnectedObserver;
  128470. /**
  128471. * Attach the input controls to a specific dom element to get the input from.
  128472. * @param element Defines the element the controls should be listened from
  128473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128474. */
  128475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128476. /**
  128477. * Detach the current controls from the specified dom element.
  128478. * @param element Defines the element to stop listening the inputs from
  128479. */
  128480. detachControl(element: Nullable<HTMLElement>): void;
  128481. /**
  128482. * Update the current camera state depending on the inputs that have been used this frame.
  128483. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128484. */
  128485. checkInputs(): void;
  128486. /**
  128487. * Gets the class name of the current intput.
  128488. * @returns the class name
  128489. */
  128490. getClassName(): string;
  128491. /**
  128492. * Get the friendly name associated with the input class.
  128493. * @returns the input friendly name
  128494. */
  128495. getSimpleName(): string;
  128496. }
  128497. }
  128498. declare module BABYLON {
  128499. interface ArcRotateCameraInputsManager {
  128500. /**
  128501. * Add orientation input support to the input manager.
  128502. * @returns the current input manager
  128503. */
  128504. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  128505. }
  128506. /**
  128507. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  128508. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128509. */
  128510. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  128511. /**
  128512. * Defines the camera the input is attached to.
  128513. */
  128514. camera: ArcRotateCamera;
  128515. /**
  128516. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  128517. */
  128518. alphaCorrection: number;
  128519. /**
  128520. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  128521. */
  128522. gammaCorrection: number;
  128523. private _alpha;
  128524. private _gamma;
  128525. private _dirty;
  128526. private _deviceOrientationHandler;
  128527. /**
  128528. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  128529. */
  128530. constructor();
  128531. /**
  128532. * Attach the input controls to a specific dom element to get the input from.
  128533. * @param element Defines the element the controls should be listened from
  128534. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128535. */
  128536. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128537. /** @hidden */
  128538. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  128539. /**
  128540. * Update the current camera state depending on the inputs that have been used this frame.
  128541. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128542. */
  128543. checkInputs(): void;
  128544. /**
  128545. * Detach the current controls from the specified dom element.
  128546. * @param element Defines the element to stop listening the inputs from
  128547. */
  128548. detachControl(element: Nullable<HTMLElement>): void;
  128549. /**
  128550. * Gets the class name of the current intput.
  128551. * @returns the class name
  128552. */
  128553. getClassName(): string;
  128554. /**
  128555. * Get the friendly name associated with the input class.
  128556. * @returns the input friendly name
  128557. */
  128558. getSimpleName(): string;
  128559. }
  128560. }
  128561. declare module BABYLON {
  128562. /**
  128563. * Listen to mouse events to control the camera.
  128564. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128565. */
  128566. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  128567. /**
  128568. * Defines the camera the input is attached to.
  128569. */
  128570. camera: FlyCamera;
  128571. /**
  128572. * Defines if touch is enabled. (Default is true.)
  128573. */
  128574. touchEnabled: boolean;
  128575. /**
  128576. * Defines the buttons associated with the input to handle camera rotation.
  128577. */
  128578. buttons: number[];
  128579. /**
  128580. * Assign buttons for Yaw control.
  128581. */
  128582. buttonsYaw: number[];
  128583. /**
  128584. * Assign buttons for Pitch control.
  128585. */
  128586. buttonsPitch: number[];
  128587. /**
  128588. * Assign buttons for Roll control.
  128589. */
  128590. buttonsRoll: number[];
  128591. /**
  128592. * Detect if any button is being pressed while mouse is moved.
  128593. * -1 = Mouse locked.
  128594. * 0 = Left button.
  128595. * 1 = Middle Button.
  128596. * 2 = Right Button.
  128597. */
  128598. activeButton: number;
  128599. /**
  128600. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  128601. * Higher values reduce its sensitivity.
  128602. */
  128603. angularSensibility: number;
  128604. private _observer;
  128605. private _rollObserver;
  128606. private previousPosition;
  128607. private noPreventDefault;
  128608. private element;
  128609. /**
  128610. * Listen to mouse events to control the camera.
  128611. * @param touchEnabled Define if touch is enabled. (Default is true.)
  128612. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128613. */
  128614. constructor(touchEnabled?: boolean);
  128615. /**
  128616. * Attach the mouse control to the HTML DOM element.
  128617. * @param element Defines the element that listens to the input events.
  128618. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  128619. */
  128620. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128621. /**
  128622. * Detach the current controls from the specified dom element.
  128623. * @param element Defines the element to stop listening the inputs from
  128624. */
  128625. detachControl(element: Nullable<HTMLElement>): void;
  128626. /**
  128627. * Gets the class name of the current input.
  128628. * @returns the class name.
  128629. */
  128630. getClassName(): string;
  128631. /**
  128632. * Get the friendly name associated with the input class.
  128633. * @returns the input's friendly name.
  128634. */
  128635. getSimpleName(): string;
  128636. private _pointerInput;
  128637. private _onMouseMove;
  128638. /**
  128639. * Rotate camera by mouse offset.
  128640. */
  128641. private rotateCamera;
  128642. }
  128643. }
  128644. declare module BABYLON {
  128645. /**
  128646. * Default Inputs manager for the FlyCamera.
  128647. * It groups all the default supported inputs for ease of use.
  128648. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128649. */
  128650. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  128651. /**
  128652. * Instantiates a new FlyCameraInputsManager.
  128653. * @param camera Defines the camera the inputs belong to.
  128654. */
  128655. constructor(camera: FlyCamera);
  128656. /**
  128657. * Add keyboard input support to the input manager.
  128658. * @returns the new FlyCameraKeyboardMoveInput().
  128659. */
  128660. addKeyboard(): FlyCameraInputsManager;
  128661. /**
  128662. * Add mouse input support to the input manager.
  128663. * @param touchEnabled Enable touch screen support.
  128664. * @returns the new FlyCameraMouseInput().
  128665. */
  128666. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  128667. }
  128668. }
  128669. declare module BABYLON {
  128670. /**
  128671. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128672. * such as in a 3D Space Shooter or a Flight Simulator.
  128673. */
  128674. export class FlyCamera extends TargetCamera {
  128675. /**
  128676. * Define the collision ellipsoid of the camera.
  128677. * This is helpful for simulating a camera body, like a player's body.
  128678. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  128679. */
  128680. ellipsoid: Vector3;
  128681. /**
  128682. * Define an offset for the position of the ellipsoid around the camera.
  128683. * This can be helpful if the camera is attached away from the player's body center,
  128684. * such as at its head.
  128685. */
  128686. ellipsoidOffset: Vector3;
  128687. /**
  128688. * Enable or disable collisions of the camera with the rest of the scene objects.
  128689. */
  128690. checkCollisions: boolean;
  128691. /**
  128692. * Enable or disable gravity on the camera.
  128693. */
  128694. applyGravity: boolean;
  128695. /**
  128696. * Define the current direction the camera is moving to.
  128697. */
  128698. cameraDirection: Vector3;
  128699. /**
  128700. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  128701. * This overrides and empties cameraRotation.
  128702. */
  128703. rotationQuaternion: Quaternion;
  128704. /**
  128705. * Track Roll to maintain the wanted Rolling when looking around.
  128706. */
  128707. _trackRoll: number;
  128708. /**
  128709. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  128710. */
  128711. rollCorrect: number;
  128712. /**
  128713. * Mimic a banked turn, Rolling the camera when Yawing.
  128714. * It's recommended to use rollCorrect = 10 for faster banking correction.
  128715. */
  128716. bankedTurn: boolean;
  128717. /**
  128718. * Limit in radians for how much Roll banking will add. (Default: 90°)
  128719. */
  128720. bankedTurnLimit: number;
  128721. /**
  128722. * Value of 0 disables the banked Roll.
  128723. * Value of 1 is equal to the Yaw angle in radians.
  128724. */
  128725. bankedTurnMultiplier: number;
  128726. /**
  128727. * The inputs manager loads all the input sources, such as keyboard and mouse.
  128728. */
  128729. inputs: FlyCameraInputsManager;
  128730. /**
  128731. * Gets the input sensibility for mouse input.
  128732. * Higher values reduce sensitivity.
  128733. */
  128734. get angularSensibility(): number;
  128735. /**
  128736. * Sets the input sensibility for a mouse input.
  128737. * Higher values reduce sensitivity.
  128738. */
  128739. set angularSensibility(value: number);
  128740. /**
  128741. * Get the keys for camera movement forward.
  128742. */
  128743. get keysForward(): number[];
  128744. /**
  128745. * Set the keys for camera movement forward.
  128746. */
  128747. set keysForward(value: number[]);
  128748. /**
  128749. * Get the keys for camera movement backward.
  128750. */
  128751. get keysBackward(): number[];
  128752. set keysBackward(value: number[]);
  128753. /**
  128754. * Get the keys for camera movement up.
  128755. */
  128756. get keysUp(): number[];
  128757. /**
  128758. * Set the keys for camera movement up.
  128759. */
  128760. set keysUp(value: number[]);
  128761. /**
  128762. * Get the keys for camera movement down.
  128763. */
  128764. get keysDown(): number[];
  128765. /**
  128766. * Set the keys for camera movement down.
  128767. */
  128768. set keysDown(value: number[]);
  128769. /**
  128770. * Get the keys for camera movement left.
  128771. */
  128772. get keysLeft(): number[];
  128773. /**
  128774. * Set the keys for camera movement left.
  128775. */
  128776. set keysLeft(value: number[]);
  128777. /**
  128778. * Set the keys for camera movement right.
  128779. */
  128780. get keysRight(): number[];
  128781. /**
  128782. * Set the keys for camera movement right.
  128783. */
  128784. set keysRight(value: number[]);
  128785. /**
  128786. * Event raised when the camera collides with a mesh in the scene.
  128787. */
  128788. onCollide: (collidedMesh: AbstractMesh) => void;
  128789. private _collider;
  128790. private _needMoveForGravity;
  128791. private _oldPosition;
  128792. private _diffPosition;
  128793. private _newPosition;
  128794. /** @hidden */
  128795. _localDirection: Vector3;
  128796. /** @hidden */
  128797. _transformedDirection: Vector3;
  128798. /**
  128799. * Instantiates a FlyCamera.
  128800. * This is a flying camera, designed for 3D movement and rotation in all directions,
  128801. * such as in a 3D Space Shooter or a Flight Simulator.
  128802. * @param name Define the name of the camera in the scene.
  128803. * @param position Define the starting position of the camera in the scene.
  128804. * @param scene Define the scene the camera belongs to.
  128805. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  128806. */
  128807. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  128808. /**
  128809. * Attach a control to the HTML DOM element.
  128810. * @param element Defines the element that listens to the input events.
  128811. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  128812. */
  128813. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128814. /**
  128815. * Detach a control from the HTML DOM element.
  128816. * The camera will stop reacting to that input.
  128817. * @param element Defines the element that listens to the input events.
  128818. */
  128819. detachControl(element: HTMLElement): void;
  128820. private _collisionMask;
  128821. /**
  128822. * Get the mask that the camera ignores in collision events.
  128823. */
  128824. get collisionMask(): number;
  128825. /**
  128826. * Set the mask that the camera ignores in collision events.
  128827. */
  128828. set collisionMask(mask: number);
  128829. /** @hidden */
  128830. _collideWithWorld(displacement: Vector3): void;
  128831. /** @hidden */
  128832. private _onCollisionPositionChange;
  128833. /** @hidden */
  128834. _checkInputs(): void;
  128835. /** @hidden */
  128836. _decideIfNeedsToMove(): boolean;
  128837. /** @hidden */
  128838. _updatePosition(): void;
  128839. /**
  128840. * Restore the Roll to its target value at the rate specified.
  128841. * @param rate - Higher means slower restoring.
  128842. * @hidden
  128843. */
  128844. restoreRoll(rate: number): void;
  128845. /**
  128846. * Destroy the camera and release the current resources held by it.
  128847. */
  128848. dispose(): void;
  128849. /**
  128850. * Get the current object class name.
  128851. * @returns the class name.
  128852. */
  128853. getClassName(): string;
  128854. }
  128855. }
  128856. declare module BABYLON {
  128857. /**
  128858. * Listen to keyboard events to control the camera.
  128859. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128860. */
  128861. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  128862. /**
  128863. * Defines the camera the input is attached to.
  128864. */
  128865. camera: FlyCamera;
  128866. /**
  128867. * The list of keyboard keys used to control the forward move of the camera.
  128868. */
  128869. keysForward: number[];
  128870. /**
  128871. * The list of keyboard keys used to control the backward move of the camera.
  128872. */
  128873. keysBackward: number[];
  128874. /**
  128875. * The list of keyboard keys used to control the forward move of the camera.
  128876. */
  128877. keysUp: number[];
  128878. /**
  128879. * The list of keyboard keys used to control the backward move of the camera.
  128880. */
  128881. keysDown: number[];
  128882. /**
  128883. * The list of keyboard keys used to control the right strafe move of the camera.
  128884. */
  128885. keysRight: number[];
  128886. /**
  128887. * The list of keyboard keys used to control the left strafe move of the camera.
  128888. */
  128889. keysLeft: number[];
  128890. private _keys;
  128891. private _onCanvasBlurObserver;
  128892. private _onKeyboardObserver;
  128893. private _engine;
  128894. private _scene;
  128895. /**
  128896. * Attach the input controls to a specific dom element to get the input from.
  128897. * @param element Defines the element the controls should be listened from
  128898. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128899. */
  128900. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128901. /**
  128902. * Detach the current controls from the specified dom element.
  128903. * @param element Defines the element to stop listening the inputs from
  128904. */
  128905. detachControl(element: Nullable<HTMLElement>): void;
  128906. /**
  128907. * Gets the class name of the current intput.
  128908. * @returns the class name
  128909. */
  128910. getClassName(): string;
  128911. /** @hidden */
  128912. _onLostFocus(e: FocusEvent): void;
  128913. /**
  128914. * Get the friendly name associated with the input class.
  128915. * @returns the input friendly name
  128916. */
  128917. getSimpleName(): string;
  128918. /**
  128919. * Update the current camera state depending on the inputs that have been used this frame.
  128920. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  128921. */
  128922. checkInputs(): void;
  128923. }
  128924. }
  128925. declare module BABYLON {
  128926. /**
  128927. * Manage the mouse wheel inputs to control a follow camera.
  128928. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128929. */
  128930. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  128931. /**
  128932. * Defines the camera the input is attached to.
  128933. */
  128934. camera: FollowCamera;
  128935. /**
  128936. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  128937. */
  128938. axisControlRadius: boolean;
  128939. /**
  128940. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  128941. */
  128942. axisControlHeight: boolean;
  128943. /**
  128944. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  128945. */
  128946. axisControlRotation: boolean;
  128947. /**
  128948. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  128949. * relation to mouseWheel events.
  128950. */
  128951. wheelPrecision: number;
  128952. /**
  128953. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  128954. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  128955. */
  128956. wheelDeltaPercentage: number;
  128957. private _wheel;
  128958. private _observer;
  128959. /**
  128960. * Attach the input controls to a specific dom element to get the input from.
  128961. * @param element Defines the element the controls should be listened from
  128962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  128963. */
  128964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  128965. /**
  128966. * Detach the current controls from the specified dom element.
  128967. * @param element Defines the element to stop listening the inputs from
  128968. */
  128969. detachControl(element: Nullable<HTMLElement>): void;
  128970. /**
  128971. * Gets the class name of the current intput.
  128972. * @returns the class name
  128973. */
  128974. getClassName(): string;
  128975. /**
  128976. * Get the friendly name associated with the input class.
  128977. * @returns the input friendly name
  128978. */
  128979. getSimpleName(): string;
  128980. }
  128981. }
  128982. declare module BABYLON {
  128983. /**
  128984. * Manage the pointers inputs to control an follow camera.
  128985. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  128986. */
  128987. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  128988. /**
  128989. * Defines the camera the input is attached to.
  128990. */
  128991. camera: FollowCamera;
  128992. /**
  128993. * Gets the class name of the current input.
  128994. * @returns the class name
  128995. */
  128996. getClassName(): string;
  128997. /**
  128998. * Defines the pointer angular sensibility along the X axis or how fast is
  128999. * the camera rotating.
  129000. * A negative number will reverse the axis direction.
  129001. */
  129002. angularSensibilityX: number;
  129003. /**
  129004. * Defines the pointer angular sensibility along the Y axis or how fast is
  129005. * the camera rotating.
  129006. * A negative number will reverse the axis direction.
  129007. */
  129008. angularSensibilityY: number;
  129009. /**
  129010. * Defines the pointer pinch precision or how fast is the camera zooming.
  129011. * A negative number will reverse the axis direction.
  129012. */
  129013. pinchPrecision: number;
  129014. /**
  129015. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  129016. * from 0.
  129017. * It defines the percentage of current camera.radius to use as delta when
  129018. * pinch zoom is used.
  129019. */
  129020. pinchDeltaPercentage: number;
  129021. /**
  129022. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  129023. */
  129024. axisXControlRadius: boolean;
  129025. /**
  129026. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  129027. */
  129028. axisXControlHeight: boolean;
  129029. /**
  129030. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  129031. */
  129032. axisXControlRotation: boolean;
  129033. /**
  129034. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  129035. */
  129036. axisYControlRadius: boolean;
  129037. /**
  129038. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  129039. */
  129040. axisYControlHeight: boolean;
  129041. /**
  129042. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  129043. */
  129044. axisYControlRotation: boolean;
  129045. /**
  129046. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  129047. */
  129048. axisPinchControlRadius: boolean;
  129049. /**
  129050. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  129051. */
  129052. axisPinchControlHeight: boolean;
  129053. /**
  129054. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  129055. */
  129056. axisPinchControlRotation: boolean;
  129057. /**
  129058. * Log error messages if basic misconfiguration has occurred.
  129059. */
  129060. warningEnable: boolean;
  129061. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  129062. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  129063. private _warningCounter;
  129064. private _warning;
  129065. }
  129066. }
  129067. declare module BABYLON {
  129068. /**
  129069. * Default Inputs manager for the FollowCamera.
  129070. * It groups all the default supported inputs for ease of use.
  129071. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129072. */
  129073. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  129074. /**
  129075. * Instantiates a new FollowCameraInputsManager.
  129076. * @param camera Defines the camera the inputs belong to
  129077. */
  129078. constructor(camera: FollowCamera);
  129079. /**
  129080. * Add keyboard input support to the input manager.
  129081. * @returns the current input manager
  129082. */
  129083. addKeyboard(): FollowCameraInputsManager;
  129084. /**
  129085. * Add mouse wheel input support to the input manager.
  129086. * @returns the current input manager
  129087. */
  129088. addMouseWheel(): FollowCameraInputsManager;
  129089. /**
  129090. * Add pointers input support to the input manager.
  129091. * @returns the current input manager
  129092. */
  129093. addPointers(): FollowCameraInputsManager;
  129094. /**
  129095. * Add orientation input support to the input manager.
  129096. * @returns the current input manager
  129097. */
  129098. addVRDeviceOrientation(): FollowCameraInputsManager;
  129099. }
  129100. }
  129101. declare module BABYLON {
  129102. /**
  129103. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  129104. * an arc rotate version arcFollowCamera are available.
  129105. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129106. */
  129107. export class FollowCamera extends TargetCamera {
  129108. /**
  129109. * Distance the follow camera should follow an object at
  129110. */
  129111. radius: number;
  129112. /**
  129113. * Minimum allowed distance of the camera to the axis of rotation
  129114. * (The camera can not get closer).
  129115. * This can help limiting how the Camera is able to move in the scene.
  129116. */
  129117. lowerRadiusLimit: Nullable<number>;
  129118. /**
  129119. * Maximum allowed distance of the camera to the axis of rotation
  129120. * (The camera can not get further).
  129121. * This can help limiting how the Camera is able to move in the scene.
  129122. */
  129123. upperRadiusLimit: Nullable<number>;
  129124. /**
  129125. * Define a rotation offset between the camera and the object it follows
  129126. */
  129127. rotationOffset: number;
  129128. /**
  129129. * Minimum allowed angle to camera position relative to target object.
  129130. * This can help limiting how the Camera is able to move in the scene.
  129131. */
  129132. lowerRotationOffsetLimit: Nullable<number>;
  129133. /**
  129134. * Maximum allowed angle to camera position relative to target object.
  129135. * This can help limiting how the Camera is able to move in the scene.
  129136. */
  129137. upperRotationOffsetLimit: Nullable<number>;
  129138. /**
  129139. * Define a height offset between the camera and the object it follows.
  129140. * It can help following an object from the top (like a car chaing a plane)
  129141. */
  129142. heightOffset: number;
  129143. /**
  129144. * Minimum allowed height of camera position relative to target object.
  129145. * This can help limiting how the Camera is able to move in the scene.
  129146. */
  129147. lowerHeightOffsetLimit: Nullable<number>;
  129148. /**
  129149. * Maximum allowed height of camera position relative to target object.
  129150. * This can help limiting how the Camera is able to move in the scene.
  129151. */
  129152. upperHeightOffsetLimit: Nullable<number>;
  129153. /**
  129154. * Define how fast the camera can accelerate to follow it s target.
  129155. */
  129156. cameraAcceleration: number;
  129157. /**
  129158. * Define the speed limit of the camera following an object.
  129159. */
  129160. maxCameraSpeed: number;
  129161. /**
  129162. * Define the target of the camera.
  129163. */
  129164. lockedTarget: Nullable<AbstractMesh>;
  129165. /**
  129166. * Defines the input associated with the camera.
  129167. */
  129168. inputs: FollowCameraInputsManager;
  129169. /**
  129170. * Instantiates the follow camera.
  129171. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129172. * @param name Define the name of the camera in the scene
  129173. * @param position Define the position of the camera
  129174. * @param scene Define the scene the camera belong to
  129175. * @param lockedTarget Define the target of the camera
  129176. */
  129177. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  129178. private _follow;
  129179. /**
  129180. * Attached controls to the current camera.
  129181. * @param element Defines the element the controls should be listened from
  129182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129183. */
  129184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  129185. /**
  129186. * Detach the current controls from the camera.
  129187. * The camera will stop reacting to inputs.
  129188. * @param element Defines the element to stop listening the inputs from
  129189. */
  129190. detachControl(element: HTMLElement): void;
  129191. /** @hidden */
  129192. _checkInputs(): void;
  129193. private _checkLimits;
  129194. /**
  129195. * Gets the camera class name.
  129196. * @returns the class name
  129197. */
  129198. getClassName(): string;
  129199. }
  129200. /**
  129201. * Arc Rotate version of the follow camera.
  129202. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  129203. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129204. */
  129205. export class ArcFollowCamera extends TargetCamera {
  129206. /** The longitudinal angle of the camera */
  129207. alpha: number;
  129208. /** The latitudinal angle of the camera */
  129209. beta: number;
  129210. /** The radius of the camera from its target */
  129211. radius: number;
  129212. private _cartesianCoordinates;
  129213. /** Define the camera target (the mesh it should follow) */
  129214. private _meshTarget;
  129215. /**
  129216. * Instantiates a new ArcFollowCamera
  129217. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  129218. * @param name Define the name of the camera
  129219. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  129220. * @param beta Define the rotation angle of the camera around the elevation axis
  129221. * @param radius Define the radius of the camera from its target point
  129222. * @param target Define the target of the camera
  129223. * @param scene Define the scene the camera belongs to
  129224. */
  129225. constructor(name: string,
  129226. /** The longitudinal angle of the camera */
  129227. alpha: number,
  129228. /** The latitudinal angle of the camera */
  129229. beta: number,
  129230. /** The radius of the camera from its target */
  129231. radius: number,
  129232. /** Define the camera target (the mesh it should follow) */
  129233. target: Nullable<AbstractMesh>, scene: Scene);
  129234. private _follow;
  129235. /** @hidden */
  129236. _checkInputs(): void;
  129237. /**
  129238. * Returns the class name of the object.
  129239. * It is mostly used internally for serialization purposes.
  129240. */
  129241. getClassName(): string;
  129242. }
  129243. }
  129244. declare module BABYLON {
  129245. /**
  129246. * Manage the keyboard inputs to control the movement of a follow camera.
  129247. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129248. */
  129249. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  129250. /**
  129251. * Defines the camera the input is attached to.
  129252. */
  129253. camera: FollowCamera;
  129254. /**
  129255. * Defines the list of key codes associated with the up action (increase heightOffset)
  129256. */
  129257. keysHeightOffsetIncr: number[];
  129258. /**
  129259. * Defines the list of key codes associated with the down action (decrease heightOffset)
  129260. */
  129261. keysHeightOffsetDecr: number[];
  129262. /**
  129263. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  129264. */
  129265. keysHeightOffsetModifierAlt: boolean;
  129266. /**
  129267. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  129268. */
  129269. keysHeightOffsetModifierCtrl: boolean;
  129270. /**
  129271. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  129272. */
  129273. keysHeightOffsetModifierShift: boolean;
  129274. /**
  129275. * Defines the list of key codes associated with the left action (increase rotationOffset)
  129276. */
  129277. keysRotationOffsetIncr: number[];
  129278. /**
  129279. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  129280. */
  129281. keysRotationOffsetDecr: number[];
  129282. /**
  129283. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  129284. */
  129285. keysRotationOffsetModifierAlt: boolean;
  129286. /**
  129287. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  129288. */
  129289. keysRotationOffsetModifierCtrl: boolean;
  129290. /**
  129291. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  129292. */
  129293. keysRotationOffsetModifierShift: boolean;
  129294. /**
  129295. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  129296. */
  129297. keysRadiusIncr: number[];
  129298. /**
  129299. * Defines the list of key codes associated with the zoom-out action (increase radius)
  129300. */
  129301. keysRadiusDecr: number[];
  129302. /**
  129303. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  129304. */
  129305. keysRadiusModifierAlt: boolean;
  129306. /**
  129307. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  129308. */
  129309. keysRadiusModifierCtrl: boolean;
  129310. /**
  129311. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  129312. */
  129313. keysRadiusModifierShift: boolean;
  129314. /**
  129315. * Defines the rate of change of heightOffset.
  129316. */
  129317. heightSensibility: number;
  129318. /**
  129319. * Defines the rate of change of rotationOffset.
  129320. */
  129321. rotationSensibility: number;
  129322. /**
  129323. * Defines the rate of change of radius.
  129324. */
  129325. radiusSensibility: number;
  129326. private _keys;
  129327. private _ctrlPressed;
  129328. private _altPressed;
  129329. private _shiftPressed;
  129330. private _onCanvasBlurObserver;
  129331. private _onKeyboardObserver;
  129332. private _engine;
  129333. private _scene;
  129334. /**
  129335. * Attach the input controls to a specific dom element to get the input from.
  129336. * @param element Defines the element the controls should be listened from
  129337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129338. */
  129339. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  129340. /**
  129341. * Detach the current controls from the specified dom element.
  129342. * @param element Defines the element to stop listening the inputs from
  129343. */
  129344. detachControl(element: Nullable<HTMLElement>): void;
  129345. /**
  129346. * Update the current camera state depending on the inputs that have been used this frame.
  129347. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129348. */
  129349. checkInputs(): void;
  129350. /**
  129351. * Gets the class name of the current input.
  129352. * @returns the class name
  129353. */
  129354. getClassName(): string;
  129355. /**
  129356. * Get the friendly name associated with the input class.
  129357. * @returns the input friendly name
  129358. */
  129359. getSimpleName(): string;
  129360. /**
  129361. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129362. * allow modification of the heightOffset value.
  129363. */
  129364. private _modifierHeightOffset;
  129365. /**
  129366. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129367. * allow modification of the rotationOffset value.
  129368. */
  129369. private _modifierRotationOffset;
  129370. /**
  129371. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  129372. * allow modification of the radius value.
  129373. */
  129374. private _modifierRadius;
  129375. }
  129376. }
  129377. declare module BABYLON {
  129378. interface FreeCameraInputsManager {
  129379. /**
  129380. * @hidden
  129381. */
  129382. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  129383. /**
  129384. * Add orientation input support to the input manager.
  129385. * @returns the current input manager
  129386. */
  129387. addDeviceOrientation(): FreeCameraInputsManager;
  129388. }
  129389. /**
  129390. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  129391. * Screen rotation is taken into account.
  129392. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129393. */
  129394. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  129395. private _camera;
  129396. private _screenOrientationAngle;
  129397. private _constantTranform;
  129398. private _screenQuaternion;
  129399. private _alpha;
  129400. private _beta;
  129401. private _gamma;
  129402. /**
  129403. * Can be used to detect if a device orientation sensor is available on a device
  129404. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  129405. * @returns a promise that will resolve on orientation change
  129406. */
  129407. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  129408. /**
  129409. * @hidden
  129410. */
  129411. _onDeviceOrientationChangedObservable: Observable<void>;
  129412. /**
  129413. * Instantiates a new input
  129414. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129415. */
  129416. constructor();
  129417. /**
  129418. * Define the camera controlled by the input.
  129419. */
  129420. get camera(): FreeCamera;
  129421. set camera(camera: FreeCamera);
  129422. /**
  129423. * Attach the input controls to a specific dom element to get the input from.
  129424. * @param element Defines the element the controls should be listened from
  129425. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129426. */
  129427. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  129428. private _orientationChanged;
  129429. private _deviceOrientation;
  129430. /**
  129431. * Detach the current controls from the specified dom element.
  129432. * @param element Defines the element to stop listening the inputs from
  129433. */
  129434. detachControl(element: Nullable<HTMLElement>): void;
  129435. /**
  129436. * Update the current camera state depending on the inputs that have been used this frame.
  129437. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129438. */
  129439. checkInputs(): void;
  129440. /**
  129441. * Gets the class name of the current intput.
  129442. * @returns the class name
  129443. */
  129444. getClassName(): string;
  129445. /**
  129446. * Get the friendly name associated with the input class.
  129447. * @returns the input friendly name
  129448. */
  129449. getSimpleName(): string;
  129450. }
  129451. }
  129452. declare module BABYLON {
  129453. /**
  129454. * Manage the gamepad inputs to control a free camera.
  129455. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129456. */
  129457. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  129458. /**
  129459. * Define the camera the input is attached to.
  129460. */
  129461. camera: FreeCamera;
  129462. /**
  129463. * Define the Gamepad controlling the input
  129464. */
  129465. gamepad: Nullable<Gamepad>;
  129466. /**
  129467. * Defines the gamepad rotation sensiblity.
  129468. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  129469. */
  129470. gamepadAngularSensibility: number;
  129471. /**
  129472. * Defines the gamepad move sensiblity.
  129473. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  129474. */
  129475. gamepadMoveSensibility: number;
  129476. private _yAxisScale;
  129477. /**
  129478. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  129479. */
  129480. get invertYAxis(): boolean;
  129481. set invertYAxis(value: boolean);
  129482. private _onGamepadConnectedObserver;
  129483. private _onGamepadDisconnectedObserver;
  129484. private _cameraTransform;
  129485. private _deltaTransform;
  129486. private _vector3;
  129487. private _vector2;
  129488. /**
  129489. * Attach the input controls to a specific dom element to get the input from.
  129490. * @param element Defines the element the controls should be listened from
  129491. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129492. */
  129493. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  129494. /**
  129495. * Detach the current controls from the specified dom element.
  129496. * @param element Defines the element to stop listening the inputs from
  129497. */
  129498. detachControl(element: Nullable<HTMLElement>): void;
  129499. /**
  129500. * Update the current camera state depending on the inputs that have been used this frame.
  129501. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129502. */
  129503. checkInputs(): void;
  129504. /**
  129505. * Gets the class name of the current intput.
  129506. * @returns the class name
  129507. */
  129508. getClassName(): string;
  129509. /**
  129510. * Get the friendly name associated with the input class.
  129511. * @returns the input friendly name
  129512. */
  129513. getSimpleName(): string;
  129514. }
  129515. }
  129516. declare module BABYLON {
  129517. /**
  129518. * Defines the potential axis of a Joystick
  129519. */
  129520. export enum JoystickAxis {
  129521. /** X axis */
  129522. X = 0,
  129523. /** Y axis */
  129524. Y = 1,
  129525. /** Z axis */
  129526. Z = 2
  129527. }
  129528. /**
  129529. * Represents the different customization options available
  129530. * for VirtualJoystick
  129531. */
  129532. interface VirtualJoystickCustomizations {
  129533. /**
  129534. * Size of the joystick's puck
  129535. */
  129536. puckSize: number;
  129537. /**
  129538. * Size of the joystick's container
  129539. */
  129540. containerSize: number;
  129541. /**
  129542. * Color of the joystick && puck
  129543. */
  129544. color: string;
  129545. /**
  129546. * Image URL for the joystick's puck
  129547. */
  129548. puckImage?: string;
  129549. /**
  129550. * Image URL for the joystick's container
  129551. */
  129552. containerImage?: string;
  129553. /**
  129554. * Defines the unmoving position of the joystick container
  129555. */
  129556. position?: {
  129557. x: number;
  129558. y: number;
  129559. };
  129560. /**
  129561. * Defines whether or not the joystick container is always visible
  129562. */
  129563. alwaysVisible: boolean;
  129564. /**
  129565. * Defines whether or not to limit the movement of the puck to the joystick's container
  129566. */
  129567. limitToContainer: boolean;
  129568. }
  129569. /**
  129570. * Class used to define virtual joystick (used in touch mode)
  129571. */
  129572. export class VirtualJoystick {
  129573. /**
  129574. * Gets or sets a boolean indicating that left and right values must be inverted
  129575. */
  129576. reverseLeftRight: boolean;
  129577. /**
  129578. * Gets or sets a boolean indicating that up and down values must be inverted
  129579. */
  129580. reverseUpDown: boolean;
  129581. /**
  129582. * Gets the offset value for the position (ie. the change of the position value)
  129583. */
  129584. deltaPosition: Vector3;
  129585. /**
  129586. * Gets a boolean indicating if the virtual joystick was pressed
  129587. */
  129588. pressed: boolean;
  129589. /**
  129590. * Canvas the virtual joystick will render onto, default z-index of this is 5
  129591. */
  129592. static Canvas: Nullable<HTMLCanvasElement>;
  129593. /**
  129594. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  129595. */
  129596. limitToContainer: boolean;
  129597. private static _globalJoystickIndex;
  129598. private static _alwaysVisibleSticks;
  129599. private static vjCanvasContext;
  129600. private static vjCanvasWidth;
  129601. private static vjCanvasHeight;
  129602. private static halfWidth;
  129603. private static _GetDefaultOptions;
  129604. private _action;
  129605. private _axisTargetedByLeftAndRight;
  129606. private _axisTargetedByUpAndDown;
  129607. private _joystickSensibility;
  129608. private _inversedSensibility;
  129609. private _joystickPointerID;
  129610. private _joystickColor;
  129611. private _joystickPointerPos;
  129612. private _joystickPreviousPointerPos;
  129613. private _joystickPointerStartPos;
  129614. private _deltaJoystickVector;
  129615. private _leftJoystick;
  129616. private _touches;
  129617. private _joystickPosition;
  129618. private _alwaysVisible;
  129619. private _puckImage;
  129620. private _containerImage;
  129621. private _joystickPuckSize;
  129622. private _joystickContainerSize;
  129623. private _clearPuckSize;
  129624. private _clearContainerSize;
  129625. private _clearPuckSizeOffset;
  129626. private _clearContainerSizeOffset;
  129627. private _onPointerDownHandlerRef;
  129628. private _onPointerMoveHandlerRef;
  129629. private _onPointerUpHandlerRef;
  129630. private _onResize;
  129631. /**
  129632. * Creates a new virtual joystick
  129633. * @param leftJoystick defines that the joystick is for left hand (false by default)
  129634. * @param customizations Defines the options we want to customize the VirtualJoystick
  129635. */
  129636. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  129637. /**
  129638. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  129639. * @param newJoystickSensibility defines the new sensibility
  129640. */
  129641. setJoystickSensibility(newJoystickSensibility: number): void;
  129642. private _onPointerDown;
  129643. private _onPointerMove;
  129644. private _onPointerUp;
  129645. /**
  129646. * Change the color of the virtual joystick
  129647. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  129648. */
  129649. setJoystickColor(newColor: string): void;
  129650. /**
  129651. * Size of the joystick's container
  129652. */
  129653. set containerSize(newSize: number);
  129654. get containerSize(): number;
  129655. /**
  129656. * Size of the joystick's puck
  129657. */
  129658. set puckSize(newSize: number);
  129659. get puckSize(): number;
  129660. /**
  129661. * Clears the set position of the joystick
  129662. */
  129663. clearPosition(): void;
  129664. /**
  129665. * Defines whether or not the joystick container is always visible
  129666. */
  129667. set alwaysVisible(value: boolean);
  129668. get alwaysVisible(): boolean;
  129669. /**
  129670. * Sets the constant position of the Joystick container
  129671. * @param x X axis coordinate
  129672. * @param y Y axis coordinate
  129673. */
  129674. setPosition(x: number, y: number): void;
  129675. /**
  129676. * Defines a callback to call when the joystick is touched
  129677. * @param action defines the callback
  129678. */
  129679. setActionOnTouch(action: () => any): void;
  129680. /**
  129681. * Defines which axis you'd like to control for left & right
  129682. * @param axis defines the axis to use
  129683. */
  129684. setAxisForLeftRight(axis: JoystickAxis): void;
  129685. /**
  129686. * Defines which axis you'd like to control for up & down
  129687. * @param axis defines the axis to use
  129688. */
  129689. setAxisForUpDown(axis: JoystickAxis): void;
  129690. /**
  129691. * Clears the canvas from the previous puck / container draw
  129692. */
  129693. private _clearPreviousDraw;
  129694. /**
  129695. * Loads `urlPath` to be used for the container's image
  129696. * @param urlPath defines the urlPath of an image to use
  129697. */
  129698. setContainerImage(urlPath: string): void;
  129699. /**
  129700. * Loads `urlPath` to be used for the puck's image
  129701. * @param urlPath defines the urlPath of an image to use
  129702. */
  129703. setPuckImage(urlPath: string): void;
  129704. /**
  129705. * Draws the Virtual Joystick's container
  129706. */
  129707. private _drawContainer;
  129708. /**
  129709. * Draws the Virtual Joystick's puck
  129710. */
  129711. private _drawPuck;
  129712. private _drawVirtualJoystick;
  129713. /**
  129714. * Release internal HTML canvas
  129715. */
  129716. releaseCanvas(): void;
  129717. }
  129718. }
  129719. declare module BABYLON {
  129720. interface FreeCameraInputsManager {
  129721. /**
  129722. * Add virtual joystick input support to the input manager.
  129723. * @returns the current input manager
  129724. */
  129725. addVirtualJoystick(): FreeCameraInputsManager;
  129726. }
  129727. /**
  129728. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  129729. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  129730. */
  129731. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  129732. /**
  129733. * Defines the camera the input is attached to.
  129734. */
  129735. camera: FreeCamera;
  129736. private _leftjoystick;
  129737. private _rightjoystick;
  129738. /**
  129739. * Gets the left stick of the virtual joystick.
  129740. * @returns The virtual Joystick
  129741. */
  129742. getLeftJoystick(): VirtualJoystick;
  129743. /**
  129744. * Gets the right stick of the virtual joystick.
  129745. * @returns The virtual Joystick
  129746. */
  129747. getRightJoystick(): VirtualJoystick;
  129748. /**
  129749. * Update the current camera state depending on the inputs that have been used this frame.
  129750. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  129751. */
  129752. checkInputs(): void;
  129753. /**
  129754. * Attach the input controls to a specific dom element to get the input from.
  129755. * @param element Defines the element the controls should be listened from
  129756. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  129757. */
  129758. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  129759. /**
  129760. * Detach the current controls from the specified dom element.
  129761. * @param element Defines the element to stop listening the inputs from
  129762. */
  129763. detachControl(element: Nullable<HTMLElement>): void;
  129764. /**
  129765. * Gets the class name of the current intput.
  129766. * @returns the class name
  129767. */
  129768. getClassName(): string;
  129769. /**
  129770. * Get the friendly name associated with the input class.
  129771. * @returns the input friendly name
  129772. */
  129773. getSimpleName(): string;
  129774. }
  129775. }
  129776. declare module BABYLON {
  129777. /**
  129778. * This represents a FPS type of camera controlled by touch.
  129779. * This is like a universal camera minus the Gamepad controls.
  129780. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129781. */
  129782. export class TouchCamera extends FreeCamera {
  129783. /**
  129784. * Defines the touch sensibility for rotation.
  129785. * The higher the faster.
  129786. */
  129787. get touchAngularSensibility(): number;
  129788. set touchAngularSensibility(value: number);
  129789. /**
  129790. * Defines the touch sensibility for move.
  129791. * The higher the faster.
  129792. */
  129793. get touchMoveSensibility(): number;
  129794. set touchMoveSensibility(value: number);
  129795. /**
  129796. * Instantiates a new touch camera.
  129797. * This represents a FPS type of camera controlled by touch.
  129798. * This is like a universal camera minus the Gamepad controls.
  129799. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  129800. * @param name Define the name of the camera in the scene
  129801. * @param position Define the start position of the camera in the scene
  129802. * @param scene Define the scene the camera belongs to
  129803. */
  129804. constructor(name: string, position: Vector3, scene: Scene);
  129805. /**
  129806. * Gets the current object class name.
  129807. * @return the class name
  129808. */
  129809. getClassName(): string;
  129810. /** @hidden */
  129811. _setupInputs(): void;
  129812. }
  129813. }
  129814. declare module BABYLON {
  129815. /**
  129816. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  129817. * being tilted forward or back and left or right.
  129818. */
  129819. export class DeviceOrientationCamera extends FreeCamera {
  129820. private _initialQuaternion;
  129821. private _quaternionCache;
  129822. private _tmpDragQuaternion;
  129823. private _disablePointerInputWhenUsingDeviceOrientation;
  129824. /**
  129825. * Creates a new device orientation camera
  129826. * @param name The name of the camera
  129827. * @param position The start position camera
  129828. * @param scene The scene the camera belongs to
  129829. */
  129830. constructor(name: string, position: Vector3, scene: Scene);
  129831. /**
  129832. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  129833. */
  129834. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  129835. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  129836. private _dragFactor;
  129837. /**
  129838. * Enabled turning on the y axis when the orientation sensor is active
  129839. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  129840. */
  129841. enableHorizontalDragging(dragFactor?: number): void;
  129842. /**
  129843. * Gets the current instance class name ("DeviceOrientationCamera").
  129844. * This helps avoiding instanceof at run time.
  129845. * @returns the class name
  129846. */
  129847. getClassName(): string;
  129848. /**
  129849. * @hidden
  129850. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  129851. */
  129852. _checkInputs(): void;
  129853. /**
  129854. * Reset the camera to its default orientation on the specified axis only.
  129855. * @param axis The axis to reset
  129856. */
  129857. resetToCurrentRotation(axis?: Axis): void;
  129858. }
  129859. }
  129860. declare module BABYLON {
  129861. /**
  129862. * Defines supported buttons for XBox360 compatible gamepads
  129863. */
  129864. export enum Xbox360Button {
  129865. /** A */
  129866. A = 0,
  129867. /** B */
  129868. B = 1,
  129869. /** X */
  129870. X = 2,
  129871. /** Y */
  129872. Y = 3,
  129873. /** Left button */
  129874. LB = 4,
  129875. /** Right button */
  129876. RB = 5,
  129877. /** Back */
  129878. Back = 8,
  129879. /** Start */
  129880. Start = 9,
  129881. /** Left stick */
  129882. LeftStick = 10,
  129883. /** Right stick */
  129884. RightStick = 11
  129885. }
  129886. /** Defines values for XBox360 DPad */
  129887. export enum Xbox360Dpad {
  129888. /** Up */
  129889. Up = 12,
  129890. /** Down */
  129891. Down = 13,
  129892. /** Left */
  129893. Left = 14,
  129894. /** Right */
  129895. Right = 15
  129896. }
  129897. /**
  129898. * Defines a XBox360 gamepad
  129899. */
  129900. export class Xbox360Pad extends Gamepad {
  129901. private _leftTrigger;
  129902. private _rightTrigger;
  129903. private _onlefttriggerchanged;
  129904. private _onrighttriggerchanged;
  129905. private _onbuttondown;
  129906. private _onbuttonup;
  129907. private _ondpaddown;
  129908. private _ondpadup;
  129909. /** Observable raised when a button is pressed */
  129910. onButtonDownObservable: Observable<Xbox360Button>;
  129911. /** Observable raised when a button is released */
  129912. onButtonUpObservable: Observable<Xbox360Button>;
  129913. /** Observable raised when a pad is pressed */
  129914. onPadDownObservable: Observable<Xbox360Dpad>;
  129915. /** Observable raised when a pad is released */
  129916. onPadUpObservable: Observable<Xbox360Dpad>;
  129917. private _buttonA;
  129918. private _buttonB;
  129919. private _buttonX;
  129920. private _buttonY;
  129921. private _buttonBack;
  129922. private _buttonStart;
  129923. private _buttonLB;
  129924. private _buttonRB;
  129925. private _buttonLeftStick;
  129926. private _buttonRightStick;
  129927. private _dPadUp;
  129928. private _dPadDown;
  129929. private _dPadLeft;
  129930. private _dPadRight;
  129931. private _isXboxOnePad;
  129932. /**
  129933. * Creates a new XBox360 gamepad object
  129934. * @param id defines the id of this gamepad
  129935. * @param index defines its index
  129936. * @param gamepad defines the internal HTML gamepad object
  129937. * @param xboxOne defines if it is a XBox One gamepad
  129938. */
  129939. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  129940. /**
  129941. * Defines the callback to call when left trigger is pressed
  129942. * @param callback defines the callback to use
  129943. */
  129944. onlefttriggerchanged(callback: (value: number) => void): void;
  129945. /**
  129946. * Defines the callback to call when right trigger is pressed
  129947. * @param callback defines the callback to use
  129948. */
  129949. onrighttriggerchanged(callback: (value: number) => void): void;
  129950. /**
  129951. * Gets the left trigger value
  129952. */
  129953. get leftTrigger(): number;
  129954. /**
  129955. * Sets the left trigger value
  129956. */
  129957. set leftTrigger(newValue: number);
  129958. /**
  129959. * Gets the right trigger value
  129960. */
  129961. get rightTrigger(): number;
  129962. /**
  129963. * Sets the right trigger value
  129964. */
  129965. set rightTrigger(newValue: number);
  129966. /**
  129967. * Defines the callback to call when a button is pressed
  129968. * @param callback defines the callback to use
  129969. */
  129970. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  129971. /**
  129972. * Defines the callback to call when a button is released
  129973. * @param callback defines the callback to use
  129974. */
  129975. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  129976. /**
  129977. * Defines the callback to call when a pad is pressed
  129978. * @param callback defines the callback to use
  129979. */
  129980. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  129981. /**
  129982. * Defines the callback to call when a pad is released
  129983. * @param callback defines the callback to use
  129984. */
  129985. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  129986. private _setButtonValue;
  129987. private _setDPadValue;
  129988. /**
  129989. * Gets the value of the `A` button
  129990. */
  129991. get buttonA(): number;
  129992. /**
  129993. * Sets the value of the `A` button
  129994. */
  129995. set buttonA(value: number);
  129996. /**
  129997. * Gets the value of the `B` button
  129998. */
  129999. get buttonB(): number;
  130000. /**
  130001. * Sets the value of the `B` button
  130002. */
  130003. set buttonB(value: number);
  130004. /**
  130005. * Gets the value of the `X` button
  130006. */
  130007. get buttonX(): number;
  130008. /**
  130009. * Sets the value of the `X` button
  130010. */
  130011. set buttonX(value: number);
  130012. /**
  130013. * Gets the value of the `Y` button
  130014. */
  130015. get buttonY(): number;
  130016. /**
  130017. * Sets the value of the `Y` button
  130018. */
  130019. set buttonY(value: number);
  130020. /**
  130021. * Gets the value of the `Start` button
  130022. */
  130023. get buttonStart(): number;
  130024. /**
  130025. * Sets the value of the `Start` button
  130026. */
  130027. set buttonStart(value: number);
  130028. /**
  130029. * Gets the value of the `Back` button
  130030. */
  130031. get buttonBack(): number;
  130032. /**
  130033. * Sets the value of the `Back` button
  130034. */
  130035. set buttonBack(value: number);
  130036. /**
  130037. * Gets the value of the `Left` button
  130038. */
  130039. get buttonLB(): number;
  130040. /**
  130041. * Sets the value of the `Left` button
  130042. */
  130043. set buttonLB(value: number);
  130044. /**
  130045. * Gets the value of the `Right` button
  130046. */
  130047. get buttonRB(): number;
  130048. /**
  130049. * Sets the value of the `Right` button
  130050. */
  130051. set buttonRB(value: number);
  130052. /**
  130053. * Gets the value of the Left joystick
  130054. */
  130055. get buttonLeftStick(): number;
  130056. /**
  130057. * Sets the value of the Left joystick
  130058. */
  130059. set buttonLeftStick(value: number);
  130060. /**
  130061. * Gets the value of the Right joystick
  130062. */
  130063. get buttonRightStick(): number;
  130064. /**
  130065. * Sets the value of the Right joystick
  130066. */
  130067. set buttonRightStick(value: number);
  130068. /**
  130069. * Gets the value of D-pad up
  130070. */
  130071. get dPadUp(): number;
  130072. /**
  130073. * Sets the value of D-pad up
  130074. */
  130075. set dPadUp(value: number);
  130076. /**
  130077. * Gets the value of D-pad down
  130078. */
  130079. get dPadDown(): number;
  130080. /**
  130081. * Sets the value of D-pad down
  130082. */
  130083. set dPadDown(value: number);
  130084. /**
  130085. * Gets the value of D-pad left
  130086. */
  130087. get dPadLeft(): number;
  130088. /**
  130089. * Sets the value of D-pad left
  130090. */
  130091. set dPadLeft(value: number);
  130092. /**
  130093. * Gets the value of D-pad right
  130094. */
  130095. get dPadRight(): number;
  130096. /**
  130097. * Sets the value of D-pad right
  130098. */
  130099. set dPadRight(value: number);
  130100. /**
  130101. * Force the gamepad to synchronize with device values
  130102. */
  130103. update(): void;
  130104. /**
  130105. * Disposes the gamepad
  130106. */
  130107. dispose(): void;
  130108. }
  130109. }
  130110. declare module BABYLON {
  130111. /**
  130112. * Defines supported buttons for DualShock compatible gamepads
  130113. */
  130114. export enum DualShockButton {
  130115. /** Cross */
  130116. Cross = 0,
  130117. /** Circle */
  130118. Circle = 1,
  130119. /** Square */
  130120. Square = 2,
  130121. /** Triangle */
  130122. Triangle = 3,
  130123. /** L1 */
  130124. L1 = 4,
  130125. /** R1 */
  130126. R1 = 5,
  130127. /** Share */
  130128. Share = 8,
  130129. /** Options */
  130130. Options = 9,
  130131. /** Left stick */
  130132. LeftStick = 10,
  130133. /** Right stick */
  130134. RightStick = 11
  130135. }
  130136. /** Defines values for DualShock DPad */
  130137. export enum DualShockDpad {
  130138. /** Up */
  130139. Up = 12,
  130140. /** Down */
  130141. Down = 13,
  130142. /** Left */
  130143. Left = 14,
  130144. /** Right */
  130145. Right = 15
  130146. }
  130147. /**
  130148. * Defines a DualShock gamepad
  130149. */
  130150. export class DualShockPad extends Gamepad {
  130151. private _leftTrigger;
  130152. private _rightTrigger;
  130153. private _onlefttriggerchanged;
  130154. private _onrighttriggerchanged;
  130155. private _onbuttondown;
  130156. private _onbuttonup;
  130157. private _ondpaddown;
  130158. private _ondpadup;
  130159. /** Observable raised when a button is pressed */
  130160. onButtonDownObservable: Observable<DualShockButton>;
  130161. /** Observable raised when a button is released */
  130162. onButtonUpObservable: Observable<DualShockButton>;
  130163. /** Observable raised when a pad is pressed */
  130164. onPadDownObservable: Observable<DualShockDpad>;
  130165. /** Observable raised when a pad is released */
  130166. onPadUpObservable: Observable<DualShockDpad>;
  130167. private _buttonCross;
  130168. private _buttonCircle;
  130169. private _buttonSquare;
  130170. private _buttonTriangle;
  130171. private _buttonShare;
  130172. private _buttonOptions;
  130173. private _buttonL1;
  130174. private _buttonR1;
  130175. private _buttonLeftStick;
  130176. private _buttonRightStick;
  130177. private _dPadUp;
  130178. private _dPadDown;
  130179. private _dPadLeft;
  130180. private _dPadRight;
  130181. /**
  130182. * Creates a new DualShock gamepad object
  130183. * @param id defines the id of this gamepad
  130184. * @param index defines its index
  130185. * @param gamepad defines the internal HTML gamepad object
  130186. */
  130187. constructor(id: string, index: number, gamepad: any);
  130188. /**
  130189. * Defines the callback to call when left trigger is pressed
  130190. * @param callback defines the callback to use
  130191. */
  130192. onlefttriggerchanged(callback: (value: number) => void): void;
  130193. /**
  130194. * Defines the callback to call when right trigger is pressed
  130195. * @param callback defines the callback to use
  130196. */
  130197. onrighttriggerchanged(callback: (value: number) => void): void;
  130198. /**
  130199. * Gets the left trigger value
  130200. */
  130201. get leftTrigger(): number;
  130202. /**
  130203. * Sets the left trigger value
  130204. */
  130205. set leftTrigger(newValue: number);
  130206. /**
  130207. * Gets the right trigger value
  130208. */
  130209. get rightTrigger(): number;
  130210. /**
  130211. * Sets the right trigger value
  130212. */
  130213. set rightTrigger(newValue: number);
  130214. /**
  130215. * Defines the callback to call when a button is pressed
  130216. * @param callback defines the callback to use
  130217. */
  130218. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  130219. /**
  130220. * Defines the callback to call when a button is released
  130221. * @param callback defines the callback to use
  130222. */
  130223. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  130224. /**
  130225. * Defines the callback to call when a pad is pressed
  130226. * @param callback defines the callback to use
  130227. */
  130228. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  130229. /**
  130230. * Defines the callback to call when a pad is released
  130231. * @param callback defines the callback to use
  130232. */
  130233. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  130234. private _setButtonValue;
  130235. private _setDPadValue;
  130236. /**
  130237. * Gets the value of the `Cross` button
  130238. */
  130239. get buttonCross(): number;
  130240. /**
  130241. * Sets the value of the `Cross` button
  130242. */
  130243. set buttonCross(value: number);
  130244. /**
  130245. * Gets the value of the `Circle` button
  130246. */
  130247. get buttonCircle(): number;
  130248. /**
  130249. * Sets the value of the `Circle` button
  130250. */
  130251. set buttonCircle(value: number);
  130252. /**
  130253. * Gets the value of the `Square` button
  130254. */
  130255. get buttonSquare(): number;
  130256. /**
  130257. * Sets the value of the `Square` button
  130258. */
  130259. set buttonSquare(value: number);
  130260. /**
  130261. * Gets the value of the `Triangle` button
  130262. */
  130263. get buttonTriangle(): number;
  130264. /**
  130265. * Sets the value of the `Triangle` button
  130266. */
  130267. set buttonTriangle(value: number);
  130268. /**
  130269. * Gets the value of the `Options` button
  130270. */
  130271. get buttonOptions(): number;
  130272. /**
  130273. * Sets the value of the `Options` button
  130274. */
  130275. set buttonOptions(value: number);
  130276. /**
  130277. * Gets the value of the `Share` button
  130278. */
  130279. get buttonShare(): number;
  130280. /**
  130281. * Sets the value of the `Share` button
  130282. */
  130283. set buttonShare(value: number);
  130284. /**
  130285. * Gets the value of the `L1` button
  130286. */
  130287. get buttonL1(): number;
  130288. /**
  130289. * Sets the value of the `L1` button
  130290. */
  130291. set buttonL1(value: number);
  130292. /**
  130293. * Gets the value of the `R1` button
  130294. */
  130295. get buttonR1(): number;
  130296. /**
  130297. * Sets the value of the `R1` button
  130298. */
  130299. set buttonR1(value: number);
  130300. /**
  130301. * Gets the value of the Left joystick
  130302. */
  130303. get buttonLeftStick(): number;
  130304. /**
  130305. * Sets the value of the Left joystick
  130306. */
  130307. set buttonLeftStick(value: number);
  130308. /**
  130309. * Gets the value of the Right joystick
  130310. */
  130311. get buttonRightStick(): number;
  130312. /**
  130313. * Sets the value of the Right joystick
  130314. */
  130315. set buttonRightStick(value: number);
  130316. /**
  130317. * Gets the value of D-pad up
  130318. */
  130319. get dPadUp(): number;
  130320. /**
  130321. * Sets the value of D-pad up
  130322. */
  130323. set dPadUp(value: number);
  130324. /**
  130325. * Gets the value of D-pad down
  130326. */
  130327. get dPadDown(): number;
  130328. /**
  130329. * Sets the value of D-pad down
  130330. */
  130331. set dPadDown(value: number);
  130332. /**
  130333. * Gets the value of D-pad left
  130334. */
  130335. get dPadLeft(): number;
  130336. /**
  130337. * Sets the value of D-pad left
  130338. */
  130339. set dPadLeft(value: number);
  130340. /**
  130341. * Gets the value of D-pad right
  130342. */
  130343. get dPadRight(): number;
  130344. /**
  130345. * Sets the value of D-pad right
  130346. */
  130347. set dPadRight(value: number);
  130348. /**
  130349. * Force the gamepad to synchronize with device values
  130350. */
  130351. update(): void;
  130352. /**
  130353. * Disposes the gamepad
  130354. */
  130355. dispose(): void;
  130356. }
  130357. }
  130358. declare module BABYLON {
  130359. /**
  130360. * Manager for handling gamepads
  130361. */
  130362. export class GamepadManager {
  130363. private _scene?;
  130364. private _babylonGamepads;
  130365. private _oneGamepadConnected;
  130366. /** @hidden */
  130367. _isMonitoring: boolean;
  130368. private _gamepadEventSupported;
  130369. private _gamepadSupport?;
  130370. /**
  130371. * observable to be triggered when the gamepad controller has been connected
  130372. */
  130373. onGamepadConnectedObservable: Observable<Gamepad>;
  130374. /**
  130375. * observable to be triggered when the gamepad controller has been disconnected
  130376. */
  130377. onGamepadDisconnectedObservable: Observable<Gamepad>;
  130378. private _onGamepadConnectedEvent;
  130379. private _onGamepadDisconnectedEvent;
  130380. /**
  130381. * Initializes the gamepad manager
  130382. * @param _scene BabylonJS scene
  130383. */
  130384. constructor(_scene?: Scene | undefined);
  130385. /**
  130386. * The gamepads in the game pad manager
  130387. */
  130388. get gamepads(): Gamepad[];
  130389. /**
  130390. * Get the gamepad controllers based on type
  130391. * @param type The type of gamepad controller
  130392. * @returns Nullable gamepad
  130393. */
  130394. getGamepadByType(type?: number): Nullable<Gamepad>;
  130395. /**
  130396. * Disposes the gamepad manager
  130397. */
  130398. dispose(): void;
  130399. private _addNewGamepad;
  130400. private _startMonitoringGamepads;
  130401. private _stopMonitoringGamepads;
  130402. /** @hidden */
  130403. _checkGamepadsStatus(): void;
  130404. private _updateGamepadObjects;
  130405. }
  130406. }
  130407. declare module BABYLON {
  130408. interface Scene {
  130409. /** @hidden */
  130410. _gamepadManager: Nullable<GamepadManager>;
  130411. /**
  130412. * Gets the gamepad manager associated with the scene
  130413. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  130414. */
  130415. gamepadManager: GamepadManager;
  130416. }
  130417. /**
  130418. * Interface representing a free camera inputs manager
  130419. */
  130420. interface FreeCameraInputsManager {
  130421. /**
  130422. * Adds gamepad input support to the FreeCameraInputsManager.
  130423. * @returns the FreeCameraInputsManager
  130424. */
  130425. addGamepad(): FreeCameraInputsManager;
  130426. }
  130427. /**
  130428. * Interface representing an arc rotate camera inputs manager
  130429. */
  130430. interface ArcRotateCameraInputsManager {
  130431. /**
  130432. * Adds gamepad input support to the ArcRotateCamera InputManager.
  130433. * @returns the camera inputs manager
  130434. */
  130435. addGamepad(): ArcRotateCameraInputsManager;
  130436. }
  130437. /**
  130438. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  130439. */
  130440. export class GamepadSystemSceneComponent implements ISceneComponent {
  130441. /**
  130442. * The component name helpfull to identify the component in the list of scene components.
  130443. */
  130444. readonly name: string;
  130445. /**
  130446. * The scene the component belongs to.
  130447. */
  130448. scene: Scene;
  130449. /**
  130450. * Creates a new instance of the component for the given scene
  130451. * @param scene Defines the scene to register the component in
  130452. */
  130453. constructor(scene: Scene);
  130454. /**
  130455. * Registers the component in a given scene
  130456. */
  130457. register(): void;
  130458. /**
  130459. * Rebuilds the elements related to this component in case of
  130460. * context lost for instance.
  130461. */
  130462. rebuild(): void;
  130463. /**
  130464. * Disposes the component and the associated ressources
  130465. */
  130466. dispose(): void;
  130467. private _beforeCameraUpdate;
  130468. }
  130469. }
  130470. declare module BABYLON {
  130471. /**
  130472. * 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,
  130473. * which still works and will still be found in many Playgrounds.
  130474. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130475. */
  130476. export class UniversalCamera extends TouchCamera {
  130477. /**
  130478. * Defines the gamepad rotation sensiblity.
  130479. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  130480. */
  130481. get gamepadAngularSensibility(): number;
  130482. set gamepadAngularSensibility(value: number);
  130483. /**
  130484. * Defines the gamepad move sensiblity.
  130485. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  130486. */
  130487. get gamepadMoveSensibility(): number;
  130488. set gamepadMoveSensibility(value: number);
  130489. /**
  130490. * 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,
  130491. * which still works and will still be found in many Playgrounds.
  130492. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130493. * @param name Define the name of the camera in the scene
  130494. * @param position Define the start position of the camera in the scene
  130495. * @param scene Define the scene the camera belongs to
  130496. */
  130497. constructor(name: string, position: Vector3, scene: Scene);
  130498. /**
  130499. * Gets the current object class name.
  130500. * @return the class name
  130501. */
  130502. getClassName(): string;
  130503. }
  130504. }
  130505. declare module BABYLON {
  130506. /**
  130507. * This represents a FPS type of camera. This is only here for back compat purpose.
  130508. * Please use the UniversalCamera instead as both are identical.
  130509. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130510. */
  130511. export class GamepadCamera extends UniversalCamera {
  130512. /**
  130513. * Instantiates a new Gamepad Camera
  130514. * This represents a FPS type of camera. This is only here for back compat purpose.
  130515. * Please use the UniversalCamera instead as both are identical.
  130516. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  130517. * @param name Define the name of the camera in the scene
  130518. * @param position Define the start position of the camera in the scene
  130519. * @param scene Define the scene the camera belongs to
  130520. */
  130521. constructor(name: string, position: Vector3, scene: Scene);
  130522. /**
  130523. * Gets the current object class name.
  130524. * @return the class name
  130525. */
  130526. getClassName(): string;
  130527. }
  130528. }
  130529. declare module BABYLON {
  130530. /** @hidden */
  130531. export var passPixelShader: {
  130532. name: string;
  130533. shader: string;
  130534. };
  130535. }
  130536. declare module BABYLON {
  130537. /** @hidden */
  130538. export var passCubePixelShader: {
  130539. name: string;
  130540. shader: string;
  130541. };
  130542. }
  130543. declare module BABYLON {
  130544. /**
  130545. * PassPostProcess which produces an output the same as it's input
  130546. */
  130547. export class PassPostProcess extends PostProcess {
  130548. /**
  130549. * Gets a string identifying the name of the class
  130550. * @returns "PassPostProcess" string
  130551. */
  130552. getClassName(): string;
  130553. /**
  130554. * Creates the PassPostProcess
  130555. * @param name The name of the effect.
  130556. * @param options The required width/height ratio to downsize to before computing the render pass.
  130557. * @param camera The camera to apply the render pass to.
  130558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130559. * @param engine The engine which the post process will be applied. (default: current engine)
  130560. * @param reusable If the post process can be reused on the same frame. (default: false)
  130561. * @param textureType The type of texture to be used when performing the post processing.
  130562. * @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)
  130563. */
  130564. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130565. /** @hidden */
  130566. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  130567. }
  130568. /**
  130569. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  130570. */
  130571. export class PassCubePostProcess extends PostProcess {
  130572. private _face;
  130573. /**
  130574. * Gets or sets the cube face to display.
  130575. * * 0 is +X
  130576. * * 1 is -X
  130577. * * 2 is +Y
  130578. * * 3 is -Y
  130579. * * 4 is +Z
  130580. * * 5 is -Z
  130581. */
  130582. get face(): number;
  130583. set face(value: number);
  130584. /**
  130585. * Gets a string identifying the name of the class
  130586. * @returns "PassCubePostProcess" string
  130587. */
  130588. getClassName(): string;
  130589. /**
  130590. * Creates the PassCubePostProcess
  130591. * @param name The name of the effect.
  130592. * @param options The required width/height ratio to downsize to before computing the render pass.
  130593. * @param camera The camera to apply the render pass to.
  130594. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  130595. * @param engine The engine which the post process will be applied. (default: current engine)
  130596. * @param reusable If the post process can be reused on the same frame. (default: false)
  130597. * @param textureType The type of texture to be used when performing the post processing.
  130598. * @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)
  130599. */
  130600. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  130601. /** @hidden */
  130602. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  130603. }
  130604. }
  130605. declare module BABYLON {
  130606. /** @hidden */
  130607. export var anaglyphPixelShader: {
  130608. name: string;
  130609. shader: string;
  130610. };
  130611. }
  130612. declare module BABYLON {
  130613. /**
  130614. * Postprocess used to generate anaglyphic rendering
  130615. */
  130616. export class AnaglyphPostProcess extends PostProcess {
  130617. private _passedProcess;
  130618. /**
  130619. * Gets a string identifying the name of the class
  130620. * @returns "AnaglyphPostProcess" string
  130621. */
  130622. getClassName(): string;
  130623. /**
  130624. * Creates a new AnaglyphPostProcess
  130625. * @param name defines postprocess name
  130626. * @param options defines creation options or target ratio scale
  130627. * @param rigCameras defines cameras using this postprocess
  130628. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  130629. * @param engine defines hosting engine
  130630. * @param reusable defines if the postprocess will be reused multiple times per frame
  130631. */
  130632. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  130633. }
  130634. }
  130635. declare module BABYLON {
  130636. /**
  130637. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  130638. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130639. */
  130640. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  130641. /**
  130642. * Creates a new AnaglyphArcRotateCamera
  130643. * @param name defines camera name
  130644. * @param alpha defines alpha angle (in radians)
  130645. * @param beta defines beta angle (in radians)
  130646. * @param radius defines radius
  130647. * @param target defines camera target
  130648. * @param interaxialDistance defines distance between each color axis
  130649. * @param scene defines the hosting scene
  130650. */
  130651. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  130652. /**
  130653. * Gets camera class name
  130654. * @returns AnaglyphArcRotateCamera
  130655. */
  130656. getClassName(): string;
  130657. }
  130658. }
  130659. declare module BABYLON {
  130660. /**
  130661. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  130662. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130663. */
  130664. export class AnaglyphFreeCamera extends FreeCamera {
  130665. /**
  130666. * Creates a new AnaglyphFreeCamera
  130667. * @param name defines camera name
  130668. * @param position defines initial position
  130669. * @param interaxialDistance defines distance between each color axis
  130670. * @param scene defines the hosting scene
  130671. */
  130672. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130673. /**
  130674. * Gets camera class name
  130675. * @returns AnaglyphFreeCamera
  130676. */
  130677. getClassName(): string;
  130678. }
  130679. }
  130680. declare module BABYLON {
  130681. /**
  130682. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  130683. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130684. */
  130685. export class AnaglyphGamepadCamera extends GamepadCamera {
  130686. /**
  130687. * Creates a new AnaglyphGamepadCamera
  130688. * @param name defines camera name
  130689. * @param position defines initial position
  130690. * @param interaxialDistance defines distance between each color axis
  130691. * @param scene defines the hosting scene
  130692. */
  130693. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130694. /**
  130695. * Gets camera class name
  130696. * @returns AnaglyphGamepadCamera
  130697. */
  130698. getClassName(): string;
  130699. }
  130700. }
  130701. declare module BABYLON {
  130702. /**
  130703. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  130704. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  130705. */
  130706. export class AnaglyphUniversalCamera extends UniversalCamera {
  130707. /**
  130708. * Creates a new AnaglyphUniversalCamera
  130709. * @param name defines camera name
  130710. * @param position defines initial position
  130711. * @param interaxialDistance defines distance between each color axis
  130712. * @param scene defines the hosting scene
  130713. */
  130714. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  130715. /**
  130716. * Gets camera class name
  130717. * @returns AnaglyphUniversalCamera
  130718. */
  130719. getClassName(): string;
  130720. }
  130721. }
  130722. declare module BABYLON {
  130723. /**
  130724. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  130725. * @see https://doc.babylonjs.com/features/cameras
  130726. */
  130727. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  130728. /**
  130729. * Creates a new StereoscopicArcRotateCamera
  130730. * @param name defines camera name
  130731. * @param alpha defines alpha angle (in radians)
  130732. * @param beta defines beta angle (in radians)
  130733. * @param radius defines radius
  130734. * @param target defines camera target
  130735. * @param interaxialDistance defines distance between each color axis
  130736. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130737. * @param scene defines the hosting scene
  130738. */
  130739. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130740. /**
  130741. * Gets camera class name
  130742. * @returns StereoscopicArcRotateCamera
  130743. */
  130744. getClassName(): string;
  130745. }
  130746. }
  130747. declare module BABYLON {
  130748. /**
  130749. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  130750. * @see https://doc.babylonjs.com/features/cameras
  130751. */
  130752. export class StereoscopicFreeCamera extends FreeCamera {
  130753. /**
  130754. * Creates a new StereoscopicFreeCamera
  130755. * @param name defines camera name
  130756. * @param position defines initial position
  130757. * @param interaxialDistance defines distance between each color axis
  130758. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130759. * @param scene defines the hosting scene
  130760. */
  130761. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130762. /**
  130763. * Gets camera class name
  130764. * @returns StereoscopicFreeCamera
  130765. */
  130766. getClassName(): string;
  130767. }
  130768. }
  130769. declare module BABYLON {
  130770. /**
  130771. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  130772. * @see https://doc.babylonjs.com/features/cameras
  130773. */
  130774. export class StereoscopicGamepadCamera extends GamepadCamera {
  130775. /**
  130776. * Creates a new StereoscopicGamepadCamera
  130777. * @param name defines camera name
  130778. * @param position defines initial position
  130779. * @param interaxialDistance defines distance between each color axis
  130780. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130781. * @param scene defines the hosting scene
  130782. */
  130783. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130784. /**
  130785. * Gets camera class name
  130786. * @returns StereoscopicGamepadCamera
  130787. */
  130788. getClassName(): string;
  130789. }
  130790. }
  130791. declare module BABYLON {
  130792. /**
  130793. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  130794. * @see https://doc.babylonjs.com/features/cameras
  130795. */
  130796. export class StereoscopicUniversalCamera extends UniversalCamera {
  130797. /**
  130798. * Creates a new StereoscopicUniversalCamera
  130799. * @param name defines camera name
  130800. * @param position defines initial position
  130801. * @param interaxialDistance defines distance between each color axis
  130802. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  130803. * @param scene defines the hosting scene
  130804. */
  130805. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  130806. /**
  130807. * Gets camera class name
  130808. * @returns StereoscopicUniversalCamera
  130809. */
  130810. getClassName(): string;
  130811. }
  130812. }
  130813. declare module BABYLON {
  130814. /**
  130815. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  130816. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130817. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130818. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130819. */
  130820. export class VirtualJoysticksCamera extends FreeCamera {
  130821. /**
  130822. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  130823. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  130824. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  130825. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  130826. * @param name Define the name of the camera in the scene
  130827. * @param position Define the start position of the camera in the scene
  130828. * @param scene Define the scene the camera belongs to
  130829. */
  130830. constructor(name: string, position: Vector3, scene: Scene);
  130831. /**
  130832. * Gets the current object class name.
  130833. * @return the class name
  130834. */
  130835. getClassName(): string;
  130836. }
  130837. }
  130838. declare module BABYLON {
  130839. /**
  130840. * This represents all the required metrics to create a VR camera.
  130841. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  130842. */
  130843. export class VRCameraMetrics {
  130844. /**
  130845. * Define the horizontal resolution off the screen.
  130846. */
  130847. hResolution: number;
  130848. /**
  130849. * Define the vertical resolution off the screen.
  130850. */
  130851. vResolution: number;
  130852. /**
  130853. * Define the horizontal screen size.
  130854. */
  130855. hScreenSize: number;
  130856. /**
  130857. * Define the vertical screen size.
  130858. */
  130859. vScreenSize: number;
  130860. /**
  130861. * Define the vertical screen center position.
  130862. */
  130863. vScreenCenter: number;
  130864. /**
  130865. * Define the distance of the eyes to the screen.
  130866. */
  130867. eyeToScreenDistance: number;
  130868. /**
  130869. * Define the distance between both lenses
  130870. */
  130871. lensSeparationDistance: number;
  130872. /**
  130873. * Define the distance between both viewer's eyes.
  130874. */
  130875. interpupillaryDistance: number;
  130876. /**
  130877. * Define the distortion factor of the VR postprocess.
  130878. * Please, touch with care.
  130879. */
  130880. distortionK: number[];
  130881. /**
  130882. * Define the chromatic aberration correction factors for the VR post process.
  130883. */
  130884. chromaAbCorrection: number[];
  130885. /**
  130886. * Define the scale factor of the post process.
  130887. * The smaller the better but the slower.
  130888. */
  130889. postProcessScaleFactor: number;
  130890. /**
  130891. * Define an offset for the lens center.
  130892. */
  130893. lensCenterOffset: number;
  130894. /**
  130895. * Define if the current vr camera should compensate the distortion of the lense or not.
  130896. */
  130897. compensateDistortion: boolean;
  130898. /**
  130899. * Defines if multiview should be enabled when rendering (Default: false)
  130900. */
  130901. multiviewEnabled: boolean;
  130902. /**
  130903. * Gets the rendering aspect ratio based on the provided resolutions.
  130904. */
  130905. get aspectRatio(): number;
  130906. /**
  130907. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  130908. */
  130909. get aspectRatioFov(): number;
  130910. /**
  130911. * @hidden
  130912. */
  130913. get leftHMatrix(): Matrix;
  130914. /**
  130915. * @hidden
  130916. */
  130917. get rightHMatrix(): Matrix;
  130918. /**
  130919. * @hidden
  130920. */
  130921. get leftPreViewMatrix(): Matrix;
  130922. /**
  130923. * @hidden
  130924. */
  130925. get rightPreViewMatrix(): Matrix;
  130926. /**
  130927. * Get the default VRMetrics based on the most generic setup.
  130928. * @returns the default vr metrics
  130929. */
  130930. static GetDefault(): VRCameraMetrics;
  130931. }
  130932. }
  130933. declare module BABYLON {
  130934. /** @hidden */
  130935. export var vrDistortionCorrectionPixelShader: {
  130936. name: string;
  130937. shader: string;
  130938. };
  130939. }
  130940. declare module BABYLON {
  130941. /**
  130942. * VRDistortionCorrectionPostProcess used for mobile VR
  130943. */
  130944. export class VRDistortionCorrectionPostProcess extends PostProcess {
  130945. private _isRightEye;
  130946. private _distortionFactors;
  130947. private _postProcessScaleFactor;
  130948. private _lensCenterOffset;
  130949. private _scaleIn;
  130950. private _scaleFactor;
  130951. private _lensCenter;
  130952. /**
  130953. * Gets a string identifying the name of the class
  130954. * @returns "VRDistortionCorrectionPostProcess" string
  130955. */
  130956. getClassName(): string;
  130957. /**
  130958. * Initializes the VRDistortionCorrectionPostProcess
  130959. * @param name The name of the effect.
  130960. * @param camera The camera to apply the render pass to.
  130961. * @param isRightEye If this is for the right eye distortion
  130962. * @param vrMetrics All the required metrics for the VR camera
  130963. */
  130964. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  130965. }
  130966. }
  130967. declare module BABYLON {
  130968. /**
  130969. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  130970. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130971. */
  130972. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  130973. /**
  130974. * Creates a new VRDeviceOrientationArcRotateCamera
  130975. * @param name defines camera name
  130976. * @param alpha defines the camera rotation along the logitudinal axis
  130977. * @param beta defines the camera rotation along the latitudinal axis
  130978. * @param radius defines the camera distance from its target
  130979. * @param target defines the camera target
  130980. * @param scene defines the scene the camera belongs to
  130981. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  130982. * @param vrCameraMetrics defines the vr metrics associated to the camera
  130983. */
  130984. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  130985. /**
  130986. * Gets camera class name
  130987. * @returns VRDeviceOrientationArcRotateCamera
  130988. */
  130989. getClassName(): string;
  130990. }
  130991. }
  130992. declare module BABYLON {
  130993. /**
  130994. * Camera used to simulate VR rendering (based on FreeCamera)
  130995. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  130996. */
  130997. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  130998. /**
  130999. * Creates a new VRDeviceOrientationFreeCamera
  131000. * @param name defines camera name
  131001. * @param position defines the start position of the camera
  131002. * @param scene defines the scene the camera belongs to
  131003. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131004. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131005. */
  131006. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131007. /**
  131008. * Gets camera class name
  131009. * @returns VRDeviceOrientationFreeCamera
  131010. */
  131011. getClassName(): string;
  131012. }
  131013. }
  131014. declare module BABYLON {
  131015. /**
  131016. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  131017. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  131018. */
  131019. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  131020. /**
  131021. * Creates a new VRDeviceOrientationGamepadCamera
  131022. * @param name defines camera name
  131023. * @param position defines the start position of the camera
  131024. * @param scene defines the scene the camera belongs to
  131025. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  131026. * @param vrCameraMetrics defines the vr metrics associated to the camera
  131027. */
  131028. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  131029. /**
  131030. * Gets camera class name
  131031. * @returns VRDeviceOrientationGamepadCamera
  131032. */
  131033. getClassName(): string;
  131034. }
  131035. }
  131036. declare module BABYLON {
  131037. /**
  131038. * A class extending Texture allowing drawing on a texture
  131039. * @see https://doc.babylonjs.com/how_to/dynamictexture
  131040. */
  131041. export class DynamicTexture extends Texture {
  131042. private _generateMipMaps;
  131043. private _canvas;
  131044. private _context;
  131045. /**
  131046. * Creates a DynamicTexture
  131047. * @param name defines the name of the texture
  131048. * @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
  131049. * @param scene defines the scene where you want the texture
  131050. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  131051. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  131052. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  131053. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  131054. */
  131055. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  131056. /**
  131057. * Get the current class name of the texture useful for serialization or dynamic coding.
  131058. * @returns "DynamicTexture"
  131059. */
  131060. getClassName(): string;
  131061. /**
  131062. * Gets the current state of canRescale
  131063. */
  131064. get canRescale(): boolean;
  131065. private _recreate;
  131066. /**
  131067. * Scales the texture
  131068. * @param ratio the scale factor to apply to both width and height
  131069. */
  131070. scale(ratio: number): void;
  131071. /**
  131072. * Resizes the texture
  131073. * @param width the new width
  131074. * @param height the new height
  131075. */
  131076. scaleTo(width: number, height: number): void;
  131077. /**
  131078. * Gets the context of the canvas used by the texture
  131079. * @returns the canvas context of the dynamic texture
  131080. */
  131081. getContext(): CanvasRenderingContext2D;
  131082. /**
  131083. * Clears the texture
  131084. */
  131085. clear(): void;
  131086. /**
  131087. * Updates the texture
  131088. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131089. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  131090. */
  131091. update(invertY?: boolean, premulAlpha?: boolean): void;
  131092. /**
  131093. * Draws text onto the texture
  131094. * @param text defines the text to be drawn
  131095. * @param x defines the placement of the text from the left
  131096. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  131097. * @param font defines the font to be used with font-style, font-size, font-name
  131098. * @param color defines the color used for the text
  131099. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  131100. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  131101. * @param update defines whether texture is immediately update (default is true)
  131102. */
  131103. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  131104. /**
  131105. * Clones the texture
  131106. * @returns the clone of the texture.
  131107. */
  131108. clone(): DynamicTexture;
  131109. /**
  131110. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  131111. * @returns a serialized dynamic texture object
  131112. */
  131113. serialize(): any;
  131114. private _IsCanvasElement;
  131115. /** @hidden */
  131116. _rebuild(): void;
  131117. }
  131118. }
  131119. declare module BABYLON {
  131120. /**
  131121. * Class containing static functions to help procedurally build meshes
  131122. */
  131123. export class GroundBuilder {
  131124. /**
  131125. * Creates a ground mesh
  131126. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  131127. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  131128. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131129. * @param name defines the name of the mesh
  131130. * @param options defines the options used to create the mesh
  131131. * @param scene defines the hosting scene
  131132. * @returns the ground mesh
  131133. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  131134. */
  131135. static CreateGround(name: string, options: {
  131136. width?: number;
  131137. height?: number;
  131138. subdivisions?: number;
  131139. subdivisionsX?: number;
  131140. subdivisionsY?: number;
  131141. updatable?: boolean;
  131142. }, scene: any): Mesh;
  131143. /**
  131144. * Creates a tiled ground mesh
  131145. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  131146. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  131147. * * 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
  131148. * * 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
  131149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131150. * @param name defines the name of the mesh
  131151. * @param options defines the options used to create the mesh
  131152. * @param scene defines the hosting scene
  131153. * @returns the tiled ground mesh
  131154. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  131155. */
  131156. static CreateTiledGround(name: string, options: {
  131157. xmin: number;
  131158. zmin: number;
  131159. xmax: number;
  131160. zmax: number;
  131161. subdivisions?: {
  131162. w: number;
  131163. h: number;
  131164. };
  131165. precision?: {
  131166. w: number;
  131167. h: number;
  131168. };
  131169. updatable?: boolean;
  131170. }, scene?: Nullable<Scene>): Mesh;
  131171. /**
  131172. * Creates a ground mesh from a height map
  131173. * * The parameter `url` sets the URL of the height map image resource.
  131174. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  131175. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  131176. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  131177. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  131178. * * 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.
  131179. * * 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).
  131180. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  131181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131182. * @param name defines the name of the mesh
  131183. * @param url defines the url to the height map
  131184. * @param options defines the options used to create the mesh
  131185. * @param scene defines the hosting scene
  131186. * @returns the ground mesh
  131187. * @see https://doc.babylonjs.com/babylon101/height_map
  131188. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  131189. */
  131190. static CreateGroundFromHeightMap(name: string, url: string, options: {
  131191. width?: number;
  131192. height?: number;
  131193. subdivisions?: number;
  131194. minHeight?: number;
  131195. maxHeight?: number;
  131196. colorFilter?: Color3;
  131197. alphaFilter?: number;
  131198. updatable?: boolean;
  131199. onReady?: (mesh: GroundMesh) => void;
  131200. }, scene?: Nullable<Scene>): GroundMesh;
  131201. }
  131202. }
  131203. declare module BABYLON {
  131204. /**
  131205. * Class containing static functions to help procedurally build meshes
  131206. */
  131207. export class TorusBuilder {
  131208. /**
  131209. * Creates a torus mesh
  131210. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  131211. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  131212. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  131213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131214. * * 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
  131215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131216. * @param name defines the name of the mesh
  131217. * @param options defines the options used to create the mesh
  131218. * @param scene defines the hosting scene
  131219. * @returns the torus mesh
  131220. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  131221. */
  131222. static CreateTorus(name: string, options: {
  131223. diameter?: number;
  131224. thickness?: number;
  131225. tessellation?: number;
  131226. updatable?: boolean;
  131227. sideOrientation?: number;
  131228. frontUVs?: Vector4;
  131229. backUVs?: Vector4;
  131230. }, scene: any): Mesh;
  131231. }
  131232. }
  131233. declare module BABYLON {
  131234. /**
  131235. * Class containing static functions to help procedurally build meshes
  131236. */
  131237. export class CylinderBuilder {
  131238. /**
  131239. * Creates a cylinder or a cone mesh
  131240. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  131241. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  131242. * * 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.
  131243. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  131244. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  131245. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  131246. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  131247. * * 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).
  131248. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  131249. * * 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).
  131250. * * 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
  131251. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  131252. * * 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
  131253. * * 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.
  131254. * * If `enclose` is false, a ring surface is one element.
  131255. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  131256. * * 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
  131257. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131258. * * 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
  131259. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131260. * @param name defines the name of the mesh
  131261. * @param options defines the options used to create the mesh
  131262. * @param scene defines the hosting scene
  131263. * @returns the cylinder mesh
  131264. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  131265. */
  131266. static CreateCylinder(name: string, options: {
  131267. height?: number;
  131268. diameterTop?: number;
  131269. diameterBottom?: number;
  131270. diameter?: number;
  131271. tessellation?: number;
  131272. subdivisions?: number;
  131273. arc?: number;
  131274. faceColors?: Color4[];
  131275. faceUV?: Vector4[];
  131276. updatable?: boolean;
  131277. hasRings?: boolean;
  131278. enclose?: boolean;
  131279. cap?: number;
  131280. sideOrientation?: number;
  131281. frontUVs?: Vector4;
  131282. backUVs?: Vector4;
  131283. }, scene: any): Mesh;
  131284. }
  131285. }
  131286. declare module BABYLON {
  131287. /**
  131288. * States of the webXR experience
  131289. */
  131290. export enum WebXRState {
  131291. /**
  131292. * Transitioning to being in XR mode
  131293. */
  131294. ENTERING_XR = 0,
  131295. /**
  131296. * Transitioning to non XR mode
  131297. */
  131298. EXITING_XR = 1,
  131299. /**
  131300. * In XR mode and presenting
  131301. */
  131302. IN_XR = 2,
  131303. /**
  131304. * Not entered XR mode
  131305. */
  131306. NOT_IN_XR = 3
  131307. }
  131308. /**
  131309. * The state of the XR camera's tracking
  131310. */
  131311. export enum WebXRTrackingState {
  131312. /**
  131313. * No transformation received, device is not being tracked
  131314. */
  131315. NOT_TRACKING = 0,
  131316. /**
  131317. * Tracking lost - using emulated position
  131318. */
  131319. TRACKING_LOST = 1,
  131320. /**
  131321. * Transformation tracking works normally
  131322. */
  131323. TRACKING = 2
  131324. }
  131325. /**
  131326. * Abstraction of the XR render target
  131327. */
  131328. export interface WebXRRenderTarget extends IDisposable {
  131329. /**
  131330. * xrpresent context of the canvas which can be used to display/mirror xr content
  131331. */
  131332. canvasContext: WebGLRenderingContext;
  131333. /**
  131334. * xr layer for the canvas
  131335. */
  131336. xrLayer: Nullable<XRWebGLLayer>;
  131337. /**
  131338. * Initializes the xr layer for the session
  131339. * @param xrSession xr session
  131340. * @returns a promise that will resolve once the XR Layer has been created
  131341. */
  131342. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  131343. }
  131344. }
  131345. declare module BABYLON {
  131346. /**
  131347. * COnfiguration object for WebXR output canvas
  131348. */
  131349. export class WebXRManagedOutputCanvasOptions {
  131350. /**
  131351. * An optional canvas in case you wish to create it yourself and provide it here.
  131352. * If not provided, a new canvas will be created
  131353. */
  131354. canvasElement?: HTMLCanvasElement;
  131355. /**
  131356. * Options for this XR Layer output
  131357. */
  131358. canvasOptions?: XRWebGLLayerOptions;
  131359. /**
  131360. * CSS styling for a newly created canvas (if not provided)
  131361. */
  131362. newCanvasCssStyle?: string;
  131363. /**
  131364. * Get the default values of the configuration object
  131365. * @param engine defines the engine to use (can be null)
  131366. * @returns default values of this configuration object
  131367. */
  131368. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  131369. }
  131370. /**
  131371. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  131372. */
  131373. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  131374. private _options;
  131375. private _canvas;
  131376. private _engine;
  131377. private _originalCanvasSize;
  131378. /**
  131379. * Rendering context of the canvas which can be used to display/mirror xr content
  131380. */
  131381. canvasContext: WebGLRenderingContext;
  131382. /**
  131383. * xr layer for the canvas
  131384. */
  131385. xrLayer: Nullable<XRWebGLLayer>;
  131386. /**
  131387. * Obseervers registered here will be triggered when the xr layer was initialized
  131388. */
  131389. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  131390. /**
  131391. * Initializes the canvas to be added/removed upon entering/exiting xr
  131392. * @param _xrSessionManager The XR Session manager
  131393. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  131394. */
  131395. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  131396. /**
  131397. * Disposes of the object
  131398. */
  131399. dispose(): void;
  131400. /**
  131401. * Initializes the xr layer for the session
  131402. * @param xrSession xr session
  131403. * @returns a promise that will resolve once the XR Layer has been created
  131404. */
  131405. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  131406. private _addCanvas;
  131407. private _removeCanvas;
  131408. private _setCanvasSize;
  131409. private _setManagedOutputCanvas;
  131410. }
  131411. }
  131412. declare module BABYLON {
  131413. /**
  131414. * Manages an XRSession to work with Babylon's engine
  131415. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  131416. */
  131417. export class WebXRSessionManager implements IDisposable {
  131418. /** The scene which the session should be created for */
  131419. scene: Scene;
  131420. private _referenceSpace;
  131421. private _rttProvider;
  131422. private _sessionEnded;
  131423. private _xrNavigator;
  131424. private baseLayer;
  131425. /**
  131426. * The base reference space from which the session started. good if you want to reset your
  131427. * reference space
  131428. */
  131429. baseReferenceSpace: XRReferenceSpace;
  131430. /**
  131431. * Current XR frame
  131432. */
  131433. currentFrame: Nullable<XRFrame>;
  131434. /** WebXR timestamp updated every frame */
  131435. currentTimestamp: number;
  131436. /**
  131437. * Used just in case of a failure to initialize an immersive session.
  131438. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  131439. */
  131440. defaultHeightCompensation: number;
  131441. /**
  131442. * Fires every time a new xrFrame arrives which can be used to update the camera
  131443. */
  131444. onXRFrameObservable: Observable<XRFrame>;
  131445. /**
  131446. * Fires when the reference space changed
  131447. */
  131448. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  131449. /**
  131450. * Fires when the xr session is ended either by the device or manually done
  131451. */
  131452. onXRSessionEnded: Observable<any>;
  131453. /**
  131454. * Fires when the xr session is ended either by the device or manually done
  131455. */
  131456. onXRSessionInit: Observable<XRSession>;
  131457. /**
  131458. * Underlying xr session
  131459. */
  131460. session: XRSession;
  131461. /**
  131462. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  131463. * or get the offset the player is currently at.
  131464. */
  131465. viewerReferenceSpace: XRReferenceSpace;
  131466. /**
  131467. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  131468. * @param scene The scene which the session should be created for
  131469. */
  131470. constructor(
  131471. /** The scene which the session should be created for */
  131472. scene: Scene);
  131473. /**
  131474. * The current reference space used in this session. This reference space can constantly change!
  131475. * It is mainly used to offset the camera's position.
  131476. */
  131477. get referenceSpace(): XRReferenceSpace;
  131478. /**
  131479. * Set a new reference space and triggers the observable
  131480. */
  131481. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  131482. /**
  131483. * Disposes of the session manager
  131484. */
  131485. dispose(): void;
  131486. /**
  131487. * Stops the xrSession and restores the render loop
  131488. * @returns Promise which resolves after it exits XR
  131489. */
  131490. exitXRAsync(): Promise<void>;
  131491. /**
  131492. * Gets the correct render target texture to be rendered this frame for this eye
  131493. * @param eye the eye for which to get the render target
  131494. * @returns the render target for the specified eye
  131495. */
  131496. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  131497. /**
  131498. * Creates a WebXRRenderTarget object for the XR session
  131499. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  131500. * @param options optional options to provide when creating a new render target
  131501. * @returns a WebXR render target to which the session can render
  131502. */
  131503. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  131504. /**
  131505. * Initializes the manager
  131506. * After initialization enterXR can be called to start an XR session
  131507. * @returns Promise which resolves after it is initialized
  131508. */
  131509. initializeAsync(): Promise<void>;
  131510. /**
  131511. * Initializes an xr session
  131512. * @param xrSessionMode mode to initialize
  131513. * @param xrSessionInit defines optional and required values to pass to the session builder
  131514. * @returns a promise which will resolve once the session has been initialized
  131515. */
  131516. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  131517. /**
  131518. * Checks if a session would be supported for the creation options specified
  131519. * @param sessionMode session mode to check if supported eg. immersive-vr
  131520. * @returns A Promise that resolves to true if supported and false if not
  131521. */
  131522. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  131523. /**
  131524. * Resets the reference space to the one started the session
  131525. */
  131526. resetReferenceSpace(): void;
  131527. /**
  131528. * Starts rendering to the xr layer
  131529. */
  131530. runXRRenderLoop(): void;
  131531. /**
  131532. * Sets the reference space on the xr session
  131533. * @param referenceSpaceType space to set
  131534. * @returns a promise that will resolve once the reference space has been set
  131535. */
  131536. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  131537. /**
  131538. * Updates the render state of the session
  131539. * @param state state to set
  131540. * @returns a promise that resolves once the render state has been updated
  131541. */
  131542. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  131543. /**
  131544. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  131545. * @param sessionMode defines the session to test
  131546. * @returns a promise with boolean as final value
  131547. */
  131548. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  131549. private _createRenderTargetTexture;
  131550. }
  131551. }
  131552. declare module BABYLON {
  131553. /**
  131554. * WebXR Camera which holds the views for the xrSession
  131555. * @see https://doc.babylonjs.com/how_to/webxr_camera
  131556. */
  131557. export class WebXRCamera extends FreeCamera {
  131558. private _xrSessionManager;
  131559. private _firstFrame;
  131560. private _referenceQuaternion;
  131561. private _referencedPosition;
  131562. private _xrInvPositionCache;
  131563. private _xrInvQuaternionCache;
  131564. private _trackingState;
  131565. /**
  131566. * Observable raised before camera teleportation
  131567. */
  131568. onBeforeCameraTeleport: Observable<Vector3>;
  131569. /**
  131570. * Observable raised after camera teleportation
  131571. */
  131572. onAfterCameraTeleport: Observable<Vector3>;
  131573. /**
  131574. * Notifies when the camera's tracking state has changed.
  131575. * Notice - will also be triggered when tracking has started (at the beginning of the session)
  131576. */
  131577. onTrackingStateChanged: Observable<WebXRTrackingState>;
  131578. /**
  131579. * Should position compensation execute on first frame.
  131580. * This is used when copying the position from a native (non XR) camera
  131581. */
  131582. compensateOnFirstFrame: boolean;
  131583. /**
  131584. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  131585. * @param name the name of the camera
  131586. * @param scene the scene to add the camera to
  131587. * @param _xrSessionManager a constructed xr session manager
  131588. */
  131589. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  131590. /**
  131591. * Get the current XR tracking state of the camera
  131592. */
  131593. get trackingState(): WebXRTrackingState;
  131594. private _setTrackingState;
  131595. /**
  131596. * Return the user's height, unrelated to the current ground.
  131597. * This will be the y position of this camera, when ground level is 0.
  131598. */
  131599. get realWorldHeight(): number;
  131600. /** @hidden */
  131601. _updateForDualEyeDebugging(): void;
  131602. /**
  131603. * Sets this camera's transformation based on a non-vr camera
  131604. * @param otherCamera the non-vr camera to copy the transformation from
  131605. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  131606. */
  131607. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  131608. /**
  131609. * Gets the current instance class name ("WebXRCamera").
  131610. * @returns the class name
  131611. */
  131612. getClassName(): string;
  131613. private _rotate180;
  131614. private _updateFromXRSession;
  131615. private _updateNumberOfRigCameras;
  131616. private _updateReferenceSpace;
  131617. private _updateReferenceSpaceOffset;
  131618. }
  131619. }
  131620. declare module BABYLON {
  131621. /**
  131622. * Defining the interface required for a (webxr) feature
  131623. */
  131624. export interface IWebXRFeature extends IDisposable {
  131625. /**
  131626. * Is this feature attached
  131627. */
  131628. attached: boolean;
  131629. /**
  131630. * Should auto-attach be disabled?
  131631. */
  131632. disableAutoAttach: boolean;
  131633. /**
  131634. * Attach the feature to the session
  131635. * Will usually be called by the features manager
  131636. *
  131637. * @param force should attachment be forced (even when already attached)
  131638. * @returns true if successful.
  131639. */
  131640. attach(force?: boolean): boolean;
  131641. /**
  131642. * Detach the feature from the session
  131643. * Will usually be called by the features manager
  131644. *
  131645. * @returns true if successful.
  131646. */
  131647. detach(): boolean;
  131648. /**
  131649. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  131650. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  131651. *
  131652. * @returns whether or not the feature is compatible in this environment
  131653. */
  131654. isCompatible(): boolean;
  131655. /**
  131656. * Was this feature disposed;
  131657. */
  131658. isDisposed: boolean;
  131659. /**
  131660. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  131661. */
  131662. xrNativeFeatureName?: string;
  131663. /**
  131664. * A list of (Babylon WebXR) features this feature depends on
  131665. */
  131666. dependsOn?: string[];
  131667. }
  131668. /**
  131669. * A list of the currently available features without referencing them
  131670. */
  131671. export class WebXRFeatureName {
  131672. /**
  131673. * The name of the anchor system feature
  131674. */
  131675. static readonly ANCHOR_SYSTEM: string;
  131676. /**
  131677. * The name of the background remover feature
  131678. */
  131679. static readonly BACKGROUND_REMOVER: string;
  131680. /**
  131681. * The name of the hit test feature
  131682. */
  131683. static readonly HIT_TEST: string;
  131684. /**
  131685. * physics impostors for xr controllers feature
  131686. */
  131687. static readonly PHYSICS_CONTROLLERS: string;
  131688. /**
  131689. * The name of the plane detection feature
  131690. */
  131691. static readonly PLANE_DETECTION: string;
  131692. /**
  131693. * The name of the pointer selection feature
  131694. */
  131695. static readonly POINTER_SELECTION: string;
  131696. /**
  131697. * The name of the teleportation feature
  131698. */
  131699. static readonly TELEPORTATION: string;
  131700. /**
  131701. * The name of the feature points feature.
  131702. */
  131703. static readonly FEATURE_POINTS: string;
  131704. /**
  131705. * The name of the hand tracking feature.
  131706. */
  131707. static readonly HAND_TRACKING: string;
  131708. }
  131709. /**
  131710. * Defining the constructor of a feature. Used to register the modules.
  131711. */
  131712. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  131713. /**
  131714. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  131715. * It is mainly used in AR sessions.
  131716. *
  131717. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  131718. */
  131719. export class WebXRFeaturesManager implements IDisposable {
  131720. private _xrSessionManager;
  131721. private static readonly _AvailableFeatures;
  131722. private _features;
  131723. /**
  131724. * constructs a new features manages.
  131725. *
  131726. * @param _xrSessionManager an instance of WebXRSessionManager
  131727. */
  131728. constructor(_xrSessionManager: WebXRSessionManager);
  131729. /**
  131730. * Used to register a module. After calling this function a developer can use this feature in the scene.
  131731. * Mainly used internally.
  131732. *
  131733. * @param featureName the name of the feature to register
  131734. * @param constructorFunction the function used to construct the module
  131735. * @param version the (babylon) version of the module
  131736. * @param stable is that a stable version of this module
  131737. */
  131738. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  131739. /**
  131740. * Returns a constructor of a specific feature.
  131741. *
  131742. * @param featureName the name of the feature to construct
  131743. * @param version the version of the feature to load
  131744. * @param xrSessionManager the xrSessionManager. Used to construct the module
  131745. * @param options optional options provided to the module.
  131746. * @returns a function that, when called, will return a new instance of this feature
  131747. */
  131748. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  131749. /**
  131750. * Can be used to return the list of features currently registered
  131751. *
  131752. * @returns an Array of available features
  131753. */
  131754. static GetAvailableFeatures(): string[];
  131755. /**
  131756. * Gets the versions available for a specific feature
  131757. * @param featureName the name of the feature
  131758. * @returns an array with the available versions
  131759. */
  131760. static GetAvailableVersions(featureName: string): string[];
  131761. /**
  131762. * Return the latest unstable version of this feature
  131763. * @param featureName the name of the feature to search
  131764. * @returns the version number. if not found will return -1
  131765. */
  131766. static GetLatestVersionOfFeature(featureName: string): number;
  131767. /**
  131768. * Return the latest stable version of this feature
  131769. * @param featureName the name of the feature to search
  131770. * @returns the version number. if not found will return -1
  131771. */
  131772. static GetStableVersionOfFeature(featureName: string): number;
  131773. /**
  131774. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  131775. * Can be used during a session to start a feature
  131776. * @param featureName the name of feature to attach
  131777. */
  131778. attachFeature(featureName: string): void;
  131779. /**
  131780. * Can be used inside a session or when the session ends to detach a specific feature
  131781. * @param featureName the name of the feature to detach
  131782. */
  131783. detachFeature(featureName: string): void;
  131784. /**
  131785. * Used to disable an already-enabled feature
  131786. * The feature will be disposed and will be recreated once enabled.
  131787. * @param featureName the feature to disable
  131788. * @returns true if disable was successful
  131789. */
  131790. disableFeature(featureName: string | {
  131791. Name: string;
  131792. }): boolean;
  131793. /**
  131794. * dispose this features manager
  131795. */
  131796. dispose(): void;
  131797. /**
  131798. * 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.
  131799. * 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.
  131800. *
  131801. * @param featureName the name of the feature to load or the class of the feature
  131802. * @param version optional version to load. if not provided the latest version will be enabled
  131803. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  131804. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  131805. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  131806. * @returns a new constructed feature or throws an error if feature not found.
  131807. */
  131808. enableFeature(featureName: string | {
  131809. Name: string;
  131810. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  131811. /**
  131812. * get the implementation of an enabled feature.
  131813. * @param featureName the name of the feature to load
  131814. * @returns the feature class, if found
  131815. */
  131816. getEnabledFeature(featureName: string): IWebXRFeature;
  131817. /**
  131818. * Get the list of enabled features
  131819. * @returns an array of enabled features
  131820. */
  131821. getEnabledFeatures(): string[];
  131822. /**
  131823. * This function will exten the session creation configuration object with enabled features.
  131824. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  131825. * according to the defined "required" variable, provided during enableFeature call
  131826. * @param xrSessionInit the xr Session init object to extend
  131827. *
  131828. * @returns an extended XRSessionInit object
  131829. */
  131830. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  131831. }
  131832. }
  131833. declare module BABYLON {
  131834. /**
  131835. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  131836. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  131837. */
  131838. export class WebXRExperienceHelper implements IDisposable {
  131839. private scene;
  131840. private _nonVRCamera;
  131841. private _originalSceneAutoClear;
  131842. private _supported;
  131843. /**
  131844. * Camera used to render xr content
  131845. */
  131846. camera: WebXRCamera;
  131847. /** A features manager for this xr session */
  131848. featuresManager: WebXRFeaturesManager;
  131849. /**
  131850. * Observers registered here will be triggered after the camera's initial transformation is set
  131851. * This can be used to set a different ground level or an extra rotation.
  131852. *
  131853. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  131854. * to the position set after this observable is done executing.
  131855. */
  131856. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  131857. /**
  131858. * Fires when the state of the experience helper has changed
  131859. */
  131860. onStateChangedObservable: Observable<WebXRState>;
  131861. /** Session manager used to keep track of xr session */
  131862. sessionManager: WebXRSessionManager;
  131863. /**
  131864. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  131865. */
  131866. state: WebXRState;
  131867. /**
  131868. * Creates a WebXRExperienceHelper
  131869. * @param scene The scene the helper should be created in
  131870. */
  131871. private constructor();
  131872. /**
  131873. * Creates the experience helper
  131874. * @param scene the scene to attach the experience helper to
  131875. * @returns a promise for the experience helper
  131876. */
  131877. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  131878. /**
  131879. * Disposes of the experience helper
  131880. */
  131881. dispose(): void;
  131882. /**
  131883. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  131884. * @param sessionMode options for the XR session
  131885. * @param referenceSpaceType frame of reference of the XR session
  131886. * @param renderTarget the output canvas that will be used to enter XR mode
  131887. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  131888. * @returns promise that resolves after xr mode has entered
  131889. */
  131890. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  131891. /**
  131892. * Exits XR mode and returns the scene to its original state
  131893. * @returns promise that resolves after xr mode has exited
  131894. */
  131895. exitXRAsync(): Promise<void>;
  131896. private _nonXRToXRCamera;
  131897. private _setState;
  131898. }
  131899. }
  131900. declare module BABYLON {
  131901. /**
  131902. * X-Y values for axes in WebXR
  131903. */
  131904. export interface IWebXRMotionControllerAxesValue {
  131905. /**
  131906. * The value of the x axis
  131907. */
  131908. x: number;
  131909. /**
  131910. * The value of the y-axis
  131911. */
  131912. y: number;
  131913. }
  131914. /**
  131915. * changed / previous values for the values of this component
  131916. */
  131917. export interface IWebXRMotionControllerComponentChangesValues<T> {
  131918. /**
  131919. * current (this frame) value
  131920. */
  131921. current: T;
  131922. /**
  131923. * previous (last change) value
  131924. */
  131925. previous: T;
  131926. }
  131927. /**
  131928. * Represents changes in the component between current frame and last values recorded
  131929. */
  131930. export interface IWebXRMotionControllerComponentChanges {
  131931. /**
  131932. * will be populated with previous and current values if axes changed
  131933. */
  131934. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  131935. /**
  131936. * will be populated with previous and current values if pressed changed
  131937. */
  131938. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131939. /**
  131940. * will be populated with previous and current values if touched changed
  131941. */
  131942. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  131943. /**
  131944. * will be populated with previous and current values if value changed
  131945. */
  131946. value?: IWebXRMotionControllerComponentChangesValues<number>;
  131947. }
  131948. /**
  131949. * This class represents a single component (for example button or thumbstick) of a motion controller
  131950. */
  131951. export class WebXRControllerComponent implements IDisposable {
  131952. /**
  131953. * the id of this component
  131954. */
  131955. id: string;
  131956. /**
  131957. * the type of the component
  131958. */
  131959. type: MotionControllerComponentType;
  131960. private _buttonIndex;
  131961. private _axesIndices;
  131962. private _axes;
  131963. private _changes;
  131964. private _currentValue;
  131965. private _hasChanges;
  131966. private _pressed;
  131967. private _touched;
  131968. /**
  131969. * button component type
  131970. */
  131971. static BUTTON_TYPE: MotionControllerComponentType;
  131972. /**
  131973. * squeeze component type
  131974. */
  131975. static SQUEEZE_TYPE: MotionControllerComponentType;
  131976. /**
  131977. * Thumbstick component type
  131978. */
  131979. static THUMBSTICK_TYPE: MotionControllerComponentType;
  131980. /**
  131981. * Touchpad component type
  131982. */
  131983. static TOUCHPAD_TYPE: MotionControllerComponentType;
  131984. /**
  131985. * trigger component type
  131986. */
  131987. static TRIGGER_TYPE: MotionControllerComponentType;
  131988. /**
  131989. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  131990. * the axes data changes
  131991. */
  131992. onAxisValueChangedObservable: Observable<{
  131993. x: number;
  131994. y: number;
  131995. }>;
  131996. /**
  131997. * Observers registered here will be triggered when the state of a button changes
  131998. * State change is either pressed / touched / value
  131999. */
  132000. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  132001. /**
  132002. * Creates a new component for a motion controller.
  132003. * It is created by the motion controller itself
  132004. *
  132005. * @param id the id of this component
  132006. * @param type the type of the component
  132007. * @param _buttonIndex index in the buttons array of the gamepad
  132008. * @param _axesIndices indices of the values in the axes array of the gamepad
  132009. */
  132010. constructor(
  132011. /**
  132012. * the id of this component
  132013. */
  132014. id: string,
  132015. /**
  132016. * the type of the component
  132017. */
  132018. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  132019. /**
  132020. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  132021. */
  132022. get axes(): IWebXRMotionControllerAxesValue;
  132023. /**
  132024. * Get the changes. Elements will be populated only if they changed with their previous and current value
  132025. */
  132026. get changes(): IWebXRMotionControllerComponentChanges;
  132027. /**
  132028. * Return whether or not the component changed the last frame
  132029. */
  132030. get hasChanges(): boolean;
  132031. /**
  132032. * is the button currently pressed
  132033. */
  132034. get pressed(): boolean;
  132035. /**
  132036. * is the button currently touched
  132037. */
  132038. get touched(): boolean;
  132039. /**
  132040. * Get the current value of this component
  132041. */
  132042. get value(): number;
  132043. /**
  132044. * Dispose this component
  132045. */
  132046. dispose(): void;
  132047. /**
  132048. * Are there axes correlating to this component
  132049. * @return true is axes data is available
  132050. */
  132051. isAxes(): boolean;
  132052. /**
  132053. * Is this component a button (hence - pressable)
  132054. * @returns true if can be pressed
  132055. */
  132056. isButton(): boolean;
  132057. /**
  132058. * update this component using the gamepad object it is in. Called on every frame
  132059. * @param nativeController the native gamepad controller object
  132060. */
  132061. update(nativeController: IMinimalMotionControllerObject): void;
  132062. }
  132063. }
  132064. declare module BABYLON {
  132065. /**
  132066. * Interface used to represent data loading progression
  132067. */
  132068. export interface ISceneLoaderProgressEvent {
  132069. /**
  132070. * Defines if data length to load can be evaluated
  132071. */
  132072. readonly lengthComputable: boolean;
  132073. /**
  132074. * Defines the loaded data length
  132075. */
  132076. readonly loaded: number;
  132077. /**
  132078. * Defines the data length to load
  132079. */
  132080. readonly total: number;
  132081. }
  132082. /**
  132083. * Interface used by SceneLoader plugins to define supported file extensions
  132084. */
  132085. export interface ISceneLoaderPluginExtensions {
  132086. /**
  132087. * Defines the list of supported extensions
  132088. */
  132089. [extension: string]: {
  132090. isBinary: boolean;
  132091. };
  132092. }
  132093. /**
  132094. * Interface used by SceneLoader plugin factory
  132095. */
  132096. export interface ISceneLoaderPluginFactory {
  132097. /**
  132098. * Defines the name of the factory
  132099. */
  132100. name: string;
  132101. /**
  132102. * Function called to create a new plugin
  132103. * @return the new plugin
  132104. */
  132105. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  132106. /**
  132107. * The callback that returns true if the data can be directly loaded.
  132108. * @param data string containing the file data
  132109. * @returns if the data can be loaded directly
  132110. */
  132111. canDirectLoad?(data: string): boolean;
  132112. }
  132113. /**
  132114. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  132115. */
  132116. export interface ISceneLoaderPluginBase {
  132117. /**
  132118. * The friendly name of this plugin.
  132119. */
  132120. name: string;
  132121. /**
  132122. * The file extensions supported by this plugin.
  132123. */
  132124. extensions: string | ISceneLoaderPluginExtensions;
  132125. /**
  132126. * The callback called when loading from a url.
  132127. * @param scene scene loading this url
  132128. * @param url url to load
  132129. * @param onSuccess callback called when the file successfully loads
  132130. * @param onProgress callback called while file is loading (if the server supports this mode)
  132131. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  132132. * @param onError callback called when the file fails to load
  132133. * @returns a file request object
  132134. */
  132135. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132136. /**
  132137. * The callback called when loading from a file object.
  132138. * @param scene scene loading this file
  132139. * @param file defines the file to load
  132140. * @param onSuccess defines the callback to call when data is loaded
  132141. * @param onProgress defines the callback to call during loading process
  132142. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  132143. * @param onError defines the callback to call when an error occurs
  132144. * @returns a file request object
  132145. */
  132146. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  132147. /**
  132148. * The callback that returns true if the data can be directly loaded.
  132149. * @param data string containing the file data
  132150. * @returns if the data can be loaded directly
  132151. */
  132152. canDirectLoad?(data: string): boolean;
  132153. /**
  132154. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  132155. * @param scene scene loading this data
  132156. * @param data string containing the data
  132157. * @returns data to pass to the plugin
  132158. */
  132159. directLoad?(scene: Scene, data: string): any;
  132160. /**
  132161. * The callback that allows custom handling of the root url based on the response url.
  132162. * @param rootUrl the original root url
  132163. * @param responseURL the response url if available
  132164. * @returns the new root url
  132165. */
  132166. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  132167. }
  132168. /**
  132169. * Interface used to define a SceneLoader plugin
  132170. */
  132171. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  132172. /**
  132173. * Import meshes into a scene.
  132174. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132175. * @param scene The scene to import into
  132176. * @param data The data to import
  132177. * @param rootUrl The root url for scene and resources
  132178. * @param meshes The meshes array to import into
  132179. * @param particleSystems The particle systems array to import into
  132180. * @param skeletons The skeletons array to import into
  132181. * @param onError The callback when import fails
  132182. * @returns True if successful or false otherwise
  132183. */
  132184. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  132185. /**
  132186. * Load into a scene.
  132187. * @param scene The scene to load into
  132188. * @param data The data to import
  132189. * @param rootUrl The root url for scene and resources
  132190. * @param onError The callback when import fails
  132191. * @returns True if successful or false otherwise
  132192. */
  132193. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  132194. /**
  132195. * Load into an asset container.
  132196. * @param scene The scene to load into
  132197. * @param data The data to import
  132198. * @param rootUrl The root url for scene and resources
  132199. * @param onError The callback when import fails
  132200. * @returns The loaded asset container
  132201. */
  132202. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  132203. }
  132204. /**
  132205. * Interface used to define an async SceneLoader plugin
  132206. */
  132207. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  132208. /**
  132209. * Import meshes into a scene.
  132210. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132211. * @param scene The scene to import into
  132212. * @param data The data to import
  132213. * @param rootUrl The root url for scene and resources
  132214. * @param onProgress The callback when the load progresses
  132215. * @param fileName Defines the name of the file to load
  132216. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  132217. */
  132218. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  132219. meshes: AbstractMesh[];
  132220. particleSystems: IParticleSystem[];
  132221. skeletons: Skeleton[];
  132222. animationGroups: AnimationGroup[];
  132223. }>;
  132224. /**
  132225. * Load into a scene.
  132226. * @param scene The scene to load into
  132227. * @param data The data to import
  132228. * @param rootUrl The root url for scene and resources
  132229. * @param onProgress The callback when the load progresses
  132230. * @param fileName Defines the name of the file to load
  132231. * @returns Nothing
  132232. */
  132233. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  132234. /**
  132235. * Load into an asset container.
  132236. * @param scene The scene to load into
  132237. * @param data The data to import
  132238. * @param rootUrl The root url for scene and resources
  132239. * @param onProgress The callback when the load progresses
  132240. * @param fileName Defines the name of the file to load
  132241. * @returns The loaded asset container
  132242. */
  132243. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  132244. }
  132245. /**
  132246. * Mode that determines how to handle old animation groups before loading new ones.
  132247. */
  132248. export enum SceneLoaderAnimationGroupLoadingMode {
  132249. /**
  132250. * Reset all old animations to initial state then dispose them.
  132251. */
  132252. Clean = 0,
  132253. /**
  132254. * Stop all old animations.
  132255. */
  132256. Stop = 1,
  132257. /**
  132258. * Restart old animations from first frame.
  132259. */
  132260. Sync = 2,
  132261. /**
  132262. * Old animations remains untouched.
  132263. */
  132264. NoSync = 3
  132265. }
  132266. /**
  132267. * Defines a plugin registered by the SceneLoader
  132268. */
  132269. interface IRegisteredPlugin {
  132270. /**
  132271. * Defines the plugin to use
  132272. */
  132273. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  132274. /**
  132275. * Defines if the plugin supports binary data
  132276. */
  132277. isBinary: boolean;
  132278. }
  132279. /**
  132280. * Class used to load scene from various file formats using registered plugins
  132281. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  132282. */
  132283. export class SceneLoader {
  132284. /**
  132285. * No logging while loading
  132286. */
  132287. static readonly NO_LOGGING: number;
  132288. /**
  132289. * Minimal logging while loading
  132290. */
  132291. static readonly MINIMAL_LOGGING: number;
  132292. /**
  132293. * Summary logging while loading
  132294. */
  132295. static readonly SUMMARY_LOGGING: number;
  132296. /**
  132297. * Detailled logging while loading
  132298. */
  132299. static readonly DETAILED_LOGGING: number;
  132300. /**
  132301. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  132302. */
  132303. static get ForceFullSceneLoadingForIncremental(): boolean;
  132304. static set ForceFullSceneLoadingForIncremental(value: boolean);
  132305. /**
  132306. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  132307. */
  132308. static get ShowLoadingScreen(): boolean;
  132309. static set ShowLoadingScreen(value: boolean);
  132310. /**
  132311. * Defines the current logging level (while loading the scene)
  132312. * @ignorenaming
  132313. */
  132314. static get loggingLevel(): number;
  132315. static set loggingLevel(value: number);
  132316. /**
  132317. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  132318. */
  132319. static get CleanBoneMatrixWeights(): boolean;
  132320. static set CleanBoneMatrixWeights(value: boolean);
  132321. /**
  132322. * Event raised when a plugin is used to load a scene
  132323. */
  132324. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  132325. private static _registeredPlugins;
  132326. private static _showingLoadingScreen;
  132327. /**
  132328. * Gets the default plugin (used to load Babylon files)
  132329. * @returns the .babylon plugin
  132330. */
  132331. static GetDefaultPlugin(): IRegisteredPlugin;
  132332. private static _GetPluginForExtension;
  132333. private static _GetPluginForDirectLoad;
  132334. private static _GetPluginForFilename;
  132335. private static _GetDirectLoad;
  132336. private static _LoadData;
  132337. private static _GetFileInfo;
  132338. /**
  132339. * Gets a plugin that can load the given extension
  132340. * @param extension defines the extension to load
  132341. * @returns a plugin or null if none works
  132342. */
  132343. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  132344. /**
  132345. * Gets a boolean indicating that the given extension can be loaded
  132346. * @param extension defines the extension to load
  132347. * @returns true if the extension is supported
  132348. */
  132349. static IsPluginForExtensionAvailable(extension: string): boolean;
  132350. /**
  132351. * Adds a new plugin to the list of registered plugins
  132352. * @param plugin defines the plugin to add
  132353. */
  132354. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  132355. /**
  132356. * Import meshes into a scene
  132357. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132358. * @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)
  132359. * @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)
  132360. * @param scene the instance of BABYLON.Scene to append to
  132361. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  132362. * @param onProgress a callback with a progress event for each file being loaded
  132363. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132364. * @param pluginExtension the extension used to determine the plugin
  132365. * @returns The loaded plugin
  132366. */
  132367. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], animationGroups: AnimationGroup[]) => void>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  132368. /**
  132369. * Import meshes into a scene
  132370. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  132371. * @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)
  132372. * @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)
  132373. * @param scene the instance of BABYLON.Scene to append to
  132374. * @param onProgress a callback with a progress event for each file being loaded
  132375. * @param pluginExtension the extension used to determine the plugin
  132376. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  132377. */
  132378. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  132379. meshes: AbstractMesh[];
  132380. particleSystems: IParticleSystem[];
  132381. skeletons: Skeleton[];
  132382. animationGroups: AnimationGroup[];
  132383. }>;
  132384. /**
  132385. * Load a scene
  132386. * @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)
  132387. * @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)
  132388. * @param engine is the instance of BABYLON.Engine to use to create the scene
  132389. * @param onSuccess a callback with the scene when import succeeds
  132390. * @param onProgress a callback with a progress event for each file being loaded
  132391. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132392. * @param pluginExtension the extension used to determine the plugin
  132393. * @returns The loaded plugin
  132394. */
  132395. 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>;
  132396. /**
  132397. * Load a scene
  132398. * @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)
  132399. * @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)
  132400. * @param engine is the instance of BABYLON.Engine to use to create the scene
  132401. * @param onProgress a callback with a progress event for each file being loaded
  132402. * @param pluginExtension the extension used to determine the plugin
  132403. * @returns The loaded scene
  132404. */
  132405. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  132406. /**
  132407. * Append a scene
  132408. * @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)
  132409. * @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)
  132410. * @param scene is the instance of BABYLON.Scene to append to
  132411. * @param onSuccess a callback with the scene when import succeeds
  132412. * @param onProgress a callback with a progress event for each file being loaded
  132413. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132414. * @param pluginExtension the extension used to determine the plugin
  132415. * @returns The loaded plugin
  132416. */
  132417. 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>;
  132418. /**
  132419. * Append a scene
  132420. * @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)
  132421. * @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)
  132422. * @param scene is the instance of BABYLON.Scene to append to
  132423. * @param onProgress a callback with a progress event for each file being loaded
  132424. * @param pluginExtension the extension used to determine the plugin
  132425. * @returns The given scene
  132426. */
  132427. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  132428. /**
  132429. * Load a scene into an asset container
  132430. * @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)
  132431. * @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)
  132432. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132433. * @param onSuccess a callback with the scene when import succeeds
  132434. * @param onProgress a callback with a progress event for each file being loaded
  132435. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132436. * @param pluginExtension the extension used to determine the plugin
  132437. * @returns The loaded plugin
  132438. */
  132439. 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>;
  132440. /**
  132441. * Load a scene into an asset container
  132442. * @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)
  132443. * @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)
  132444. * @param scene is the instance of Scene to append to
  132445. * @param onProgress a callback with a progress event for each file being loaded
  132446. * @param pluginExtension the extension used to determine the plugin
  132447. * @returns The loaded asset container
  132448. */
  132449. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  132450. /**
  132451. * Import animations from a file into a scene
  132452. * @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)
  132453. * @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)
  132454. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132455. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  132456. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  132457. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  132458. * @param onSuccess a callback with the scene when import succeeds
  132459. * @param onProgress a callback with a progress event for each file being loaded
  132460. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132461. * @param pluginExtension the extension used to determine the plugin
  132462. */
  132463. 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;
  132464. /**
  132465. * Import animations from a file into a scene
  132466. * @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)
  132467. * @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)
  132468. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  132469. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  132470. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  132471. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  132472. * @param onSuccess a callback with the scene when import succeeds
  132473. * @param onProgress a callback with a progress event for each file being loaded
  132474. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  132475. * @param pluginExtension the extension used to determine the plugin
  132476. * @returns the updated scene with imported animations
  132477. */
  132478. 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>;
  132479. }
  132480. }
  132481. declare module BABYLON {
  132482. /**
  132483. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  132484. */
  132485. export type MotionControllerHandedness = "none" | "left" | "right";
  132486. /**
  132487. * The type of components available in motion controllers.
  132488. * This is not the name of the component.
  132489. */
  132490. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  132491. /**
  132492. * The state of a controller component
  132493. */
  132494. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  132495. /**
  132496. * The schema of motion controller layout.
  132497. * No object will be initialized using this interface
  132498. * This is used just to define the profile.
  132499. */
  132500. export interface IMotionControllerLayout {
  132501. /**
  132502. * Path to load the assets. Usually relative to the base path
  132503. */
  132504. assetPath: string;
  132505. /**
  132506. * Available components (unsorted)
  132507. */
  132508. components: {
  132509. /**
  132510. * A map of component Ids
  132511. */
  132512. [componentId: string]: {
  132513. /**
  132514. * The type of input the component outputs
  132515. */
  132516. type: MotionControllerComponentType;
  132517. /**
  132518. * The indices of this component in the gamepad object
  132519. */
  132520. gamepadIndices: {
  132521. /**
  132522. * Index of button
  132523. */
  132524. button?: number;
  132525. /**
  132526. * If available, index of x-axis
  132527. */
  132528. xAxis?: number;
  132529. /**
  132530. * If available, index of y-axis
  132531. */
  132532. yAxis?: number;
  132533. };
  132534. /**
  132535. * The mesh's root node name
  132536. */
  132537. rootNodeName: string;
  132538. /**
  132539. * Animation definitions for this model
  132540. */
  132541. visualResponses: {
  132542. [stateKey: string]: {
  132543. /**
  132544. * What property will be animated
  132545. */
  132546. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  132547. /**
  132548. * What states influence this visual response
  132549. */
  132550. states: MotionControllerComponentStateType[];
  132551. /**
  132552. * Type of animation - movement or visibility
  132553. */
  132554. valueNodeProperty: "transform" | "visibility";
  132555. /**
  132556. * Base node name to move. Its position will be calculated according to the min and max nodes
  132557. */
  132558. valueNodeName?: string;
  132559. /**
  132560. * Minimum movement node
  132561. */
  132562. minNodeName?: string;
  132563. /**
  132564. * Max movement node
  132565. */
  132566. maxNodeName?: string;
  132567. };
  132568. };
  132569. /**
  132570. * If touch enabled, what is the name of node to display user feedback
  132571. */
  132572. touchPointNodeName?: string;
  132573. };
  132574. };
  132575. /**
  132576. * Is it xr standard mapping or not
  132577. */
  132578. gamepadMapping: "" | "xr-standard";
  132579. /**
  132580. * Base root node of this entire model
  132581. */
  132582. rootNodeName: string;
  132583. /**
  132584. * Defines the main button component id
  132585. */
  132586. selectComponentId: string;
  132587. }
  132588. /**
  132589. * A definition for the layout map in the input profile
  132590. */
  132591. export interface IMotionControllerLayoutMap {
  132592. /**
  132593. * Layouts with handedness type as a key
  132594. */
  132595. [handedness: string]: IMotionControllerLayout;
  132596. }
  132597. /**
  132598. * The XR Input profile schema
  132599. * Profiles can be found here:
  132600. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  132601. */
  132602. export interface IMotionControllerProfile {
  132603. /**
  132604. * fallback profiles for this profileId
  132605. */
  132606. fallbackProfileIds: string[];
  132607. /**
  132608. * The layout map, with handedness as key
  132609. */
  132610. layouts: IMotionControllerLayoutMap;
  132611. /**
  132612. * The id of this profile
  132613. * correlates to the profile(s) in the xrInput.profiles array
  132614. */
  132615. profileId: string;
  132616. }
  132617. /**
  132618. * A helper-interface for the 3 meshes needed for controller button animation
  132619. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  132620. */
  132621. export interface IMotionControllerButtonMeshMap {
  132622. /**
  132623. * the mesh that defines the pressed value mesh position.
  132624. * This is used to find the max-position of this button
  132625. */
  132626. pressedMesh: AbstractMesh;
  132627. /**
  132628. * the mesh that defines the unpressed value mesh position.
  132629. * This is used to find the min (or initial) position of this button
  132630. */
  132631. unpressedMesh: AbstractMesh;
  132632. /**
  132633. * The mesh that will be changed when value changes
  132634. */
  132635. valueMesh: AbstractMesh;
  132636. }
  132637. /**
  132638. * A helper-interface for the 3 meshes needed for controller axis animation.
  132639. * This will be expanded when touchpad animations are fully supported
  132640. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  132641. */
  132642. export interface IMotionControllerMeshMap {
  132643. /**
  132644. * the mesh that defines the maximum value mesh position.
  132645. */
  132646. maxMesh?: AbstractMesh;
  132647. /**
  132648. * the mesh that defines the minimum value mesh position.
  132649. */
  132650. minMesh?: AbstractMesh;
  132651. /**
  132652. * The mesh that will be changed when axis value changes
  132653. */
  132654. valueMesh?: AbstractMesh;
  132655. }
  132656. /**
  132657. * The elements needed for change-detection of the gamepad objects in motion controllers
  132658. */
  132659. export interface IMinimalMotionControllerObject {
  132660. /**
  132661. * Available axes of this controller
  132662. */
  132663. axes: number[];
  132664. /**
  132665. * An array of available buttons
  132666. */
  132667. buttons: Array<{
  132668. /**
  132669. * Value of the button/trigger
  132670. */
  132671. value: number;
  132672. /**
  132673. * If the button/trigger is currently touched
  132674. */
  132675. touched: boolean;
  132676. /**
  132677. * If the button/trigger is currently pressed
  132678. */
  132679. pressed: boolean;
  132680. }>;
  132681. /**
  132682. * EXPERIMENTAL haptic support.
  132683. */
  132684. hapticActuators?: Array<{
  132685. pulse: (value: number, duration: number) => Promise<boolean>;
  132686. }>;
  132687. }
  132688. /**
  132689. * An Abstract Motion controller
  132690. * This class receives an xrInput and a profile layout and uses those to initialize the components
  132691. * Each component has an observable to check for changes in value and state
  132692. */
  132693. export abstract class WebXRAbstractMotionController implements IDisposable {
  132694. protected scene: Scene;
  132695. protected layout: IMotionControllerLayout;
  132696. /**
  132697. * The gamepad object correlating to this controller
  132698. */
  132699. gamepadObject: IMinimalMotionControllerObject;
  132700. /**
  132701. * handedness (left/right/none) of this controller
  132702. */
  132703. handedness: MotionControllerHandedness;
  132704. private _initComponent;
  132705. private _modelReady;
  132706. /**
  132707. * A map of components (WebXRControllerComponent) in this motion controller
  132708. * Components have a ComponentType and can also have both button and axis definitions
  132709. */
  132710. readonly components: {
  132711. [id: string]: WebXRControllerComponent;
  132712. };
  132713. /**
  132714. * Disable the model's animation. Can be set at any time.
  132715. */
  132716. disableAnimation: boolean;
  132717. /**
  132718. * Observers registered here will be triggered when the model of this controller is done loading
  132719. */
  132720. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  132721. /**
  132722. * The profile id of this motion controller
  132723. */
  132724. abstract profileId: string;
  132725. /**
  132726. * The root mesh of the model. It is null if the model was not yet initialized
  132727. */
  132728. rootMesh: Nullable<AbstractMesh>;
  132729. /**
  132730. * constructs a new abstract motion controller
  132731. * @param scene the scene to which the model of the controller will be added
  132732. * @param layout The profile layout to load
  132733. * @param gamepadObject The gamepad object correlating to this controller
  132734. * @param handedness handedness (left/right/none) of this controller
  132735. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  132736. */
  132737. constructor(scene: Scene, layout: IMotionControllerLayout,
  132738. /**
  132739. * The gamepad object correlating to this controller
  132740. */
  132741. gamepadObject: IMinimalMotionControllerObject,
  132742. /**
  132743. * handedness (left/right/none) of this controller
  132744. */
  132745. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  132746. /**
  132747. * Dispose this controller, the model mesh and all its components
  132748. */
  132749. dispose(): void;
  132750. /**
  132751. * Returns all components of specific type
  132752. * @param type the type to search for
  132753. * @return an array of components with this type
  132754. */
  132755. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  132756. /**
  132757. * get a component based an its component id as defined in layout.components
  132758. * @param id the id of the component
  132759. * @returns the component correlates to the id or undefined if not found
  132760. */
  132761. getComponent(id: string): WebXRControllerComponent;
  132762. /**
  132763. * Get the list of components available in this motion controller
  132764. * @returns an array of strings correlating to available components
  132765. */
  132766. getComponentIds(): string[];
  132767. /**
  132768. * Get the first component of specific type
  132769. * @param type type of component to find
  132770. * @return a controller component or null if not found
  132771. */
  132772. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  132773. /**
  132774. * Get the main (Select) component of this controller as defined in the layout
  132775. * @returns the main component of this controller
  132776. */
  132777. getMainComponent(): WebXRControllerComponent;
  132778. /**
  132779. * Loads the model correlating to this controller
  132780. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  132781. * @returns A promise fulfilled with the result of the model loading
  132782. */
  132783. loadModel(): Promise<boolean>;
  132784. /**
  132785. * Update this model using the current XRFrame
  132786. * @param xrFrame the current xr frame to use and update the model
  132787. */
  132788. updateFromXRFrame(xrFrame: XRFrame): void;
  132789. /**
  132790. * Backwards compatibility due to a deeply-integrated typo
  132791. */
  132792. get handness(): XREye;
  132793. /**
  132794. * Pulse (vibrate) this controller
  132795. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  132796. * Consecutive calls to this function will cancel the last pulse call
  132797. *
  132798. * @param value the strength of the pulse in 0.0...1.0 range
  132799. * @param duration Duration of the pulse in milliseconds
  132800. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  132801. * @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
  132802. */
  132803. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  132804. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132805. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  132806. /**
  132807. * Moves the axis on the controller mesh based on its current state
  132808. * @param axis the index of the axis
  132809. * @param axisValue the value of the axis which determines the meshes new position
  132810. * @hidden
  132811. */
  132812. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  132813. /**
  132814. * Update the model itself with the current frame data
  132815. * @param xrFrame the frame to use for updating the model mesh
  132816. */
  132817. protected updateModel(xrFrame: XRFrame): void;
  132818. /**
  132819. * Get the filename and path for this controller's model
  132820. * @returns a map of filename and path
  132821. */
  132822. protected abstract _getFilenameAndPath(): {
  132823. filename: string;
  132824. path: string;
  132825. };
  132826. /**
  132827. * This function is called before the mesh is loaded. It checks for loading constraints.
  132828. * For example, this function can check if the GLB loader is available
  132829. * If this function returns false, the generic controller will be loaded instead
  132830. * @returns Is the client ready to load the mesh
  132831. */
  132832. protected abstract _getModelLoadingConstraints(): boolean;
  132833. /**
  132834. * This function will be called after the model was successfully loaded and can be used
  132835. * for mesh transformations before it is available for the user
  132836. * @param meshes the loaded meshes
  132837. */
  132838. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  132839. /**
  132840. * Set the root mesh for this controller. Important for the WebXR controller class
  132841. * @param meshes the loaded meshes
  132842. */
  132843. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  132844. /**
  132845. * A function executed each frame that updates the mesh (if needed)
  132846. * @param xrFrame the current xrFrame
  132847. */
  132848. protected abstract _updateModel(xrFrame: XRFrame): void;
  132849. private _getGenericFilenameAndPath;
  132850. private _getGenericParentMesh;
  132851. }
  132852. }
  132853. declare module BABYLON {
  132854. /**
  132855. * A generic trigger-only motion controller for WebXR
  132856. */
  132857. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  132858. /**
  132859. * Static version of the profile id of this controller
  132860. */
  132861. static ProfileId: string;
  132862. profileId: string;
  132863. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  132864. protected _getFilenameAndPath(): {
  132865. filename: string;
  132866. path: string;
  132867. };
  132868. protected _getModelLoadingConstraints(): boolean;
  132869. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  132870. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132871. protected _updateModel(): void;
  132872. }
  132873. }
  132874. declare module BABYLON {
  132875. /**
  132876. * Class containing static functions to help procedurally build meshes
  132877. */
  132878. export class SphereBuilder {
  132879. /**
  132880. * Creates a sphere mesh
  132881. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  132882. * * 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`)
  132883. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  132884. * * 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
  132885. * * 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)
  132886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  132887. * * 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
  132888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  132889. * @param name defines the name of the mesh
  132890. * @param options defines the options used to create the mesh
  132891. * @param scene defines the hosting scene
  132892. * @returns the sphere mesh
  132893. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  132894. */
  132895. static CreateSphere(name: string, options: {
  132896. segments?: number;
  132897. diameter?: number;
  132898. diameterX?: number;
  132899. diameterY?: number;
  132900. diameterZ?: number;
  132901. arc?: number;
  132902. slice?: number;
  132903. sideOrientation?: number;
  132904. frontUVs?: Vector4;
  132905. backUVs?: Vector4;
  132906. updatable?: boolean;
  132907. }, scene?: Nullable<Scene>): Mesh;
  132908. }
  132909. }
  132910. declare module BABYLON {
  132911. /**
  132912. * A profiled motion controller has its profile loaded from an online repository.
  132913. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  132914. */
  132915. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  132916. private _repositoryUrl;
  132917. private _buttonMeshMapping;
  132918. private _touchDots;
  132919. /**
  132920. * The profile ID of this controller. Will be populated when the controller initializes.
  132921. */
  132922. profileId: string;
  132923. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  132924. dispose(): void;
  132925. protected _getFilenameAndPath(): {
  132926. filename: string;
  132927. path: string;
  132928. };
  132929. protected _getModelLoadingConstraints(): boolean;
  132930. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  132931. protected _setRootMesh(meshes: AbstractMesh[]): void;
  132932. protected _updateModel(_xrFrame: XRFrame): void;
  132933. }
  132934. }
  132935. declare module BABYLON {
  132936. /**
  132937. * A construction function type to create a new controller based on an xrInput object
  132938. */
  132939. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  132940. /**
  132941. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  132942. *
  132943. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  132944. * it should be replaced with auto-loaded controllers.
  132945. *
  132946. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  132947. */
  132948. export class WebXRMotionControllerManager {
  132949. private static _AvailableControllers;
  132950. private static _Fallbacks;
  132951. private static _ProfileLoadingPromises;
  132952. private static _ProfilesList;
  132953. /**
  132954. * The base URL of the online controller repository. Can be changed at any time.
  132955. */
  132956. static BaseRepositoryUrl: string;
  132957. /**
  132958. * Which repository gets priority - local or online
  132959. */
  132960. static PrioritizeOnlineRepository: boolean;
  132961. /**
  132962. * Use the online repository, or use only locally-defined controllers
  132963. */
  132964. static UseOnlineRepository: boolean;
  132965. /**
  132966. * Clear the cache used for profile loading and reload when requested again
  132967. */
  132968. static ClearProfilesCache(): void;
  132969. /**
  132970. * Register the default fallbacks.
  132971. * This function is called automatically when this file is imported.
  132972. */
  132973. static DefaultFallbacks(): void;
  132974. /**
  132975. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  132976. * @param profileId the profile to which a fallback needs to be found
  132977. * @return an array with corresponding fallback profiles
  132978. */
  132979. static FindFallbackWithProfileId(profileId: string): string[];
  132980. /**
  132981. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  132982. * The order of search:
  132983. *
  132984. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  132985. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  132986. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  132987. * 4) return the generic trigger controller if none were found
  132988. *
  132989. * @param xrInput the xrInput to which a new controller is initialized
  132990. * @param scene the scene to which the model will be added
  132991. * @param forceProfile force a certain profile for this controller
  132992. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  132993. */
  132994. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  132995. /**
  132996. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  132997. *
  132998. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  132999. *
  133000. * @param type the profile type to register
  133001. * @param constructFunction the function to be called when loading this profile
  133002. */
  133003. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  133004. /**
  133005. * Register a fallback to a specific profile.
  133006. * @param profileId the profileId that will receive the fallbacks
  133007. * @param fallbacks A list of fallback profiles
  133008. */
  133009. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  133010. /**
  133011. * Will update the list of profiles available in the repository
  133012. * @return a promise that resolves to a map of profiles available online
  133013. */
  133014. static UpdateProfilesList(): Promise<{
  133015. [profile: string]: string;
  133016. }>;
  133017. private static _LoadProfileFromRepository;
  133018. private static _LoadProfilesFromAvailableControllers;
  133019. }
  133020. }
  133021. declare module BABYLON {
  133022. /**
  133023. * Configuration options for the WebXR controller creation
  133024. */
  133025. export interface IWebXRControllerOptions {
  133026. /**
  133027. * Should the controller mesh be animated when a user interacts with it
  133028. * The pressed buttons / thumbstick and touchpad animations will be disabled
  133029. */
  133030. disableMotionControllerAnimation?: boolean;
  133031. /**
  133032. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  133033. */
  133034. doNotLoadControllerMesh?: boolean;
  133035. /**
  133036. * Force a specific controller type for this controller.
  133037. * This can be used when creating your own profile or when testing different controllers
  133038. */
  133039. forceControllerProfile?: string;
  133040. /**
  133041. * Defines a rendering group ID for meshes that will be loaded.
  133042. * This is for the default controllers only.
  133043. */
  133044. renderingGroupId?: number;
  133045. }
  133046. /**
  133047. * Represents an XR controller
  133048. */
  133049. export class WebXRInputSource {
  133050. private _scene;
  133051. /** The underlying input source for the controller */
  133052. inputSource: XRInputSource;
  133053. private _options;
  133054. private _tmpVector;
  133055. private _uniqueId;
  133056. private _disposed;
  133057. /**
  133058. * 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
  133059. */
  133060. grip?: AbstractMesh;
  133061. /**
  133062. * If available, this is the gamepad object related to this controller.
  133063. * Using this object it is possible to get click events and trackpad changes of the
  133064. * webxr controller that is currently being used.
  133065. */
  133066. motionController?: WebXRAbstractMotionController;
  133067. /**
  133068. * Event that fires when the controller is removed/disposed.
  133069. * The object provided as event data is this controller, after associated assets were disposed.
  133070. * uniqueId is still available.
  133071. */
  133072. onDisposeObservable: Observable<WebXRInputSource>;
  133073. /**
  133074. * Will be triggered when the mesh associated with the motion controller is done loading.
  133075. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  133076. * A shortened version of controller -> motion controller -> on mesh loaded.
  133077. */
  133078. onMeshLoadedObservable: Observable<AbstractMesh>;
  133079. /**
  133080. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  133081. */
  133082. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  133083. /**
  133084. * Pointer which can be used to select objects or attach a visible laser to
  133085. */
  133086. pointer: AbstractMesh;
  133087. /**
  133088. * Creates the input source object
  133089. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  133090. * @param _scene the scene which the controller should be associated to
  133091. * @param inputSource the underlying input source for the controller
  133092. * @param _options options for this controller creation
  133093. */
  133094. constructor(_scene: Scene,
  133095. /** The underlying input source for the controller */
  133096. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  133097. /**
  133098. * Get this controllers unique id
  133099. */
  133100. get uniqueId(): string;
  133101. /**
  133102. * Disposes of the object
  133103. */
  133104. dispose(): void;
  133105. /**
  133106. * Gets a world space ray coming from the pointer or grip
  133107. * @param result the resulting ray
  133108. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  133109. */
  133110. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  133111. /**
  133112. * Updates the controller pose based on the given XRFrame
  133113. * @param xrFrame xr frame to update the pose with
  133114. * @param referenceSpace reference space to use
  133115. */
  133116. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  133117. }
  133118. }
  133119. declare module BABYLON {
  133120. /**
  133121. * The schema for initialization options of the XR Input class
  133122. */
  133123. export interface IWebXRInputOptions {
  133124. /**
  133125. * If set to true no model will be automatically loaded
  133126. */
  133127. doNotLoadControllerMeshes?: boolean;
  133128. /**
  133129. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  133130. * If not found, the xr input profile data will be used.
  133131. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  133132. */
  133133. forceInputProfile?: string;
  133134. /**
  133135. * Do not send a request to the controller repository to load the profile.
  133136. *
  133137. * Instead, use the controllers available in babylon itself.
  133138. */
  133139. disableOnlineControllerRepository?: boolean;
  133140. /**
  133141. * A custom URL for the controllers repository
  133142. */
  133143. customControllersRepositoryURL?: string;
  133144. /**
  133145. * Should the controller model's components not move according to the user input
  133146. */
  133147. disableControllerAnimation?: boolean;
  133148. /**
  133149. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  133150. */
  133151. controllerOptions?: IWebXRControllerOptions;
  133152. }
  133153. /**
  133154. * XR input used to track XR inputs such as controllers/rays
  133155. */
  133156. export class WebXRInput implements IDisposable {
  133157. /**
  133158. * the xr session manager for this session
  133159. */
  133160. xrSessionManager: WebXRSessionManager;
  133161. /**
  133162. * the WebXR camera for this session. Mainly used for teleportation
  133163. */
  133164. xrCamera: WebXRCamera;
  133165. private readonly options;
  133166. /**
  133167. * XR controllers being tracked
  133168. */
  133169. controllers: Array<WebXRInputSource>;
  133170. private _frameObserver;
  133171. private _sessionEndedObserver;
  133172. private _sessionInitObserver;
  133173. /**
  133174. * Event when a controller has been connected/added
  133175. */
  133176. onControllerAddedObservable: Observable<WebXRInputSource>;
  133177. /**
  133178. * Event when a controller has been removed/disconnected
  133179. */
  133180. onControllerRemovedObservable: Observable<WebXRInputSource>;
  133181. /**
  133182. * Initializes the WebXRInput
  133183. * @param xrSessionManager the xr session manager for this session
  133184. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  133185. * @param options = initialization options for this xr input
  133186. */
  133187. constructor(
  133188. /**
  133189. * the xr session manager for this session
  133190. */
  133191. xrSessionManager: WebXRSessionManager,
  133192. /**
  133193. * the WebXR camera for this session. Mainly used for teleportation
  133194. */
  133195. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  133196. private _onInputSourcesChange;
  133197. private _addAndRemoveControllers;
  133198. /**
  133199. * Disposes of the object
  133200. */
  133201. dispose(): void;
  133202. }
  133203. }
  133204. declare module BABYLON {
  133205. /**
  133206. * This is the base class for all WebXR features.
  133207. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  133208. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  133209. */
  133210. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  133211. protected _xrSessionManager: WebXRSessionManager;
  133212. private _attached;
  133213. private _removeOnDetach;
  133214. /**
  133215. * Is this feature disposed?
  133216. */
  133217. isDisposed: boolean;
  133218. /**
  133219. * Should auto-attach be disabled?
  133220. */
  133221. disableAutoAttach: boolean;
  133222. /**
  133223. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  133224. */
  133225. xrNativeFeatureName: string;
  133226. /**
  133227. * Construct a new (abstract) WebXR feature
  133228. * @param _xrSessionManager the xr session manager for this feature
  133229. */
  133230. constructor(_xrSessionManager: WebXRSessionManager);
  133231. /**
  133232. * Is this feature attached
  133233. */
  133234. get attached(): boolean;
  133235. /**
  133236. * attach this feature
  133237. *
  133238. * @param force should attachment be forced (even when already attached)
  133239. * @returns true if successful, false is failed or already attached
  133240. */
  133241. attach(force?: boolean): boolean;
  133242. /**
  133243. * detach this feature.
  133244. *
  133245. * @returns true if successful, false if failed or already detached
  133246. */
  133247. detach(): boolean;
  133248. /**
  133249. * Dispose this feature and all of the resources attached
  133250. */
  133251. dispose(): void;
  133252. /**
  133253. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  133254. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  133255. *
  133256. * @returns whether or not the feature is compatible in this environment
  133257. */
  133258. isCompatible(): boolean;
  133259. /**
  133260. * This is used to register callbacks that will automatically be removed when detach is called.
  133261. * @param observable the observable to which the observer will be attached
  133262. * @param callback the callback to register
  133263. */
  133264. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  133265. /**
  133266. * Code in this function will be executed on each xrFrame received from the browser.
  133267. * This function will not execute after the feature is detached.
  133268. * @param _xrFrame the current frame
  133269. */
  133270. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  133271. }
  133272. }
  133273. declare module BABYLON {
  133274. /**
  133275. * Renders a layer on top of an existing scene
  133276. */
  133277. export class UtilityLayerRenderer implements IDisposable {
  133278. /** the original scene that will be rendered on top of */
  133279. originalScene: Scene;
  133280. private _pointerCaptures;
  133281. private _lastPointerEvents;
  133282. private static _DefaultUtilityLayer;
  133283. private static _DefaultKeepDepthUtilityLayer;
  133284. private _sharedGizmoLight;
  133285. private _renderCamera;
  133286. /**
  133287. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  133288. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  133289. * @returns the camera that is used when rendering the utility layer
  133290. */
  133291. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  133292. /**
  133293. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  133294. * @param cam the camera that should be used when rendering the utility layer
  133295. */
  133296. setRenderCamera(cam: Nullable<Camera>): void;
  133297. /**
  133298. * @hidden
  133299. * Light which used by gizmos to get light shading
  133300. */
  133301. _getSharedGizmoLight(): HemisphericLight;
  133302. /**
  133303. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  133304. */
  133305. pickUtilitySceneFirst: boolean;
  133306. /**
  133307. * 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)
  133308. */
  133309. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  133310. /**
  133311. * 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)
  133312. */
  133313. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  133314. /**
  133315. * The scene that is rendered on top of the original scene
  133316. */
  133317. utilityLayerScene: Scene;
  133318. /**
  133319. * If the utility layer should automatically be rendered on top of existing scene
  133320. */
  133321. shouldRender: boolean;
  133322. /**
  133323. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  133324. */
  133325. onlyCheckPointerDownEvents: boolean;
  133326. /**
  133327. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  133328. */
  133329. processAllEvents: boolean;
  133330. /**
  133331. * Observable raised when the pointer move from the utility layer scene to the main scene
  133332. */
  133333. onPointerOutObservable: Observable<number>;
  133334. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  133335. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  133336. private _afterRenderObserver;
  133337. private _sceneDisposeObserver;
  133338. private _originalPointerObserver;
  133339. /**
  133340. * Instantiates a UtilityLayerRenderer
  133341. * @param originalScene the original scene that will be rendered on top of
  133342. * @param handleEvents boolean indicating if the utility layer should handle events
  133343. */
  133344. constructor(
  133345. /** the original scene that will be rendered on top of */
  133346. originalScene: Scene, handleEvents?: boolean);
  133347. private _notifyObservers;
  133348. /**
  133349. * Renders the utility layers scene on top of the original scene
  133350. */
  133351. render(): void;
  133352. /**
  133353. * Disposes of the renderer
  133354. */
  133355. dispose(): void;
  133356. private _updateCamera;
  133357. }
  133358. }
  133359. declare module BABYLON {
  133360. /**
  133361. * Options interface for the pointer selection module
  133362. */
  133363. export interface IWebXRControllerPointerSelectionOptions {
  133364. /**
  133365. * if provided, this scene will be used to render meshes.
  133366. */
  133367. customUtilityLayerScene?: Scene;
  133368. /**
  133369. * 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)
  133370. * If not disabled, the last picked point will be used to execute a pointer up event
  133371. * If disabled, pointer up event will be triggered right after the pointer down event.
  133372. * Used in screen and gaze target ray mode only
  133373. */
  133374. disablePointerUpOnTouchOut: boolean;
  133375. /**
  133376. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  133377. */
  133378. forceGazeMode: boolean;
  133379. /**
  133380. * 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
  133381. * to start a new countdown to the pointer down event.
  133382. * Defaults to 1.
  133383. */
  133384. gazeModePointerMovedFactor?: number;
  133385. /**
  133386. * Different button type to use instead of the main component
  133387. */
  133388. overrideButtonId?: string;
  133389. /**
  133390. * use this rendering group id for the meshes (optional)
  133391. */
  133392. renderingGroupId?: number;
  133393. /**
  133394. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  133395. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  133396. * 3000 means 3 seconds between pointing at something and selecting it
  133397. */
  133398. timeToSelect?: number;
  133399. /**
  133400. * Should meshes created here be added to a utility layer or the main scene
  133401. */
  133402. useUtilityLayer?: boolean;
  133403. /**
  133404. * Optional WebXR camera to be used for gaze selection
  133405. */
  133406. gazeCamera?: WebXRCamera;
  133407. /**
  133408. * the xr input to use with this pointer selection
  133409. */
  133410. xrInput: WebXRInput;
  133411. /**
  133412. * Should the scene pointerX and pointerY update be disabled
  133413. * This is required for fullscreen AR GUI, but might slow down other experiences.
  133414. * Disable in VR, if not needed.
  133415. * The first rig camera (left eye) will be used to calculate the projection
  133416. */
  133417. disableScenePointerVectorUpdate: boolean;
  133418. /**
  133419. * Enable pointer selection on all controllers instead of switching between them
  133420. */
  133421. enablePointerSelectionOnAllControllers?: boolean;
  133422. /**
  133423. * The preferred hand to give the pointer selection to. This will be prioritized when the controller initialize.
  133424. * If switch is enabled, it will still allow the user to switch between the different controllers
  133425. */
  133426. preferredHandedness?: XRHandedness;
  133427. /**
  133428. * Disable switching the pointer selection from one controller to the other.
  133429. * 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
  133430. */
  133431. disableSwitchOnClick?: boolean;
  133432. /**
  133433. * The maximum distance of the pointer selection feature. Defaults to 100.
  133434. */
  133435. maxPointerDistance?: number;
  133436. }
  133437. /**
  133438. * A module that will enable pointer selection for motion controllers of XR Input Sources
  133439. */
  133440. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  133441. private readonly _options;
  133442. private static _idCounter;
  133443. private _attachController;
  133444. private _controllers;
  133445. private _scene;
  133446. private _tmpVectorForPickCompare;
  133447. private _attachedController;
  133448. /**
  133449. * The module's name
  133450. */
  133451. static readonly Name: string;
  133452. /**
  133453. * The (Babylon) version of this module.
  133454. * This is an integer representing the implementation version.
  133455. * This number does not correspond to the WebXR specs version
  133456. */
  133457. static readonly Version: number;
  133458. /**
  133459. * Disable lighting on the laser pointer (so it will always be visible)
  133460. */
  133461. disablePointerLighting: boolean;
  133462. /**
  133463. * Disable lighting on the selection mesh (so it will always be visible)
  133464. */
  133465. disableSelectionMeshLighting: boolean;
  133466. /**
  133467. * Should the laser pointer be displayed
  133468. */
  133469. displayLaserPointer: boolean;
  133470. /**
  133471. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  133472. */
  133473. displaySelectionMesh: boolean;
  133474. /**
  133475. * This color will be set to the laser pointer when selection is triggered
  133476. */
  133477. laserPointerPickedColor: Color3;
  133478. /**
  133479. * Default color of the laser pointer
  133480. */
  133481. laserPointerDefaultColor: Color3;
  133482. /**
  133483. * default color of the selection ring
  133484. */
  133485. selectionMeshDefaultColor: Color3;
  133486. /**
  133487. * This color will be applied to the selection ring when selection is triggered
  133488. */
  133489. selectionMeshPickedColor: Color3;
  133490. /**
  133491. * Optional filter to be used for ray selection. This predicate shares behavior with
  133492. * scene.pointerMovePredicate which takes priority if it is also assigned.
  133493. */
  133494. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  133495. /**
  133496. * constructs a new background remover module
  133497. * @param _xrSessionManager the session manager for this module
  133498. * @param _options read-only options to be used in this module
  133499. */
  133500. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  133501. /**
  133502. * attach this feature
  133503. * Will usually be called by the features manager
  133504. *
  133505. * @returns true if successful.
  133506. */
  133507. attach(): boolean;
  133508. /**
  133509. * detach this feature.
  133510. * Will usually be called by the features manager
  133511. *
  133512. * @returns true if successful.
  133513. */
  133514. detach(): boolean;
  133515. /**
  133516. * Will get the mesh under a specific pointer.
  133517. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  133518. * @param controllerId the controllerId to check
  133519. * @returns The mesh under pointer or null if no mesh is under the pointer
  133520. */
  133521. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  133522. /**
  133523. * Get the xr controller that correlates to the pointer id in the pointer event
  133524. *
  133525. * @param id the pointer id to search for
  133526. * @returns the controller that correlates to this id or null if not found
  133527. */
  133528. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  133529. private _identityMatrix;
  133530. private _screenCoordinatesRef;
  133531. private _viewportRef;
  133532. protected _onXRFrame(_xrFrame: XRFrame): void;
  133533. private _attachGazeMode;
  133534. private _attachScreenRayMode;
  133535. private _attachTrackedPointerRayMode;
  133536. private _convertNormalToDirectionOfRay;
  133537. private _detachController;
  133538. private _generateNewMeshPair;
  133539. private _pickingMoved;
  133540. private _updatePointerDistance;
  133541. /** @hidden */
  133542. get lasterPointerDefaultColor(): Color3;
  133543. }
  133544. }
  133545. declare module BABYLON {
  133546. /**
  133547. * Button which can be used to enter a different mode of XR
  133548. */
  133549. export class WebXREnterExitUIButton {
  133550. /** button element */
  133551. element: HTMLElement;
  133552. /** XR initialization options for the button */
  133553. sessionMode: XRSessionMode;
  133554. /** Reference space type */
  133555. referenceSpaceType: XRReferenceSpaceType;
  133556. /**
  133557. * Creates a WebXREnterExitUIButton
  133558. * @param element button element
  133559. * @param sessionMode XR initialization session mode
  133560. * @param referenceSpaceType the type of reference space to be used
  133561. */
  133562. constructor(
  133563. /** button element */
  133564. element: HTMLElement,
  133565. /** XR initialization options for the button */
  133566. sessionMode: XRSessionMode,
  133567. /** Reference space type */
  133568. referenceSpaceType: XRReferenceSpaceType);
  133569. /**
  133570. * Extendable function which can be used to update the button's visuals when the state changes
  133571. * @param activeButton the current active button in the UI
  133572. */
  133573. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  133574. }
  133575. /**
  133576. * Options to create the webXR UI
  133577. */
  133578. export class WebXREnterExitUIOptions {
  133579. /**
  133580. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  133581. */
  133582. customButtons?: Array<WebXREnterExitUIButton>;
  133583. /**
  133584. * A reference space type to use when creating the default button.
  133585. * Default is local-floor
  133586. */
  133587. referenceSpaceType?: XRReferenceSpaceType;
  133588. /**
  133589. * Context to enter xr with
  133590. */
  133591. renderTarget?: Nullable<WebXRRenderTarget>;
  133592. /**
  133593. * A session mode to use when creating the default button.
  133594. * Default is immersive-vr
  133595. */
  133596. sessionMode?: XRSessionMode;
  133597. /**
  133598. * A list of optional features to init the session with
  133599. */
  133600. optionalFeatures?: string[];
  133601. /**
  133602. * A list of optional features to init the session with
  133603. */
  133604. requiredFeatures?: string[];
  133605. }
  133606. /**
  133607. * UI to allow the user to enter/exit XR mode
  133608. */
  133609. export class WebXREnterExitUI implements IDisposable {
  133610. private scene;
  133611. /** version of the options passed to this UI */
  133612. options: WebXREnterExitUIOptions;
  133613. private _activeButton;
  133614. private _buttons;
  133615. /**
  133616. * The HTML Div Element to which buttons are added.
  133617. */
  133618. readonly overlay: HTMLDivElement;
  133619. /**
  133620. * Fired every time the active button is changed.
  133621. *
  133622. * When xr is entered via a button that launches xr that button will be the callback parameter
  133623. *
  133624. * When exiting xr the callback parameter will be null)
  133625. */
  133626. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  133627. /**
  133628. *
  133629. * @param scene babylon scene object to use
  133630. * @param options (read-only) version of the options passed to this UI
  133631. */
  133632. private constructor();
  133633. /**
  133634. * Creates UI to allow the user to enter/exit XR mode
  133635. * @param scene the scene to add the ui to
  133636. * @param helper the xr experience helper to enter/exit xr with
  133637. * @param options options to configure the UI
  133638. * @returns the created ui
  133639. */
  133640. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  133641. /**
  133642. * Disposes of the XR UI component
  133643. */
  133644. dispose(): void;
  133645. private _updateButtons;
  133646. }
  133647. }
  133648. declare module BABYLON {
  133649. /**
  133650. * Class containing static functions to help procedurally build meshes
  133651. */
  133652. export class LinesBuilder {
  133653. /**
  133654. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  133655. * * 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
  133656. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  133657. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  133658. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  133659. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  133660. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133661. * * 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
  133662. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  133663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  133665. * @param name defines the name of the new line system
  133666. * @param options defines the options used to create the line system
  133667. * @param scene defines the hosting scene
  133668. * @returns a new line system mesh
  133669. */
  133670. static CreateLineSystem(name: string, options: {
  133671. lines: Vector3[][];
  133672. updatable?: boolean;
  133673. instance?: Nullable<LinesMesh>;
  133674. colors?: Nullable<Color4[][]>;
  133675. useVertexAlpha?: boolean;
  133676. }, scene: Nullable<Scene>): LinesMesh;
  133677. /**
  133678. * Creates a line mesh
  133679. * 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
  133680. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133681. * * The parameter `points` is an array successive Vector3
  133682. * * 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
  133683. * * The optional parameter `colors` is an array of successive Color4, one per line point
  133684. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  133685. * * When updating an instance, remember that only point positions can change, not the number of points
  133686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133687. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  133688. * @param name defines the name of the new line system
  133689. * @param options defines the options used to create the line system
  133690. * @param scene defines the hosting scene
  133691. * @returns a new line mesh
  133692. */
  133693. static CreateLines(name: string, options: {
  133694. points: Vector3[];
  133695. updatable?: boolean;
  133696. instance?: Nullable<LinesMesh>;
  133697. colors?: Color4[];
  133698. useVertexAlpha?: boolean;
  133699. }, scene?: Nullable<Scene>): LinesMesh;
  133700. /**
  133701. * Creates a dashed line mesh
  133702. * * 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
  133703. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  133704. * * The parameter `points` is an array successive Vector3
  133705. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  133706. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  133707. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  133708. * * 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
  133709. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  133710. * * When updating an instance, remember that only point positions can change, not the number of points
  133711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133712. * @param name defines the name of the mesh
  133713. * @param options defines the options used to create the mesh
  133714. * @param scene defines the hosting scene
  133715. * @returns the dashed line mesh
  133716. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  133717. */
  133718. static CreateDashedLines(name: string, options: {
  133719. points: Vector3[];
  133720. dashSize?: number;
  133721. gapSize?: number;
  133722. dashNb?: number;
  133723. updatable?: boolean;
  133724. instance?: LinesMesh;
  133725. useVertexAlpha?: boolean;
  133726. }, scene?: Nullable<Scene>): LinesMesh;
  133727. }
  133728. }
  133729. declare module BABYLON {
  133730. /**
  133731. * Construction options for a timer
  133732. */
  133733. export interface ITimerOptions<T> {
  133734. /**
  133735. * Time-to-end
  133736. */
  133737. timeout: number;
  133738. /**
  133739. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  133740. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  133741. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  133742. */
  133743. contextObservable: Observable<T>;
  133744. /**
  133745. * Optional parameters when adding an observer to the observable
  133746. */
  133747. observableParameters?: {
  133748. mask?: number;
  133749. insertFirst?: boolean;
  133750. scope?: any;
  133751. };
  133752. /**
  133753. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  133754. */
  133755. breakCondition?: (data?: ITimerData<T>) => boolean;
  133756. /**
  133757. * Will be triggered when the time condition has met
  133758. */
  133759. onEnded?: (data: ITimerData<any>) => void;
  133760. /**
  133761. * Will be triggered when the break condition has met (prematurely ended)
  133762. */
  133763. onAborted?: (data: ITimerData<any>) => void;
  133764. /**
  133765. * Optional function to execute on each tick (or count)
  133766. */
  133767. onTick?: (data: ITimerData<any>) => void;
  133768. }
  133769. /**
  133770. * An interface defining the data sent by the timer
  133771. */
  133772. export interface ITimerData<T> {
  133773. /**
  133774. * When did it start
  133775. */
  133776. startTime: number;
  133777. /**
  133778. * Time now
  133779. */
  133780. currentTime: number;
  133781. /**
  133782. * Time passed since started
  133783. */
  133784. deltaTime: number;
  133785. /**
  133786. * How much is completed, in [0.0...1.0].
  133787. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  133788. */
  133789. completeRate: number;
  133790. /**
  133791. * What the registered observable sent in the last count
  133792. */
  133793. payload: T;
  133794. }
  133795. /**
  133796. * The current state of the timer
  133797. */
  133798. export enum TimerState {
  133799. /**
  133800. * Timer initialized, not yet started
  133801. */
  133802. INIT = 0,
  133803. /**
  133804. * Timer started and counting
  133805. */
  133806. STARTED = 1,
  133807. /**
  133808. * Timer ended (whether aborted or time reached)
  133809. */
  133810. ENDED = 2
  133811. }
  133812. /**
  133813. * A simple version of the timer. Will take options and start the timer immediately after calling it
  133814. *
  133815. * @param options options with which to initialize this timer
  133816. */
  133817. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  133818. /**
  133819. * An advanced implementation of a timer class
  133820. */
  133821. export class AdvancedTimer<T = any> implements IDisposable {
  133822. /**
  133823. * Will notify each time the timer calculates the remaining time
  133824. */
  133825. onEachCountObservable: Observable<ITimerData<T>>;
  133826. /**
  133827. * Will trigger when the timer was aborted due to the break condition
  133828. */
  133829. onTimerAbortedObservable: Observable<ITimerData<T>>;
  133830. /**
  133831. * Will trigger when the timer ended successfully
  133832. */
  133833. onTimerEndedObservable: Observable<ITimerData<T>>;
  133834. /**
  133835. * Will trigger when the timer state has changed
  133836. */
  133837. onStateChangedObservable: Observable<TimerState>;
  133838. private _observer;
  133839. private _contextObservable;
  133840. private _observableParameters;
  133841. private _startTime;
  133842. private _timer;
  133843. private _state;
  133844. private _breakCondition;
  133845. private _timeToEnd;
  133846. private _breakOnNextTick;
  133847. /**
  133848. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  133849. * @param options construction options for this advanced timer
  133850. */
  133851. constructor(options: ITimerOptions<T>);
  133852. /**
  133853. * set a breaking condition for this timer. Default is to never break during count
  133854. * @param predicate the new break condition. Returns true to break, false otherwise
  133855. */
  133856. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  133857. /**
  133858. * Reset ALL associated observables in this advanced timer
  133859. */
  133860. clearObservables(): void;
  133861. /**
  133862. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  133863. *
  133864. * @param timeToEnd how much time to measure until timer ended
  133865. */
  133866. start(timeToEnd?: number): void;
  133867. /**
  133868. * Will force a stop on the next tick.
  133869. */
  133870. stop(): void;
  133871. /**
  133872. * Dispose this timer, clearing all resources
  133873. */
  133874. dispose(): void;
  133875. private _setState;
  133876. private _tick;
  133877. private _stop;
  133878. }
  133879. }
  133880. declare module BABYLON {
  133881. /**
  133882. * The options container for the teleportation module
  133883. */
  133884. export interface IWebXRTeleportationOptions {
  133885. /**
  133886. * if provided, this scene will be used to render meshes.
  133887. */
  133888. customUtilityLayerScene?: Scene;
  133889. /**
  133890. * Values to configure the default target mesh
  133891. */
  133892. defaultTargetMeshOptions?: {
  133893. /**
  133894. * Fill color of the teleportation area
  133895. */
  133896. teleportationFillColor?: string;
  133897. /**
  133898. * Border color for the teleportation area
  133899. */
  133900. teleportationBorderColor?: string;
  133901. /**
  133902. * Disable the mesh's animation sequence
  133903. */
  133904. disableAnimation?: boolean;
  133905. /**
  133906. * Disable lighting on the material or the ring and arrow
  133907. */
  133908. disableLighting?: boolean;
  133909. /**
  133910. * Override the default material of the torus and arrow
  133911. */
  133912. torusArrowMaterial?: Material;
  133913. };
  133914. /**
  133915. * A list of meshes to use as floor meshes.
  133916. * Meshes can be added and removed after initializing the feature using the
  133917. * addFloorMesh and removeFloorMesh functions
  133918. * If empty, rotation will still work
  133919. */
  133920. floorMeshes?: AbstractMesh[];
  133921. /**
  133922. * use this rendering group id for the meshes (optional)
  133923. */
  133924. renderingGroupId?: number;
  133925. /**
  133926. * Should teleportation move only to snap points
  133927. */
  133928. snapPointsOnly?: boolean;
  133929. /**
  133930. * An array of points to which the teleportation will snap to.
  133931. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  133932. */
  133933. snapPositions?: Vector3[];
  133934. /**
  133935. * How close should the teleportation ray be in order to snap to position.
  133936. * Default to 0.8 units (meters)
  133937. */
  133938. snapToPositionRadius?: number;
  133939. /**
  133940. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  133941. * If you want to support rotation, make sure your mesh has a direction indicator.
  133942. *
  133943. * When left untouched, the default mesh will be initialized.
  133944. */
  133945. teleportationTargetMesh?: AbstractMesh;
  133946. /**
  133947. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  133948. */
  133949. timeToTeleport?: number;
  133950. /**
  133951. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  133952. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  133953. */
  133954. useMainComponentOnly?: boolean;
  133955. /**
  133956. * Should meshes created here be added to a utility layer or the main scene
  133957. */
  133958. useUtilityLayer?: boolean;
  133959. /**
  133960. * Babylon XR Input class for controller
  133961. */
  133962. xrInput: WebXRInput;
  133963. /**
  133964. * Meshes that the teleportation ray cannot go through
  133965. */
  133966. pickBlockerMeshes?: AbstractMesh[];
  133967. }
  133968. /**
  133969. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  133970. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  133971. * the input of the attached controllers.
  133972. */
  133973. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  133974. private _options;
  133975. private _controllers;
  133976. private _currentTeleportationControllerId;
  133977. private _floorMeshes;
  133978. private _quadraticBezierCurve;
  133979. private _selectionFeature;
  133980. private _snapToPositions;
  133981. private _snappedToPoint;
  133982. private _teleportationRingMaterial?;
  133983. private _tmpRay;
  133984. private _tmpVector;
  133985. private _tmpQuaternion;
  133986. /**
  133987. * The module's name
  133988. */
  133989. static readonly Name: string;
  133990. /**
  133991. * The (Babylon) version of this module.
  133992. * This is an integer representing the implementation version.
  133993. * This number does not correspond to the webxr specs version
  133994. */
  133995. static readonly Version: number;
  133996. /**
  133997. * Is movement backwards enabled
  133998. */
  133999. backwardsMovementEnabled: boolean;
  134000. /**
  134001. * Distance to travel when moving backwards
  134002. */
  134003. backwardsTeleportationDistance: number;
  134004. /**
  134005. * The distance from the user to the inspection point in the direction of the controller
  134006. * A higher number will allow the user to move further
  134007. * defaults to 5 (meters, in xr units)
  134008. */
  134009. parabolicCheckRadius: number;
  134010. /**
  134011. * Should the module support parabolic ray on top of direct ray
  134012. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  134013. * Very helpful when moving between floors / different heights
  134014. */
  134015. parabolicRayEnabled: boolean;
  134016. /**
  134017. * How much rotation should be applied when rotating right and left
  134018. */
  134019. rotationAngle: number;
  134020. /**
  134021. * Is rotation enabled when moving forward?
  134022. * Disabling this feature will prevent the user from deciding the direction when teleporting
  134023. */
  134024. rotationEnabled: boolean;
  134025. /**
  134026. * constructs a new anchor system
  134027. * @param _xrSessionManager an instance of WebXRSessionManager
  134028. * @param _options configuration object for this feature
  134029. */
  134030. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  134031. /**
  134032. * Get the snapPointsOnly flag
  134033. */
  134034. get snapPointsOnly(): boolean;
  134035. /**
  134036. * Sets the snapPointsOnly flag
  134037. * @param snapToPoints should teleportation be exclusively to snap points
  134038. */
  134039. set snapPointsOnly(snapToPoints: boolean);
  134040. /**
  134041. * Add a new mesh to the floor meshes array
  134042. * @param mesh the mesh to use as floor mesh
  134043. */
  134044. addFloorMesh(mesh: AbstractMesh): void;
  134045. /**
  134046. * Add a new snap-to point to fix teleportation to this position
  134047. * @param newSnapPoint The new Snap-To point
  134048. */
  134049. addSnapPoint(newSnapPoint: Vector3): void;
  134050. attach(): boolean;
  134051. detach(): boolean;
  134052. dispose(): void;
  134053. /**
  134054. * Remove a mesh from the floor meshes array
  134055. * @param mesh the mesh to remove
  134056. */
  134057. removeFloorMesh(mesh: AbstractMesh): void;
  134058. /**
  134059. * Remove a mesh from the floor meshes array using its name
  134060. * @param name the mesh name to remove
  134061. */
  134062. removeFloorMeshByName(name: string): void;
  134063. /**
  134064. * 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
  134065. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  134066. * @returns was the point found and removed or not
  134067. */
  134068. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  134069. /**
  134070. * This function sets a selection feature that will be disabled when
  134071. * the forward ray is shown and will be reattached when hidden.
  134072. * This is used to remove the selection rays when moving.
  134073. * @param selectionFeature the feature to disable when forward movement is enabled
  134074. */
  134075. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  134076. protected _onXRFrame(_xrFrame: XRFrame): void;
  134077. private _attachController;
  134078. private _createDefaultTargetMesh;
  134079. private _detachController;
  134080. private _findClosestSnapPointWithRadius;
  134081. private _setTargetMeshPosition;
  134082. private _setTargetMeshVisibility;
  134083. private _showParabolicPath;
  134084. private _teleportForward;
  134085. }
  134086. }
  134087. declare module BABYLON {
  134088. /**
  134089. * Options for the default xr helper
  134090. */
  134091. export class WebXRDefaultExperienceOptions {
  134092. /**
  134093. * Enable or disable default UI to enter XR
  134094. */
  134095. disableDefaultUI?: boolean;
  134096. /**
  134097. * Should teleportation not initialize. defaults to false.
  134098. */
  134099. disableTeleportation?: boolean;
  134100. /**
  134101. * Floor meshes that will be used for teleport
  134102. */
  134103. floorMeshes?: Array<AbstractMesh>;
  134104. /**
  134105. * If set to true, the first frame will not be used to reset position
  134106. * The first frame is mainly used when copying transformation from the old camera
  134107. * Mainly used in AR
  134108. */
  134109. ignoreNativeCameraTransformation?: boolean;
  134110. /**
  134111. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  134112. */
  134113. inputOptions?: IWebXRInputOptions;
  134114. /**
  134115. * optional configuration for the output canvas
  134116. */
  134117. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  134118. /**
  134119. * optional UI options. This can be used among other to change session mode and reference space type
  134120. */
  134121. uiOptions?: WebXREnterExitUIOptions;
  134122. /**
  134123. * When loading teleportation and pointer select, use stable versions instead of latest.
  134124. */
  134125. useStablePlugins?: boolean;
  134126. /**
  134127. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  134128. */
  134129. renderingGroupId?: number;
  134130. /**
  134131. * A list of optional features to init the session with
  134132. * If set to true, all features we support will be added
  134133. */
  134134. optionalFeatures?: boolean | string[];
  134135. }
  134136. /**
  134137. * Default experience which provides a similar setup to the previous webVRExperience
  134138. */
  134139. export class WebXRDefaultExperience {
  134140. /**
  134141. * Base experience
  134142. */
  134143. baseExperience: WebXRExperienceHelper;
  134144. /**
  134145. * Enables ui for entering/exiting xr
  134146. */
  134147. enterExitUI: WebXREnterExitUI;
  134148. /**
  134149. * Input experience extension
  134150. */
  134151. input: WebXRInput;
  134152. /**
  134153. * Enables laser pointer and selection
  134154. */
  134155. pointerSelection: WebXRControllerPointerSelection;
  134156. /**
  134157. * Default target xr should render to
  134158. */
  134159. renderTarget: WebXRRenderTarget;
  134160. /**
  134161. * Enables teleportation
  134162. */
  134163. teleportation: WebXRMotionControllerTeleportation;
  134164. private constructor();
  134165. /**
  134166. * Creates the default xr experience
  134167. * @param scene scene
  134168. * @param options options for basic configuration
  134169. * @returns resulting WebXRDefaultExperience
  134170. */
  134171. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  134172. /**
  134173. * DIsposes of the experience helper
  134174. */
  134175. dispose(): void;
  134176. }
  134177. }
  134178. declare module BABYLON {
  134179. /**
  134180. * Options to modify the vr teleportation behavior.
  134181. */
  134182. export interface VRTeleportationOptions {
  134183. /**
  134184. * The name of the mesh which should be used as the teleportation floor. (default: null)
  134185. */
  134186. floorMeshName?: string;
  134187. /**
  134188. * A list of meshes to be used as the teleportation floor. (default: empty)
  134189. */
  134190. floorMeshes?: Mesh[];
  134191. /**
  134192. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  134193. */
  134194. teleportationMode?: number;
  134195. /**
  134196. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  134197. */
  134198. teleportationTime?: number;
  134199. /**
  134200. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  134201. */
  134202. teleportationSpeed?: number;
  134203. /**
  134204. * The easing function used in the animation or null for Linear. (default CircleEase)
  134205. */
  134206. easingFunction?: EasingFunction;
  134207. }
  134208. /**
  134209. * Options to modify the vr experience helper's behavior.
  134210. */
  134211. export interface VRExperienceHelperOptions extends WebVROptions {
  134212. /**
  134213. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  134214. */
  134215. createDeviceOrientationCamera?: boolean;
  134216. /**
  134217. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  134218. */
  134219. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  134220. /**
  134221. * Uses the main button on the controller to toggle the laser casted. (default: true)
  134222. */
  134223. laserToggle?: boolean;
  134224. /**
  134225. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  134226. */
  134227. floorMeshes?: Mesh[];
  134228. /**
  134229. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  134230. */
  134231. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  134232. /**
  134233. * Defines if WebXR should be used instead of WebVR (if available)
  134234. */
  134235. useXR?: boolean;
  134236. }
  134237. /**
  134238. * Event containing information after VR has been entered
  134239. */
  134240. export class OnAfterEnteringVRObservableEvent {
  134241. /**
  134242. * If entering vr was successful
  134243. */
  134244. success: boolean;
  134245. }
  134246. /**
  134247. * Helps to quickly add VR support to an existing scene.
  134248. * See https://doc.babylonjs.com/how_to/webvr_helper
  134249. */
  134250. export class VRExperienceHelper {
  134251. /** Options to modify the vr experience helper's behavior. */
  134252. webVROptions: VRExperienceHelperOptions;
  134253. private _scene;
  134254. private _position;
  134255. private _btnVR;
  134256. private _btnVRDisplayed;
  134257. private _webVRsupported;
  134258. private _webVRready;
  134259. private _webVRrequesting;
  134260. private _webVRpresenting;
  134261. private _hasEnteredVR;
  134262. private _fullscreenVRpresenting;
  134263. private _inputElement;
  134264. private _webVRCamera;
  134265. private _vrDeviceOrientationCamera;
  134266. private _deviceOrientationCamera;
  134267. private _existingCamera;
  134268. private _onKeyDown;
  134269. private _onVrDisplayPresentChange;
  134270. private _onVRDisplayChanged;
  134271. private _onVRRequestPresentStart;
  134272. private _onVRRequestPresentComplete;
  134273. /**
  134274. * 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)
  134275. */
  134276. enableGazeEvenWhenNoPointerLock: boolean;
  134277. /**
  134278. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  134279. */
  134280. exitVROnDoubleTap: boolean;
  134281. /**
  134282. * Observable raised right before entering VR.
  134283. */
  134284. onEnteringVRObservable: Observable<VRExperienceHelper>;
  134285. /**
  134286. * Observable raised when entering VR has completed.
  134287. */
  134288. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  134289. /**
  134290. * Observable raised when exiting VR.
  134291. */
  134292. onExitingVRObservable: Observable<VRExperienceHelper>;
  134293. /**
  134294. * Observable raised when controller mesh is loaded.
  134295. */
  134296. onControllerMeshLoadedObservable: Observable<WebVRController>;
  134297. /** Return this.onEnteringVRObservable
  134298. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  134299. */
  134300. get onEnteringVR(): Observable<VRExperienceHelper>;
  134301. /** Return this.onExitingVRObservable
  134302. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  134303. */
  134304. get onExitingVR(): Observable<VRExperienceHelper>;
  134305. /** Return this.onControllerMeshLoadedObservable
  134306. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  134307. */
  134308. get onControllerMeshLoaded(): Observable<WebVRController>;
  134309. private _rayLength;
  134310. private _useCustomVRButton;
  134311. private _teleportationRequested;
  134312. private _teleportActive;
  134313. private _floorMeshName;
  134314. private _floorMeshesCollection;
  134315. private _teleportationMode;
  134316. private _teleportationTime;
  134317. private _teleportationSpeed;
  134318. private _teleportationEasing;
  134319. private _rotationAllowed;
  134320. private _teleportBackwardsVector;
  134321. private _teleportationTarget;
  134322. private _isDefaultTeleportationTarget;
  134323. private _postProcessMove;
  134324. private _teleportationFillColor;
  134325. private _teleportationBorderColor;
  134326. private _rotationAngle;
  134327. private _haloCenter;
  134328. private _cameraGazer;
  134329. private _padSensibilityUp;
  134330. private _padSensibilityDown;
  134331. private _leftController;
  134332. private _rightController;
  134333. private _gazeColor;
  134334. private _laserColor;
  134335. private _pickedLaserColor;
  134336. private _pickedGazeColor;
  134337. /**
  134338. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  134339. */
  134340. onNewMeshSelected: Observable<AbstractMesh>;
  134341. /**
  134342. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  134343. * This observable will provide the mesh and the controller used to select the mesh
  134344. */
  134345. onMeshSelectedWithController: Observable<{
  134346. mesh: AbstractMesh;
  134347. controller: WebVRController;
  134348. }>;
  134349. /**
  134350. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  134351. */
  134352. onNewMeshPicked: Observable<PickingInfo>;
  134353. private _circleEase;
  134354. /**
  134355. * Observable raised before camera teleportation
  134356. */
  134357. onBeforeCameraTeleport: Observable<Vector3>;
  134358. /**
  134359. * Observable raised after camera teleportation
  134360. */
  134361. onAfterCameraTeleport: Observable<Vector3>;
  134362. /**
  134363. * Observable raised when current selected mesh gets unselected
  134364. */
  134365. onSelectedMeshUnselected: Observable<AbstractMesh>;
  134366. private _raySelectionPredicate;
  134367. /**
  134368. * To be optionaly changed by user to define custom ray selection
  134369. */
  134370. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  134371. /**
  134372. * To be optionaly changed by user to define custom selection logic (after ray selection)
  134373. */
  134374. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  134375. /**
  134376. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  134377. */
  134378. teleportationEnabled: boolean;
  134379. private _defaultHeight;
  134380. private _teleportationInitialized;
  134381. private _interactionsEnabled;
  134382. private _interactionsRequested;
  134383. private _displayGaze;
  134384. private _displayLaserPointer;
  134385. /**
  134386. * The mesh used to display where the user is going to teleport.
  134387. */
  134388. get teleportationTarget(): Mesh;
  134389. /**
  134390. * Sets the mesh to be used to display where the user is going to teleport.
  134391. */
  134392. set teleportationTarget(value: Mesh);
  134393. /**
  134394. * 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
  134395. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  134396. * See https://doc.babylonjs.com/resources/baking_transformations
  134397. */
  134398. get gazeTrackerMesh(): Mesh;
  134399. set gazeTrackerMesh(value: Mesh);
  134400. /**
  134401. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  134402. */
  134403. updateGazeTrackerScale: boolean;
  134404. /**
  134405. * If the gaze trackers color should be updated when selecting meshes
  134406. */
  134407. updateGazeTrackerColor: boolean;
  134408. /**
  134409. * If the controller laser color should be updated when selecting meshes
  134410. */
  134411. updateControllerLaserColor: boolean;
  134412. /**
  134413. * The gaze tracking mesh corresponding to the left controller
  134414. */
  134415. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  134416. /**
  134417. * The gaze tracking mesh corresponding to the right controller
  134418. */
  134419. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  134420. /**
  134421. * If the ray of the gaze should be displayed.
  134422. */
  134423. get displayGaze(): boolean;
  134424. /**
  134425. * Sets if the ray of the gaze should be displayed.
  134426. */
  134427. set displayGaze(value: boolean);
  134428. /**
  134429. * If the ray of the LaserPointer should be displayed.
  134430. */
  134431. get displayLaserPointer(): boolean;
  134432. /**
  134433. * Sets if the ray of the LaserPointer should be displayed.
  134434. */
  134435. set displayLaserPointer(value: boolean);
  134436. /**
  134437. * The deviceOrientationCamera used as the camera when not in VR.
  134438. */
  134439. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  134440. /**
  134441. * Based on the current WebVR support, returns the current VR camera used.
  134442. */
  134443. get currentVRCamera(): Nullable<Camera>;
  134444. /**
  134445. * The webVRCamera which is used when in VR.
  134446. */
  134447. get webVRCamera(): WebVRFreeCamera;
  134448. /**
  134449. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  134450. */
  134451. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  134452. /**
  134453. * The html button that is used to trigger entering into VR.
  134454. */
  134455. get vrButton(): Nullable<HTMLButtonElement>;
  134456. private get _teleportationRequestInitiated();
  134457. /**
  134458. * Defines whether or not Pointer lock should be requested when switching to
  134459. * full screen.
  134460. */
  134461. requestPointerLockOnFullScreen: boolean;
  134462. /**
  134463. * If asking to force XR, this will be populated with the default xr experience
  134464. */
  134465. xr: WebXRDefaultExperience;
  134466. /**
  134467. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  134468. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  134469. */
  134470. xrTestDone: boolean;
  134471. /**
  134472. * Instantiates a VRExperienceHelper.
  134473. * Helps to quickly add VR support to an existing scene.
  134474. * @param scene The scene the VRExperienceHelper belongs to.
  134475. * @param webVROptions Options to modify the vr experience helper's behavior.
  134476. */
  134477. constructor(scene: Scene,
  134478. /** Options to modify the vr experience helper's behavior. */
  134479. webVROptions?: VRExperienceHelperOptions);
  134480. private completeVRInit;
  134481. private _onDefaultMeshLoaded;
  134482. private _onResize;
  134483. private _onFullscreenChange;
  134484. /**
  134485. * Gets a value indicating if we are currently in VR mode.
  134486. */
  134487. get isInVRMode(): boolean;
  134488. private onVrDisplayPresentChange;
  134489. private onVRDisplayChanged;
  134490. private moveButtonToBottomRight;
  134491. private displayVRButton;
  134492. private updateButtonVisibility;
  134493. private _cachedAngularSensibility;
  134494. /**
  134495. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  134496. * Otherwise, will use the fullscreen API.
  134497. */
  134498. enterVR(): void;
  134499. /**
  134500. * Attempt to exit VR, or fullscreen.
  134501. */
  134502. exitVR(): void;
  134503. /**
  134504. * The position of the vr experience helper.
  134505. */
  134506. get position(): Vector3;
  134507. /**
  134508. * Sets the position of the vr experience helper.
  134509. */
  134510. set position(value: Vector3);
  134511. /**
  134512. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  134513. */
  134514. enableInteractions(): void;
  134515. private get _noControllerIsActive();
  134516. private beforeRender;
  134517. private _isTeleportationFloor;
  134518. /**
  134519. * Adds a floor mesh to be used for teleportation.
  134520. * @param floorMesh the mesh to be used for teleportation.
  134521. */
  134522. addFloorMesh(floorMesh: Mesh): void;
  134523. /**
  134524. * Removes a floor mesh from being used for teleportation.
  134525. * @param floorMesh the mesh to be removed.
  134526. */
  134527. removeFloorMesh(floorMesh: Mesh): void;
  134528. /**
  134529. * Enables interactions and teleportation using the VR controllers and gaze.
  134530. * @param vrTeleportationOptions options to modify teleportation behavior.
  134531. */
  134532. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  134533. private _onNewGamepadConnected;
  134534. private _tryEnableInteractionOnController;
  134535. private _onNewGamepadDisconnected;
  134536. private _enableInteractionOnController;
  134537. private _checkTeleportWithRay;
  134538. private _checkRotate;
  134539. private _checkTeleportBackwards;
  134540. private _enableTeleportationOnController;
  134541. private _createTeleportationCircles;
  134542. private _displayTeleportationTarget;
  134543. private _hideTeleportationTarget;
  134544. private _rotateCamera;
  134545. private _moveTeleportationSelectorTo;
  134546. private _workingVector;
  134547. private _workingQuaternion;
  134548. private _workingMatrix;
  134549. /**
  134550. * Time Constant Teleportation Mode
  134551. */
  134552. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  134553. /**
  134554. * Speed Constant Teleportation Mode
  134555. */
  134556. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  134557. /**
  134558. * Teleports the users feet to the desired location
  134559. * @param location The location where the user's feet should be placed
  134560. */
  134561. teleportCamera(location: Vector3): void;
  134562. private _convertNormalToDirectionOfRay;
  134563. private _castRayAndSelectObject;
  134564. private _notifySelectedMeshUnselected;
  134565. /**
  134566. * Permanently set new colors for the laser pointer
  134567. * @param color the new laser color
  134568. * @param pickedColor the new laser color when picked mesh detected
  134569. */
  134570. setLaserColor(color: Color3, pickedColor?: Color3): void;
  134571. /**
  134572. * Set lighting enabled / disabled on the laser pointer of both controllers
  134573. * @param enabled should the lighting be enabled on the laser pointer
  134574. */
  134575. setLaserLightingState(enabled?: boolean): void;
  134576. /**
  134577. * Permanently set new colors for the gaze pointer
  134578. * @param color the new gaze color
  134579. * @param pickedColor the new gaze color when picked mesh detected
  134580. */
  134581. setGazeColor(color: Color3, pickedColor?: Color3): void;
  134582. /**
  134583. * Sets the color of the laser ray from the vr controllers.
  134584. * @param color new color for the ray.
  134585. */
  134586. changeLaserColor(color: Color3): void;
  134587. /**
  134588. * Sets the color of the ray from the vr headsets gaze.
  134589. * @param color new color for the ray.
  134590. */
  134591. changeGazeColor(color: Color3): void;
  134592. /**
  134593. * Exits VR and disposes of the vr experience helper
  134594. */
  134595. dispose(): void;
  134596. /**
  134597. * Gets the name of the VRExperienceHelper class
  134598. * @returns "VRExperienceHelper"
  134599. */
  134600. getClassName(): string;
  134601. }
  134602. }
  134603. declare module BABYLON {
  134604. /**
  134605. * Contains an array of blocks representing the octree
  134606. */
  134607. export interface IOctreeContainer<T> {
  134608. /**
  134609. * Blocks within the octree
  134610. */
  134611. blocks: Array<OctreeBlock<T>>;
  134612. }
  134613. /**
  134614. * Class used to store a cell in an octree
  134615. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134616. */
  134617. export class OctreeBlock<T> {
  134618. /**
  134619. * Gets the content of the current block
  134620. */
  134621. entries: T[];
  134622. /**
  134623. * Gets the list of block children
  134624. */
  134625. blocks: Array<OctreeBlock<T>>;
  134626. private _depth;
  134627. private _maxDepth;
  134628. private _capacity;
  134629. private _minPoint;
  134630. private _maxPoint;
  134631. private _boundingVectors;
  134632. private _creationFunc;
  134633. /**
  134634. * Creates a new block
  134635. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  134636. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  134637. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  134638. * @param depth defines the current depth of this block in the octree
  134639. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  134640. * @param creationFunc defines a callback to call when an element is added to the block
  134641. */
  134642. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  134643. /**
  134644. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  134645. */
  134646. get capacity(): number;
  134647. /**
  134648. * Gets the minimum vector (in world space) of the block's bounding box
  134649. */
  134650. get minPoint(): Vector3;
  134651. /**
  134652. * Gets the maximum vector (in world space) of the block's bounding box
  134653. */
  134654. get maxPoint(): Vector3;
  134655. /**
  134656. * Add a new element to this block
  134657. * @param entry defines the element to add
  134658. */
  134659. addEntry(entry: T): void;
  134660. /**
  134661. * Remove an element from this block
  134662. * @param entry defines the element to remove
  134663. */
  134664. removeEntry(entry: T): void;
  134665. /**
  134666. * Add an array of elements to this block
  134667. * @param entries defines the array of elements to add
  134668. */
  134669. addEntries(entries: T[]): void;
  134670. /**
  134671. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  134672. * @param frustumPlanes defines the frustum planes to test
  134673. * @param selection defines the array to store current content if selection is positive
  134674. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134675. */
  134676. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  134677. /**
  134678. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  134679. * @param sphereCenter defines the bounding sphere center
  134680. * @param sphereRadius defines the bounding sphere radius
  134681. * @param selection defines the array to store current content if selection is positive
  134682. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134683. */
  134684. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  134685. /**
  134686. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  134687. * @param ray defines the ray to test with
  134688. * @param selection defines the array to store current content if selection is positive
  134689. */
  134690. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  134691. /**
  134692. * Subdivide the content into child blocks (this block will then be empty)
  134693. */
  134694. createInnerBlocks(): void;
  134695. /**
  134696. * @hidden
  134697. */
  134698. 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;
  134699. }
  134700. }
  134701. declare module BABYLON {
  134702. /**
  134703. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  134704. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134705. */
  134706. export class Octree<T> {
  134707. /** 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.) */
  134708. maxDepth: number;
  134709. /**
  134710. * Blocks within the octree containing objects
  134711. */
  134712. blocks: Array<OctreeBlock<T>>;
  134713. /**
  134714. * Content stored in the octree
  134715. */
  134716. dynamicContent: T[];
  134717. private _maxBlockCapacity;
  134718. private _selectionContent;
  134719. private _creationFunc;
  134720. /**
  134721. * Creates a octree
  134722. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134723. * @param creationFunc function to be used to instatiate the octree
  134724. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  134725. * @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.)
  134726. */
  134727. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  134728. /** 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.) */
  134729. maxDepth?: number);
  134730. /**
  134731. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  134732. * @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);
  134733. * @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);
  134734. * @param entries meshes to be added to the octree blocks
  134735. */
  134736. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  134737. /**
  134738. * Adds a mesh to the octree
  134739. * @param entry Mesh to add to the octree
  134740. */
  134741. addMesh(entry: T): void;
  134742. /**
  134743. * Remove an element from the octree
  134744. * @param entry defines the element to remove
  134745. */
  134746. removeMesh(entry: T): void;
  134747. /**
  134748. * Selects an array of meshes within the frustum
  134749. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  134750. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  134751. * @returns array of meshes within the frustum
  134752. */
  134753. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  134754. /**
  134755. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  134756. * @param sphereCenter defines the bounding sphere center
  134757. * @param sphereRadius defines the bounding sphere radius
  134758. * @param allowDuplicate defines if the selection array can contains duplicated entries
  134759. * @returns an array of objects that intersect the sphere
  134760. */
  134761. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  134762. /**
  134763. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  134764. * @param ray defines the ray to test with
  134765. * @returns array of intersected objects
  134766. */
  134767. intersectsRay(ray: Ray): SmartArray<T>;
  134768. /**
  134769. * Adds a mesh into the octree block if it intersects the block
  134770. */
  134771. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  134772. /**
  134773. * Adds a submesh into the octree block if it intersects the block
  134774. */
  134775. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  134776. }
  134777. }
  134778. declare module BABYLON {
  134779. interface Scene {
  134780. /**
  134781. * @hidden
  134782. * Backing Filed
  134783. */
  134784. _selectionOctree: Octree<AbstractMesh>;
  134785. /**
  134786. * Gets the octree used to boost mesh selection (picking)
  134787. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134788. */
  134789. selectionOctree: Octree<AbstractMesh>;
  134790. /**
  134791. * Creates or updates the octree used to boost selection (picking)
  134792. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134793. * @param maxCapacity defines the maximum capacity per leaf
  134794. * @param maxDepth defines the maximum depth of the octree
  134795. * @returns an octree of AbstractMesh
  134796. */
  134797. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  134798. }
  134799. interface AbstractMesh {
  134800. /**
  134801. * @hidden
  134802. * Backing Field
  134803. */
  134804. _submeshesOctree: Octree<SubMesh>;
  134805. /**
  134806. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  134807. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  134808. * @param maxCapacity defines the maximum size of each block (64 by default)
  134809. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  134810. * @returns the new octree
  134811. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  134812. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  134813. */
  134814. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  134815. }
  134816. /**
  134817. * Defines the octree scene component responsible to manage any octrees
  134818. * in a given scene.
  134819. */
  134820. export class OctreeSceneComponent {
  134821. /**
  134822. * The component name help to identify the component in the list of scene components.
  134823. */
  134824. readonly name: string;
  134825. /**
  134826. * The scene the component belongs to.
  134827. */
  134828. scene: Scene;
  134829. /**
  134830. * Indicates if the meshes have been checked to make sure they are isEnabled()
  134831. */
  134832. readonly checksIsEnabled: boolean;
  134833. /**
  134834. * Creates a new instance of the component for the given scene
  134835. * @param scene Defines the scene to register the component in
  134836. */
  134837. constructor(scene: Scene);
  134838. /**
  134839. * Registers the component in a given scene
  134840. */
  134841. register(): void;
  134842. /**
  134843. * Return the list of active meshes
  134844. * @returns the list of active meshes
  134845. */
  134846. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  134847. /**
  134848. * Return the list of active sub meshes
  134849. * @param mesh The mesh to get the candidates sub meshes from
  134850. * @returns the list of active sub meshes
  134851. */
  134852. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  134853. private _tempRay;
  134854. /**
  134855. * Return the list of sub meshes intersecting with a given local ray
  134856. * @param mesh defines the mesh to find the submesh for
  134857. * @param localRay defines the ray in local space
  134858. * @returns the list of intersecting sub meshes
  134859. */
  134860. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  134861. /**
  134862. * Return the list of sub meshes colliding with a collider
  134863. * @param mesh defines the mesh to find the submesh for
  134864. * @param collider defines the collider to evaluate the collision against
  134865. * @returns the list of colliding sub meshes
  134866. */
  134867. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  134868. /**
  134869. * Rebuilds the elements related to this component in case of
  134870. * context lost for instance.
  134871. */
  134872. rebuild(): void;
  134873. /**
  134874. * Disposes the component and the associated ressources.
  134875. */
  134876. dispose(): void;
  134877. }
  134878. }
  134879. declare module BABYLON {
  134880. /**
  134881. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  134882. */
  134883. export class Gizmo implements IDisposable {
  134884. /** The utility layer the gizmo will be added to */
  134885. gizmoLayer: UtilityLayerRenderer;
  134886. /**
  134887. * The root mesh of the gizmo
  134888. */
  134889. _rootMesh: Mesh;
  134890. private _attachedMesh;
  134891. private _attachedNode;
  134892. /**
  134893. * Ratio for the scale of the gizmo (Default: 1)
  134894. */
  134895. protected _scaleRatio: number;
  134896. /**
  134897. * boolean updated by pointermove when a gizmo mesh is hovered
  134898. */
  134899. protected _isHovered: boolean;
  134900. /**
  134901. * Ratio for the scale of the gizmo (Default: 1)
  134902. */
  134903. set scaleRatio(value: number);
  134904. get scaleRatio(): number;
  134905. /**
  134906. * True when the mouse pointer is hovered a gizmo mesh
  134907. */
  134908. get isHovered(): boolean;
  134909. /**
  134910. * If a custom mesh has been set (Default: false)
  134911. */
  134912. protected _customMeshSet: boolean;
  134913. /**
  134914. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  134915. * * When set, interactions will be enabled
  134916. */
  134917. get attachedMesh(): Nullable<AbstractMesh>;
  134918. set attachedMesh(value: Nullable<AbstractMesh>);
  134919. /**
  134920. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  134921. * * When set, interactions will be enabled
  134922. */
  134923. get attachedNode(): Nullable<Node>;
  134924. set attachedNode(value: Nullable<Node>);
  134925. /**
  134926. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134927. * @param mesh The mesh to replace the default mesh of the gizmo
  134928. */
  134929. setCustomMesh(mesh: Mesh): void;
  134930. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  134931. /**
  134932. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  134933. */
  134934. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134935. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134936. /**
  134937. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  134938. */
  134939. updateGizmoPositionToMatchAttachedMesh: boolean;
  134940. /**
  134941. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  134942. */
  134943. updateScale: boolean;
  134944. protected _interactionsEnabled: boolean;
  134945. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134946. private _beforeRenderObserver;
  134947. private _tempQuaternion;
  134948. private _tempVector;
  134949. private _tempVector2;
  134950. private _tempMatrix1;
  134951. private _tempMatrix2;
  134952. private _rightHandtoLeftHandMatrix;
  134953. /**
  134954. * Creates a gizmo
  134955. * @param gizmoLayer The utility layer the gizmo will be added to
  134956. */
  134957. constructor(
  134958. /** The utility layer the gizmo will be added to */
  134959. gizmoLayer?: UtilityLayerRenderer);
  134960. /**
  134961. * Updates the gizmo to match the attached mesh's position/rotation
  134962. */
  134963. protected _update(): void;
  134964. /**
  134965. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  134966. * @param value Node, TransformNode or mesh
  134967. */
  134968. protected _matrixChanged(): void;
  134969. /**
  134970. * Disposes of the gizmo
  134971. */
  134972. dispose(): void;
  134973. }
  134974. }
  134975. declare module BABYLON {
  134976. /**
  134977. * Single plane drag gizmo
  134978. */
  134979. export class PlaneDragGizmo extends Gizmo {
  134980. /**
  134981. * Drag behavior responsible for the gizmos dragging interactions
  134982. */
  134983. dragBehavior: PointerDragBehavior;
  134984. private _pointerObserver;
  134985. /**
  134986. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134987. */
  134988. snapDistance: number;
  134989. /**
  134990. * Event that fires each time the gizmo snaps to a new location.
  134991. * * snapDistance is the the change in distance
  134992. */
  134993. onSnapObservable: Observable<{
  134994. snapDistance: number;
  134995. }>;
  134996. private _plane;
  134997. private _coloredMaterial;
  134998. private _hoverMaterial;
  134999. private _isEnabled;
  135000. private _parent;
  135001. /** @hidden */
  135002. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  135003. /** @hidden */
  135004. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  135005. /**
  135006. * Creates a PlaneDragGizmo
  135007. * @param gizmoLayer The utility layer the gizmo will be added to
  135008. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  135009. * @param color The color of the gizmo
  135010. */
  135011. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  135012. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135013. /**
  135014. * If the gizmo is enabled
  135015. */
  135016. set isEnabled(value: boolean);
  135017. get isEnabled(): boolean;
  135018. /**
  135019. * Disposes of the gizmo
  135020. */
  135021. dispose(): void;
  135022. }
  135023. }
  135024. declare module BABYLON {
  135025. /**
  135026. * Gizmo that enables dragging a mesh along 3 axis
  135027. */
  135028. export class PositionGizmo extends Gizmo {
  135029. /**
  135030. * Internal gizmo used for interactions on the x axis
  135031. */
  135032. xGizmo: AxisDragGizmo;
  135033. /**
  135034. * Internal gizmo used for interactions on the y axis
  135035. */
  135036. yGizmo: AxisDragGizmo;
  135037. /**
  135038. * Internal gizmo used for interactions on the z axis
  135039. */
  135040. zGizmo: AxisDragGizmo;
  135041. /**
  135042. * Internal gizmo used for interactions on the yz plane
  135043. */
  135044. xPlaneGizmo: PlaneDragGizmo;
  135045. /**
  135046. * Internal gizmo used for interactions on the xz plane
  135047. */
  135048. yPlaneGizmo: PlaneDragGizmo;
  135049. /**
  135050. * Internal gizmo used for interactions on the xy plane
  135051. */
  135052. zPlaneGizmo: PlaneDragGizmo;
  135053. /**
  135054. * private variables
  135055. */
  135056. private _meshAttached;
  135057. private _nodeAttached;
  135058. private _snapDistance;
  135059. /** Fires an event when any of it's sub gizmos are dragged */
  135060. onDragStartObservable: Observable<unknown>;
  135061. /** Fires an event when any of it's sub gizmos are released from dragging */
  135062. onDragEndObservable: Observable<unknown>;
  135063. /**
  135064. * If set to true, planar drag is enabled
  135065. */
  135066. private _planarGizmoEnabled;
  135067. get attachedMesh(): Nullable<AbstractMesh>;
  135068. set attachedMesh(mesh: Nullable<AbstractMesh>);
  135069. get attachedNode(): Nullable<Node>;
  135070. set attachedNode(node: Nullable<Node>);
  135071. /**
  135072. * True when the mouse pointer is hovering a gizmo mesh
  135073. */
  135074. get isHovered(): boolean;
  135075. /**
  135076. * Creates a PositionGizmo
  135077. * @param gizmoLayer The utility layer the gizmo will be added to
  135078. @param thickness display gizmo axis thickness
  135079. */
  135080. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  135081. /**
  135082. * If the planar drag gizmo is enabled
  135083. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  135084. */
  135085. set planarGizmoEnabled(value: boolean);
  135086. get planarGizmoEnabled(): boolean;
  135087. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  135088. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  135089. /**
  135090. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135091. */
  135092. set snapDistance(value: number);
  135093. get snapDistance(): number;
  135094. /**
  135095. * Ratio for the scale of the gizmo (Default: 1)
  135096. */
  135097. set scaleRatio(value: number);
  135098. get scaleRatio(): number;
  135099. /**
  135100. * Disposes of the gizmo
  135101. */
  135102. dispose(): void;
  135103. /**
  135104. * CustomMeshes are not supported by this gizmo
  135105. * @param mesh The mesh to replace the default mesh of the gizmo
  135106. */
  135107. setCustomMesh(mesh: Mesh): void;
  135108. }
  135109. }
  135110. declare module BABYLON {
  135111. /**
  135112. * Single axis drag gizmo
  135113. */
  135114. export class AxisDragGizmo extends Gizmo {
  135115. /**
  135116. * Drag behavior responsible for the gizmos dragging interactions
  135117. */
  135118. dragBehavior: PointerDragBehavior;
  135119. private _pointerObserver;
  135120. /**
  135121. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  135122. */
  135123. snapDistance: number;
  135124. /**
  135125. * Event that fires each time the gizmo snaps to a new location.
  135126. * * snapDistance is the the change in distance
  135127. */
  135128. onSnapObservable: Observable<{
  135129. snapDistance: number;
  135130. }>;
  135131. private _isEnabled;
  135132. private _parent;
  135133. private _arrow;
  135134. private _coloredMaterial;
  135135. private _hoverMaterial;
  135136. /** @hidden */
  135137. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  135138. /** @hidden */
  135139. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  135140. /**
  135141. * Creates an AxisDragGizmo
  135142. * @param gizmoLayer The utility layer the gizmo will be added to
  135143. * @param dragAxis The axis which the gizmo will be able to drag on
  135144. * @param color The color of the gizmo
  135145. * @param thickness display gizmo axis thickness
  135146. */
  135147. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  135148. protected _attachedNodeChanged(value: Nullable<Node>): void;
  135149. /**
  135150. * If the gizmo is enabled
  135151. */
  135152. set isEnabled(value: boolean);
  135153. get isEnabled(): boolean;
  135154. /**
  135155. * Disposes of the gizmo
  135156. */
  135157. dispose(): void;
  135158. }
  135159. }
  135160. declare module BABYLON.Debug {
  135161. /**
  135162. * The Axes viewer will show 3 axes in a specific point in space
  135163. */
  135164. export class AxesViewer {
  135165. private _xAxis;
  135166. private _yAxis;
  135167. private _zAxis;
  135168. private _scaleLinesFactor;
  135169. private _instanced;
  135170. /**
  135171. * Gets the hosting scene
  135172. */
  135173. scene: Nullable<Scene>;
  135174. /**
  135175. * Gets or sets a number used to scale line length
  135176. */
  135177. scaleLines: number;
  135178. /** Gets the node hierarchy used to render x-axis */
  135179. get xAxis(): TransformNode;
  135180. /** Gets the node hierarchy used to render y-axis */
  135181. get yAxis(): TransformNode;
  135182. /** Gets the node hierarchy used to render z-axis */
  135183. get zAxis(): TransformNode;
  135184. /**
  135185. * Creates a new AxesViewer
  135186. * @param scene defines the hosting scene
  135187. * @param scaleLines defines a number used to scale line length (1 by default)
  135188. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  135189. * @param xAxis defines the node hierarchy used to render the x-axis
  135190. * @param yAxis defines the node hierarchy used to render the y-axis
  135191. * @param zAxis defines the node hierarchy used to render the z-axis
  135192. */
  135193. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  135194. /**
  135195. * Force the viewer to update
  135196. * @param position defines the position of the viewer
  135197. * @param xaxis defines the x axis of the viewer
  135198. * @param yaxis defines the y axis of the viewer
  135199. * @param zaxis defines the z axis of the viewer
  135200. */
  135201. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  135202. /**
  135203. * Creates an instance of this axes viewer.
  135204. * @returns a new axes viewer with instanced meshes
  135205. */
  135206. createInstance(): AxesViewer;
  135207. /** Releases resources */
  135208. dispose(): void;
  135209. private static _SetRenderingGroupId;
  135210. }
  135211. }
  135212. declare module BABYLON.Debug {
  135213. /**
  135214. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  135215. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  135216. */
  135217. export class BoneAxesViewer extends AxesViewer {
  135218. /**
  135219. * Gets or sets the target mesh where to display the axes viewer
  135220. */
  135221. mesh: Nullable<Mesh>;
  135222. /**
  135223. * Gets or sets the target bone where to display the axes viewer
  135224. */
  135225. bone: Nullable<Bone>;
  135226. /** Gets current position */
  135227. pos: Vector3;
  135228. /** Gets direction of X axis */
  135229. xaxis: Vector3;
  135230. /** Gets direction of Y axis */
  135231. yaxis: Vector3;
  135232. /** Gets direction of Z axis */
  135233. zaxis: Vector3;
  135234. /**
  135235. * Creates a new BoneAxesViewer
  135236. * @param scene defines the hosting scene
  135237. * @param bone defines the target bone
  135238. * @param mesh defines the target mesh
  135239. * @param scaleLines defines a scaling factor for line length (1 by default)
  135240. */
  135241. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  135242. /**
  135243. * Force the viewer to update
  135244. */
  135245. update(): void;
  135246. /** Releases resources */
  135247. dispose(): void;
  135248. }
  135249. }
  135250. declare module BABYLON {
  135251. /**
  135252. * Interface used to define scene explorer extensibility option
  135253. */
  135254. export interface IExplorerExtensibilityOption {
  135255. /**
  135256. * Define the option label
  135257. */
  135258. label: string;
  135259. /**
  135260. * Defines the action to execute on click
  135261. */
  135262. action: (entity: any) => void;
  135263. }
  135264. /**
  135265. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  135266. */
  135267. export interface IExplorerExtensibilityGroup {
  135268. /**
  135269. * Defines a predicate to test if a given type mut be extended
  135270. */
  135271. predicate: (entity: any) => boolean;
  135272. /**
  135273. * Gets the list of options added to a type
  135274. */
  135275. entries: IExplorerExtensibilityOption[];
  135276. }
  135277. /**
  135278. * Interface used to define the options to use to create the Inspector
  135279. */
  135280. export interface IInspectorOptions {
  135281. /**
  135282. * Display in overlay mode (default: false)
  135283. */
  135284. overlay?: boolean;
  135285. /**
  135286. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  135287. */
  135288. globalRoot?: HTMLElement;
  135289. /**
  135290. * Display the Scene explorer
  135291. */
  135292. showExplorer?: boolean;
  135293. /**
  135294. * Display the property inspector
  135295. */
  135296. showInspector?: boolean;
  135297. /**
  135298. * Display in embed mode (both panes on the right)
  135299. */
  135300. embedMode?: boolean;
  135301. /**
  135302. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  135303. */
  135304. handleResize?: boolean;
  135305. /**
  135306. * Allow the panes to popup (default: true)
  135307. */
  135308. enablePopup?: boolean;
  135309. /**
  135310. * Allow the panes to be closed by users (default: true)
  135311. */
  135312. enableClose?: boolean;
  135313. /**
  135314. * Optional list of extensibility entries
  135315. */
  135316. explorerExtensibility?: IExplorerExtensibilityGroup[];
  135317. /**
  135318. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  135319. */
  135320. inspectorURL?: string;
  135321. /**
  135322. * Optional initial tab (default to DebugLayerTab.Properties)
  135323. */
  135324. initialTab?: DebugLayerTab;
  135325. }
  135326. interface Scene {
  135327. /**
  135328. * @hidden
  135329. * Backing field
  135330. */
  135331. _debugLayer: DebugLayer;
  135332. /**
  135333. * Gets the debug layer (aka Inspector) associated with the scene
  135334. * @see https://doc.babylonjs.com/features/playground_debuglayer
  135335. */
  135336. debugLayer: DebugLayer;
  135337. }
  135338. /**
  135339. * Enum of inspector action tab
  135340. */
  135341. export enum DebugLayerTab {
  135342. /**
  135343. * Properties tag (default)
  135344. */
  135345. Properties = 0,
  135346. /**
  135347. * Debug tab
  135348. */
  135349. Debug = 1,
  135350. /**
  135351. * Statistics tab
  135352. */
  135353. Statistics = 2,
  135354. /**
  135355. * Tools tab
  135356. */
  135357. Tools = 3,
  135358. /**
  135359. * Settings tab
  135360. */
  135361. Settings = 4
  135362. }
  135363. /**
  135364. * The debug layer (aka Inspector) is the go to tool in order to better understand
  135365. * what is happening in your scene
  135366. * @see https://doc.babylonjs.com/features/playground_debuglayer
  135367. */
  135368. export class DebugLayer {
  135369. /**
  135370. * Define the url to get the inspector script from.
  135371. * By default it uses the babylonjs CDN.
  135372. * @ignoreNaming
  135373. */
  135374. static InspectorURL: string;
  135375. private _scene;
  135376. private BJSINSPECTOR;
  135377. private _onPropertyChangedObservable?;
  135378. /**
  135379. * Observable triggered when a property is changed through the inspector.
  135380. */
  135381. get onPropertyChangedObservable(): any;
  135382. /**
  135383. * Instantiates a new debug layer.
  135384. * The debug layer (aka Inspector) is the go to tool in order to better understand
  135385. * what is happening in your scene
  135386. * @see https://doc.babylonjs.com/features/playground_debuglayer
  135387. * @param scene Defines the scene to inspect
  135388. */
  135389. constructor(scene: Scene);
  135390. /** Creates the inspector window. */
  135391. private _createInspector;
  135392. /**
  135393. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  135394. * @param entity defines the entity to select
  135395. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  135396. */
  135397. select(entity: any, lineContainerTitles?: string | string[]): void;
  135398. /** Get the inspector from bundle or global */
  135399. private _getGlobalInspector;
  135400. /**
  135401. * Get if the inspector is visible or not.
  135402. * @returns true if visible otherwise, false
  135403. */
  135404. isVisible(): boolean;
  135405. /**
  135406. * Hide the inspector and close its window.
  135407. */
  135408. hide(): void;
  135409. /**
  135410. * Update the scene in the inspector
  135411. */
  135412. setAsActiveScene(): void;
  135413. /**
  135414. * Launch the debugLayer.
  135415. * @param config Define the configuration of the inspector
  135416. * @return a promise fulfilled when the debug layer is visible
  135417. */
  135418. show(config?: IInspectorOptions): Promise<DebugLayer>;
  135419. }
  135420. }
  135421. declare module BABYLON {
  135422. /**
  135423. * Class containing static functions to help procedurally build meshes
  135424. */
  135425. export class BoxBuilder {
  135426. /**
  135427. * Creates a box mesh
  135428. * * The parameter `size` sets the size (float) of each box side (default 1)
  135429. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  135430. * * 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)
  135431. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135433. * * 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
  135434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135435. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135436. * @param name defines the name of the mesh
  135437. * @param options defines the options used to create the mesh
  135438. * @param scene defines the hosting scene
  135439. * @returns the box mesh
  135440. */
  135441. static CreateBox(name: string, options: {
  135442. size?: number;
  135443. width?: number;
  135444. height?: number;
  135445. depth?: number;
  135446. faceUV?: Vector4[];
  135447. faceColors?: Color4[];
  135448. sideOrientation?: number;
  135449. frontUVs?: Vector4;
  135450. backUVs?: Vector4;
  135451. wrap?: boolean;
  135452. topBaseAt?: number;
  135453. bottomBaseAt?: number;
  135454. updatable?: boolean;
  135455. }, scene?: Nullable<Scene>): Mesh;
  135456. }
  135457. }
  135458. declare module BABYLON.Debug {
  135459. /**
  135460. * Used to show the physics impostor around the specific mesh
  135461. */
  135462. export class PhysicsViewer {
  135463. /** @hidden */
  135464. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  135465. /** @hidden */
  135466. protected _meshes: Array<Nullable<AbstractMesh>>;
  135467. /** @hidden */
  135468. protected _scene: Nullable<Scene>;
  135469. /** @hidden */
  135470. protected _numMeshes: number;
  135471. /** @hidden */
  135472. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  135473. private _renderFunction;
  135474. private _utilityLayer;
  135475. private _debugBoxMesh;
  135476. private _debugSphereMesh;
  135477. private _debugCylinderMesh;
  135478. private _debugMaterial;
  135479. private _debugMeshMeshes;
  135480. /**
  135481. * Creates a new PhysicsViewer
  135482. * @param scene defines the hosting scene
  135483. */
  135484. constructor(scene: Scene);
  135485. /** @hidden */
  135486. protected _updateDebugMeshes(): void;
  135487. /**
  135488. * Renders a specified physic impostor
  135489. * @param impostor defines the impostor to render
  135490. * @param targetMesh defines the mesh represented by the impostor
  135491. * @returns the new debug mesh used to render the impostor
  135492. */
  135493. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  135494. /**
  135495. * Hides a specified physic impostor
  135496. * @param impostor defines the impostor to hide
  135497. */
  135498. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  135499. private _getDebugMaterial;
  135500. private _getDebugBoxMesh;
  135501. private _getDebugSphereMesh;
  135502. private _getDebugCylinderMesh;
  135503. private _getDebugMeshMesh;
  135504. private _getDebugMesh;
  135505. /** Releases all resources */
  135506. dispose(): void;
  135507. }
  135508. }
  135509. declare module BABYLON {
  135510. /**
  135511. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  135512. * in order to better appreciate the issue one might have.
  135513. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  135514. */
  135515. export class RayHelper {
  135516. /**
  135517. * Defines the ray we are currently tryin to visualize.
  135518. */
  135519. ray: Nullable<Ray>;
  135520. private _renderPoints;
  135521. private _renderLine;
  135522. private _renderFunction;
  135523. private _scene;
  135524. private _onAfterRenderObserver;
  135525. private _onAfterStepObserver;
  135526. private _attachedToMesh;
  135527. private _meshSpaceDirection;
  135528. private _meshSpaceOrigin;
  135529. /**
  135530. * Helper function to create a colored helper in a scene in one line.
  135531. * @param ray Defines the ray we are currently tryin to visualize
  135532. * @param scene Defines the scene the ray is used in
  135533. * @param color Defines the color we want to see the ray in
  135534. * @returns The newly created ray helper.
  135535. */
  135536. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  135537. /**
  135538. * Instantiate a new ray helper.
  135539. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  135540. * in order to better appreciate the issue one might have.
  135541. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  135542. * @param ray Defines the ray we are currently tryin to visualize
  135543. */
  135544. constructor(ray: Ray);
  135545. /**
  135546. * Shows the ray we are willing to debug.
  135547. * @param scene Defines the scene the ray needs to be rendered in
  135548. * @param color Defines the color the ray needs to be rendered in
  135549. */
  135550. show(scene: Scene, color?: Color3): void;
  135551. /**
  135552. * Hides the ray we are debugging.
  135553. */
  135554. hide(): void;
  135555. private _render;
  135556. /**
  135557. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  135558. * @param mesh Defines the mesh we want the helper attached to
  135559. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  135560. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  135561. * @param length Defines the length of the ray
  135562. */
  135563. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  135564. /**
  135565. * Detach the ray helper from the mesh it has previously been attached to.
  135566. */
  135567. detachFromMesh(): void;
  135568. private _updateToMesh;
  135569. /**
  135570. * Dispose the helper and release its associated resources.
  135571. */
  135572. dispose(): void;
  135573. }
  135574. }
  135575. declare module BABYLON {
  135576. /**
  135577. * Defines the options associated with the creation of a SkeletonViewer.
  135578. */
  135579. export interface ISkeletonViewerOptions {
  135580. /** Should the system pause animations before building the Viewer? */
  135581. pauseAnimations: boolean;
  135582. /** Should the system return the skeleton to rest before building? */
  135583. returnToRest: boolean;
  135584. /** public Display Mode of the Viewer */
  135585. displayMode: number;
  135586. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  135587. displayOptions: ISkeletonViewerDisplayOptions;
  135588. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  135589. computeBonesUsingShaders: boolean;
  135590. /** Flag ignore non weighted bones */
  135591. useAllBones: boolean;
  135592. }
  135593. /**
  135594. * Defines how to display the various bone meshes for the viewer.
  135595. */
  135596. export interface ISkeletonViewerDisplayOptions {
  135597. /** How far down to start tapering the bone spurs */
  135598. midStep?: number;
  135599. /** How big is the midStep? */
  135600. midStepFactor?: number;
  135601. /** Base for the Sphere Size */
  135602. sphereBaseSize?: number;
  135603. /** The ratio of the sphere to the longest bone in units */
  135604. sphereScaleUnit?: number;
  135605. /** Ratio for the Sphere Size */
  135606. sphereFactor?: number;
  135607. /** Whether a spur should attach its far end to the child bone position */
  135608. spurFollowsChild?: boolean;
  135609. /** Whether to show local axes or not */
  135610. showLocalAxes?: boolean;
  135611. /** Length of each local axis */
  135612. localAxesSize?: number;
  135613. }
  135614. /**
  135615. * Defines the constructor options for the BoneWeight Shader.
  135616. */
  135617. export interface IBoneWeightShaderOptions {
  135618. /** Skeleton to Map */
  135619. skeleton: Skeleton;
  135620. /** Colors for Uninfluenced bones */
  135621. colorBase?: Color3;
  135622. /** Colors for 0.0-0.25 Weight bones */
  135623. colorZero?: Color3;
  135624. /** Color for 0.25-0.5 Weight Influence */
  135625. colorQuarter?: Color3;
  135626. /** Color for 0.5-0.75 Weight Influence */
  135627. colorHalf?: Color3;
  135628. /** Color for 0.75-1 Weight Influence */
  135629. colorFull?: Color3;
  135630. /** Color for Zero Weight Influence */
  135631. targetBoneIndex?: number;
  135632. }
  135633. /**
  135634. * Simple structure of the gradient steps for the Color Map.
  135635. */
  135636. export interface ISkeletonMapShaderColorMapKnot {
  135637. /** Color of the Knot */
  135638. color: Color3;
  135639. /** Location of the Knot */
  135640. location: number;
  135641. }
  135642. /**
  135643. * Defines the constructor options for the SkeletonMap Shader.
  135644. */
  135645. export interface ISkeletonMapShaderOptions {
  135646. /** Skeleton to Map */
  135647. skeleton: Skeleton;
  135648. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  135649. colorMap?: ISkeletonMapShaderColorMapKnot[];
  135650. }
  135651. }
  135652. declare module BABYLON {
  135653. /**
  135654. * Class containing static functions to help procedurally build meshes
  135655. */
  135656. export class RibbonBuilder {
  135657. /**
  135658. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135659. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  135660. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  135661. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135662. * * 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
  135663. * * 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
  135664. * * 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
  135665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135666. * * 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
  135667. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135668. * * 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
  135669. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135670. * * 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
  135671. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135673. * @param name defines the name of the mesh
  135674. * @param options defines the options used to create the mesh
  135675. * @param scene defines the hosting scene
  135676. * @returns the ribbon mesh
  135677. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135678. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135679. */
  135680. static CreateRibbon(name: string, options: {
  135681. pathArray: Vector3[][];
  135682. closeArray?: boolean;
  135683. closePath?: boolean;
  135684. offset?: number;
  135685. updatable?: boolean;
  135686. sideOrientation?: number;
  135687. frontUVs?: Vector4;
  135688. backUVs?: Vector4;
  135689. instance?: Mesh;
  135690. invertUV?: boolean;
  135691. uvs?: Vector2[];
  135692. colors?: Color4[];
  135693. }, scene?: Nullable<Scene>): Mesh;
  135694. }
  135695. }
  135696. declare module BABYLON {
  135697. /**
  135698. * Class containing static functions to help procedurally build meshes
  135699. */
  135700. export class ShapeBuilder {
  135701. /**
  135702. * 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.
  135703. * * 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.
  135704. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135705. * * 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.
  135706. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  135707. * * 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
  135708. * * 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
  135709. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  135710. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135711. * * 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
  135712. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  135713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135714. * @param name defines the name of the mesh
  135715. * @param options defines the options used to create the mesh
  135716. * @param scene defines the hosting scene
  135717. * @returns the extruded shape mesh
  135718. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135719. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135720. */
  135721. static ExtrudeShape(name: string, options: {
  135722. shape: Vector3[];
  135723. path: Vector3[];
  135724. scale?: number;
  135725. rotation?: number;
  135726. cap?: number;
  135727. updatable?: boolean;
  135728. sideOrientation?: number;
  135729. frontUVs?: Vector4;
  135730. backUVs?: Vector4;
  135731. instance?: Mesh;
  135732. invertUV?: boolean;
  135733. }, scene?: Nullable<Scene>): Mesh;
  135734. /**
  135735. * Creates an custom extruded shape mesh.
  135736. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  135737. * * 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.
  135738. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  135739. * * 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
  135740. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  135741. * * 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
  135742. * * It must returns a float value that will be the scale value applied to the shape on each path point
  135743. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  135744. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  135745. * * 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
  135746. * * 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
  135747. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  135748. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135749. * * 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
  135750. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135751. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135752. * @param name defines the name of the mesh
  135753. * @param options defines the options used to create the mesh
  135754. * @param scene defines the hosting scene
  135755. * @returns the custom extruded shape mesh
  135756. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  135757. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  135759. */
  135760. static ExtrudeShapeCustom(name: string, options: {
  135761. shape: Vector3[];
  135762. path: Vector3[];
  135763. scaleFunction?: any;
  135764. rotationFunction?: any;
  135765. ribbonCloseArray?: boolean;
  135766. ribbonClosePath?: boolean;
  135767. cap?: number;
  135768. updatable?: boolean;
  135769. sideOrientation?: number;
  135770. frontUVs?: Vector4;
  135771. backUVs?: Vector4;
  135772. instance?: Mesh;
  135773. invertUV?: boolean;
  135774. }, scene?: Nullable<Scene>): Mesh;
  135775. private static _ExtrudeShapeGeneric;
  135776. }
  135777. }
  135778. declare module BABYLON.Debug {
  135779. /**
  135780. * Class used to render a debug view of a given skeleton
  135781. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  135782. */
  135783. export class SkeletonViewer {
  135784. /** defines the skeleton to render */
  135785. skeleton: Skeleton;
  135786. /** defines the mesh attached to the skeleton */
  135787. mesh: AbstractMesh;
  135788. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135789. autoUpdateBonesMatrices: boolean;
  135790. /** defines the rendering group id to use with the viewer */
  135791. renderingGroupId: number;
  135792. /** is the options for the viewer */
  135793. options: Partial<ISkeletonViewerOptions>;
  135794. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  135795. static readonly DISPLAY_LINES: number;
  135796. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  135797. static readonly DISPLAY_SPHERES: number;
  135798. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  135799. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  135800. /** public static method to create a BoneWeight Shader
  135801. * @param options The constructor options
  135802. * @param scene The scene that the shader is scoped to
  135803. * @returns The created ShaderMaterial
  135804. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  135805. */
  135806. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  135807. /** public static method to create a BoneWeight Shader
  135808. * @param options The constructor options
  135809. * @param scene The scene that the shader is scoped to
  135810. * @returns The created ShaderMaterial
  135811. */
  135812. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  135813. /** private static method to create a BoneWeight Shader
  135814. * @param size The size of the buffer to create (usually the bone count)
  135815. * @param colorMap The gradient data to generate
  135816. * @param scene The scene that the shader is scoped to
  135817. * @returns an Array of floats from the color gradient values
  135818. */
  135819. private static _CreateBoneMapColorBuffer;
  135820. /** If SkeletonViewer scene scope. */
  135821. private _scene;
  135822. /** Gets or sets the color used to render the skeleton */
  135823. color: Color3;
  135824. /** Array of the points of the skeleton fo the line view. */
  135825. private _debugLines;
  135826. /** The SkeletonViewers Mesh. */
  135827. private _debugMesh;
  135828. /** The local axes Meshes. */
  135829. private _localAxes;
  135830. /** If SkeletonViewer is enabled. */
  135831. private _isEnabled;
  135832. /** If SkeletonViewer is ready. */
  135833. private _ready;
  135834. /** SkeletonViewer render observable. */
  135835. private _obs;
  135836. /** The Utility Layer to render the gizmos in. */
  135837. private _utilityLayer;
  135838. private _boneIndices;
  135839. /** Gets the Scene. */
  135840. get scene(): Scene;
  135841. /** Gets the utilityLayer. */
  135842. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  135843. /** Checks Ready Status. */
  135844. get isReady(): Boolean;
  135845. /** Sets Ready Status. */
  135846. set ready(value: boolean);
  135847. /** Gets the debugMesh */
  135848. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  135849. /** Sets the debugMesh */
  135850. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  135851. /** Gets the displayMode */
  135852. get displayMode(): number;
  135853. /** Sets the displayMode */
  135854. set displayMode(value: number);
  135855. /**
  135856. * Creates a new SkeletonViewer
  135857. * @param skeleton defines the skeleton to render
  135858. * @param mesh defines the mesh attached to the skeleton
  135859. * @param scene defines the hosting scene
  135860. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  135861. * @param renderingGroupId defines the rendering group id to use with the viewer
  135862. * @param options All of the extra constructor options for the SkeletonViewer
  135863. */
  135864. constructor(
  135865. /** defines the skeleton to render */
  135866. skeleton: Skeleton,
  135867. /** defines the mesh attached to the skeleton */
  135868. mesh: AbstractMesh,
  135869. /** The Scene scope*/
  135870. scene: Scene,
  135871. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  135872. autoUpdateBonesMatrices?: boolean,
  135873. /** defines the rendering group id to use with the viewer */
  135874. renderingGroupId?: number,
  135875. /** is the options for the viewer */
  135876. options?: Partial<ISkeletonViewerOptions>);
  135877. /** The Dynamic bindings for the update functions */
  135878. private _bindObs;
  135879. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  135880. update(): void;
  135881. /** Gets or sets a boolean indicating if the viewer is enabled */
  135882. set isEnabled(value: boolean);
  135883. get isEnabled(): boolean;
  135884. private _getBonePosition;
  135885. private _getLinesForBonesWithLength;
  135886. private _getLinesForBonesNoLength;
  135887. /** function to revert the mesh and scene back to the initial state. */
  135888. private _revert;
  135889. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  135890. private _getAbsoluteBindPoseToRef;
  135891. /** function to build and bind sphere joint points and spur bone representations. */
  135892. private _buildSpheresAndSpurs;
  135893. private _buildLocalAxes;
  135894. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  135895. private _displayLinesUpdate;
  135896. /** Changes the displayMode of the skeleton viewer
  135897. * @param mode The displayMode numerical value
  135898. */
  135899. changeDisplayMode(mode: number): void;
  135900. /** Sets a display option of the skeleton viewer
  135901. *
  135902. * | Option | Type | Default | Description |
  135903. * | ---------------- | ------- | ------- | ----------- |
  135904. * | 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`. |
  135905. * | 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`. |
  135906. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  135907. * | 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`. |
  135908. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  135909. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  135910. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  135911. *
  135912. * @param option String of the option name
  135913. * @param value The numerical option value
  135914. */
  135915. changeDisplayOptions(option: string, value: number): void;
  135916. /** Release associated resources */
  135917. dispose(): void;
  135918. }
  135919. }
  135920. declare module BABYLON {
  135921. /**
  135922. * Enum for Device Types
  135923. */
  135924. export enum DeviceType {
  135925. /** Generic */
  135926. Generic = 0,
  135927. /** Keyboard */
  135928. Keyboard = 1,
  135929. /** Mouse */
  135930. Mouse = 2,
  135931. /** Touch Pointers */
  135932. Touch = 3,
  135933. /** PS4 Dual Shock */
  135934. DualShock = 4,
  135935. /** Xbox */
  135936. Xbox = 5,
  135937. /** Switch Controller */
  135938. Switch = 6
  135939. }
  135940. /**
  135941. * Enum for All Pointers (Touch/Mouse)
  135942. */
  135943. export enum PointerInput {
  135944. /** Horizontal Axis */
  135945. Horizontal = 0,
  135946. /** Vertical Axis */
  135947. Vertical = 1,
  135948. /** Left Click or Touch */
  135949. LeftClick = 2,
  135950. /** Middle Click */
  135951. MiddleClick = 3,
  135952. /** Right Click */
  135953. RightClick = 4,
  135954. /** Browser Back */
  135955. BrowserBack = 5,
  135956. /** Browser Forward */
  135957. BrowserForward = 6
  135958. }
  135959. /**
  135960. * Enum for Dual Shock Gamepad
  135961. */
  135962. export enum DualShockInput {
  135963. /** Cross */
  135964. Cross = 0,
  135965. /** Circle */
  135966. Circle = 1,
  135967. /** Square */
  135968. Square = 2,
  135969. /** Triangle */
  135970. Triangle = 3,
  135971. /** L1 */
  135972. L1 = 4,
  135973. /** R1 */
  135974. R1 = 5,
  135975. /** L2 */
  135976. L2 = 6,
  135977. /** R2 */
  135978. R2 = 7,
  135979. /** Share */
  135980. Share = 8,
  135981. /** Options */
  135982. Options = 9,
  135983. /** L3 */
  135984. L3 = 10,
  135985. /** R3 */
  135986. R3 = 11,
  135987. /** DPadUp */
  135988. DPadUp = 12,
  135989. /** DPadDown */
  135990. DPadDown = 13,
  135991. /** DPadLeft */
  135992. DPadLeft = 14,
  135993. /** DRight */
  135994. DPadRight = 15,
  135995. /** Home */
  135996. Home = 16,
  135997. /** TouchPad */
  135998. TouchPad = 17,
  135999. /** LStickXAxis */
  136000. LStickXAxis = 18,
  136001. /** LStickYAxis */
  136002. LStickYAxis = 19,
  136003. /** RStickXAxis */
  136004. RStickXAxis = 20,
  136005. /** RStickYAxis */
  136006. RStickYAxis = 21
  136007. }
  136008. /**
  136009. * Enum for Xbox Gamepad
  136010. */
  136011. export enum XboxInput {
  136012. /** A */
  136013. A = 0,
  136014. /** B */
  136015. B = 1,
  136016. /** X */
  136017. X = 2,
  136018. /** Y */
  136019. Y = 3,
  136020. /** LB */
  136021. LB = 4,
  136022. /** RB */
  136023. RB = 5,
  136024. /** LT */
  136025. LT = 6,
  136026. /** RT */
  136027. RT = 7,
  136028. /** Back */
  136029. Back = 8,
  136030. /** Start */
  136031. Start = 9,
  136032. /** LS */
  136033. LS = 10,
  136034. /** RS */
  136035. RS = 11,
  136036. /** DPadUp */
  136037. DPadUp = 12,
  136038. /** DPadDown */
  136039. DPadDown = 13,
  136040. /** DPadLeft */
  136041. DPadLeft = 14,
  136042. /** DRight */
  136043. DPadRight = 15,
  136044. /** Home */
  136045. Home = 16,
  136046. /** LStickXAxis */
  136047. LStickXAxis = 17,
  136048. /** LStickYAxis */
  136049. LStickYAxis = 18,
  136050. /** RStickXAxis */
  136051. RStickXAxis = 19,
  136052. /** RStickYAxis */
  136053. RStickYAxis = 20
  136054. }
  136055. /**
  136056. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  136057. */
  136058. export enum SwitchInput {
  136059. /** B */
  136060. B = 0,
  136061. /** A */
  136062. A = 1,
  136063. /** Y */
  136064. Y = 2,
  136065. /** X */
  136066. X = 3,
  136067. /** L */
  136068. L = 4,
  136069. /** R */
  136070. R = 5,
  136071. /** ZL */
  136072. ZL = 6,
  136073. /** ZR */
  136074. ZR = 7,
  136075. /** Minus */
  136076. Minus = 8,
  136077. /** Plus */
  136078. Plus = 9,
  136079. /** LS */
  136080. LS = 10,
  136081. /** RS */
  136082. RS = 11,
  136083. /** DPadUp */
  136084. DPadUp = 12,
  136085. /** DPadDown */
  136086. DPadDown = 13,
  136087. /** DPadLeft */
  136088. DPadLeft = 14,
  136089. /** DRight */
  136090. DPadRight = 15,
  136091. /** Home */
  136092. Home = 16,
  136093. /** Capture */
  136094. Capture = 17,
  136095. /** LStickXAxis */
  136096. LStickXAxis = 18,
  136097. /** LStickYAxis */
  136098. LStickYAxis = 19,
  136099. /** RStickXAxis */
  136100. RStickXAxis = 20,
  136101. /** RStickYAxis */
  136102. RStickYAxis = 21
  136103. }
  136104. }
  136105. declare module BABYLON {
  136106. /**
  136107. * This class will take all inputs from Keyboard, Pointer, and
  136108. * any Gamepads and provide a polling system that all devices
  136109. * will use. This class assumes that there will only be one
  136110. * pointer device and one keyboard.
  136111. */
  136112. export class DeviceInputSystem implements IDisposable {
  136113. /**
  136114. * Callback to be triggered when a device is connected
  136115. */
  136116. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  136117. /**
  136118. * Callback to be triggered when a device is disconnected
  136119. */
  136120. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  136121. /**
  136122. * Callback to be triggered when event driven input is updated
  136123. */
  136124. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  136125. private _inputs;
  136126. private _gamepads;
  136127. private _keyboardActive;
  136128. private _pointerActive;
  136129. private _elementToAttachTo;
  136130. private _keyboardDownEvent;
  136131. private _keyboardUpEvent;
  136132. private _pointerMoveEvent;
  136133. private _pointerDownEvent;
  136134. private _pointerUpEvent;
  136135. private _gamepadConnectedEvent;
  136136. private _gamepadDisconnectedEvent;
  136137. private static _MAX_KEYCODES;
  136138. private static _MAX_POINTER_INPUTS;
  136139. private constructor();
  136140. /**
  136141. * Creates a new DeviceInputSystem instance
  136142. * @param engine Engine to pull input element from
  136143. * @returns The new instance
  136144. */
  136145. static Create(engine: Engine): DeviceInputSystem;
  136146. /**
  136147. * Checks for current device input value, given an id and input index
  136148. * @param deviceName Id of connected device
  136149. * @param inputIndex Index of device input
  136150. * @returns Current value of input
  136151. */
  136152. /**
  136153. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  136154. * @param deviceType Enum specifiying device type
  136155. * @param deviceSlot "Slot" or index that device is referenced in
  136156. * @param inputIndex Id of input to be checked
  136157. * @returns Current value of input
  136158. */
  136159. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  136160. /**
  136161. * Dispose of all the eventlisteners
  136162. */
  136163. dispose(): void;
  136164. /**
  136165. * Add device and inputs to device array
  136166. * @param deviceType Enum specifiying device type
  136167. * @param deviceSlot "Slot" or index that device is referenced in
  136168. * @param numberOfInputs Number of input entries to create for given device
  136169. */
  136170. private _registerDevice;
  136171. /**
  136172. * Given a specific device name, remove that device from the device map
  136173. * @param deviceType Enum specifiying device type
  136174. * @param deviceSlot "Slot" or index that device is referenced in
  136175. */
  136176. private _unregisterDevice;
  136177. /**
  136178. * Handle all actions that come from keyboard interaction
  136179. */
  136180. private _handleKeyActions;
  136181. /**
  136182. * Handle all actions that come from pointer interaction
  136183. */
  136184. private _handlePointerActions;
  136185. /**
  136186. * Handle all actions that come from gamepad interaction
  136187. */
  136188. private _handleGamepadActions;
  136189. /**
  136190. * Update all non-event based devices with each frame
  136191. * @param deviceType Enum specifiying device type
  136192. * @param deviceSlot "Slot" or index that device is referenced in
  136193. * @param inputIndex Id of input to be checked
  136194. */
  136195. private _updateDevice;
  136196. /**
  136197. * Gets DeviceType from the device name
  136198. * @param deviceName Name of Device from DeviceInputSystem
  136199. * @returns DeviceType enum value
  136200. */
  136201. private _getGamepadDeviceType;
  136202. }
  136203. }
  136204. declare module BABYLON {
  136205. /**
  136206. * Type to handle enforcement of inputs
  136207. */
  136208. 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;
  136209. }
  136210. declare module BABYLON {
  136211. /**
  136212. * Class that handles all input for a specific device
  136213. */
  136214. export class DeviceSource<T extends DeviceType> {
  136215. /** Type of device */
  136216. readonly deviceType: DeviceType;
  136217. /** "Slot" or index that device is referenced in */
  136218. readonly deviceSlot: number;
  136219. /**
  136220. * Observable to handle device input changes per device
  136221. */
  136222. readonly onInputChangedObservable: Observable<{
  136223. inputIndex: DeviceInput<T>;
  136224. previousState: Nullable<number>;
  136225. currentState: Nullable<number>;
  136226. }>;
  136227. private readonly _deviceInputSystem;
  136228. /**
  136229. * Default Constructor
  136230. * @param deviceInputSystem Reference to DeviceInputSystem
  136231. * @param deviceType Type of device
  136232. * @param deviceSlot "Slot" or index that device is referenced in
  136233. */
  136234. constructor(deviceInputSystem: DeviceInputSystem,
  136235. /** Type of device */
  136236. deviceType: DeviceType,
  136237. /** "Slot" or index that device is referenced in */
  136238. deviceSlot?: number);
  136239. /**
  136240. * Get input for specific input
  136241. * @param inputIndex index of specific input on device
  136242. * @returns Input value from DeviceInputSystem
  136243. */
  136244. getInput(inputIndex: DeviceInput<T>): number;
  136245. }
  136246. /**
  136247. * Class to keep track of devices
  136248. */
  136249. export class DeviceSourceManager implements IDisposable {
  136250. /**
  136251. * Observable to be triggered when before a device is connected
  136252. */
  136253. readonly onBeforeDeviceConnectedObservable: Observable<{
  136254. deviceType: DeviceType;
  136255. deviceSlot: number;
  136256. }>;
  136257. /**
  136258. * Observable to be triggered when before a device is disconnected
  136259. */
  136260. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  136261. deviceType: DeviceType;
  136262. deviceSlot: number;
  136263. }>;
  136264. /**
  136265. * Observable to be triggered when after a device is connected
  136266. */
  136267. readonly onAfterDeviceConnectedObservable: Observable<{
  136268. deviceType: DeviceType;
  136269. deviceSlot: number;
  136270. }>;
  136271. /**
  136272. * Observable to be triggered when after a device is disconnected
  136273. */
  136274. readonly onAfterDeviceDisconnectedObservable: Observable<{
  136275. deviceType: DeviceType;
  136276. deviceSlot: number;
  136277. }>;
  136278. private readonly _devices;
  136279. private readonly _firstDevice;
  136280. private readonly _deviceInputSystem;
  136281. /**
  136282. * Default Constructor
  136283. * @param engine engine to pull input element from
  136284. */
  136285. constructor(engine: Engine);
  136286. /**
  136287. * Gets a DeviceSource, given a type and slot
  136288. * @param deviceType Enum specifying device type
  136289. * @param deviceSlot "Slot" or index that device is referenced in
  136290. * @returns DeviceSource object
  136291. */
  136292. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  136293. /**
  136294. * Gets an array of DeviceSource objects for a given device type
  136295. * @param deviceType Enum specifying device type
  136296. * @returns Array of DeviceSource objects
  136297. */
  136298. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  136299. /**
  136300. * Dispose of DeviceInputSystem and other parts
  136301. */
  136302. dispose(): void;
  136303. /**
  136304. * Function to add device name to device list
  136305. * @param deviceType Enum specifying device type
  136306. * @param deviceSlot "Slot" or index that device is referenced in
  136307. */
  136308. private _addDevice;
  136309. /**
  136310. * Function to remove device name to device list
  136311. * @param deviceType Enum specifying device type
  136312. * @param deviceSlot "Slot" or index that device is referenced in
  136313. */
  136314. private _removeDevice;
  136315. /**
  136316. * Updates array storing first connected device of each type
  136317. * @param type Type of Device
  136318. */
  136319. private _updateFirstDevices;
  136320. }
  136321. }
  136322. declare module BABYLON {
  136323. /**
  136324. * Options to create the null engine
  136325. */
  136326. export class NullEngineOptions {
  136327. /**
  136328. * Render width (Default: 512)
  136329. */
  136330. renderWidth: number;
  136331. /**
  136332. * Render height (Default: 256)
  136333. */
  136334. renderHeight: number;
  136335. /**
  136336. * Texture size (Default: 512)
  136337. */
  136338. textureSize: number;
  136339. /**
  136340. * If delta time between frames should be constant
  136341. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136342. */
  136343. deterministicLockstep: boolean;
  136344. /**
  136345. * Maximum about of steps between frames (Default: 4)
  136346. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136347. */
  136348. lockstepMaxSteps: number;
  136349. /**
  136350. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  136351. */
  136352. useHighPrecisionMatrix?: boolean;
  136353. }
  136354. /**
  136355. * The null engine class provides support for headless version of babylon.js.
  136356. * This can be used in server side scenario or for testing purposes
  136357. */
  136358. export class NullEngine extends Engine {
  136359. private _options;
  136360. /**
  136361. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  136362. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136363. * @returns true if engine is in deterministic lock step mode
  136364. */
  136365. isDeterministicLockStep(): boolean;
  136366. /**
  136367. * Gets the max steps when engine is running in deterministic lock step
  136368. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  136369. * @returns the max steps
  136370. */
  136371. getLockstepMaxSteps(): number;
  136372. /**
  136373. * Gets the current hardware scaling level.
  136374. * By default the hardware scaling level is computed from the window device ratio.
  136375. * 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.
  136376. * @returns a number indicating the current hardware scaling level
  136377. */
  136378. getHardwareScalingLevel(): number;
  136379. constructor(options?: NullEngineOptions);
  136380. /**
  136381. * Creates a vertex buffer
  136382. * @param vertices the data for the vertex buffer
  136383. * @returns the new WebGL static buffer
  136384. */
  136385. createVertexBuffer(vertices: FloatArray): DataBuffer;
  136386. /**
  136387. * Creates a new index buffer
  136388. * @param indices defines the content of the index buffer
  136389. * @param updatable defines if the index buffer must be updatable
  136390. * @returns a new webGL buffer
  136391. */
  136392. createIndexBuffer(indices: IndicesArray): DataBuffer;
  136393. /**
  136394. * Clear the current render buffer or the current render target (if any is set up)
  136395. * @param color defines the color to use
  136396. * @param backBuffer defines if the back buffer must be cleared
  136397. * @param depth defines if the depth buffer must be cleared
  136398. * @param stencil defines if the stencil buffer must be cleared
  136399. */
  136400. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  136401. /**
  136402. * Gets the current render width
  136403. * @param useScreen defines if screen size must be used (or the current render target if any)
  136404. * @returns a number defining the current render width
  136405. */
  136406. getRenderWidth(useScreen?: boolean): number;
  136407. /**
  136408. * Gets the current render height
  136409. * @param useScreen defines if screen size must be used (or the current render target if any)
  136410. * @returns a number defining the current render height
  136411. */
  136412. getRenderHeight(useScreen?: boolean): number;
  136413. /**
  136414. * Set the WebGL's viewport
  136415. * @param viewport defines the viewport element to be used
  136416. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  136417. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  136418. */
  136419. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  136420. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  136421. /**
  136422. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  136423. * @param pipelineContext defines the pipeline context to use
  136424. * @param uniformsNames defines the list of uniform names
  136425. * @returns an array of webGL uniform locations
  136426. */
  136427. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  136428. /**
  136429. * Gets the lsit of active attributes for a given webGL program
  136430. * @param pipelineContext defines the pipeline context to use
  136431. * @param attributesNames defines the list of attribute names to get
  136432. * @returns an array of indices indicating the offset of each attribute
  136433. */
  136434. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  136435. /**
  136436. * Binds an effect to the webGL context
  136437. * @param effect defines the effect to bind
  136438. */
  136439. bindSamplers(effect: Effect): void;
  136440. /**
  136441. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  136442. * @param effect defines the effect to activate
  136443. */
  136444. enableEffect(effect: Effect): void;
  136445. /**
  136446. * Set various states to the webGL context
  136447. * @param culling defines backface culling state
  136448. * @param zOffset defines the value to apply to zOffset (0 by default)
  136449. * @param force defines if states must be applied even if cache is up to date
  136450. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  136451. */
  136452. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  136453. /**
  136454. * Set the value of an uniform to an array of int32
  136455. * @param uniform defines the webGL uniform location where to store the value
  136456. * @param array defines the array of int32 to store
  136457. * @returns true if value was set
  136458. */
  136459. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136460. /**
  136461. * Set the value of an uniform to an array of int32 (stored as vec2)
  136462. * @param uniform defines the webGL uniform location where to store the value
  136463. * @param array defines the array of int32 to store
  136464. * @returns true if value was set
  136465. */
  136466. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136467. /**
  136468. * Set the value of an uniform to an array of int32 (stored as vec3)
  136469. * @param uniform defines the webGL uniform location where to store the value
  136470. * @param array defines the array of int32 to store
  136471. * @returns true if value was set
  136472. */
  136473. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136474. /**
  136475. * Set the value of an uniform to an array of int32 (stored as vec4)
  136476. * @param uniform defines the webGL uniform location where to store the value
  136477. * @param array defines the array of int32 to store
  136478. * @returns true if value was set
  136479. */
  136480. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  136481. /**
  136482. * Set the value of an uniform to an array of float32
  136483. * @param uniform defines the webGL uniform location where to store the value
  136484. * @param array defines the array of float32 to store
  136485. * @returns true if value was set
  136486. */
  136487. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136488. /**
  136489. * Set the value of an uniform to an array of float32 (stored as vec2)
  136490. * @param uniform defines the webGL uniform location where to store the value
  136491. * @param array defines the array of float32 to store
  136492. * @returns true if value was set
  136493. */
  136494. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136495. /**
  136496. * Set the value of an uniform to an array of float32 (stored as vec3)
  136497. * @param uniform defines the webGL uniform location where to store the value
  136498. * @param array defines the array of float32 to store
  136499. * @returns true if value was set
  136500. */
  136501. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136502. /**
  136503. * Set the value of an uniform to an array of float32 (stored as vec4)
  136504. * @param uniform defines the webGL uniform location where to store the value
  136505. * @param array defines the array of float32 to store
  136506. * @returns true if value was set
  136507. */
  136508. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  136509. /**
  136510. * Set the value of an uniform to an array of number
  136511. * @param uniform defines the webGL uniform location where to store the value
  136512. * @param array defines the array of number to store
  136513. * @returns true if value was set
  136514. */
  136515. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  136516. /**
  136517. * Set the value of an uniform to an array of number (stored as vec2)
  136518. * @param uniform defines the webGL uniform location where to store the value
  136519. * @param array defines the array of number to store
  136520. * @returns true if value was set
  136521. */
  136522. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  136523. /**
  136524. * Set the value of an uniform to an array of number (stored as vec3)
  136525. * @param uniform defines the webGL uniform location where to store the value
  136526. * @param array defines the array of number to store
  136527. * @returns true if value was set
  136528. */
  136529. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  136530. /**
  136531. * Set the value of an uniform to an array of number (stored as vec4)
  136532. * @param uniform defines the webGL uniform location where to store the value
  136533. * @param array defines the array of number to store
  136534. * @returns true if value was set
  136535. */
  136536. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  136537. /**
  136538. * Set the value of an uniform to an array of float32 (stored as matrices)
  136539. * @param uniform defines the webGL uniform location where to store the value
  136540. * @param matrices defines the array of float32 to store
  136541. * @returns true if value was set
  136542. */
  136543. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  136544. /**
  136545. * Set the value of an uniform to a matrix (3x3)
  136546. * @param uniform defines the webGL uniform location where to store the value
  136547. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  136548. * @returns true if value was set
  136549. */
  136550. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136551. /**
  136552. * Set the value of an uniform to a matrix (2x2)
  136553. * @param uniform defines the webGL uniform location where to store the value
  136554. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  136555. * @returns true if value was set
  136556. */
  136557. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  136558. /**
  136559. * Set the value of an uniform to a number (float)
  136560. * @param uniform defines the webGL uniform location where to store the value
  136561. * @param value defines the float number to store
  136562. * @returns true if value was set
  136563. */
  136564. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  136565. /**
  136566. * Set the value of an uniform to a vec2
  136567. * @param uniform defines the webGL uniform location where to store the value
  136568. * @param x defines the 1st component of the value
  136569. * @param y defines the 2nd component of the value
  136570. * @returns true if value was set
  136571. */
  136572. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  136573. /**
  136574. * Set the value of an uniform to a vec3
  136575. * @param uniform defines the webGL uniform location where to store the value
  136576. * @param x defines the 1st component of the value
  136577. * @param y defines the 2nd component of the value
  136578. * @param z defines the 3rd component of the value
  136579. * @returns true if value was set
  136580. */
  136581. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  136582. /**
  136583. * Set the value of an uniform to a boolean
  136584. * @param uniform defines the webGL uniform location where to store the value
  136585. * @param bool defines the boolean to store
  136586. * @returns true if value was set
  136587. */
  136588. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  136589. /**
  136590. * Set the value of an uniform to a vec4
  136591. * @param uniform defines the webGL uniform location where to store the value
  136592. * @param x defines the 1st component of the value
  136593. * @param y defines the 2nd component of the value
  136594. * @param z defines the 3rd component of the value
  136595. * @param w defines the 4th component of the value
  136596. * @returns true if value was set
  136597. */
  136598. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  136599. /**
  136600. * Sets the current alpha mode
  136601. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  136602. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  136603. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  136604. */
  136605. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  136606. /**
  136607. * Bind webGl buffers directly to the webGL context
  136608. * @param vertexBuffers defines the vertex buffer to bind
  136609. * @param indexBuffer defines the index buffer to bind
  136610. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  136611. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  136612. * @param effect defines the effect associated with the vertex buffer
  136613. */
  136614. bindBuffers(vertexBuffers: {
  136615. [key: string]: VertexBuffer;
  136616. }, indexBuffer: DataBuffer, effect: Effect): void;
  136617. /**
  136618. * Force the entire cache to be cleared
  136619. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  136620. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  136621. */
  136622. wipeCaches(bruteForce?: boolean): void;
  136623. /**
  136624. * Send a draw order
  136625. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  136626. * @param indexStart defines the starting index
  136627. * @param indexCount defines the number of index to draw
  136628. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136629. */
  136630. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  136631. /**
  136632. * Draw a list of indexed primitives
  136633. * @param fillMode defines the primitive to use
  136634. * @param indexStart defines the starting index
  136635. * @param indexCount defines the number of index to draw
  136636. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136637. */
  136638. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  136639. /**
  136640. * Draw a list of unindexed primitives
  136641. * @param fillMode defines the primitive to use
  136642. * @param verticesStart defines the index of first vertex to draw
  136643. * @param verticesCount defines the count of vertices to draw
  136644. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  136645. */
  136646. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  136647. /** @hidden */
  136648. _createTexture(): WebGLTexture;
  136649. /** @hidden */
  136650. _releaseTexture(texture: InternalTexture): void;
  136651. /**
  136652. * Usually called from Texture.ts.
  136653. * Passed information to create a WebGLTexture
  136654. * @param urlArg defines a value which contains one of the following:
  136655. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  136656. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  136657. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  136658. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  136659. * @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)
  136660. * @param scene needed for loading to the correct scene
  136661. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  136662. * @param onLoad optional callback to be called upon successful completion
  136663. * @param onError optional callback to be called upon failure
  136664. * @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
  136665. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  136666. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  136667. * @param forcedExtension defines the extension to use to pick the right loader
  136668. * @param mimeType defines an optional mime type
  136669. * @returns a InternalTexture for assignment back into BABYLON.Texture
  136670. */
  136671. 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;
  136672. /**
  136673. * Creates a new render target texture
  136674. * @param size defines the size of the texture
  136675. * @param options defines the options used to create the texture
  136676. * @returns a new render target texture stored in an InternalTexture
  136677. */
  136678. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  136679. /**
  136680. * Update the sampling mode of a given texture
  136681. * @param samplingMode defines the required sampling mode
  136682. * @param texture defines the texture to update
  136683. */
  136684. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  136685. /**
  136686. * Binds the frame buffer to the specified texture.
  136687. * @param texture The texture to render to or null for the default canvas
  136688. * @param faceIndex The face of the texture to render to in case of cube texture
  136689. * @param requiredWidth The width of the target to render to
  136690. * @param requiredHeight The height of the target to render to
  136691. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  136692. * @param lodLevel defines le lod level to bind to the frame buffer
  136693. */
  136694. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  136695. /**
  136696. * Unbind the current render target texture from the webGL context
  136697. * @param texture defines the render target texture to unbind
  136698. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  136699. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  136700. */
  136701. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  136702. /**
  136703. * Creates a dynamic vertex buffer
  136704. * @param vertices the data for the dynamic vertex buffer
  136705. * @returns the new WebGL dynamic buffer
  136706. */
  136707. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  136708. /**
  136709. * Update the content of a dynamic texture
  136710. * @param texture defines the texture to update
  136711. * @param canvas defines the canvas containing the source
  136712. * @param invertY defines if data must be stored with Y axis inverted
  136713. * @param premulAlpha defines if alpha is stored as premultiplied
  136714. * @param format defines the format of the data
  136715. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  136716. */
  136717. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  136718. /**
  136719. * Gets a boolean indicating if all created effects are ready
  136720. * @returns true if all effects are ready
  136721. */
  136722. areAllEffectsReady(): boolean;
  136723. /**
  136724. * @hidden
  136725. * Get the current error code of the webGL context
  136726. * @returns the error code
  136727. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  136728. */
  136729. getError(): number;
  136730. /** @hidden */
  136731. _getUnpackAlignement(): number;
  136732. /** @hidden */
  136733. _unpackFlipY(value: boolean): void;
  136734. /**
  136735. * Update a dynamic index buffer
  136736. * @param indexBuffer defines the target index buffer
  136737. * @param indices defines the data to update
  136738. * @param offset defines the offset in the target index buffer where update should start
  136739. */
  136740. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  136741. /**
  136742. * Updates a dynamic vertex buffer.
  136743. * @param vertexBuffer the vertex buffer to update
  136744. * @param vertices the data used to update the vertex buffer
  136745. * @param byteOffset the byte offset of the data (optional)
  136746. * @param byteLength the byte length of the data (optional)
  136747. */
  136748. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  136749. /** @hidden */
  136750. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  136751. /** @hidden */
  136752. _bindTexture(channel: number, texture: InternalTexture): void;
  136753. protected _deleteBuffer(buffer: WebGLBuffer): void;
  136754. /**
  136755. * 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
  136756. */
  136757. releaseEffects(): void;
  136758. displayLoadingUI(): void;
  136759. hideLoadingUI(): void;
  136760. /** @hidden */
  136761. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136762. /** @hidden */
  136763. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136764. /** @hidden */
  136765. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  136766. /** @hidden */
  136767. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  136768. }
  136769. }
  136770. declare module BABYLON {
  136771. /**
  136772. * @hidden
  136773. **/
  136774. export class _TimeToken {
  136775. _startTimeQuery: Nullable<WebGLQuery>;
  136776. _endTimeQuery: Nullable<WebGLQuery>;
  136777. _timeElapsedQuery: Nullable<WebGLQuery>;
  136778. _timeElapsedQueryEnded: boolean;
  136779. }
  136780. }
  136781. declare module BABYLON {
  136782. /** @hidden */
  136783. export class _OcclusionDataStorage {
  136784. /** @hidden */
  136785. occlusionInternalRetryCounter: number;
  136786. /** @hidden */
  136787. isOcclusionQueryInProgress: boolean;
  136788. /** @hidden */
  136789. isOccluded: boolean;
  136790. /** @hidden */
  136791. occlusionRetryCount: number;
  136792. /** @hidden */
  136793. occlusionType: number;
  136794. /** @hidden */
  136795. occlusionQueryAlgorithmType: number;
  136796. }
  136797. interface Engine {
  136798. /**
  136799. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  136800. * @return the new query
  136801. */
  136802. createQuery(): WebGLQuery;
  136803. /**
  136804. * Delete and release a webGL query
  136805. * @param query defines the query to delete
  136806. * @return the current engine
  136807. */
  136808. deleteQuery(query: WebGLQuery): Engine;
  136809. /**
  136810. * Check if a given query has resolved and got its value
  136811. * @param query defines the query to check
  136812. * @returns true if the query got its value
  136813. */
  136814. isQueryResultAvailable(query: WebGLQuery): boolean;
  136815. /**
  136816. * Gets the value of a given query
  136817. * @param query defines the query to check
  136818. * @returns the value of the query
  136819. */
  136820. getQueryResult(query: WebGLQuery): number;
  136821. /**
  136822. * Initiates an occlusion query
  136823. * @param algorithmType defines the algorithm to use
  136824. * @param query defines the query to use
  136825. * @returns the current engine
  136826. * @see https://doc.babylonjs.com/features/occlusionquery
  136827. */
  136828. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  136829. /**
  136830. * Ends an occlusion query
  136831. * @see https://doc.babylonjs.com/features/occlusionquery
  136832. * @param algorithmType defines the algorithm to use
  136833. * @returns the current engine
  136834. */
  136835. endOcclusionQuery(algorithmType: number): Engine;
  136836. /**
  136837. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  136838. * Please note that only one query can be issued at a time
  136839. * @returns a time token used to track the time span
  136840. */
  136841. startTimeQuery(): Nullable<_TimeToken>;
  136842. /**
  136843. * Ends a time query
  136844. * @param token defines the token used to measure the time span
  136845. * @returns the time spent (in ns)
  136846. */
  136847. endTimeQuery(token: _TimeToken): int;
  136848. /** @hidden */
  136849. _currentNonTimestampToken: Nullable<_TimeToken>;
  136850. /** @hidden */
  136851. _createTimeQuery(): WebGLQuery;
  136852. /** @hidden */
  136853. _deleteTimeQuery(query: WebGLQuery): void;
  136854. /** @hidden */
  136855. _getGlAlgorithmType(algorithmType: number): number;
  136856. /** @hidden */
  136857. _getTimeQueryResult(query: WebGLQuery): any;
  136858. /** @hidden */
  136859. _getTimeQueryAvailability(query: WebGLQuery): any;
  136860. }
  136861. interface AbstractMesh {
  136862. /**
  136863. * Backing filed
  136864. * @hidden
  136865. */
  136866. __occlusionDataStorage: _OcclusionDataStorage;
  136867. /**
  136868. * Access property
  136869. * @hidden
  136870. */
  136871. _occlusionDataStorage: _OcclusionDataStorage;
  136872. /**
  136873. * 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.
  136874. * The default value is -1 which means don't break the query and wait till the result
  136875. * @see https://doc.babylonjs.com/features/occlusionquery
  136876. */
  136877. occlusionRetryCount: number;
  136878. /**
  136879. * 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:
  136880. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  136881. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  136882. * * 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.
  136883. * @see https://doc.babylonjs.com/features/occlusionquery
  136884. */
  136885. occlusionType: number;
  136886. /**
  136887. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  136888. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  136889. * * 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.
  136890. * @see https://doc.babylonjs.com/features/occlusionquery
  136891. */
  136892. occlusionQueryAlgorithmType: number;
  136893. /**
  136894. * 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
  136895. * @see https://doc.babylonjs.com/features/occlusionquery
  136896. */
  136897. isOccluded: boolean;
  136898. /**
  136899. * Flag to check the progress status of the query
  136900. * @see https://doc.babylonjs.com/features/occlusionquery
  136901. */
  136902. isOcclusionQueryInProgress: boolean;
  136903. }
  136904. }
  136905. declare module BABYLON {
  136906. /** @hidden */
  136907. export var _forceTransformFeedbackToBundle: boolean;
  136908. interface Engine {
  136909. /**
  136910. * Creates a webGL transform feedback object
  136911. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  136912. * @returns the webGL transform feedback object
  136913. */
  136914. createTransformFeedback(): WebGLTransformFeedback;
  136915. /**
  136916. * Delete a webGL transform feedback object
  136917. * @param value defines the webGL transform feedback object to delete
  136918. */
  136919. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  136920. /**
  136921. * Bind a webGL transform feedback object to the webgl context
  136922. * @param value defines the webGL transform feedback object to bind
  136923. */
  136924. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  136925. /**
  136926. * Begins a transform feedback operation
  136927. * @param usePoints defines if points or triangles must be used
  136928. */
  136929. beginTransformFeedback(usePoints: boolean): void;
  136930. /**
  136931. * Ends a transform feedback operation
  136932. */
  136933. endTransformFeedback(): void;
  136934. /**
  136935. * Specify the varyings to use with transform feedback
  136936. * @param program defines the associated webGL program
  136937. * @param value defines the list of strings representing the varying names
  136938. */
  136939. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  136940. /**
  136941. * Bind a webGL buffer for a transform feedback operation
  136942. * @param value defines the webGL buffer to bind
  136943. */
  136944. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  136945. }
  136946. }
  136947. declare module BABYLON {
  136948. /**
  136949. * Class used to define an additional view for the engine
  136950. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136951. */
  136952. export class EngineView {
  136953. /** Defines the canvas where to render the view */
  136954. target: HTMLCanvasElement;
  136955. /** Defines an optional camera used to render the view (will use active camera else) */
  136956. camera?: Camera;
  136957. }
  136958. interface Engine {
  136959. /**
  136960. * Gets or sets the HTML element to use for attaching events
  136961. */
  136962. inputElement: Nullable<HTMLElement>;
  136963. /**
  136964. * Gets the current engine view
  136965. * @see https://doc.babylonjs.com/how_to/multi_canvases
  136966. */
  136967. activeView: Nullable<EngineView>;
  136968. /** Gets or sets the list of views */
  136969. views: EngineView[];
  136970. /**
  136971. * Register a new child canvas
  136972. * @param canvas defines the canvas to register
  136973. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  136974. * @returns the associated view
  136975. */
  136976. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  136977. /**
  136978. * Remove a registered child canvas
  136979. * @param canvas defines the canvas to remove
  136980. * @returns the current engine
  136981. */
  136982. unRegisterView(canvas: HTMLCanvasElement): Engine;
  136983. }
  136984. }
  136985. declare module BABYLON {
  136986. interface Engine {
  136987. /** @hidden */
  136988. _excludedCompressedTextures: string[];
  136989. /** @hidden */
  136990. _textureFormatInUse: string;
  136991. /**
  136992. * Gets the list of texture formats supported
  136993. */
  136994. readonly texturesSupported: Array<string>;
  136995. /**
  136996. * Gets the texture format in use
  136997. */
  136998. readonly textureFormatInUse: Nullable<string>;
  136999. /**
  137000. * Set the compressed texture extensions or file names to skip.
  137001. *
  137002. * @param skippedFiles defines the list of those texture files you want to skip
  137003. * Example: [".dds", ".env", "myfile.png"]
  137004. */
  137005. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  137006. /**
  137007. * Set the compressed texture format to use, based on the formats you have, and the formats
  137008. * supported by the hardware / browser.
  137009. *
  137010. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  137011. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  137012. * to API arguments needed to compressed textures. This puts the burden on the container
  137013. * generator to house the arcane code for determining these for current & future formats.
  137014. *
  137015. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  137016. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  137017. *
  137018. * Note: The result of this call is not taken into account when a texture is base64.
  137019. *
  137020. * @param formatsAvailable defines the list of those format families you have created
  137021. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  137022. *
  137023. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  137024. * @returns The extension selected.
  137025. */
  137026. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  137027. }
  137028. }
  137029. declare module BABYLON {
  137030. /** @hidden */
  137031. export var rgbdEncodePixelShader: {
  137032. name: string;
  137033. shader: string;
  137034. };
  137035. }
  137036. declare module BABYLON {
  137037. /**
  137038. * Raw texture data and descriptor sufficient for WebGL texture upload
  137039. */
  137040. export interface EnvironmentTextureInfo {
  137041. /**
  137042. * Version of the environment map
  137043. */
  137044. version: number;
  137045. /**
  137046. * Width of image
  137047. */
  137048. width: number;
  137049. /**
  137050. * Irradiance information stored in the file.
  137051. */
  137052. irradiance: any;
  137053. /**
  137054. * Specular information stored in the file.
  137055. */
  137056. specular: any;
  137057. }
  137058. /**
  137059. * Defines One Image in the file. It requires only the position in the file
  137060. * as well as the length.
  137061. */
  137062. interface BufferImageData {
  137063. /**
  137064. * Length of the image data.
  137065. */
  137066. length: number;
  137067. /**
  137068. * Position of the data from the null terminator delimiting the end of the JSON.
  137069. */
  137070. position: number;
  137071. }
  137072. /**
  137073. * Defines the specular data enclosed in the file.
  137074. * This corresponds to the version 1 of the data.
  137075. */
  137076. export interface EnvironmentTextureSpecularInfoV1 {
  137077. /**
  137078. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  137079. */
  137080. specularDataPosition?: number;
  137081. /**
  137082. * This contains all the images data needed to reconstruct the cubemap.
  137083. */
  137084. mipmaps: Array<BufferImageData>;
  137085. /**
  137086. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  137087. */
  137088. lodGenerationScale: number;
  137089. }
  137090. /**
  137091. * Sets of helpers addressing the serialization and deserialization of environment texture
  137092. * stored in a BabylonJS env file.
  137093. * Those files are usually stored as .env files.
  137094. */
  137095. export class EnvironmentTextureTools {
  137096. /**
  137097. * Magic number identifying the env file.
  137098. */
  137099. private static _MagicBytes;
  137100. /**
  137101. * Gets the environment info from an env file.
  137102. * @param data The array buffer containing the .env bytes.
  137103. * @returns the environment file info (the json header) if successfully parsed.
  137104. */
  137105. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  137106. /**
  137107. * Creates an environment texture from a loaded cube texture.
  137108. * @param texture defines the cube texture to convert in env file
  137109. * @return a promise containing the environment data if succesfull.
  137110. */
  137111. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  137112. /**
  137113. * Creates a JSON representation of the spherical data.
  137114. * @param texture defines the texture containing the polynomials
  137115. * @return the JSON representation of the spherical info
  137116. */
  137117. private static _CreateEnvTextureIrradiance;
  137118. /**
  137119. * Creates the ArrayBufferViews used for initializing environment texture image data.
  137120. * @param data the image data
  137121. * @param info parameters that determine what views will be created for accessing the underlying buffer
  137122. * @return the views described by info providing access to the underlying buffer
  137123. */
  137124. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  137125. /**
  137126. * Uploads the texture info contained in the env file to the GPU.
  137127. * @param texture defines the internal texture to upload to
  137128. * @param data defines the data to load
  137129. * @param info defines the texture info retrieved through the GetEnvInfo method
  137130. * @returns a promise
  137131. */
  137132. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  137133. private static _OnImageReadyAsync;
  137134. /**
  137135. * Uploads the levels of image data to the GPU.
  137136. * @param texture defines the internal texture to upload to
  137137. * @param imageData defines the array buffer views of image data [mipmap][face]
  137138. * @returns a promise
  137139. */
  137140. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  137141. /**
  137142. * Uploads spherical polynomials information to the texture.
  137143. * @param texture defines the texture we are trying to upload the information to
  137144. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  137145. */
  137146. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  137147. /** @hidden */
  137148. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  137149. }
  137150. }
  137151. declare module BABYLON {
  137152. /**
  137153. * Class used to inline functions in shader code
  137154. */
  137155. export class ShaderCodeInliner {
  137156. private static readonly _RegexpFindFunctionNameAndType;
  137157. private _sourceCode;
  137158. private _functionDescr;
  137159. private _numMaxIterations;
  137160. /** Gets or sets the token used to mark the functions to inline */
  137161. inlineToken: string;
  137162. /** Gets or sets the debug mode */
  137163. debug: boolean;
  137164. /** Gets the code after the inlining process */
  137165. get code(): string;
  137166. /**
  137167. * Initializes the inliner
  137168. * @param sourceCode shader code source to inline
  137169. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  137170. */
  137171. constructor(sourceCode: string, numMaxIterations?: number);
  137172. /**
  137173. * Start the processing of the shader code
  137174. */
  137175. processCode(): void;
  137176. private _collectFunctions;
  137177. private _processInlining;
  137178. private _extractBetweenMarkers;
  137179. private _skipWhitespaces;
  137180. private _removeComments;
  137181. private _replaceFunctionCallsByCode;
  137182. private _findBackward;
  137183. private _escapeRegExp;
  137184. private _replaceNames;
  137185. }
  137186. }
  137187. declare module BABYLON {
  137188. /**
  137189. * Container for accessors for natively-stored mesh data buffers.
  137190. */
  137191. class NativeDataBuffer extends DataBuffer {
  137192. /**
  137193. * Accessor value used to identify/retrieve a natively-stored index buffer.
  137194. */
  137195. nativeIndexBuffer?: any;
  137196. /**
  137197. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  137198. */
  137199. nativeVertexBuffer?: any;
  137200. }
  137201. /** @hidden */
  137202. class NativeTexture extends InternalTexture {
  137203. getInternalTexture(): InternalTexture;
  137204. getViewCount(): number;
  137205. }
  137206. /** @hidden */
  137207. export class NativeEngine extends Engine {
  137208. private readonly _native;
  137209. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  137210. private readonly INVALID_HANDLE;
  137211. private _boundBuffersVertexArray;
  137212. private _currentDepthTest;
  137213. getHardwareScalingLevel(): number;
  137214. constructor();
  137215. dispose(): void;
  137216. /**
  137217. * Can be used to override the current requestAnimationFrame requester.
  137218. * @hidden
  137219. */
  137220. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  137221. /**
  137222. * Override default engine behavior.
  137223. * @param color
  137224. * @param backBuffer
  137225. * @param depth
  137226. * @param stencil
  137227. */
  137228. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  137229. /**
  137230. * Gets host document
  137231. * @returns the host document object
  137232. */
  137233. getHostDocument(): Nullable<Document>;
  137234. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  137235. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  137236. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  137237. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  137238. [key: string]: VertexBuffer;
  137239. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  137240. bindBuffers(vertexBuffers: {
  137241. [key: string]: VertexBuffer;
  137242. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  137243. recordVertexArrayObject(vertexBuffers: {
  137244. [key: string]: VertexBuffer;
  137245. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  137246. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  137247. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  137248. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  137249. /**
  137250. * Draw a list of indexed primitives
  137251. * @param fillMode defines the primitive to use
  137252. * @param indexStart defines the starting index
  137253. * @param indexCount defines the number of index to draw
  137254. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137255. */
  137256. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  137257. /**
  137258. * Draw a list of unindexed primitives
  137259. * @param fillMode defines the primitive to use
  137260. * @param verticesStart defines the index of first vertex to draw
  137261. * @param verticesCount defines the count of vertices to draw
  137262. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  137263. */
  137264. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  137265. createPipelineContext(): IPipelineContext;
  137266. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  137267. /** @hidden */
  137268. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  137269. /** @hidden */
  137270. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  137271. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  137272. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  137273. protected _setProgram(program: WebGLProgram): void;
  137274. _releaseEffect(effect: Effect): void;
  137275. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  137276. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  137277. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  137278. bindSamplers(effect: Effect): void;
  137279. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  137280. getRenderWidth(useScreen?: boolean): number;
  137281. getRenderHeight(useScreen?: boolean): number;
  137282. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  137283. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  137284. /**
  137285. * Set the z offset to apply to current rendering
  137286. * @param value defines the offset to apply
  137287. */
  137288. setZOffset(value: number): void;
  137289. /**
  137290. * Gets the current value of the zOffset
  137291. * @returns the current zOffset state
  137292. */
  137293. getZOffset(): number;
  137294. /**
  137295. * Enable or disable depth buffering
  137296. * @param enable defines the state to set
  137297. */
  137298. setDepthBuffer(enable: boolean): void;
  137299. /**
  137300. * Gets a boolean indicating if depth writing is enabled
  137301. * @returns the current depth writing state
  137302. */
  137303. getDepthWrite(): boolean;
  137304. setDepthFunctionToGreater(): void;
  137305. setDepthFunctionToGreaterOrEqual(): void;
  137306. setDepthFunctionToLess(): void;
  137307. setDepthFunctionToLessOrEqual(): void;
  137308. /**
  137309. * Enable or disable depth writing
  137310. * @param enable defines the state to set
  137311. */
  137312. setDepthWrite(enable: boolean): void;
  137313. /**
  137314. * Enable or disable color writing
  137315. * @param enable defines the state to set
  137316. */
  137317. setColorWrite(enable: boolean): void;
  137318. /**
  137319. * Gets a boolean indicating if color writing is enabled
  137320. * @returns the current color writing state
  137321. */
  137322. getColorWrite(): boolean;
  137323. /**
  137324. * Sets alpha constants used by some alpha blending modes
  137325. * @param r defines the red component
  137326. * @param g defines the green component
  137327. * @param b defines the blue component
  137328. * @param a defines the alpha component
  137329. */
  137330. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  137331. /**
  137332. * Sets the current alpha mode
  137333. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  137334. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  137335. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  137336. */
  137337. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  137338. /**
  137339. * Gets the current alpha mode
  137340. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  137341. * @returns the current alpha mode
  137342. */
  137343. getAlphaMode(): number;
  137344. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  137345. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137346. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137347. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137348. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  137349. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137350. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137351. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137352. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  137353. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  137354. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  137355. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  137356. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  137357. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  137358. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  137359. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  137360. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  137361. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  137362. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  137363. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  137364. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  137365. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  137366. wipeCaches(bruteForce?: boolean): void;
  137367. _createTexture(): WebGLTexture;
  137368. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  137369. /**
  137370. * Update the content of a dynamic texture
  137371. * @param texture defines the texture to update
  137372. * @param canvas defines the canvas containing the source
  137373. * @param invertY defines if data must be stored with Y axis inverted
  137374. * @param premulAlpha defines if alpha is stored as premultiplied
  137375. * @param format defines the format of the data
  137376. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  137377. */
  137378. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  137379. /**
  137380. * Usually called from Texture.ts.
  137381. * Passed information to create a WebGLTexture
  137382. * @param url defines a value which contains one of the following:
  137383. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  137384. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  137385. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  137386. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  137387. * @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)
  137388. * @param scene needed for loading to the correct scene
  137389. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  137390. * @param onLoad optional callback to be called upon successful completion
  137391. * @param onError optional callback to be called upon failure
  137392. * @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
  137393. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  137394. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  137395. * @param forcedExtension defines the extension to use to pick the right loader
  137396. * @param mimeType defines an optional mime type
  137397. * @param loaderOptions options to be passed to the loader
  137398. * @returns a InternalTexture for assignment back into BABYLON.Texture
  137399. */
  137400. 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;
  137401. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  137402. _releaseFramebufferObjects(texture: InternalTexture): void;
  137403. /**
  137404. * Creates a cube texture
  137405. * @param rootUrl defines the url where the files to load is located
  137406. * @param scene defines the current scene
  137407. * @param files defines the list of files to load (1 per face)
  137408. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  137409. * @param onLoad defines an optional callback raised when the texture is loaded
  137410. * @param onError defines an optional callback raised if there is an issue to load the texture
  137411. * @param format defines the format of the data
  137412. * @param forcedExtension defines the extension to use to pick the right loader
  137413. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  137414. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  137415. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  137416. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  137417. * @returns the cube texture as an InternalTexture
  137418. */
  137419. 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;
  137420. createRenderTargetTexture(size: number | {
  137421. width: number;
  137422. height: number;
  137423. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  137424. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  137425. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  137426. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  137427. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  137428. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  137429. /**
  137430. * Updates a dynamic vertex buffer.
  137431. * @param vertexBuffer the vertex buffer to update
  137432. * @param data the data used to update the vertex buffer
  137433. * @param byteOffset the byte offset of the data (optional)
  137434. * @param byteLength the byte length of the data (optional)
  137435. */
  137436. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  137437. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  137438. private _updateAnisotropicLevel;
  137439. private _getAddressMode;
  137440. /** @hidden */
  137441. _bindTexture(channel: number, texture: InternalTexture): void;
  137442. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  137443. releaseEffects(): void;
  137444. /** @hidden */
  137445. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137446. /** @hidden */
  137447. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137448. /** @hidden */
  137449. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  137450. /** @hidden */
  137451. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  137452. private _getNativeSamplingMode;
  137453. private _getNativeTextureFormat;
  137454. private _getNativeAlphaMode;
  137455. private _getNativeAttribType;
  137456. }
  137457. }
  137458. declare module BABYLON {
  137459. /**
  137460. * Gather the list of clipboard event types as constants.
  137461. */
  137462. export class ClipboardEventTypes {
  137463. /**
  137464. * The clipboard event is fired when a copy command is active (pressed).
  137465. */
  137466. static readonly COPY: number;
  137467. /**
  137468. * The clipboard event is fired when a cut command is active (pressed).
  137469. */
  137470. static readonly CUT: number;
  137471. /**
  137472. * The clipboard event is fired when a paste command is active (pressed).
  137473. */
  137474. static readonly PASTE: number;
  137475. }
  137476. /**
  137477. * This class is used to store clipboard related info for the onClipboardObservable event.
  137478. */
  137479. export class ClipboardInfo {
  137480. /**
  137481. * Defines the type of event (BABYLON.ClipboardEventTypes)
  137482. */
  137483. type: number;
  137484. /**
  137485. * Defines the related dom event
  137486. */
  137487. event: ClipboardEvent;
  137488. /**
  137489. *Creates an instance of ClipboardInfo.
  137490. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  137491. * @param event Defines the related dom event
  137492. */
  137493. constructor(
  137494. /**
  137495. * Defines the type of event (BABYLON.ClipboardEventTypes)
  137496. */
  137497. type: number,
  137498. /**
  137499. * Defines the related dom event
  137500. */
  137501. event: ClipboardEvent);
  137502. /**
  137503. * Get the clipboard event's type from the keycode.
  137504. * @param keyCode Defines the keyCode for the current keyboard event.
  137505. * @return {number}
  137506. */
  137507. static GetTypeFromCharacter(keyCode: number): number;
  137508. }
  137509. }
  137510. declare module BABYLON {
  137511. /**
  137512. * Google Daydream controller
  137513. */
  137514. export class DaydreamController extends WebVRController {
  137515. /**
  137516. * Base Url for the controller model.
  137517. */
  137518. static MODEL_BASE_URL: string;
  137519. /**
  137520. * File name for the controller model.
  137521. */
  137522. static MODEL_FILENAME: string;
  137523. /**
  137524. * Gamepad Id prefix used to identify Daydream Controller.
  137525. */
  137526. static readonly GAMEPAD_ID_PREFIX: string;
  137527. /**
  137528. * Creates a new DaydreamController from a gamepad
  137529. * @param vrGamepad the gamepad that the controller should be created from
  137530. */
  137531. constructor(vrGamepad: any);
  137532. /**
  137533. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137534. * @param scene scene in which to add meshes
  137535. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137536. */
  137537. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137538. /**
  137539. * Called once for each button that changed state since the last frame
  137540. * @param buttonIdx Which button index changed
  137541. * @param state New state of the button
  137542. * @param changes Which properties on the state changed since last frame
  137543. */
  137544. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137545. }
  137546. }
  137547. declare module BABYLON {
  137548. /**
  137549. * Gear VR Controller
  137550. */
  137551. export class GearVRController extends WebVRController {
  137552. /**
  137553. * Base Url for the controller model.
  137554. */
  137555. static MODEL_BASE_URL: string;
  137556. /**
  137557. * File name for the controller model.
  137558. */
  137559. static MODEL_FILENAME: string;
  137560. /**
  137561. * Gamepad Id prefix used to identify this controller.
  137562. */
  137563. static readonly GAMEPAD_ID_PREFIX: string;
  137564. private readonly _buttonIndexToObservableNameMap;
  137565. /**
  137566. * Creates a new GearVRController from a gamepad
  137567. * @param vrGamepad the gamepad that the controller should be created from
  137568. */
  137569. constructor(vrGamepad: any);
  137570. /**
  137571. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137572. * @param scene scene in which to add meshes
  137573. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137574. */
  137575. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137576. /**
  137577. * Called once for each button that changed state since the last frame
  137578. * @param buttonIdx Which button index changed
  137579. * @param state New state of the button
  137580. * @param changes Which properties on the state changed since last frame
  137581. */
  137582. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137583. }
  137584. }
  137585. declare module BABYLON {
  137586. /**
  137587. * Generic Controller
  137588. */
  137589. export class GenericController extends WebVRController {
  137590. /**
  137591. * Base Url for the controller model.
  137592. */
  137593. static readonly MODEL_BASE_URL: string;
  137594. /**
  137595. * File name for the controller model.
  137596. */
  137597. static readonly MODEL_FILENAME: string;
  137598. /**
  137599. * Creates a new GenericController from a gamepad
  137600. * @param vrGamepad the gamepad that the controller should be created from
  137601. */
  137602. constructor(vrGamepad: any);
  137603. /**
  137604. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137605. * @param scene scene in which to add meshes
  137606. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137607. */
  137608. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137609. /**
  137610. * Called once for each button that changed state since the last frame
  137611. * @param buttonIdx Which button index changed
  137612. * @param state New state of the button
  137613. * @param changes Which properties on the state changed since last frame
  137614. */
  137615. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137616. }
  137617. }
  137618. declare module BABYLON {
  137619. /**
  137620. * Oculus Touch Controller
  137621. */
  137622. export class OculusTouchController extends WebVRController {
  137623. /**
  137624. * Base Url for the controller model.
  137625. */
  137626. static MODEL_BASE_URL: string;
  137627. /**
  137628. * File name for the left controller model.
  137629. */
  137630. static MODEL_LEFT_FILENAME: string;
  137631. /**
  137632. * File name for the right controller model.
  137633. */
  137634. static MODEL_RIGHT_FILENAME: string;
  137635. /**
  137636. * Base Url for the Quest controller model.
  137637. */
  137638. static QUEST_MODEL_BASE_URL: string;
  137639. /**
  137640. * @hidden
  137641. * If the controllers are running on a device that needs the updated Quest controller models
  137642. */
  137643. static _IsQuest: boolean;
  137644. /**
  137645. * Fired when the secondary trigger on this controller is modified
  137646. */
  137647. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  137648. /**
  137649. * Fired when the thumb rest on this controller is modified
  137650. */
  137651. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  137652. /**
  137653. * Creates a new OculusTouchController from a gamepad
  137654. * @param vrGamepad the gamepad that the controller should be created from
  137655. */
  137656. constructor(vrGamepad: any);
  137657. /**
  137658. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137659. * @param scene scene in which to add meshes
  137660. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137661. */
  137662. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137663. /**
  137664. * Fired when the A button on this controller is modified
  137665. */
  137666. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137667. /**
  137668. * Fired when the B button on this controller is modified
  137669. */
  137670. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137671. /**
  137672. * Fired when the X button on this controller is modified
  137673. */
  137674. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137675. /**
  137676. * Fired when the Y button on this controller is modified
  137677. */
  137678. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137679. /**
  137680. * Called once for each button that changed state since the last frame
  137681. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  137682. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  137683. * 2) secondary trigger (same)
  137684. * 3) A (right) X (left), touch, pressed = value
  137685. * 4) B / Y
  137686. * 5) thumb rest
  137687. * @param buttonIdx Which button index changed
  137688. * @param state New state of the button
  137689. * @param changes Which properties on the state changed since last frame
  137690. */
  137691. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137692. }
  137693. }
  137694. declare module BABYLON {
  137695. /**
  137696. * Vive Controller
  137697. */
  137698. export class ViveController extends WebVRController {
  137699. /**
  137700. * Base Url for the controller model.
  137701. */
  137702. static MODEL_BASE_URL: string;
  137703. /**
  137704. * File name for the controller model.
  137705. */
  137706. static MODEL_FILENAME: string;
  137707. /**
  137708. * Creates a new ViveController from a gamepad
  137709. * @param vrGamepad the gamepad that the controller should be created from
  137710. */
  137711. constructor(vrGamepad: any);
  137712. /**
  137713. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137714. * @param scene scene in which to add meshes
  137715. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137716. */
  137717. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  137718. /**
  137719. * Fired when the left button on this controller is modified
  137720. */
  137721. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137722. /**
  137723. * Fired when the right button on this controller is modified
  137724. */
  137725. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137726. /**
  137727. * Fired when the menu button on this controller is modified
  137728. */
  137729. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137730. /**
  137731. * Called once for each button that changed state since the last frame
  137732. * Vive mapping:
  137733. * 0: touchpad
  137734. * 1: trigger
  137735. * 2: left AND right buttons
  137736. * 3: menu button
  137737. * @param buttonIdx Which button index changed
  137738. * @param state New state of the button
  137739. * @param changes Which properties on the state changed since last frame
  137740. */
  137741. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137742. }
  137743. }
  137744. declare module BABYLON {
  137745. /**
  137746. * Defines the WindowsMotionController object that the state of the windows motion controller
  137747. */
  137748. export class WindowsMotionController extends WebVRController {
  137749. /**
  137750. * The base url used to load the left and right controller models
  137751. */
  137752. static MODEL_BASE_URL: string;
  137753. /**
  137754. * The name of the left controller model file
  137755. */
  137756. static MODEL_LEFT_FILENAME: string;
  137757. /**
  137758. * The name of the right controller model file
  137759. */
  137760. static MODEL_RIGHT_FILENAME: string;
  137761. /**
  137762. * The controller name prefix for this controller type
  137763. */
  137764. static readonly GAMEPAD_ID_PREFIX: string;
  137765. /**
  137766. * The controller id pattern for this controller type
  137767. */
  137768. private static readonly GAMEPAD_ID_PATTERN;
  137769. private _loadedMeshInfo;
  137770. protected readonly _mapping: {
  137771. buttons: string[];
  137772. buttonMeshNames: {
  137773. trigger: string;
  137774. menu: string;
  137775. grip: string;
  137776. thumbstick: string;
  137777. trackpad: string;
  137778. };
  137779. buttonObservableNames: {
  137780. trigger: string;
  137781. menu: string;
  137782. grip: string;
  137783. thumbstick: string;
  137784. trackpad: string;
  137785. };
  137786. axisMeshNames: string[];
  137787. pointingPoseMeshName: string;
  137788. };
  137789. /**
  137790. * Fired when the trackpad on this controller is clicked
  137791. */
  137792. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137793. /**
  137794. * Fired when the trackpad on this controller is modified
  137795. */
  137796. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137797. /**
  137798. * The current x and y values of this controller's trackpad
  137799. */
  137800. trackpad: StickValues;
  137801. /**
  137802. * Creates a new WindowsMotionController from a gamepad
  137803. * @param vrGamepad the gamepad that the controller should be created from
  137804. */
  137805. constructor(vrGamepad: any);
  137806. /**
  137807. * Fired when the trigger on this controller is modified
  137808. */
  137809. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137810. /**
  137811. * Fired when the menu button on this controller is modified
  137812. */
  137813. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137814. /**
  137815. * Fired when the grip button on this controller is modified
  137816. */
  137817. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137818. /**
  137819. * Fired when the thumbstick button on this controller is modified
  137820. */
  137821. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137822. /**
  137823. * Fired when the touchpad button on this controller is modified
  137824. */
  137825. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137826. /**
  137827. * Fired when the touchpad values on this controller are modified
  137828. */
  137829. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  137830. protected _updateTrackpad(): void;
  137831. /**
  137832. * Called once per frame by the engine.
  137833. */
  137834. update(): void;
  137835. /**
  137836. * Called once for each button that changed state since the last frame
  137837. * @param buttonIdx Which button index changed
  137838. * @param state New state of the button
  137839. * @param changes Which properties on the state changed since last frame
  137840. */
  137841. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  137842. /**
  137843. * Moves the buttons on the controller mesh based on their current state
  137844. * @param buttonName the name of the button to move
  137845. * @param buttonValue the value of the button which determines the buttons new position
  137846. */
  137847. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  137848. /**
  137849. * Moves the axis on the controller mesh based on its current state
  137850. * @param axis the index of the axis
  137851. * @param axisValue the value of the axis which determines the meshes new position
  137852. * @hidden
  137853. */
  137854. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  137855. /**
  137856. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  137857. * @param scene scene in which to add meshes
  137858. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  137859. */
  137860. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  137861. /**
  137862. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  137863. * can be transformed by button presses and axes values, based on this._mapping.
  137864. *
  137865. * @param scene scene in which the meshes exist
  137866. * @param meshes list of meshes that make up the controller model to process
  137867. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  137868. */
  137869. private processModel;
  137870. private createMeshInfo;
  137871. /**
  137872. * Gets the ray of the controller in the direction the controller is pointing
  137873. * @param length the length the resulting ray should be
  137874. * @returns a ray in the direction the controller is pointing
  137875. */
  137876. getForwardRay(length?: number): Ray;
  137877. /**
  137878. * Disposes of the controller
  137879. */
  137880. dispose(): void;
  137881. }
  137882. /**
  137883. * This class represents a new windows motion controller in XR.
  137884. */
  137885. export class XRWindowsMotionController extends WindowsMotionController {
  137886. /**
  137887. * Changing the original WIndowsMotionController mapping to fir the new mapping
  137888. */
  137889. protected readonly _mapping: {
  137890. buttons: string[];
  137891. buttonMeshNames: {
  137892. trigger: string;
  137893. menu: string;
  137894. grip: string;
  137895. thumbstick: string;
  137896. trackpad: string;
  137897. };
  137898. buttonObservableNames: {
  137899. trigger: string;
  137900. menu: string;
  137901. grip: string;
  137902. thumbstick: string;
  137903. trackpad: string;
  137904. };
  137905. axisMeshNames: string[];
  137906. pointingPoseMeshName: string;
  137907. };
  137908. /**
  137909. * Construct a new XR-Based windows motion controller
  137910. *
  137911. * @param gamepadInfo the gamepad object from the browser
  137912. */
  137913. constructor(gamepadInfo: any);
  137914. /**
  137915. * holds the thumbstick values (X,Y)
  137916. */
  137917. thumbstickValues: StickValues;
  137918. /**
  137919. * Fired when the thumbstick on this controller is clicked
  137920. */
  137921. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  137922. /**
  137923. * Fired when the thumbstick on this controller is modified
  137924. */
  137925. onThumbstickValuesChangedObservable: Observable<StickValues>;
  137926. /**
  137927. * Fired when the touchpad button on this controller is modified
  137928. */
  137929. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  137930. /**
  137931. * Fired when the touchpad values on this controller are modified
  137932. */
  137933. onTrackpadValuesChangedObservable: Observable<StickValues>;
  137934. /**
  137935. * Fired when the thumbstick button on this controller is modified
  137936. * here to prevent breaking changes
  137937. */
  137938. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  137939. /**
  137940. * updating the thumbstick(!) and not the trackpad.
  137941. * This is named this way due to the difference between WebVR and XR and to avoid
  137942. * changing the parent class.
  137943. */
  137944. protected _updateTrackpad(): void;
  137945. /**
  137946. * Disposes the class with joy
  137947. */
  137948. dispose(): void;
  137949. }
  137950. }
  137951. declare module BABYLON {
  137952. /**
  137953. * Class containing static functions to help procedurally build meshes
  137954. */
  137955. export class PolyhedronBuilder {
  137956. /**
  137957. * Creates a polyhedron mesh
  137958. * * 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
  137959. * * The parameter `size` (positive float, default 1) sets the polygon size
  137960. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  137961. * * 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`
  137962. * * 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
  137963. * * 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)`)
  137964. * * 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
  137965. * * 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
  137966. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  137967. * * 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
  137968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  137969. * @param name defines the name of the mesh
  137970. * @param options defines the options used to create the mesh
  137971. * @param scene defines the hosting scene
  137972. * @returns the polyhedron mesh
  137973. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  137974. */
  137975. static CreatePolyhedron(name: string, options: {
  137976. type?: number;
  137977. size?: number;
  137978. sizeX?: number;
  137979. sizeY?: number;
  137980. sizeZ?: number;
  137981. custom?: any;
  137982. faceUV?: Vector4[];
  137983. faceColors?: Color4[];
  137984. flat?: boolean;
  137985. updatable?: boolean;
  137986. sideOrientation?: number;
  137987. frontUVs?: Vector4;
  137988. backUVs?: Vector4;
  137989. }, scene?: Nullable<Scene>): Mesh;
  137990. }
  137991. }
  137992. declare module BABYLON {
  137993. /**
  137994. * Gizmo that enables scaling a mesh along 3 axis
  137995. */
  137996. export class ScaleGizmo extends Gizmo {
  137997. /**
  137998. * Internal gizmo used for interactions on the x axis
  137999. */
  138000. xGizmo: AxisScaleGizmo;
  138001. /**
  138002. * Internal gizmo used for interactions on the y axis
  138003. */
  138004. yGizmo: AxisScaleGizmo;
  138005. /**
  138006. * Internal gizmo used for interactions on the z axis
  138007. */
  138008. zGizmo: AxisScaleGizmo;
  138009. /**
  138010. * Internal gizmo used to scale all axis equally
  138011. */
  138012. uniformScaleGizmo: AxisScaleGizmo;
  138013. private _meshAttached;
  138014. private _nodeAttached;
  138015. private _snapDistance;
  138016. private _uniformScalingMesh;
  138017. private _octahedron;
  138018. private _sensitivity;
  138019. /** Fires an event when any of it's sub gizmos are dragged */
  138020. onDragStartObservable: Observable<unknown>;
  138021. /** Fires an event when any of it's sub gizmos are released from dragging */
  138022. onDragEndObservable: Observable<unknown>;
  138023. get attachedMesh(): Nullable<AbstractMesh>;
  138024. set attachedMesh(mesh: Nullable<AbstractMesh>);
  138025. get attachedNode(): Nullable<Node>;
  138026. set attachedNode(node: Nullable<Node>);
  138027. /**
  138028. * True when the mouse pointer is hovering a gizmo mesh
  138029. */
  138030. get isHovered(): boolean;
  138031. /**
  138032. * Creates a ScaleGizmo
  138033. * @param gizmoLayer The utility layer the gizmo will be added to
  138034. * @param thickness display gizmo axis thickness
  138035. */
  138036. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  138037. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  138038. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  138039. /**
  138040. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  138041. */
  138042. set snapDistance(value: number);
  138043. get snapDistance(): number;
  138044. /**
  138045. * Ratio for the scale of the gizmo (Default: 1)
  138046. */
  138047. set scaleRatio(value: number);
  138048. get scaleRatio(): number;
  138049. /**
  138050. * Sensitivity factor for dragging (Default: 1)
  138051. */
  138052. set sensitivity(value: number);
  138053. get sensitivity(): number;
  138054. /**
  138055. * Disposes of the gizmo
  138056. */
  138057. dispose(): void;
  138058. }
  138059. }
  138060. declare module BABYLON {
  138061. /**
  138062. * Single axis scale gizmo
  138063. */
  138064. export class AxisScaleGizmo extends Gizmo {
  138065. /**
  138066. * Drag behavior responsible for the gizmos dragging interactions
  138067. */
  138068. dragBehavior: PointerDragBehavior;
  138069. private _pointerObserver;
  138070. /**
  138071. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  138072. */
  138073. snapDistance: number;
  138074. /**
  138075. * Event that fires each time the gizmo snaps to a new location.
  138076. * * snapDistance is the the change in distance
  138077. */
  138078. onSnapObservable: Observable<{
  138079. snapDistance: number;
  138080. }>;
  138081. /**
  138082. * If the scaling operation should be done on all axis (default: false)
  138083. */
  138084. uniformScaling: boolean;
  138085. /**
  138086. * Custom sensitivity value for the drag strength
  138087. */
  138088. sensitivity: number;
  138089. private _isEnabled;
  138090. private _parent;
  138091. private _arrow;
  138092. private _coloredMaterial;
  138093. private _hoverMaterial;
  138094. /**
  138095. * Creates an AxisScaleGizmo
  138096. * @param gizmoLayer The utility layer the gizmo will be added to
  138097. * @param dragAxis The axis which the gizmo will be able to scale on
  138098. * @param color The color of the gizmo
  138099. * @param thickness display gizmo axis thickness
  138100. */
  138101. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  138102. protected _attachedNodeChanged(value: Nullable<Node>): void;
  138103. /**
  138104. * If the gizmo is enabled
  138105. */
  138106. set isEnabled(value: boolean);
  138107. get isEnabled(): boolean;
  138108. /**
  138109. * Disposes of the gizmo
  138110. */
  138111. dispose(): void;
  138112. /**
  138113. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  138114. * @param mesh The mesh to replace the default mesh of the gizmo
  138115. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  138116. */
  138117. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  138118. }
  138119. }
  138120. declare module BABYLON {
  138121. /**
  138122. * Bounding box gizmo
  138123. */
  138124. export class BoundingBoxGizmo extends Gizmo {
  138125. private _lineBoundingBox;
  138126. private _rotateSpheresParent;
  138127. private _scaleBoxesParent;
  138128. private _boundingDimensions;
  138129. private _renderObserver;
  138130. private _pointerObserver;
  138131. private _scaleDragSpeed;
  138132. private _tmpQuaternion;
  138133. private _tmpVector;
  138134. private _tmpRotationMatrix;
  138135. /**
  138136. * 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)
  138137. */
  138138. ignoreChildren: boolean;
  138139. /**
  138140. * 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)
  138141. */
  138142. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  138143. /**
  138144. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  138145. */
  138146. rotationSphereSize: number;
  138147. /**
  138148. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  138149. */
  138150. scaleBoxSize: number;
  138151. /**
  138152. * 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)
  138153. */
  138154. fixedDragMeshScreenSize: boolean;
  138155. /**
  138156. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  138157. */
  138158. fixedDragMeshScreenSizeDistanceFactor: number;
  138159. /**
  138160. * Fired when a rotation sphere or scale box is dragged
  138161. */
  138162. onDragStartObservable: Observable<{}>;
  138163. /**
  138164. * Fired when a scale box is dragged
  138165. */
  138166. onScaleBoxDragObservable: Observable<{}>;
  138167. /**
  138168. * Fired when a scale box drag is ended
  138169. */
  138170. onScaleBoxDragEndObservable: Observable<{}>;
  138171. /**
  138172. * Fired when a rotation sphere is dragged
  138173. */
  138174. onRotationSphereDragObservable: Observable<{}>;
  138175. /**
  138176. * Fired when a rotation sphere drag is ended
  138177. */
  138178. onRotationSphereDragEndObservable: Observable<{}>;
  138179. /**
  138180. * 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)
  138181. */
  138182. scalePivot: Nullable<Vector3>;
  138183. /**
  138184. * Mesh used as a pivot to rotate the attached node
  138185. */
  138186. private _anchorMesh;
  138187. private _existingMeshScale;
  138188. private _dragMesh;
  138189. private pointerDragBehavior;
  138190. private coloredMaterial;
  138191. private hoverColoredMaterial;
  138192. /**
  138193. * Sets the color of the bounding box gizmo
  138194. * @param color the color to set
  138195. */
  138196. setColor(color: Color3): void;
  138197. /**
  138198. * Creates an BoundingBoxGizmo
  138199. * @param gizmoLayer The utility layer the gizmo will be added to
  138200. * @param color The color of the gizmo
  138201. */
  138202. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  138203. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  138204. private _selectNode;
  138205. /**
  138206. * Updates the bounding box information for the Gizmo
  138207. */
  138208. updateBoundingBox(): void;
  138209. private _updateRotationSpheres;
  138210. private _updateScaleBoxes;
  138211. /**
  138212. * Enables rotation on the specified axis and disables rotation on the others
  138213. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  138214. */
  138215. setEnabledRotationAxis(axis: string): void;
  138216. /**
  138217. * Enables/disables scaling
  138218. * @param enable if scaling should be enabled
  138219. * @param homogeneousScaling defines if scaling should only be homogeneous
  138220. */
  138221. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  138222. private _updateDummy;
  138223. /**
  138224. * Enables a pointer drag behavior on the bounding box of the gizmo
  138225. */
  138226. enableDragBehavior(): void;
  138227. /**
  138228. * Disposes of the gizmo
  138229. */
  138230. dispose(): void;
  138231. /**
  138232. * 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)
  138233. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  138234. * @returns the bounding box mesh with the passed in mesh as a child
  138235. */
  138236. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  138237. /**
  138238. * CustomMeshes are not supported by this gizmo
  138239. * @param mesh The mesh to replace the default mesh of the gizmo
  138240. */
  138241. setCustomMesh(mesh: Mesh): void;
  138242. }
  138243. }
  138244. declare module BABYLON {
  138245. /**
  138246. * Single plane rotation gizmo
  138247. */
  138248. export class PlaneRotationGizmo extends Gizmo {
  138249. /**
  138250. * Drag behavior responsible for the gizmos dragging interactions
  138251. */
  138252. dragBehavior: PointerDragBehavior;
  138253. private _pointerObserver;
  138254. /**
  138255. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  138256. */
  138257. snapDistance: number;
  138258. /**
  138259. * Event that fires each time the gizmo snaps to a new location.
  138260. * * snapDistance is the the change in distance
  138261. */
  138262. onSnapObservable: Observable<{
  138263. snapDistance: number;
  138264. }>;
  138265. private _isEnabled;
  138266. private _parent;
  138267. /**
  138268. * Creates a PlaneRotationGizmo
  138269. * @param gizmoLayer The utility layer the gizmo will be added to
  138270. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  138271. * @param color The color of the gizmo
  138272. * @param tessellation Amount of tessellation to be used when creating rotation circles
  138273. * @param useEulerRotation Use and update Euler angle instead of quaternion
  138274. * @param thickness display gizmo axis thickness
  138275. */
  138276. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  138277. protected _attachedNodeChanged(value: Nullable<Node>): void;
  138278. /**
  138279. * If the gizmo is enabled
  138280. */
  138281. set isEnabled(value: boolean);
  138282. get isEnabled(): boolean;
  138283. /**
  138284. * Disposes of the gizmo
  138285. */
  138286. dispose(): void;
  138287. }
  138288. }
  138289. declare module BABYLON {
  138290. /**
  138291. * Gizmo that enables rotating a mesh along 3 axis
  138292. */
  138293. export class RotationGizmo extends Gizmo {
  138294. /**
  138295. * Internal gizmo used for interactions on the x axis
  138296. */
  138297. xGizmo: PlaneRotationGizmo;
  138298. /**
  138299. * Internal gizmo used for interactions on the y axis
  138300. */
  138301. yGizmo: PlaneRotationGizmo;
  138302. /**
  138303. * Internal gizmo used for interactions on the z axis
  138304. */
  138305. zGizmo: PlaneRotationGizmo;
  138306. /** Fires an event when any of it's sub gizmos are dragged */
  138307. onDragStartObservable: Observable<unknown>;
  138308. /** Fires an event when any of it's sub gizmos are released from dragging */
  138309. onDragEndObservable: Observable<unknown>;
  138310. private _meshAttached;
  138311. private _nodeAttached;
  138312. get attachedMesh(): Nullable<AbstractMesh>;
  138313. set attachedMesh(mesh: Nullable<AbstractMesh>);
  138314. get attachedNode(): Nullable<Node>;
  138315. set attachedNode(node: Nullable<Node>);
  138316. protected _checkBillboardTransform(): void;
  138317. /**
  138318. * True when the mouse pointer is hovering a gizmo mesh
  138319. */
  138320. get isHovered(): boolean;
  138321. /**
  138322. * Creates a RotationGizmo
  138323. * @param gizmoLayer The utility layer the gizmo will be added to
  138324. * @param tessellation Amount of tessellation to be used when creating rotation circles
  138325. * @param useEulerRotation Use and update Euler angle instead of quaternion
  138326. * @param thickness display gizmo axis thickness
  138327. */
  138328. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  138329. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  138330. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  138331. /**
  138332. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  138333. */
  138334. set snapDistance(value: number);
  138335. get snapDistance(): number;
  138336. /**
  138337. * Ratio for the scale of the gizmo (Default: 1)
  138338. */
  138339. set scaleRatio(value: number);
  138340. get scaleRatio(): number;
  138341. /**
  138342. * Disposes of the gizmo
  138343. */
  138344. dispose(): void;
  138345. /**
  138346. * CustomMeshes are not supported by this gizmo
  138347. * @param mesh The mesh to replace the default mesh of the gizmo
  138348. */
  138349. setCustomMesh(mesh: Mesh): void;
  138350. }
  138351. }
  138352. declare module BABYLON {
  138353. /**
  138354. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  138355. */
  138356. export class GizmoManager implements IDisposable {
  138357. private scene;
  138358. /**
  138359. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  138360. */
  138361. gizmos: {
  138362. positionGizmo: Nullable<PositionGizmo>;
  138363. rotationGizmo: Nullable<RotationGizmo>;
  138364. scaleGizmo: Nullable<ScaleGizmo>;
  138365. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  138366. };
  138367. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  138368. clearGizmoOnEmptyPointerEvent: boolean;
  138369. /** Fires an event when the manager is attached to a mesh */
  138370. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  138371. /** Fires an event when the manager is attached to a node */
  138372. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  138373. private _gizmosEnabled;
  138374. private _pointerObserver;
  138375. private _attachedMesh;
  138376. private _attachedNode;
  138377. private _boundingBoxColor;
  138378. private _defaultUtilityLayer;
  138379. private _defaultKeepDepthUtilityLayer;
  138380. private _thickness;
  138381. /**
  138382. * When bounding box gizmo is enabled, this can be used to track drag/end events
  138383. */
  138384. boundingBoxDragBehavior: SixDofDragBehavior;
  138385. /**
  138386. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  138387. */
  138388. attachableMeshes: Nullable<Array<AbstractMesh>>;
  138389. /**
  138390. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  138391. */
  138392. attachableNodes: Nullable<Array<Node>>;
  138393. /**
  138394. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  138395. */
  138396. usePointerToAttachGizmos: boolean;
  138397. /**
  138398. * Utility layer that the bounding box gizmo belongs to
  138399. */
  138400. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  138401. /**
  138402. * Utility layer that all gizmos besides bounding box belong to
  138403. */
  138404. get utilityLayer(): UtilityLayerRenderer;
  138405. /**
  138406. * True when the mouse pointer is hovering a gizmo mesh
  138407. */
  138408. get isHovered(): boolean;
  138409. /**
  138410. * Instatiates a gizmo manager
  138411. * @param scene the scene to overlay the gizmos on top of
  138412. * @param thickness display gizmo axis thickness
  138413. */
  138414. constructor(scene: Scene, thickness?: number);
  138415. /**
  138416. * Attaches a set of gizmos to the specified mesh
  138417. * @param mesh The mesh the gizmo's should be attached to
  138418. */
  138419. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  138420. /**
  138421. * Attaches a set of gizmos to the specified node
  138422. * @param node The node the gizmo's should be attached to
  138423. */
  138424. attachToNode(node: Nullable<Node>): void;
  138425. /**
  138426. * If the position gizmo is enabled
  138427. */
  138428. set positionGizmoEnabled(value: boolean);
  138429. get positionGizmoEnabled(): boolean;
  138430. /**
  138431. * If the rotation gizmo is enabled
  138432. */
  138433. set rotationGizmoEnabled(value: boolean);
  138434. get rotationGizmoEnabled(): boolean;
  138435. /**
  138436. * If the scale gizmo is enabled
  138437. */
  138438. set scaleGizmoEnabled(value: boolean);
  138439. get scaleGizmoEnabled(): boolean;
  138440. /**
  138441. * If the boundingBox gizmo is enabled
  138442. */
  138443. set boundingBoxGizmoEnabled(value: boolean);
  138444. get boundingBoxGizmoEnabled(): boolean;
  138445. /**
  138446. * Disposes of the gizmo manager
  138447. */
  138448. dispose(): void;
  138449. }
  138450. }
  138451. declare module BABYLON {
  138452. /**
  138453. * A directional light is defined by a direction (what a surprise!).
  138454. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  138455. * 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.
  138456. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138457. */
  138458. export class DirectionalLight extends ShadowLight {
  138459. private _shadowFrustumSize;
  138460. /**
  138461. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  138462. */
  138463. get shadowFrustumSize(): number;
  138464. /**
  138465. * Specifies a fix frustum size for the shadow generation.
  138466. */
  138467. set shadowFrustumSize(value: number);
  138468. private _shadowOrthoScale;
  138469. /**
  138470. * Gets the shadow projection scale against the optimal computed one.
  138471. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  138472. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  138473. */
  138474. get shadowOrthoScale(): number;
  138475. /**
  138476. * Sets the shadow projection scale against the optimal computed one.
  138477. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  138478. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  138479. */
  138480. set shadowOrthoScale(value: number);
  138481. /**
  138482. * Automatically compute the projection matrix to best fit (including all the casters)
  138483. * on each frame.
  138484. */
  138485. autoUpdateExtends: boolean;
  138486. /**
  138487. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  138488. * on each frame. autoUpdateExtends must be set to true for this to work
  138489. */
  138490. autoCalcShadowZBounds: boolean;
  138491. private _orthoLeft;
  138492. private _orthoRight;
  138493. private _orthoTop;
  138494. private _orthoBottom;
  138495. /**
  138496. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  138497. * The directional light is emitted from everywhere in the given direction.
  138498. * It can cast shadows.
  138499. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138500. * @param name The friendly name of the light
  138501. * @param direction The direction of the light
  138502. * @param scene The scene the light belongs to
  138503. */
  138504. constructor(name: string, direction: Vector3, scene: Scene);
  138505. /**
  138506. * Returns the string "DirectionalLight".
  138507. * @return The class name
  138508. */
  138509. getClassName(): string;
  138510. /**
  138511. * Returns the integer 1.
  138512. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138513. */
  138514. getTypeID(): number;
  138515. /**
  138516. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  138517. * Returns the DirectionalLight Shadow projection matrix.
  138518. */
  138519. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138520. /**
  138521. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  138522. * Returns the DirectionalLight Shadow projection matrix.
  138523. */
  138524. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  138525. /**
  138526. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  138527. * Returns the DirectionalLight Shadow projection matrix.
  138528. */
  138529. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138530. protected _buildUniformLayout(): void;
  138531. /**
  138532. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  138533. * @param effect The effect to update
  138534. * @param lightIndex The index of the light in the effect to update
  138535. * @returns The directional light
  138536. */
  138537. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  138538. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  138539. /**
  138540. * Gets the minZ used for shadow according to both the scene and the light.
  138541. *
  138542. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  138543. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  138544. * @param activeCamera The camera we are returning the min for
  138545. * @returns the depth min z
  138546. */
  138547. getDepthMinZ(activeCamera: Camera): number;
  138548. /**
  138549. * Gets the maxZ used for shadow according to both the scene and the light.
  138550. *
  138551. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  138552. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  138553. * @param activeCamera The camera we are returning the max for
  138554. * @returns the depth max z
  138555. */
  138556. getDepthMaxZ(activeCamera: Camera): number;
  138557. /**
  138558. * Prepares the list of defines specific to the light type.
  138559. * @param defines the list of defines
  138560. * @param lightIndex defines the index of the light for the effect
  138561. */
  138562. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138563. }
  138564. }
  138565. declare module BABYLON {
  138566. /**
  138567. * Class containing static functions to help procedurally build meshes
  138568. */
  138569. export class HemisphereBuilder {
  138570. /**
  138571. * Creates a hemisphere mesh
  138572. * @param name defines the name of the mesh
  138573. * @param options defines the options used to create the mesh
  138574. * @param scene defines the hosting scene
  138575. * @returns the hemisphere mesh
  138576. */
  138577. static CreateHemisphere(name: string, options: {
  138578. segments?: number;
  138579. diameter?: number;
  138580. sideOrientation?: number;
  138581. }, scene: any): Mesh;
  138582. }
  138583. }
  138584. declare module BABYLON {
  138585. /**
  138586. * A spot light is defined by a position, a direction, an angle, and an exponent.
  138587. * These values define a cone of light starting from the position, emitting toward the direction.
  138588. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  138589. * and the exponent defines the speed of the decay of the light with distance (reach).
  138590. * Documentation: https://doc.babylonjs.com/babylon101/lights
  138591. */
  138592. export class SpotLight extends ShadowLight {
  138593. private _angle;
  138594. private _innerAngle;
  138595. private _cosHalfAngle;
  138596. private _lightAngleScale;
  138597. private _lightAngleOffset;
  138598. /**
  138599. * Gets the cone angle of the spot light in Radians.
  138600. */
  138601. get angle(): number;
  138602. /**
  138603. * Sets the cone angle of the spot light in Radians.
  138604. */
  138605. set angle(value: number);
  138606. /**
  138607. * Only used in gltf falloff mode, this defines the angle where
  138608. * the directional falloff will start before cutting at angle which could be seen
  138609. * as outer angle.
  138610. */
  138611. get innerAngle(): number;
  138612. /**
  138613. * Only used in gltf falloff mode, this defines the angle where
  138614. * the directional falloff will start before cutting at angle which could be seen
  138615. * as outer angle.
  138616. */
  138617. set innerAngle(value: number);
  138618. private _shadowAngleScale;
  138619. /**
  138620. * Allows scaling the angle of the light for shadow generation only.
  138621. */
  138622. get shadowAngleScale(): number;
  138623. /**
  138624. * Allows scaling the angle of the light for shadow generation only.
  138625. */
  138626. set shadowAngleScale(value: number);
  138627. /**
  138628. * The light decay speed with the distance from the emission spot.
  138629. */
  138630. exponent: number;
  138631. private _projectionTextureMatrix;
  138632. /**
  138633. * Allows reading the projecton texture
  138634. */
  138635. get projectionTextureMatrix(): Matrix;
  138636. protected _projectionTextureLightNear: number;
  138637. /**
  138638. * Gets the near clip of the Spotlight for texture projection.
  138639. */
  138640. get projectionTextureLightNear(): number;
  138641. /**
  138642. * Sets the near clip of the Spotlight for texture projection.
  138643. */
  138644. set projectionTextureLightNear(value: number);
  138645. protected _projectionTextureLightFar: number;
  138646. /**
  138647. * Gets the far clip of the Spotlight for texture projection.
  138648. */
  138649. get projectionTextureLightFar(): number;
  138650. /**
  138651. * Sets the far clip of the Spotlight for texture projection.
  138652. */
  138653. set projectionTextureLightFar(value: number);
  138654. protected _projectionTextureUpDirection: Vector3;
  138655. /**
  138656. * Gets the Up vector of the Spotlight for texture projection.
  138657. */
  138658. get projectionTextureUpDirection(): Vector3;
  138659. /**
  138660. * Sets the Up vector of the Spotlight for texture projection.
  138661. */
  138662. set projectionTextureUpDirection(value: Vector3);
  138663. private _projectionTexture;
  138664. /**
  138665. * Gets the projection texture of the light.
  138666. */
  138667. get projectionTexture(): Nullable<BaseTexture>;
  138668. /**
  138669. * Sets the projection texture of the light.
  138670. */
  138671. set projectionTexture(value: Nullable<BaseTexture>);
  138672. private _projectionTextureViewLightDirty;
  138673. private _projectionTextureProjectionLightDirty;
  138674. private _projectionTextureDirty;
  138675. private _projectionTextureViewTargetVector;
  138676. private _projectionTextureViewLightMatrix;
  138677. private _projectionTextureProjectionLightMatrix;
  138678. private _projectionTextureScalingMatrix;
  138679. /**
  138680. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  138681. * It can cast shadows.
  138682. * Documentation : https://doc.babylonjs.com/babylon101/lights
  138683. * @param name The light friendly name
  138684. * @param position The position of the spot light in the scene
  138685. * @param direction The direction of the light in the scene
  138686. * @param angle The cone angle of the light in Radians
  138687. * @param exponent The light decay speed with the distance from the emission spot
  138688. * @param scene The scene the lights belongs to
  138689. */
  138690. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  138691. /**
  138692. * Returns the string "SpotLight".
  138693. * @returns the class name
  138694. */
  138695. getClassName(): string;
  138696. /**
  138697. * Returns the integer 2.
  138698. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  138699. */
  138700. getTypeID(): number;
  138701. /**
  138702. * Overrides the direction setter to recompute the projection texture view light Matrix.
  138703. */
  138704. protected _setDirection(value: Vector3): void;
  138705. /**
  138706. * Overrides the position setter to recompute the projection texture view light Matrix.
  138707. */
  138708. protected _setPosition(value: Vector3): void;
  138709. /**
  138710. * 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.
  138711. * Returns the SpotLight.
  138712. */
  138713. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  138714. protected _computeProjectionTextureViewLightMatrix(): void;
  138715. protected _computeProjectionTextureProjectionLightMatrix(): void;
  138716. /**
  138717. * Main function for light texture projection matrix computing.
  138718. */
  138719. protected _computeProjectionTextureMatrix(): void;
  138720. protected _buildUniformLayout(): void;
  138721. private _computeAngleValues;
  138722. /**
  138723. * Sets the passed Effect "effect" with the Light textures.
  138724. * @param effect The effect to update
  138725. * @param lightIndex The index of the light in the effect to update
  138726. * @returns The light
  138727. */
  138728. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  138729. /**
  138730. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  138731. * @param effect The effect to update
  138732. * @param lightIndex The index of the light in the effect to update
  138733. * @returns The spot light
  138734. */
  138735. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  138736. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  138737. /**
  138738. * Disposes the light and the associated resources.
  138739. */
  138740. dispose(): void;
  138741. /**
  138742. * Prepares the list of defines specific to the light type.
  138743. * @param defines the list of defines
  138744. * @param lightIndex defines the index of the light for the effect
  138745. */
  138746. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  138747. }
  138748. }
  138749. declare module BABYLON {
  138750. /**
  138751. * Gizmo that enables viewing a light
  138752. */
  138753. export class LightGizmo extends Gizmo {
  138754. private _lightMesh;
  138755. private _material;
  138756. private _cachedPosition;
  138757. private _cachedForward;
  138758. private _attachedMeshParent;
  138759. private _pointerObserver;
  138760. /**
  138761. * Event that fires each time the gizmo is clicked
  138762. */
  138763. onClickedObservable: Observable<Light>;
  138764. /**
  138765. * Creates a LightGizmo
  138766. * @param gizmoLayer The utility layer the gizmo will be added to
  138767. */
  138768. constructor(gizmoLayer?: UtilityLayerRenderer);
  138769. private _light;
  138770. /**
  138771. * The light that the gizmo is attached to
  138772. */
  138773. set light(light: Nullable<Light>);
  138774. get light(): Nullable<Light>;
  138775. /**
  138776. * Gets the material used to render the light gizmo
  138777. */
  138778. get material(): StandardMaterial;
  138779. /**
  138780. * @hidden
  138781. * Updates the gizmo to match the attached mesh's position/rotation
  138782. */
  138783. protected _update(): void;
  138784. private static _Scale;
  138785. /**
  138786. * Creates the lines for a light mesh
  138787. */
  138788. private static _CreateLightLines;
  138789. /**
  138790. * Disposes of the light gizmo
  138791. */
  138792. dispose(): void;
  138793. private static _CreateHemisphericLightMesh;
  138794. private static _CreatePointLightMesh;
  138795. private static _CreateSpotLightMesh;
  138796. private static _CreateDirectionalLightMesh;
  138797. }
  138798. }
  138799. declare module BABYLON {
  138800. /**
  138801. * Gizmo that enables viewing a camera
  138802. */
  138803. export class CameraGizmo extends Gizmo {
  138804. private _cameraMesh;
  138805. private _cameraLinesMesh;
  138806. private _material;
  138807. private _pointerObserver;
  138808. /**
  138809. * Event that fires each time the gizmo is clicked
  138810. */
  138811. onClickedObservable: Observable<Camera>;
  138812. /**
  138813. * Creates a CameraGizmo
  138814. * @param gizmoLayer The utility layer the gizmo will be added to
  138815. */
  138816. constructor(gizmoLayer?: UtilityLayerRenderer);
  138817. private _camera;
  138818. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  138819. get displayFrustum(): boolean;
  138820. set displayFrustum(value: boolean);
  138821. /**
  138822. * The camera that the gizmo is attached to
  138823. */
  138824. set camera(camera: Nullable<Camera>);
  138825. get camera(): Nullable<Camera>;
  138826. /**
  138827. * Gets the material used to render the camera gizmo
  138828. */
  138829. get material(): StandardMaterial;
  138830. /**
  138831. * @hidden
  138832. * Updates the gizmo to match the attached mesh's position/rotation
  138833. */
  138834. protected _update(): void;
  138835. private static _Scale;
  138836. private _invProjection;
  138837. /**
  138838. * Disposes of the camera gizmo
  138839. */
  138840. dispose(): void;
  138841. private static _CreateCameraMesh;
  138842. private static _CreateCameraFrustum;
  138843. }
  138844. }
  138845. declare module BABYLON {
  138846. /** @hidden */
  138847. export var backgroundFragmentDeclaration: {
  138848. name: string;
  138849. shader: string;
  138850. };
  138851. }
  138852. declare module BABYLON {
  138853. /** @hidden */
  138854. export var backgroundUboDeclaration: {
  138855. name: string;
  138856. shader: string;
  138857. };
  138858. }
  138859. declare module BABYLON {
  138860. /** @hidden */
  138861. export var backgroundPixelShader: {
  138862. name: string;
  138863. shader: string;
  138864. };
  138865. }
  138866. declare module BABYLON {
  138867. /** @hidden */
  138868. export var backgroundVertexDeclaration: {
  138869. name: string;
  138870. shader: string;
  138871. };
  138872. }
  138873. declare module BABYLON {
  138874. /** @hidden */
  138875. export var backgroundVertexShader: {
  138876. name: string;
  138877. shader: string;
  138878. };
  138879. }
  138880. declare module BABYLON {
  138881. /**
  138882. * Background material used to create an efficient environement around your scene.
  138883. */
  138884. export class BackgroundMaterial extends PushMaterial {
  138885. /**
  138886. * Standard reflectance value at parallel view angle.
  138887. */
  138888. static StandardReflectance0: number;
  138889. /**
  138890. * Standard reflectance value at grazing angle.
  138891. */
  138892. static StandardReflectance90: number;
  138893. protected _primaryColor: Color3;
  138894. /**
  138895. * Key light Color (multiply against the environement texture)
  138896. */
  138897. primaryColor: Color3;
  138898. protected __perceptualColor: Nullable<Color3>;
  138899. /**
  138900. * Experimental Internal Use Only.
  138901. *
  138902. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  138903. * This acts as a helper to set the primary color to a more "human friendly" value.
  138904. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  138905. * output color as close as possible from the chosen value.
  138906. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  138907. * part of lighting setup.)
  138908. */
  138909. get _perceptualColor(): Nullable<Color3>;
  138910. set _perceptualColor(value: Nullable<Color3>);
  138911. protected _primaryColorShadowLevel: float;
  138912. /**
  138913. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  138914. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  138915. */
  138916. get primaryColorShadowLevel(): float;
  138917. set primaryColorShadowLevel(value: float);
  138918. protected _primaryColorHighlightLevel: float;
  138919. /**
  138920. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  138921. * The primary color is used at the level chosen to define what the white area would look.
  138922. */
  138923. get primaryColorHighlightLevel(): float;
  138924. set primaryColorHighlightLevel(value: float);
  138925. protected _reflectionTexture: Nullable<BaseTexture>;
  138926. /**
  138927. * Reflection Texture used in the material.
  138928. * Should be author in a specific way for the best result (refer to the documentation).
  138929. */
  138930. reflectionTexture: Nullable<BaseTexture>;
  138931. protected _reflectionBlur: float;
  138932. /**
  138933. * Reflection Texture level of blur.
  138934. *
  138935. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  138936. * texture twice.
  138937. */
  138938. reflectionBlur: float;
  138939. protected _diffuseTexture: Nullable<BaseTexture>;
  138940. /**
  138941. * Diffuse Texture used in the material.
  138942. * Should be author in a specific way for the best result (refer to the documentation).
  138943. */
  138944. diffuseTexture: Nullable<BaseTexture>;
  138945. protected _shadowLights: Nullable<IShadowLight[]>;
  138946. /**
  138947. * Specify the list of lights casting shadow on the material.
  138948. * All scene shadow lights will be included if null.
  138949. */
  138950. shadowLights: Nullable<IShadowLight[]>;
  138951. protected _shadowLevel: float;
  138952. /**
  138953. * Helps adjusting the shadow to a softer level if required.
  138954. * 0 means black shadows and 1 means no shadows.
  138955. */
  138956. shadowLevel: float;
  138957. protected _sceneCenter: Vector3;
  138958. /**
  138959. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  138960. * It is usually zero but might be interesting to modify according to your setup.
  138961. */
  138962. sceneCenter: Vector3;
  138963. protected _opacityFresnel: boolean;
  138964. /**
  138965. * This helps specifying that the material is falling off to the sky box at grazing angle.
  138966. * This helps ensuring a nice transition when the camera goes under the ground.
  138967. */
  138968. opacityFresnel: boolean;
  138969. protected _reflectionFresnel: boolean;
  138970. /**
  138971. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  138972. * This helps adding a mirror texture on the ground.
  138973. */
  138974. reflectionFresnel: boolean;
  138975. protected _reflectionFalloffDistance: number;
  138976. /**
  138977. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  138978. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  138979. */
  138980. reflectionFalloffDistance: number;
  138981. protected _reflectionAmount: number;
  138982. /**
  138983. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  138984. */
  138985. reflectionAmount: number;
  138986. protected _reflectionReflectance0: number;
  138987. /**
  138988. * This specifies the weight of the reflection at grazing angle.
  138989. */
  138990. reflectionReflectance0: number;
  138991. protected _reflectionReflectance90: number;
  138992. /**
  138993. * This specifies the weight of the reflection at a perpendicular point of view.
  138994. */
  138995. reflectionReflectance90: number;
  138996. /**
  138997. * Sets the reflection reflectance fresnel values according to the default standard
  138998. * empirically know to work well :-)
  138999. */
  139000. set reflectionStandardFresnelWeight(value: number);
  139001. protected _useRGBColor: boolean;
  139002. /**
  139003. * Helps to directly use the maps channels instead of their level.
  139004. */
  139005. useRGBColor: boolean;
  139006. protected _enableNoise: boolean;
  139007. /**
  139008. * This helps reducing the banding effect that could occur on the background.
  139009. */
  139010. enableNoise: boolean;
  139011. /**
  139012. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  139013. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  139014. * Recommended to be keep at 1.0 except for special cases.
  139015. */
  139016. get fovMultiplier(): number;
  139017. set fovMultiplier(value: number);
  139018. private _fovMultiplier;
  139019. /**
  139020. * Enable the FOV adjustment feature controlled by fovMultiplier.
  139021. */
  139022. useEquirectangularFOV: boolean;
  139023. private _maxSimultaneousLights;
  139024. /**
  139025. * Number of Simultaneous lights allowed on the material.
  139026. */
  139027. maxSimultaneousLights: int;
  139028. private _shadowOnly;
  139029. /**
  139030. * Make the material only render shadows
  139031. */
  139032. shadowOnly: boolean;
  139033. /**
  139034. * Default configuration related to image processing available in the Background Material.
  139035. */
  139036. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  139037. /**
  139038. * Keep track of the image processing observer to allow dispose and replace.
  139039. */
  139040. private _imageProcessingObserver;
  139041. /**
  139042. * Attaches a new image processing configuration to the PBR Material.
  139043. * @param configuration (if null the scene configuration will be use)
  139044. */
  139045. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  139046. /**
  139047. * Gets the image processing configuration used either in this material.
  139048. */
  139049. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  139050. /**
  139051. * Sets the Default image processing configuration used either in the this material.
  139052. *
  139053. * If sets to null, the scene one is in use.
  139054. */
  139055. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  139056. /**
  139057. * Gets wether the color curves effect is enabled.
  139058. */
  139059. get cameraColorCurvesEnabled(): boolean;
  139060. /**
  139061. * Sets wether the color curves effect is enabled.
  139062. */
  139063. set cameraColorCurvesEnabled(value: boolean);
  139064. /**
  139065. * Gets wether the color grading effect is enabled.
  139066. */
  139067. get cameraColorGradingEnabled(): boolean;
  139068. /**
  139069. * Gets wether the color grading effect is enabled.
  139070. */
  139071. set cameraColorGradingEnabled(value: boolean);
  139072. /**
  139073. * Gets wether tonemapping is enabled or not.
  139074. */
  139075. get cameraToneMappingEnabled(): boolean;
  139076. /**
  139077. * Sets wether tonemapping is enabled or not
  139078. */
  139079. set cameraToneMappingEnabled(value: boolean);
  139080. /**
  139081. * The camera exposure used on this material.
  139082. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  139083. * This corresponds to a photographic exposure.
  139084. */
  139085. get cameraExposure(): float;
  139086. /**
  139087. * The camera exposure used on this material.
  139088. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  139089. * This corresponds to a photographic exposure.
  139090. */
  139091. set cameraExposure(value: float);
  139092. /**
  139093. * Gets The camera contrast used on this material.
  139094. */
  139095. get cameraContrast(): float;
  139096. /**
  139097. * Sets The camera contrast used on this material.
  139098. */
  139099. set cameraContrast(value: float);
  139100. /**
  139101. * Gets the Color Grading 2D Lookup Texture.
  139102. */
  139103. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  139104. /**
  139105. * Sets the Color Grading 2D Lookup Texture.
  139106. */
  139107. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  139108. /**
  139109. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  139110. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  139111. * 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;
  139112. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  139113. */
  139114. get cameraColorCurves(): Nullable<ColorCurves>;
  139115. /**
  139116. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  139117. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  139118. * 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;
  139119. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  139120. */
  139121. set cameraColorCurves(value: Nullable<ColorCurves>);
  139122. /**
  139123. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  139124. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  139125. */
  139126. switchToBGR: boolean;
  139127. private _renderTargets;
  139128. private _reflectionControls;
  139129. private _white;
  139130. private _primaryShadowColor;
  139131. private _primaryHighlightColor;
  139132. /**
  139133. * Instantiates a Background Material in the given scene
  139134. * @param name The friendly name of the material
  139135. * @param scene The scene to add the material to
  139136. */
  139137. constructor(name: string, scene: Scene);
  139138. /**
  139139. * Gets a boolean indicating that current material needs to register RTT
  139140. */
  139141. get hasRenderTargetTextures(): boolean;
  139142. /**
  139143. * The entire material has been created in order to prevent overdraw.
  139144. * @returns false
  139145. */
  139146. needAlphaTesting(): boolean;
  139147. /**
  139148. * The entire material has been created in order to prevent overdraw.
  139149. * @returns true if blending is enable
  139150. */
  139151. needAlphaBlending(): boolean;
  139152. /**
  139153. * Checks wether the material is ready to be rendered for a given mesh.
  139154. * @param mesh The mesh to render
  139155. * @param subMesh The submesh to check against
  139156. * @param useInstances Specify wether or not the material is used with instances
  139157. * @returns true if all the dependencies are ready (Textures, Effects...)
  139158. */
  139159. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  139160. /**
  139161. * Compute the primary color according to the chosen perceptual color.
  139162. */
  139163. private _computePrimaryColorFromPerceptualColor;
  139164. /**
  139165. * Compute the highlights and shadow colors according to their chosen levels.
  139166. */
  139167. private _computePrimaryColors;
  139168. /**
  139169. * Build the uniform buffer used in the material.
  139170. */
  139171. buildUniformLayout(): void;
  139172. /**
  139173. * Unbind the material.
  139174. */
  139175. unbind(): void;
  139176. /**
  139177. * Bind only the world matrix to the material.
  139178. * @param world The world matrix to bind.
  139179. */
  139180. bindOnlyWorldMatrix(world: Matrix): void;
  139181. /**
  139182. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  139183. * @param world The world matrix to bind.
  139184. * @param subMesh The submesh to bind for.
  139185. */
  139186. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  139187. /**
  139188. * Checks to see if a texture is used in the material.
  139189. * @param texture - Base texture to use.
  139190. * @returns - Boolean specifying if a texture is used in the material.
  139191. */
  139192. hasTexture(texture: BaseTexture): boolean;
  139193. /**
  139194. * Dispose the material.
  139195. * @param forceDisposeEffect Force disposal of the associated effect.
  139196. * @param forceDisposeTextures Force disposal of the associated textures.
  139197. */
  139198. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  139199. /**
  139200. * Clones the material.
  139201. * @param name The cloned name.
  139202. * @returns The cloned material.
  139203. */
  139204. clone(name: string): BackgroundMaterial;
  139205. /**
  139206. * Serializes the current material to its JSON representation.
  139207. * @returns The JSON representation.
  139208. */
  139209. serialize(): any;
  139210. /**
  139211. * Gets the class name of the material
  139212. * @returns "BackgroundMaterial"
  139213. */
  139214. getClassName(): string;
  139215. /**
  139216. * Parse a JSON input to create back a background material.
  139217. * @param source The JSON data to parse
  139218. * @param scene The scene to create the parsed material in
  139219. * @param rootUrl The root url of the assets the material depends upon
  139220. * @returns the instantiated BackgroundMaterial.
  139221. */
  139222. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  139223. }
  139224. }
  139225. declare module BABYLON {
  139226. /**
  139227. * Represents the different options available during the creation of
  139228. * a Environment helper.
  139229. *
  139230. * This can control the default ground, skybox and image processing setup of your scene.
  139231. */
  139232. export interface IEnvironmentHelperOptions {
  139233. /**
  139234. * Specifies whether or not to create a ground.
  139235. * True by default.
  139236. */
  139237. createGround: boolean;
  139238. /**
  139239. * Specifies the ground size.
  139240. * 15 by default.
  139241. */
  139242. groundSize: number;
  139243. /**
  139244. * The texture used on the ground for the main color.
  139245. * Comes from the BabylonJS CDN by default.
  139246. *
  139247. * Remarks: Can be either a texture or a url.
  139248. */
  139249. groundTexture: string | BaseTexture;
  139250. /**
  139251. * The color mixed in the ground texture by default.
  139252. * BabylonJS clearColor by default.
  139253. */
  139254. groundColor: Color3;
  139255. /**
  139256. * Specifies the ground opacity.
  139257. * 1 by default.
  139258. */
  139259. groundOpacity: number;
  139260. /**
  139261. * Enables the ground to receive shadows.
  139262. * True by default.
  139263. */
  139264. enableGroundShadow: boolean;
  139265. /**
  139266. * Helps preventing the shadow to be fully black on the ground.
  139267. * 0.5 by default.
  139268. */
  139269. groundShadowLevel: number;
  139270. /**
  139271. * Creates a mirror texture attach to the ground.
  139272. * false by default.
  139273. */
  139274. enableGroundMirror: boolean;
  139275. /**
  139276. * Specifies the ground mirror size ratio.
  139277. * 0.3 by default as the default kernel is 64.
  139278. */
  139279. groundMirrorSizeRatio: number;
  139280. /**
  139281. * Specifies the ground mirror blur kernel size.
  139282. * 64 by default.
  139283. */
  139284. groundMirrorBlurKernel: number;
  139285. /**
  139286. * Specifies the ground mirror visibility amount.
  139287. * 1 by default
  139288. */
  139289. groundMirrorAmount: number;
  139290. /**
  139291. * Specifies the ground mirror reflectance weight.
  139292. * This uses the standard weight of the background material to setup the fresnel effect
  139293. * of the mirror.
  139294. * 1 by default.
  139295. */
  139296. groundMirrorFresnelWeight: number;
  139297. /**
  139298. * Specifies the ground mirror Falloff distance.
  139299. * This can helps reducing the size of the reflection.
  139300. * 0 by Default.
  139301. */
  139302. groundMirrorFallOffDistance: number;
  139303. /**
  139304. * Specifies the ground mirror texture type.
  139305. * Unsigned Int by Default.
  139306. */
  139307. groundMirrorTextureType: number;
  139308. /**
  139309. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  139310. * the shown objects.
  139311. */
  139312. groundYBias: number;
  139313. /**
  139314. * Specifies whether or not to create a skybox.
  139315. * True by default.
  139316. */
  139317. createSkybox: boolean;
  139318. /**
  139319. * Specifies the skybox size.
  139320. * 20 by default.
  139321. */
  139322. skyboxSize: number;
  139323. /**
  139324. * The texture used on the skybox for the main color.
  139325. * Comes from the BabylonJS CDN by default.
  139326. *
  139327. * Remarks: Can be either a texture or a url.
  139328. */
  139329. skyboxTexture: string | BaseTexture;
  139330. /**
  139331. * The color mixed in the skybox texture by default.
  139332. * BabylonJS clearColor by default.
  139333. */
  139334. skyboxColor: Color3;
  139335. /**
  139336. * The background rotation around the Y axis of the scene.
  139337. * This helps aligning the key lights of your scene with the background.
  139338. * 0 by default.
  139339. */
  139340. backgroundYRotation: number;
  139341. /**
  139342. * Compute automatically the size of the elements to best fit with the scene.
  139343. */
  139344. sizeAuto: boolean;
  139345. /**
  139346. * Default position of the rootMesh if autoSize is not true.
  139347. */
  139348. rootPosition: Vector3;
  139349. /**
  139350. * Sets up the image processing in the scene.
  139351. * true by default.
  139352. */
  139353. setupImageProcessing: boolean;
  139354. /**
  139355. * The texture used as your environment texture in the scene.
  139356. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  139357. *
  139358. * Remarks: Can be either a texture or a url.
  139359. */
  139360. environmentTexture: string | BaseTexture;
  139361. /**
  139362. * The value of the exposure to apply to the scene.
  139363. * 0.6 by default if setupImageProcessing is true.
  139364. */
  139365. cameraExposure: number;
  139366. /**
  139367. * The value of the contrast to apply to the scene.
  139368. * 1.6 by default if setupImageProcessing is true.
  139369. */
  139370. cameraContrast: number;
  139371. /**
  139372. * Specifies whether or not tonemapping should be enabled in the scene.
  139373. * true by default if setupImageProcessing is true.
  139374. */
  139375. toneMappingEnabled: boolean;
  139376. }
  139377. /**
  139378. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  139379. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  139380. * It also helps with the default setup of your imageProcessing configuration.
  139381. */
  139382. export class EnvironmentHelper {
  139383. /**
  139384. * Default ground texture URL.
  139385. */
  139386. private static _groundTextureCDNUrl;
  139387. /**
  139388. * Default skybox texture URL.
  139389. */
  139390. private static _skyboxTextureCDNUrl;
  139391. /**
  139392. * Default environment texture URL.
  139393. */
  139394. private static _environmentTextureCDNUrl;
  139395. /**
  139396. * Creates the default options for the helper.
  139397. */
  139398. private static _getDefaultOptions;
  139399. private _rootMesh;
  139400. /**
  139401. * Gets the root mesh created by the helper.
  139402. */
  139403. get rootMesh(): Mesh;
  139404. private _skybox;
  139405. /**
  139406. * Gets the skybox created by the helper.
  139407. */
  139408. get skybox(): Nullable<Mesh>;
  139409. private _skyboxTexture;
  139410. /**
  139411. * Gets the skybox texture created by the helper.
  139412. */
  139413. get skyboxTexture(): Nullable<BaseTexture>;
  139414. private _skyboxMaterial;
  139415. /**
  139416. * Gets the skybox material created by the helper.
  139417. */
  139418. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  139419. private _ground;
  139420. /**
  139421. * Gets the ground mesh created by the helper.
  139422. */
  139423. get ground(): Nullable<Mesh>;
  139424. private _groundTexture;
  139425. /**
  139426. * Gets the ground texture created by the helper.
  139427. */
  139428. get groundTexture(): Nullable<BaseTexture>;
  139429. private _groundMirror;
  139430. /**
  139431. * Gets the ground mirror created by the helper.
  139432. */
  139433. get groundMirror(): Nullable<MirrorTexture>;
  139434. /**
  139435. * Gets the ground mirror render list to helps pushing the meshes
  139436. * you wish in the ground reflection.
  139437. */
  139438. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  139439. private _groundMaterial;
  139440. /**
  139441. * Gets the ground material created by the helper.
  139442. */
  139443. get groundMaterial(): Nullable<BackgroundMaterial>;
  139444. /**
  139445. * Stores the creation options.
  139446. */
  139447. private readonly _scene;
  139448. private _options;
  139449. /**
  139450. * This observable will be notified with any error during the creation of the environment,
  139451. * mainly texture creation errors.
  139452. */
  139453. onErrorObservable: Observable<{
  139454. message?: string;
  139455. exception?: any;
  139456. }>;
  139457. /**
  139458. * constructor
  139459. * @param options Defines the options we want to customize the helper
  139460. * @param scene The scene to add the material to
  139461. */
  139462. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  139463. /**
  139464. * Updates the background according to the new options
  139465. * @param options
  139466. */
  139467. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  139468. /**
  139469. * Sets the primary color of all the available elements.
  139470. * @param color the main color to affect to the ground and the background
  139471. */
  139472. setMainColor(color: Color3): void;
  139473. /**
  139474. * Setup the image processing according to the specified options.
  139475. */
  139476. private _setupImageProcessing;
  139477. /**
  139478. * Setup the environment texture according to the specified options.
  139479. */
  139480. private _setupEnvironmentTexture;
  139481. /**
  139482. * Setup the background according to the specified options.
  139483. */
  139484. private _setupBackground;
  139485. /**
  139486. * Get the scene sizes according to the setup.
  139487. */
  139488. private _getSceneSize;
  139489. /**
  139490. * Setup the ground according to the specified options.
  139491. */
  139492. private _setupGround;
  139493. /**
  139494. * Setup the ground material according to the specified options.
  139495. */
  139496. private _setupGroundMaterial;
  139497. /**
  139498. * Setup the ground diffuse texture according to the specified options.
  139499. */
  139500. private _setupGroundDiffuseTexture;
  139501. /**
  139502. * Setup the ground mirror texture according to the specified options.
  139503. */
  139504. private _setupGroundMirrorTexture;
  139505. /**
  139506. * Setup the ground to receive the mirror texture.
  139507. */
  139508. private _setupMirrorInGroundMaterial;
  139509. /**
  139510. * Setup the skybox according to the specified options.
  139511. */
  139512. private _setupSkybox;
  139513. /**
  139514. * Setup the skybox material according to the specified options.
  139515. */
  139516. private _setupSkyboxMaterial;
  139517. /**
  139518. * Setup the skybox reflection texture according to the specified options.
  139519. */
  139520. private _setupSkyboxReflectionTexture;
  139521. private _errorHandler;
  139522. /**
  139523. * Dispose all the elements created by the Helper.
  139524. */
  139525. dispose(): void;
  139526. }
  139527. }
  139528. declare module BABYLON {
  139529. /**
  139530. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  139531. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  139532. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  139533. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139534. */
  139535. export abstract class TextureDome<T extends Texture> extends TransformNode {
  139536. protected onError: Nullable<(message?: string, exception?: any) => void>;
  139537. /**
  139538. * Define the source as a Monoscopic panoramic 360/180.
  139539. */
  139540. static readonly MODE_MONOSCOPIC: number;
  139541. /**
  139542. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  139543. */
  139544. static readonly MODE_TOPBOTTOM: number;
  139545. /**
  139546. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  139547. */
  139548. static readonly MODE_SIDEBYSIDE: number;
  139549. private _halfDome;
  139550. private _crossEye;
  139551. protected _useDirectMapping: boolean;
  139552. /**
  139553. * The texture being displayed on the sphere
  139554. */
  139555. protected _texture: T;
  139556. /**
  139557. * Gets the texture being displayed on the sphere
  139558. */
  139559. get texture(): T;
  139560. /**
  139561. * Sets the texture being displayed on the sphere
  139562. */
  139563. set texture(newTexture: T);
  139564. /**
  139565. * The skybox material
  139566. */
  139567. protected _material: BackgroundMaterial;
  139568. /**
  139569. * The surface used for the dome
  139570. */
  139571. protected _mesh: Mesh;
  139572. /**
  139573. * Gets the mesh used for the dome.
  139574. */
  139575. get mesh(): Mesh;
  139576. /**
  139577. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  139578. */
  139579. private _halfDomeMask;
  139580. /**
  139581. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  139582. * Also see the options.resolution property.
  139583. */
  139584. get fovMultiplier(): number;
  139585. set fovMultiplier(value: number);
  139586. protected _textureMode: number;
  139587. /**
  139588. * Gets or set the current texture mode for the texture. It can be:
  139589. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139590. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139591. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139592. */
  139593. get textureMode(): number;
  139594. /**
  139595. * Sets the current texture mode for the texture. It can be:
  139596. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139597. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139598. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139599. */
  139600. set textureMode(value: number);
  139601. /**
  139602. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  139603. */
  139604. get halfDome(): boolean;
  139605. /**
  139606. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  139607. */
  139608. set halfDome(enabled: boolean);
  139609. /**
  139610. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  139611. */
  139612. set crossEye(enabled: boolean);
  139613. /**
  139614. * Is it a cross-eye texture?
  139615. */
  139616. get crossEye(): boolean;
  139617. /**
  139618. * The background material of this dome.
  139619. */
  139620. get material(): BackgroundMaterial;
  139621. /**
  139622. * Oberserver used in Stereoscopic VR Mode.
  139623. */
  139624. private _onBeforeCameraRenderObserver;
  139625. /**
  139626. * Observable raised when an error occured while loading the 360 image
  139627. */
  139628. onLoadErrorObservable: Observable<string>;
  139629. /**
  139630. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  139631. * @param name Element's name, child elements will append suffixes for their own names.
  139632. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  139633. * @param options An object containing optional or exposed sub element properties
  139634. */
  139635. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  139636. resolution?: number;
  139637. clickToPlay?: boolean;
  139638. autoPlay?: boolean;
  139639. loop?: boolean;
  139640. size?: number;
  139641. poster?: string;
  139642. faceForward?: boolean;
  139643. useDirectMapping?: boolean;
  139644. halfDomeMode?: boolean;
  139645. crossEyeMode?: boolean;
  139646. generateMipMaps?: boolean;
  139647. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  139648. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  139649. protected _changeTextureMode(value: number): void;
  139650. /**
  139651. * Releases resources associated with this node.
  139652. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  139653. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  139654. */
  139655. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  139656. }
  139657. }
  139658. declare module BABYLON {
  139659. /**
  139660. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  139661. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  139662. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  139663. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  139664. */
  139665. export class PhotoDome extends TextureDome<Texture> {
  139666. /**
  139667. * Define the image as a Monoscopic panoramic 360 image.
  139668. */
  139669. static readonly MODE_MONOSCOPIC: number;
  139670. /**
  139671. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  139672. */
  139673. static readonly MODE_TOPBOTTOM: number;
  139674. /**
  139675. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  139676. */
  139677. static readonly MODE_SIDEBYSIDE: number;
  139678. /**
  139679. * Gets or sets the texture being displayed on the sphere
  139680. */
  139681. get photoTexture(): Texture;
  139682. /**
  139683. * sets the texture being displayed on the sphere
  139684. */
  139685. set photoTexture(value: Texture);
  139686. /**
  139687. * Gets the current video mode for the video. It can be:
  139688. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139689. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139690. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139691. */
  139692. get imageMode(): number;
  139693. /**
  139694. * Sets the current video mode for the video. It can be:
  139695. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  139696. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  139697. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  139698. */
  139699. set imageMode(value: number);
  139700. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  139701. }
  139702. }
  139703. declare module BABYLON {
  139704. /**
  139705. * Direct draw surface info
  139706. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  139707. */
  139708. export interface DDSInfo {
  139709. /**
  139710. * Width of the texture
  139711. */
  139712. width: number;
  139713. /**
  139714. * Width of the texture
  139715. */
  139716. height: number;
  139717. /**
  139718. * Number of Mipmaps for the texture
  139719. * @see https://en.wikipedia.org/wiki/Mipmap
  139720. */
  139721. mipmapCount: number;
  139722. /**
  139723. * If the textures format is a known fourCC format
  139724. * @see https://www.fourcc.org/
  139725. */
  139726. isFourCC: boolean;
  139727. /**
  139728. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  139729. */
  139730. isRGB: boolean;
  139731. /**
  139732. * If the texture is a lumincance format
  139733. */
  139734. isLuminance: boolean;
  139735. /**
  139736. * If this is a cube texture
  139737. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  139738. */
  139739. isCube: boolean;
  139740. /**
  139741. * If the texture is a compressed format eg. FOURCC_DXT1
  139742. */
  139743. isCompressed: boolean;
  139744. /**
  139745. * The dxgiFormat of the texture
  139746. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  139747. */
  139748. dxgiFormat: number;
  139749. /**
  139750. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  139751. */
  139752. textureType: number;
  139753. /**
  139754. * Sphericle polynomial created for the dds texture
  139755. */
  139756. sphericalPolynomial?: SphericalPolynomial;
  139757. }
  139758. /**
  139759. * Class used to provide DDS decompression tools
  139760. */
  139761. export class DDSTools {
  139762. /**
  139763. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  139764. */
  139765. static StoreLODInAlphaChannel: boolean;
  139766. /**
  139767. * Gets DDS information from an array buffer
  139768. * @param data defines the array buffer view to read data from
  139769. * @returns the DDS information
  139770. */
  139771. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  139772. private static _FloatView;
  139773. private static _Int32View;
  139774. private static _ToHalfFloat;
  139775. private static _FromHalfFloat;
  139776. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  139777. private static _GetHalfFloatRGBAArrayBuffer;
  139778. private static _GetFloatRGBAArrayBuffer;
  139779. private static _GetFloatAsUIntRGBAArrayBuffer;
  139780. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  139781. private static _GetRGBAArrayBuffer;
  139782. private static _ExtractLongWordOrder;
  139783. private static _GetRGBArrayBuffer;
  139784. private static _GetLuminanceArrayBuffer;
  139785. /**
  139786. * Uploads DDS Levels to a Babylon Texture
  139787. * @hidden
  139788. */
  139789. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  139790. }
  139791. interface ThinEngine {
  139792. /**
  139793. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  139794. * @param rootUrl defines the url where the file to load is located
  139795. * @param scene defines the current scene
  139796. * @param lodScale defines scale to apply to the mip map selection
  139797. * @param lodOffset defines offset to apply to the mip map selection
  139798. * @param onLoad defines an optional callback raised when the texture is loaded
  139799. * @param onError defines an optional callback raised if there is an issue to load the texture
  139800. * @param format defines the format of the data
  139801. * @param forcedExtension defines the extension to use to pick the right loader
  139802. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  139803. * @returns the cube texture as an InternalTexture
  139804. */
  139805. 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;
  139806. }
  139807. }
  139808. declare module BABYLON {
  139809. /**
  139810. * Implementation of the DDS Texture Loader.
  139811. * @hidden
  139812. */
  139813. export class _DDSTextureLoader implements IInternalTextureLoader {
  139814. /**
  139815. * Defines wether the loader supports cascade loading the different faces.
  139816. */
  139817. readonly supportCascades: boolean;
  139818. /**
  139819. * This returns if the loader support the current file information.
  139820. * @param extension defines the file extension of the file being loaded
  139821. * @returns true if the loader can load the specified file
  139822. */
  139823. canLoad(extension: string): boolean;
  139824. /**
  139825. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139826. * @param data contains the texture data
  139827. * @param texture defines the BabylonJS internal texture
  139828. * @param createPolynomials will be true if polynomials have been requested
  139829. * @param onLoad defines the callback to trigger once the texture is ready
  139830. * @param onError defines the callback to trigger in case of error
  139831. */
  139832. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139833. /**
  139834. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139835. * @param data contains the texture data
  139836. * @param texture defines the BabylonJS internal texture
  139837. * @param callback defines the method to call once ready to upload
  139838. */
  139839. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139840. }
  139841. }
  139842. declare module BABYLON {
  139843. /**
  139844. * Implementation of the ENV Texture Loader.
  139845. * @hidden
  139846. */
  139847. export class _ENVTextureLoader implements IInternalTextureLoader {
  139848. /**
  139849. * Defines wether the loader supports cascade loading the different faces.
  139850. */
  139851. readonly supportCascades: boolean;
  139852. /**
  139853. * This returns if the loader support the current file information.
  139854. * @param extension defines the file extension of the file being loaded
  139855. * @returns true if the loader can load the specified file
  139856. */
  139857. canLoad(extension: string): boolean;
  139858. /**
  139859. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139860. * @param data contains the texture data
  139861. * @param texture defines the BabylonJS internal texture
  139862. * @param createPolynomials will be true if polynomials have been requested
  139863. * @param onLoad defines the callback to trigger once the texture is ready
  139864. * @param onError defines the callback to trigger in case of error
  139865. */
  139866. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139867. /**
  139868. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139869. * @param data contains the texture data
  139870. * @param texture defines the BabylonJS internal texture
  139871. * @param callback defines the method to call once ready to upload
  139872. */
  139873. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139874. }
  139875. }
  139876. declare module BABYLON {
  139877. /**
  139878. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  139879. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  139880. */
  139881. export class KhronosTextureContainer {
  139882. /** contents of the KTX container file */
  139883. data: ArrayBufferView;
  139884. private static HEADER_LEN;
  139885. private static COMPRESSED_2D;
  139886. private static COMPRESSED_3D;
  139887. private static TEX_2D;
  139888. private static TEX_3D;
  139889. /**
  139890. * Gets the openGL type
  139891. */
  139892. glType: number;
  139893. /**
  139894. * Gets the openGL type size
  139895. */
  139896. glTypeSize: number;
  139897. /**
  139898. * Gets the openGL format
  139899. */
  139900. glFormat: number;
  139901. /**
  139902. * Gets the openGL internal format
  139903. */
  139904. glInternalFormat: number;
  139905. /**
  139906. * Gets the base internal format
  139907. */
  139908. glBaseInternalFormat: number;
  139909. /**
  139910. * Gets image width in pixel
  139911. */
  139912. pixelWidth: number;
  139913. /**
  139914. * Gets image height in pixel
  139915. */
  139916. pixelHeight: number;
  139917. /**
  139918. * Gets image depth in pixels
  139919. */
  139920. pixelDepth: number;
  139921. /**
  139922. * Gets the number of array elements
  139923. */
  139924. numberOfArrayElements: number;
  139925. /**
  139926. * Gets the number of faces
  139927. */
  139928. numberOfFaces: number;
  139929. /**
  139930. * Gets the number of mipmap levels
  139931. */
  139932. numberOfMipmapLevels: number;
  139933. /**
  139934. * Gets the bytes of key value data
  139935. */
  139936. bytesOfKeyValueData: number;
  139937. /**
  139938. * Gets the load type
  139939. */
  139940. loadType: number;
  139941. /**
  139942. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  139943. */
  139944. isInvalid: boolean;
  139945. /**
  139946. * Creates a new KhronosTextureContainer
  139947. * @param data contents of the KTX container file
  139948. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  139949. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  139950. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  139951. */
  139952. constructor(
  139953. /** contents of the KTX container file */
  139954. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  139955. /**
  139956. * Uploads KTX content to a Babylon Texture.
  139957. * It is assumed that the texture has already been created & is currently bound
  139958. * @hidden
  139959. */
  139960. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  139961. private _upload2DCompressedLevels;
  139962. /**
  139963. * Checks if the given data starts with a KTX file identifier.
  139964. * @param data the data to check
  139965. * @returns true if the data is a KTX file or false otherwise
  139966. */
  139967. static IsValid(data: ArrayBufferView): boolean;
  139968. }
  139969. }
  139970. declare module BABYLON {
  139971. /**
  139972. * Helper class to push actions to a pool of workers.
  139973. */
  139974. export class WorkerPool implements IDisposable {
  139975. private _workerInfos;
  139976. private _pendingActions;
  139977. /**
  139978. * Constructor
  139979. * @param workers Array of workers to use for actions
  139980. */
  139981. constructor(workers: Array<Worker>);
  139982. /**
  139983. * Terminates all workers and clears any pending actions.
  139984. */
  139985. dispose(): void;
  139986. /**
  139987. * Pushes an action to the worker pool. If all the workers are active, the action will be
  139988. * pended until a worker has completed its action.
  139989. * @param action The action to perform. Call onComplete when the action is complete.
  139990. */
  139991. push(action: (worker: Worker, onComplete: () => void) => void): void;
  139992. private _execute;
  139993. }
  139994. }
  139995. declare module BABYLON {
  139996. /**
  139997. * Class for loading KTX2 files
  139998. */
  139999. export class KhronosTextureContainer2 {
  140000. private static _WorkerPoolPromise?;
  140001. private static _Initialized;
  140002. private static _Ktx2Decoder;
  140003. /**
  140004. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  140005. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  140006. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  140007. * Urls you can change:
  140008. * URLConfig.jsDecoderModule
  140009. * URLConfig.wasmUASTCToASTC
  140010. * URLConfig.wasmUASTCToBC7
  140011. * URLConfig.jsMSCTranscoder
  140012. * URLConfig.wasmMSCTranscoder
  140013. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  140014. */
  140015. static URLConfig: {
  140016. jsDecoderModule: string;
  140017. wasmUASTCToASTC: null;
  140018. wasmUASTCToBC7: null;
  140019. jsMSCTranscoder: null;
  140020. wasmMSCTranscoder: null;
  140021. };
  140022. /**
  140023. * Default number of workers used to handle data decoding
  140024. */
  140025. static DefaultNumWorkers: number;
  140026. private static GetDefaultNumWorkers;
  140027. private _engine;
  140028. private static _CreateWorkerPool;
  140029. /**
  140030. * Constructor
  140031. * @param engine The engine to use
  140032. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  140033. */
  140034. constructor(engine: ThinEngine, numWorkers?: number);
  140035. /** @hidden */
  140036. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture, options?: any): Promise<void>;
  140037. /**
  140038. * Stop all async operations and release resources.
  140039. */
  140040. dispose(): void;
  140041. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  140042. /**
  140043. * Checks if the given data starts with a KTX2 file identifier.
  140044. * @param data the data to check
  140045. * @returns true if the data is a KTX2 file or false otherwise
  140046. */
  140047. static IsValid(data: ArrayBufferView): boolean;
  140048. }
  140049. }
  140050. declare module BABYLON {
  140051. /**
  140052. * Implementation of the KTX Texture Loader.
  140053. * @hidden
  140054. */
  140055. export class _KTXTextureLoader implements IInternalTextureLoader {
  140056. /**
  140057. * Defines wether the loader supports cascade loading the different faces.
  140058. */
  140059. readonly supportCascades: boolean;
  140060. /**
  140061. * This returns if the loader support the current file information.
  140062. * @param extension defines the file extension of the file being loaded
  140063. * @param mimeType defines the optional mime type of the file being loaded
  140064. * @returns true if the loader can load the specified file
  140065. */
  140066. canLoad(extension: string, mimeType?: string): boolean;
  140067. /**
  140068. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  140069. * @param data contains the texture data
  140070. * @param texture defines the BabylonJS internal texture
  140071. * @param createPolynomials will be true if polynomials have been requested
  140072. * @param onLoad defines the callback to trigger once the texture is ready
  140073. * @param onError defines the callback to trigger in case of error
  140074. */
  140075. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  140076. /**
  140077. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  140078. * @param data contains the texture data
  140079. * @param texture defines the BabylonJS internal texture
  140080. * @param callback defines the method to call once ready to upload
  140081. */
  140082. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void, options?: any): void;
  140083. }
  140084. }
  140085. declare module BABYLON {
  140086. /** @hidden */
  140087. export var _forceSceneHelpersToBundle: boolean;
  140088. interface Scene {
  140089. /**
  140090. * Creates a default light for the scene.
  140091. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  140092. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  140093. */
  140094. createDefaultLight(replace?: boolean): void;
  140095. /**
  140096. * Creates a default camera for the scene.
  140097. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  140098. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  140099. * @param replace has default false, when true replaces the active camera in the scene
  140100. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  140101. */
  140102. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  140103. /**
  140104. * Creates a default camera and a default light.
  140105. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  140106. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  140107. * @param replace has the default false, when true replaces the active camera/light in the scene
  140108. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  140109. */
  140110. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  140111. /**
  140112. * Creates a new sky box
  140113. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  140114. * @param environmentTexture defines the texture to use as environment texture
  140115. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  140116. * @param scale defines the overall scale of the skybox
  140117. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  140118. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  140119. * @returns a new mesh holding the sky box
  140120. */
  140121. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  140122. /**
  140123. * Creates a new environment
  140124. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  140125. * @param options defines the options you can use to configure the environment
  140126. * @returns the new EnvironmentHelper
  140127. */
  140128. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  140129. /**
  140130. * Creates a new VREXperienceHelper
  140131. * @see https://doc.babylonjs.com/how_to/webvr_helper
  140132. * @param webVROptions defines the options used to create the new VREXperienceHelper
  140133. * @returns a new VREXperienceHelper
  140134. */
  140135. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  140136. /**
  140137. * Creates a new WebXRDefaultExperience
  140138. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  140139. * @param options experience options
  140140. * @returns a promise for a new WebXRDefaultExperience
  140141. */
  140142. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  140143. }
  140144. }
  140145. declare module BABYLON {
  140146. /**
  140147. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  140148. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  140149. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  140150. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  140151. */
  140152. export class VideoDome extends TextureDome<VideoTexture> {
  140153. /**
  140154. * Define the video source as a Monoscopic panoramic 360 video.
  140155. */
  140156. static readonly MODE_MONOSCOPIC: number;
  140157. /**
  140158. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  140159. */
  140160. static readonly MODE_TOPBOTTOM: number;
  140161. /**
  140162. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  140163. */
  140164. static readonly MODE_SIDEBYSIDE: number;
  140165. /**
  140166. * Get the video texture associated with this video dome
  140167. */
  140168. get videoTexture(): VideoTexture;
  140169. /**
  140170. * Get the video mode of this dome
  140171. */
  140172. get videoMode(): number;
  140173. /**
  140174. * Set the video mode of this dome.
  140175. * @see textureMode
  140176. */
  140177. set videoMode(value: number);
  140178. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  140179. }
  140180. }
  140181. declare module BABYLON {
  140182. /**
  140183. * This class can be used to get instrumentation data from a Babylon engine
  140184. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  140185. */
  140186. export class EngineInstrumentation implements IDisposable {
  140187. /**
  140188. * Define the instrumented engine.
  140189. */
  140190. engine: Engine;
  140191. private _captureGPUFrameTime;
  140192. private _gpuFrameTimeToken;
  140193. private _gpuFrameTime;
  140194. private _captureShaderCompilationTime;
  140195. private _shaderCompilationTime;
  140196. private _onBeginFrameObserver;
  140197. private _onEndFrameObserver;
  140198. private _onBeforeShaderCompilationObserver;
  140199. private _onAfterShaderCompilationObserver;
  140200. /**
  140201. * Gets the perf counter used for GPU frame time
  140202. */
  140203. get gpuFrameTimeCounter(): PerfCounter;
  140204. /**
  140205. * Gets the GPU frame time capture status
  140206. */
  140207. get captureGPUFrameTime(): boolean;
  140208. /**
  140209. * Enable or disable the GPU frame time capture
  140210. */
  140211. set captureGPUFrameTime(value: boolean);
  140212. /**
  140213. * Gets the perf counter used for shader compilation time
  140214. */
  140215. get shaderCompilationTimeCounter(): PerfCounter;
  140216. /**
  140217. * Gets the shader compilation time capture status
  140218. */
  140219. get captureShaderCompilationTime(): boolean;
  140220. /**
  140221. * Enable or disable the shader compilation time capture
  140222. */
  140223. set captureShaderCompilationTime(value: boolean);
  140224. /**
  140225. * Instantiates a new engine instrumentation.
  140226. * This class can be used to get instrumentation data from a Babylon engine
  140227. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  140228. * @param engine Defines the engine to instrument
  140229. */
  140230. constructor(
  140231. /**
  140232. * Define the instrumented engine.
  140233. */
  140234. engine: Engine);
  140235. /**
  140236. * Dispose and release associated resources.
  140237. */
  140238. dispose(): void;
  140239. }
  140240. }
  140241. declare module BABYLON {
  140242. /**
  140243. * This class can be used to get instrumentation data from a Babylon engine
  140244. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  140245. */
  140246. export class SceneInstrumentation implements IDisposable {
  140247. /**
  140248. * Defines the scene to instrument
  140249. */
  140250. scene: Scene;
  140251. private _captureActiveMeshesEvaluationTime;
  140252. private _activeMeshesEvaluationTime;
  140253. private _captureRenderTargetsRenderTime;
  140254. private _renderTargetsRenderTime;
  140255. private _captureFrameTime;
  140256. private _frameTime;
  140257. private _captureRenderTime;
  140258. private _renderTime;
  140259. private _captureInterFrameTime;
  140260. private _interFrameTime;
  140261. private _captureParticlesRenderTime;
  140262. private _particlesRenderTime;
  140263. private _captureSpritesRenderTime;
  140264. private _spritesRenderTime;
  140265. private _capturePhysicsTime;
  140266. private _physicsTime;
  140267. private _captureAnimationsTime;
  140268. private _animationsTime;
  140269. private _captureCameraRenderTime;
  140270. private _cameraRenderTime;
  140271. private _onBeforeActiveMeshesEvaluationObserver;
  140272. private _onAfterActiveMeshesEvaluationObserver;
  140273. private _onBeforeRenderTargetsRenderObserver;
  140274. private _onAfterRenderTargetsRenderObserver;
  140275. private _onAfterRenderObserver;
  140276. private _onBeforeDrawPhaseObserver;
  140277. private _onAfterDrawPhaseObserver;
  140278. private _onBeforeAnimationsObserver;
  140279. private _onBeforeParticlesRenderingObserver;
  140280. private _onAfterParticlesRenderingObserver;
  140281. private _onBeforeSpritesRenderingObserver;
  140282. private _onAfterSpritesRenderingObserver;
  140283. private _onBeforePhysicsObserver;
  140284. private _onAfterPhysicsObserver;
  140285. private _onAfterAnimationsObserver;
  140286. private _onBeforeCameraRenderObserver;
  140287. private _onAfterCameraRenderObserver;
  140288. /**
  140289. * Gets the perf counter used for active meshes evaluation time
  140290. */
  140291. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  140292. /**
  140293. * Gets the active meshes evaluation time capture status
  140294. */
  140295. get captureActiveMeshesEvaluationTime(): boolean;
  140296. /**
  140297. * Enable or disable the active meshes evaluation time capture
  140298. */
  140299. set captureActiveMeshesEvaluationTime(value: boolean);
  140300. /**
  140301. * Gets the perf counter used for render targets render time
  140302. */
  140303. get renderTargetsRenderTimeCounter(): PerfCounter;
  140304. /**
  140305. * Gets the render targets render time capture status
  140306. */
  140307. get captureRenderTargetsRenderTime(): boolean;
  140308. /**
  140309. * Enable or disable the render targets render time capture
  140310. */
  140311. set captureRenderTargetsRenderTime(value: boolean);
  140312. /**
  140313. * Gets the perf counter used for particles render time
  140314. */
  140315. get particlesRenderTimeCounter(): PerfCounter;
  140316. /**
  140317. * Gets the particles render time capture status
  140318. */
  140319. get captureParticlesRenderTime(): boolean;
  140320. /**
  140321. * Enable or disable the particles render time capture
  140322. */
  140323. set captureParticlesRenderTime(value: boolean);
  140324. /**
  140325. * Gets the perf counter used for sprites render time
  140326. */
  140327. get spritesRenderTimeCounter(): PerfCounter;
  140328. /**
  140329. * Gets the sprites render time capture status
  140330. */
  140331. get captureSpritesRenderTime(): boolean;
  140332. /**
  140333. * Enable or disable the sprites render time capture
  140334. */
  140335. set captureSpritesRenderTime(value: boolean);
  140336. /**
  140337. * Gets the perf counter used for physics time
  140338. */
  140339. get physicsTimeCounter(): PerfCounter;
  140340. /**
  140341. * Gets the physics time capture status
  140342. */
  140343. get capturePhysicsTime(): boolean;
  140344. /**
  140345. * Enable or disable the physics time capture
  140346. */
  140347. set capturePhysicsTime(value: boolean);
  140348. /**
  140349. * Gets the perf counter used for animations time
  140350. */
  140351. get animationsTimeCounter(): PerfCounter;
  140352. /**
  140353. * Gets the animations time capture status
  140354. */
  140355. get captureAnimationsTime(): boolean;
  140356. /**
  140357. * Enable or disable the animations time capture
  140358. */
  140359. set captureAnimationsTime(value: boolean);
  140360. /**
  140361. * Gets the perf counter used for frame time capture
  140362. */
  140363. get frameTimeCounter(): PerfCounter;
  140364. /**
  140365. * Gets the frame time capture status
  140366. */
  140367. get captureFrameTime(): boolean;
  140368. /**
  140369. * Enable or disable the frame time capture
  140370. */
  140371. set captureFrameTime(value: boolean);
  140372. /**
  140373. * Gets the perf counter used for inter-frames time capture
  140374. */
  140375. get interFrameTimeCounter(): PerfCounter;
  140376. /**
  140377. * Gets the inter-frames time capture status
  140378. */
  140379. get captureInterFrameTime(): boolean;
  140380. /**
  140381. * Enable or disable the inter-frames time capture
  140382. */
  140383. set captureInterFrameTime(value: boolean);
  140384. /**
  140385. * Gets the perf counter used for render time capture
  140386. */
  140387. get renderTimeCounter(): PerfCounter;
  140388. /**
  140389. * Gets the render time capture status
  140390. */
  140391. get captureRenderTime(): boolean;
  140392. /**
  140393. * Enable or disable the render time capture
  140394. */
  140395. set captureRenderTime(value: boolean);
  140396. /**
  140397. * Gets the perf counter used for camera render time capture
  140398. */
  140399. get cameraRenderTimeCounter(): PerfCounter;
  140400. /**
  140401. * Gets the camera render time capture status
  140402. */
  140403. get captureCameraRenderTime(): boolean;
  140404. /**
  140405. * Enable or disable the camera render time capture
  140406. */
  140407. set captureCameraRenderTime(value: boolean);
  140408. /**
  140409. * Gets the perf counter used for draw calls
  140410. */
  140411. get drawCallsCounter(): PerfCounter;
  140412. /**
  140413. * Instantiates a new scene instrumentation.
  140414. * This class can be used to get instrumentation data from a Babylon engine
  140415. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  140416. * @param scene Defines the scene to instrument
  140417. */
  140418. constructor(
  140419. /**
  140420. * Defines the scene to instrument
  140421. */
  140422. scene: Scene);
  140423. /**
  140424. * Dispose and release associated resources.
  140425. */
  140426. dispose(): void;
  140427. }
  140428. }
  140429. declare module BABYLON {
  140430. /** @hidden */
  140431. export var glowMapGenerationPixelShader: {
  140432. name: string;
  140433. shader: string;
  140434. };
  140435. }
  140436. declare module BABYLON {
  140437. /** @hidden */
  140438. export var glowMapGenerationVertexShader: {
  140439. name: string;
  140440. shader: string;
  140441. };
  140442. }
  140443. declare module BABYLON {
  140444. /**
  140445. * Effect layer options. This helps customizing the behaviour
  140446. * of the effect layer.
  140447. */
  140448. export interface IEffectLayerOptions {
  140449. /**
  140450. * Multiplication factor apply to the canvas size to compute the render target size
  140451. * used to generated the objects (the smaller the faster).
  140452. */
  140453. mainTextureRatio: number;
  140454. /**
  140455. * Enforces a fixed size texture to ensure effect stability across devices.
  140456. */
  140457. mainTextureFixedSize?: number;
  140458. /**
  140459. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  140460. */
  140461. alphaBlendingMode: number;
  140462. /**
  140463. * The camera attached to the layer.
  140464. */
  140465. camera: Nullable<Camera>;
  140466. /**
  140467. * The rendering group to draw the layer in.
  140468. */
  140469. renderingGroupId: number;
  140470. }
  140471. /**
  140472. * The effect layer Helps adding post process effect blended with the main pass.
  140473. *
  140474. * This can be for instance use to generate glow or higlight effects on the scene.
  140475. *
  140476. * The effect layer class can not be used directly and is intented to inherited from to be
  140477. * customized per effects.
  140478. */
  140479. export abstract class EffectLayer {
  140480. private _vertexBuffers;
  140481. private _indexBuffer;
  140482. private _cachedDefines;
  140483. private _effectLayerMapGenerationEffect;
  140484. private _effectLayerOptions;
  140485. private _mergeEffect;
  140486. protected _scene: Scene;
  140487. protected _engine: Engine;
  140488. protected _maxSize: number;
  140489. protected _mainTextureDesiredSize: ISize;
  140490. protected _mainTexture: RenderTargetTexture;
  140491. protected _shouldRender: boolean;
  140492. protected _postProcesses: PostProcess[];
  140493. protected _textures: BaseTexture[];
  140494. protected _emissiveTextureAndColor: {
  140495. texture: Nullable<BaseTexture>;
  140496. color: Color4;
  140497. };
  140498. /**
  140499. * The name of the layer
  140500. */
  140501. name: string;
  140502. /**
  140503. * The clear color of the texture used to generate the glow map.
  140504. */
  140505. neutralColor: Color4;
  140506. /**
  140507. * Specifies whether the highlight layer is enabled or not.
  140508. */
  140509. isEnabled: boolean;
  140510. /**
  140511. * Gets the camera attached to the layer.
  140512. */
  140513. get camera(): Nullable<Camera>;
  140514. /**
  140515. * Gets the rendering group id the layer should render in.
  140516. */
  140517. get renderingGroupId(): number;
  140518. set renderingGroupId(renderingGroupId: number);
  140519. /**
  140520. * Specifies if the bounding boxes should be rendered normally or if they should undergo the effect of the layer
  140521. */
  140522. disableBoundingBoxesFromEffectLayer: boolean;
  140523. /**
  140524. * An event triggered when the effect layer has been disposed.
  140525. */
  140526. onDisposeObservable: Observable<EffectLayer>;
  140527. /**
  140528. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  140529. */
  140530. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  140531. /**
  140532. * An event triggered when the generated texture is being merged in the scene.
  140533. */
  140534. onBeforeComposeObservable: Observable<EffectLayer>;
  140535. /**
  140536. * An event triggered when the mesh is rendered into the effect render target.
  140537. */
  140538. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  140539. /**
  140540. * An event triggered after the mesh has been rendered into the effect render target.
  140541. */
  140542. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  140543. /**
  140544. * An event triggered when the generated texture has been merged in the scene.
  140545. */
  140546. onAfterComposeObservable: Observable<EffectLayer>;
  140547. /**
  140548. * An event triggered when the efffect layer changes its size.
  140549. */
  140550. onSizeChangedObservable: Observable<EffectLayer>;
  140551. /** @hidden */
  140552. static _SceneComponentInitialization: (scene: Scene) => void;
  140553. /**
  140554. * Instantiates a new effect Layer and references it in the scene.
  140555. * @param name The name of the layer
  140556. * @param scene The scene to use the layer in
  140557. */
  140558. constructor(
  140559. /** The Friendly of the effect in the scene */
  140560. name: string, scene: Scene);
  140561. /**
  140562. * Get the effect name of the layer.
  140563. * @return The effect name
  140564. */
  140565. abstract getEffectName(): string;
  140566. /**
  140567. * Checks for the readiness of the element composing the layer.
  140568. * @param subMesh the mesh to check for
  140569. * @param useInstances specify whether or not to use instances to render the mesh
  140570. * @return true if ready otherwise, false
  140571. */
  140572. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140573. /**
  140574. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  140575. * @returns true if the effect requires stencil during the main canvas render pass.
  140576. */
  140577. abstract needStencil(): boolean;
  140578. /**
  140579. * Create the merge effect. This is the shader use to blit the information back
  140580. * to the main canvas at the end of the scene rendering.
  140581. * @returns The effect containing the shader used to merge the effect on the main canvas
  140582. */
  140583. protected abstract _createMergeEffect(): Effect;
  140584. /**
  140585. * Creates the render target textures and post processes used in the effect layer.
  140586. */
  140587. protected abstract _createTextureAndPostProcesses(): void;
  140588. /**
  140589. * Implementation specific of rendering the generating effect on the main canvas.
  140590. * @param effect The effect used to render through
  140591. */
  140592. protected abstract _internalRender(effect: Effect): void;
  140593. /**
  140594. * Sets the required values for both the emissive texture and and the main color.
  140595. */
  140596. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140597. /**
  140598. * Free any resources and references associated to a mesh.
  140599. * Internal use
  140600. * @param mesh The mesh to free.
  140601. */
  140602. abstract _disposeMesh(mesh: Mesh): void;
  140603. /**
  140604. * Serializes this layer (Glow or Highlight for example)
  140605. * @returns a serialized layer object
  140606. */
  140607. abstract serialize?(): any;
  140608. /**
  140609. * Initializes the effect layer with the required options.
  140610. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  140611. */
  140612. protected _init(options: Partial<IEffectLayerOptions>): void;
  140613. /**
  140614. * Generates the index buffer of the full screen quad blending to the main canvas.
  140615. */
  140616. private _generateIndexBuffer;
  140617. /**
  140618. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  140619. */
  140620. private _generateVertexBuffer;
  140621. /**
  140622. * Sets the main texture desired size which is the closest power of two
  140623. * of the engine canvas size.
  140624. */
  140625. private _setMainTextureSize;
  140626. /**
  140627. * Creates the main texture for the effect layer.
  140628. */
  140629. protected _createMainTexture(): void;
  140630. /**
  140631. * Adds specific effects defines.
  140632. * @param defines The defines to add specifics to.
  140633. */
  140634. protected _addCustomEffectDefines(defines: string[]): void;
  140635. /**
  140636. * Checks for the readiness of the element composing the layer.
  140637. * @param subMesh the mesh to check for
  140638. * @param useInstances specify whether or not to use instances to render the mesh
  140639. * @param emissiveTexture the associated emissive texture used to generate the glow
  140640. * @return true if ready otherwise, false
  140641. */
  140642. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  140643. /**
  140644. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  140645. */
  140646. render(): void;
  140647. /**
  140648. * Determine if a given mesh will be used in the current effect.
  140649. * @param mesh mesh to test
  140650. * @returns true if the mesh will be used
  140651. */
  140652. hasMesh(mesh: AbstractMesh): boolean;
  140653. /**
  140654. * Returns true if the layer contains information to display, otherwise false.
  140655. * @returns true if the glow layer should be rendered
  140656. */
  140657. shouldRender(): boolean;
  140658. /**
  140659. * Returns true if the mesh should render, otherwise false.
  140660. * @param mesh The mesh to render
  140661. * @returns true if it should render otherwise false
  140662. */
  140663. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  140664. /**
  140665. * Returns true if the mesh can be rendered, otherwise false.
  140666. * @param mesh The mesh to render
  140667. * @param material The material used on the mesh
  140668. * @returns true if it can be rendered otherwise false
  140669. */
  140670. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140671. /**
  140672. * Returns true if the mesh should render, otherwise false.
  140673. * @param mesh The mesh to render
  140674. * @returns true if it should render otherwise false
  140675. */
  140676. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  140677. /**
  140678. * Renders the submesh passed in parameter to the generation map.
  140679. */
  140680. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  140681. /**
  140682. * Defines whether the current material of the mesh should be use to render the effect.
  140683. * @param mesh defines the current mesh to render
  140684. */
  140685. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140686. /**
  140687. * Rebuild the required buffers.
  140688. * @hidden Internal use only.
  140689. */
  140690. _rebuild(): void;
  140691. /**
  140692. * Dispose only the render target textures and post process.
  140693. */
  140694. private _disposeTextureAndPostProcesses;
  140695. /**
  140696. * Dispose the highlight layer and free resources.
  140697. */
  140698. dispose(): void;
  140699. /**
  140700. * Gets the class name of the effect layer
  140701. * @returns the string with the class name of the effect layer
  140702. */
  140703. getClassName(): string;
  140704. /**
  140705. * Creates an effect layer from parsed effect layer data
  140706. * @param parsedEffectLayer defines effect layer data
  140707. * @param scene defines the current scene
  140708. * @param rootUrl defines the root URL containing the effect layer information
  140709. * @returns a parsed effect Layer
  140710. */
  140711. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  140712. }
  140713. }
  140714. declare module BABYLON {
  140715. interface AbstractScene {
  140716. /**
  140717. * The list of effect layers (highlights/glow) added to the scene
  140718. * @see https://doc.babylonjs.com/how_to/highlight_layer
  140719. * @see https://doc.babylonjs.com/how_to/glow_layer
  140720. */
  140721. effectLayers: Array<EffectLayer>;
  140722. /**
  140723. * Removes the given effect layer from this scene.
  140724. * @param toRemove defines the effect layer to remove
  140725. * @returns the index of the removed effect layer
  140726. */
  140727. removeEffectLayer(toRemove: EffectLayer): number;
  140728. /**
  140729. * Adds the given effect layer to this scene
  140730. * @param newEffectLayer defines the effect layer to add
  140731. */
  140732. addEffectLayer(newEffectLayer: EffectLayer): void;
  140733. }
  140734. /**
  140735. * Defines the layer scene component responsible to manage any effect layers
  140736. * in a given scene.
  140737. */
  140738. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  140739. /**
  140740. * The component name helpfull to identify the component in the list of scene components.
  140741. */
  140742. readonly name: string;
  140743. /**
  140744. * The scene the component belongs to.
  140745. */
  140746. scene: Scene;
  140747. private _engine;
  140748. private _renderEffects;
  140749. private _needStencil;
  140750. private _previousStencilState;
  140751. /**
  140752. * Creates a new instance of the component for the given scene
  140753. * @param scene Defines the scene to register the component in
  140754. */
  140755. constructor(scene: Scene);
  140756. /**
  140757. * Registers the component in a given scene
  140758. */
  140759. register(): void;
  140760. /**
  140761. * Rebuilds the elements related to this component in case of
  140762. * context lost for instance.
  140763. */
  140764. rebuild(): void;
  140765. /**
  140766. * Serializes the component data to the specified json object
  140767. * @param serializationObject The object to serialize to
  140768. */
  140769. serialize(serializationObject: any): void;
  140770. /**
  140771. * Adds all the elements from the container to the scene
  140772. * @param container the container holding the elements
  140773. */
  140774. addFromContainer(container: AbstractScene): void;
  140775. /**
  140776. * Removes all the elements in the container from the scene
  140777. * @param container contains the elements to remove
  140778. * @param dispose if the removed element should be disposed (default: false)
  140779. */
  140780. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140781. /**
  140782. * Disposes the component and the associated ressources.
  140783. */
  140784. dispose(): void;
  140785. private _isReadyForMesh;
  140786. private _renderMainTexture;
  140787. private _setStencil;
  140788. private _setStencilBack;
  140789. private _draw;
  140790. private _drawCamera;
  140791. private _drawRenderingGroup;
  140792. }
  140793. }
  140794. declare module BABYLON {
  140795. /** @hidden */
  140796. export var glowMapMergePixelShader: {
  140797. name: string;
  140798. shader: string;
  140799. };
  140800. }
  140801. declare module BABYLON {
  140802. /** @hidden */
  140803. export var glowMapMergeVertexShader: {
  140804. name: string;
  140805. shader: string;
  140806. };
  140807. }
  140808. declare module BABYLON {
  140809. interface AbstractScene {
  140810. /**
  140811. * Return a the first highlight layer of the scene with a given name.
  140812. * @param name The name of the highlight layer to look for.
  140813. * @return The highlight layer if found otherwise null.
  140814. */
  140815. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  140816. }
  140817. /**
  140818. * Glow layer options. This helps customizing the behaviour
  140819. * of the glow layer.
  140820. */
  140821. export interface IGlowLayerOptions {
  140822. /**
  140823. * Multiplication factor apply to the canvas size to compute the render target size
  140824. * used to generated the glowing objects (the smaller the faster).
  140825. */
  140826. mainTextureRatio: number;
  140827. /**
  140828. * Enforces a fixed size texture to ensure resize independant blur.
  140829. */
  140830. mainTextureFixedSize?: number;
  140831. /**
  140832. * How big is the kernel of the blur texture.
  140833. */
  140834. blurKernelSize: number;
  140835. /**
  140836. * The camera attached to the layer.
  140837. */
  140838. camera: Nullable<Camera>;
  140839. /**
  140840. * Enable MSAA by chosing the number of samples.
  140841. */
  140842. mainTextureSamples?: number;
  140843. /**
  140844. * The rendering group to draw the layer in.
  140845. */
  140846. renderingGroupId: number;
  140847. }
  140848. /**
  140849. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  140850. *
  140851. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  140852. *
  140853. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  140854. */
  140855. export class GlowLayer extends EffectLayer {
  140856. /**
  140857. * Effect Name of the layer.
  140858. */
  140859. static readonly EffectName: string;
  140860. /**
  140861. * The default blur kernel size used for the glow.
  140862. */
  140863. static DefaultBlurKernelSize: number;
  140864. /**
  140865. * The default texture size ratio used for the glow.
  140866. */
  140867. static DefaultTextureRatio: number;
  140868. /**
  140869. * Sets the kernel size of the blur.
  140870. */
  140871. set blurKernelSize(value: number);
  140872. /**
  140873. * Gets the kernel size of the blur.
  140874. */
  140875. get blurKernelSize(): number;
  140876. /**
  140877. * Sets the glow intensity.
  140878. */
  140879. set intensity(value: number);
  140880. /**
  140881. * Gets the glow intensity.
  140882. */
  140883. get intensity(): number;
  140884. private _options;
  140885. private _intensity;
  140886. private _horizontalBlurPostprocess1;
  140887. private _verticalBlurPostprocess1;
  140888. private _horizontalBlurPostprocess2;
  140889. private _verticalBlurPostprocess2;
  140890. private _blurTexture1;
  140891. private _blurTexture2;
  140892. private _postProcesses1;
  140893. private _postProcesses2;
  140894. private _includedOnlyMeshes;
  140895. private _excludedMeshes;
  140896. private _meshesUsingTheirOwnMaterials;
  140897. /**
  140898. * Callback used to let the user override the color selection on a per mesh basis
  140899. */
  140900. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  140901. /**
  140902. * Callback used to let the user override the texture selection on a per mesh basis
  140903. */
  140904. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  140905. /**
  140906. * Instantiates a new glow Layer and references it to the scene.
  140907. * @param name The name of the layer
  140908. * @param scene The scene to use the layer in
  140909. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  140910. */
  140911. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  140912. /**
  140913. * Get the effect name of the layer.
  140914. * @return The effect name
  140915. */
  140916. getEffectName(): string;
  140917. /**
  140918. * Create the merge effect. This is the shader use to blit the information back
  140919. * to the main canvas at the end of the scene rendering.
  140920. */
  140921. protected _createMergeEffect(): Effect;
  140922. /**
  140923. * Creates the render target textures and post processes used in the glow layer.
  140924. */
  140925. protected _createTextureAndPostProcesses(): void;
  140926. /**
  140927. * Checks for the readiness of the element composing the layer.
  140928. * @param subMesh the mesh to check for
  140929. * @param useInstances specify wether or not to use instances to render the mesh
  140930. * @param emissiveTexture the associated emissive texture used to generate the glow
  140931. * @return true if ready otherwise, false
  140932. */
  140933. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140934. /**
  140935. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  140936. */
  140937. needStencil(): boolean;
  140938. /**
  140939. * Returns true if the mesh can be rendered, otherwise false.
  140940. * @param mesh The mesh to render
  140941. * @param material The material used on the mesh
  140942. * @returns true if it can be rendered otherwise false
  140943. */
  140944. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  140945. /**
  140946. * Implementation specific of rendering the generating effect on the main canvas.
  140947. * @param effect The effect used to render through
  140948. */
  140949. protected _internalRender(effect: Effect): void;
  140950. /**
  140951. * Sets the required values for both the emissive texture and and the main color.
  140952. */
  140953. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  140954. /**
  140955. * Returns true if the mesh should render, otherwise false.
  140956. * @param mesh The mesh to render
  140957. * @returns true if it should render otherwise false
  140958. */
  140959. protected _shouldRenderMesh(mesh: Mesh): boolean;
  140960. /**
  140961. * Adds specific effects defines.
  140962. * @param defines The defines to add specifics to.
  140963. */
  140964. protected _addCustomEffectDefines(defines: string[]): void;
  140965. /**
  140966. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  140967. * @param mesh The mesh to exclude from the glow layer
  140968. */
  140969. addExcludedMesh(mesh: Mesh): void;
  140970. /**
  140971. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  140972. * @param mesh The mesh to remove
  140973. */
  140974. removeExcludedMesh(mesh: Mesh): void;
  140975. /**
  140976. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  140977. * @param mesh The mesh to include in the glow layer
  140978. */
  140979. addIncludedOnlyMesh(mesh: Mesh): void;
  140980. /**
  140981. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  140982. * @param mesh The mesh to remove
  140983. */
  140984. removeIncludedOnlyMesh(mesh: Mesh): void;
  140985. /**
  140986. * Determine if a given mesh will be used in the glow layer
  140987. * @param mesh The mesh to test
  140988. * @returns true if the mesh will be highlighted by the current glow layer
  140989. */
  140990. hasMesh(mesh: AbstractMesh): boolean;
  140991. /**
  140992. * Defines whether the current material of the mesh should be use to render the effect.
  140993. * @param mesh defines the current mesh to render
  140994. */
  140995. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  140996. /**
  140997. * Add a mesh to be rendered through its own material and not with emissive only.
  140998. * @param mesh The mesh for which we need to use its material
  140999. */
  141000. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  141001. /**
  141002. * Remove a mesh from being rendered through its own material and not with emissive only.
  141003. * @param mesh The mesh for which we need to not use its material
  141004. */
  141005. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  141006. /**
  141007. * Free any resources and references associated to a mesh.
  141008. * Internal use
  141009. * @param mesh The mesh to free.
  141010. * @hidden
  141011. */
  141012. _disposeMesh(mesh: Mesh): void;
  141013. /**
  141014. * Gets the class name of the effect layer
  141015. * @returns the string with the class name of the effect layer
  141016. */
  141017. getClassName(): string;
  141018. /**
  141019. * Serializes this glow layer
  141020. * @returns a serialized glow layer object
  141021. */
  141022. serialize(): any;
  141023. /**
  141024. * Creates a Glow Layer from parsed glow layer data
  141025. * @param parsedGlowLayer defines glow layer data
  141026. * @param scene defines the current scene
  141027. * @param rootUrl defines the root URL containing the glow layer information
  141028. * @returns a parsed Glow Layer
  141029. */
  141030. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  141031. }
  141032. }
  141033. declare module BABYLON {
  141034. /** @hidden */
  141035. export var glowBlurPostProcessPixelShader: {
  141036. name: string;
  141037. shader: string;
  141038. };
  141039. }
  141040. declare module BABYLON {
  141041. interface AbstractScene {
  141042. /**
  141043. * Return a the first highlight layer of the scene with a given name.
  141044. * @param name The name of the highlight layer to look for.
  141045. * @return The highlight layer if found otherwise null.
  141046. */
  141047. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  141048. }
  141049. /**
  141050. * Highlight layer options. This helps customizing the behaviour
  141051. * of the highlight layer.
  141052. */
  141053. export interface IHighlightLayerOptions {
  141054. /**
  141055. * Multiplication factor apply to the canvas size to compute the render target size
  141056. * used to generated the glowing objects (the smaller the faster).
  141057. */
  141058. mainTextureRatio: number;
  141059. /**
  141060. * Enforces a fixed size texture to ensure resize independant blur.
  141061. */
  141062. mainTextureFixedSize?: number;
  141063. /**
  141064. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  141065. * of the picture to blur (the smaller the faster).
  141066. */
  141067. blurTextureSizeRatio: number;
  141068. /**
  141069. * How big in texel of the blur texture is the vertical blur.
  141070. */
  141071. blurVerticalSize: number;
  141072. /**
  141073. * How big in texel of the blur texture is the horizontal blur.
  141074. */
  141075. blurHorizontalSize: number;
  141076. /**
  141077. * Alpha blending mode used to apply the blur. Default is combine.
  141078. */
  141079. alphaBlendingMode: number;
  141080. /**
  141081. * The camera attached to the layer.
  141082. */
  141083. camera: Nullable<Camera>;
  141084. /**
  141085. * Should we display highlight as a solid stroke?
  141086. */
  141087. isStroke?: boolean;
  141088. /**
  141089. * The rendering group to draw the layer in.
  141090. */
  141091. renderingGroupId: number;
  141092. }
  141093. /**
  141094. * The highlight layer Helps adding a glow effect around a mesh.
  141095. *
  141096. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  141097. * glowy meshes to your scene.
  141098. *
  141099. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  141100. */
  141101. export class HighlightLayer extends EffectLayer {
  141102. name: string;
  141103. /**
  141104. * Effect Name of the highlight layer.
  141105. */
  141106. static readonly EffectName: string;
  141107. /**
  141108. * The neutral color used during the preparation of the glow effect.
  141109. * This is black by default as the blend operation is a blend operation.
  141110. */
  141111. static NeutralColor: Color4;
  141112. /**
  141113. * Stencil value used for glowing meshes.
  141114. */
  141115. static GlowingMeshStencilReference: number;
  141116. /**
  141117. * Stencil value used for the other meshes in the scene.
  141118. */
  141119. static NormalMeshStencilReference: number;
  141120. /**
  141121. * Specifies whether or not the inner glow is ACTIVE in the layer.
  141122. */
  141123. innerGlow: boolean;
  141124. /**
  141125. * Specifies whether or not the outer glow is ACTIVE in the layer.
  141126. */
  141127. outerGlow: boolean;
  141128. /**
  141129. * Specifies the horizontal size of the blur.
  141130. */
  141131. set blurHorizontalSize(value: number);
  141132. /**
  141133. * Specifies the vertical size of the blur.
  141134. */
  141135. set blurVerticalSize(value: number);
  141136. /**
  141137. * Gets the horizontal size of the blur.
  141138. */
  141139. get blurHorizontalSize(): number;
  141140. /**
  141141. * Gets the vertical size of the blur.
  141142. */
  141143. get blurVerticalSize(): number;
  141144. /**
  141145. * An event triggered when the highlight layer is being blurred.
  141146. */
  141147. onBeforeBlurObservable: Observable<HighlightLayer>;
  141148. /**
  141149. * An event triggered when the highlight layer has been blurred.
  141150. */
  141151. onAfterBlurObservable: Observable<HighlightLayer>;
  141152. private _instanceGlowingMeshStencilReference;
  141153. private _options;
  141154. private _downSamplePostprocess;
  141155. private _horizontalBlurPostprocess;
  141156. private _verticalBlurPostprocess;
  141157. private _blurTexture;
  141158. private _meshes;
  141159. private _excludedMeshes;
  141160. /**
  141161. * Instantiates a new highlight Layer and references it to the scene..
  141162. * @param name The name of the layer
  141163. * @param scene The scene to use the layer in
  141164. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  141165. */
  141166. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  141167. /**
  141168. * Get the effect name of the layer.
  141169. * @return The effect name
  141170. */
  141171. getEffectName(): string;
  141172. /**
  141173. * Create the merge effect. This is the shader use to blit the information back
  141174. * to the main canvas at the end of the scene rendering.
  141175. */
  141176. protected _createMergeEffect(): Effect;
  141177. /**
  141178. * Creates the render target textures and post processes used in the highlight layer.
  141179. */
  141180. protected _createTextureAndPostProcesses(): void;
  141181. /**
  141182. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  141183. */
  141184. needStencil(): boolean;
  141185. /**
  141186. * Checks for the readiness of the element composing the layer.
  141187. * @param subMesh the mesh to check for
  141188. * @param useInstances specify wether or not to use instances to render the mesh
  141189. * @param emissiveTexture the associated emissive texture used to generate the glow
  141190. * @return true if ready otherwise, false
  141191. */
  141192. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141193. /**
  141194. * Implementation specific of rendering the generating effect on the main canvas.
  141195. * @param effect The effect used to render through
  141196. */
  141197. protected _internalRender(effect: Effect): void;
  141198. /**
  141199. * Returns true if the layer contains information to display, otherwise false.
  141200. */
  141201. shouldRender(): boolean;
  141202. /**
  141203. * Returns true if the mesh should render, otherwise false.
  141204. * @param mesh The mesh to render
  141205. * @returns true if it should render otherwise false
  141206. */
  141207. protected _shouldRenderMesh(mesh: Mesh): boolean;
  141208. /**
  141209. * Returns true if the mesh can be rendered, otherwise false.
  141210. * @param mesh The mesh to render
  141211. * @param material The material used on the mesh
  141212. * @returns true if it can be rendered otherwise false
  141213. */
  141214. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  141215. /**
  141216. * Adds specific effects defines.
  141217. * @param defines The defines to add specifics to.
  141218. */
  141219. protected _addCustomEffectDefines(defines: string[]): void;
  141220. /**
  141221. * Sets the required values for both the emissive texture and and the main color.
  141222. */
  141223. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  141224. /**
  141225. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  141226. * @param mesh The mesh to exclude from the highlight layer
  141227. */
  141228. addExcludedMesh(mesh: Mesh): void;
  141229. /**
  141230. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  141231. * @param mesh The mesh to highlight
  141232. */
  141233. removeExcludedMesh(mesh: Mesh): void;
  141234. /**
  141235. * Determine if a given mesh will be highlighted by the current HighlightLayer
  141236. * @param mesh mesh to test
  141237. * @returns true if the mesh will be highlighted by the current HighlightLayer
  141238. */
  141239. hasMesh(mesh: AbstractMesh): boolean;
  141240. /**
  141241. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  141242. * @param mesh The mesh to highlight
  141243. * @param color The color of the highlight
  141244. * @param glowEmissiveOnly Extract the glow from the emissive texture
  141245. */
  141246. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  141247. /**
  141248. * Remove a mesh from the highlight layer in order to make it stop glowing.
  141249. * @param mesh The mesh to highlight
  141250. */
  141251. removeMesh(mesh: Mesh): void;
  141252. /**
  141253. * Remove all the meshes currently referenced in the highlight layer
  141254. */
  141255. removeAllMeshes(): void;
  141256. /**
  141257. * Force the stencil to the normal expected value for none glowing parts
  141258. */
  141259. private _defaultStencilReference;
  141260. /**
  141261. * Free any resources and references associated to a mesh.
  141262. * Internal use
  141263. * @param mesh The mesh to free.
  141264. * @hidden
  141265. */
  141266. _disposeMesh(mesh: Mesh): void;
  141267. /**
  141268. * Dispose the highlight layer and free resources.
  141269. */
  141270. dispose(): void;
  141271. /**
  141272. * Gets the class name of the effect layer
  141273. * @returns the string with the class name of the effect layer
  141274. */
  141275. getClassName(): string;
  141276. /**
  141277. * Serializes this Highlight layer
  141278. * @returns a serialized Highlight layer object
  141279. */
  141280. serialize(): any;
  141281. /**
  141282. * Creates a Highlight layer from parsed Highlight layer data
  141283. * @param parsedHightlightLayer defines the Highlight layer data
  141284. * @param scene defines the current scene
  141285. * @param rootUrl defines the root URL containing the Highlight layer information
  141286. * @returns a parsed Highlight layer
  141287. */
  141288. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  141289. }
  141290. }
  141291. declare module BABYLON {
  141292. interface AbstractScene {
  141293. /**
  141294. * The list of layers (background and foreground) of the scene
  141295. */
  141296. layers: Array<Layer>;
  141297. }
  141298. /**
  141299. * Defines the layer scene component responsible to manage any layers
  141300. * in a given scene.
  141301. */
  141302. export class LayerSceneComponent implements ISceneComponent {
  141303. /**
  141304. * The component name helpfull to identify the component in the list of scene components.
  141305. */
  141306. readonly name: string;
  141307. /**
  141308. * The scene the component belongs to.
  141309. */
  141310. scene: Scene;
  141311. private _engine;
  141312. /**
  141313. * Creates a new instance of the component for the given scene
  141314. * @param scene Defines the scene to register the component in
  141315. */
  141316. constructor(scene: Scene);
  141317. /**
  141318. * Registers the component in a given scene
  141319. */
  141320. register(): void;
  141321. /**
  141322. * Rebuilds the elements related to this component in case of
  141323. * context lost for instance.
  141324. */
  141325. rebuild(): void;
  141326. /**
  141327. * Disposes the component and the associated ressources.
  141328. */
  141329. dispose(): void;
  141330. private _draw;
  141331. private _drawCameraPredicate;
  141332. private _drawCameraBackground;
  141333. private _drawCameraForeground;
  141334. private _drawRenderTargetPredicate;
  141335. private _drawRenderTargetBackground;
  141336. private _drawRenderTargetForeground;
  141337. /**
  141338. * Adds all the elements from the container to the scene
  141339. * @param container the container holding the elements
  141340. */
  141341. addFromContainer(container: AbstractScene): void;
  141342. /**
  141343. * Removes all the elements in the container from the scene
  141344. * @param container contains the elements to remove
  141345. * @param dispose if the removed element should be disposed (default: false)
  141346. */
  141347. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141348. }
  141349. }
  141350. declare module BABYLON {
  141351. /** @hidden */
  141352. export var layerPixelShader: {
  141353. name: string;
  141354. shader: string;
  141355. };
  141356. }
  141357. declare module BABYLON {
  141358. /** @hidden */
  141359. export var layerVertexShader: {
  141360. name: string;
  141361. shader: string;
  141362. };
  141363. }
  141364. declare module BABYLON {
  141365. /**
  141366. * This represents a full screen 2d layer.
  141367. * This can be useful to display a picture in the background of your scene for instance.
  141368. * @see https://www.babylonjs-playground.com/#08A2BS#1
  141369. */
  141370. export class Layer {
  141371. /**
  141372. * Define the name of the layer.
  141373. */
  141374. name: string;
  141375. /**
  141376. * Define the texture the layer should display.
  141377. */
  141378. texture: Nullable<Texture>;
  141379. /**
  141380. * Is the layer in background or foreground.
  141381. */
  141382. isBackground: boolean;
  141383. /**
  141384. * Define the color of the layer (instead of texture).
  141385. */
  141386. color: Color4;
  141387. /**
  141388. * Define the scale of the layer in order to zoom in out of the texture.
  141389. */
  141390. scale: Vector2;
  141391. /**
  141392. * Define an offset for the layer in order to shift the texture.
  141393. */
  141394. offset: Vector2;
  141395. /**
  141396. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  141397. */
  141398. alphaBlendingMode: number;
  141399. /**
  141400. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  141401. * Alpha test will not mix with the background color in case of transparency.
  141402. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  141403. */
  141404. alphaTest: boolean;
  141405. /**
  141406. * Define a mask to restrict the layer to only some of the scene cameras.
  141407. */
  141408. layerMask: number;
  141409. /**
  141410. * Define the list of render target the layer is visible into.
  141411. */
  141412. renderTargetTextures: RenderTargetTexture[];
  141413. /**
  141414. * Define if the layer is only used in renderTarget or if it also
  141415. * renders in the main frame buffer of the canvas.
  141416. */
  141417. renderOnlyInRenderTargetTextures: boolean;
  141418. private _scene;
  141419. private _vertexBuffers;
  141420. private _indexBuffer;
  141421. private _effect;
  141422. private _previousDefines;
  141423. /**
  141424. * An event triggered when the layer is disposed.
  141425. */
  141426. onDisposeObservable: Observable<Layer>;
  141427. private _onDisposeObserver;
  141428. /**
  141429. * Back compatibility with callback before the onDisposeObservable existed.
  141430. * The set callback will be triggered when the layer has been disposed.
  141431. */
  141432. set onDispose(callback: () => void);
  141433. /**
  141434. * An event triggered before rendering the scene
  141435. */
  141436. onBeforeRenderObservable: Observable<Layer>;
  141437. private _onBeforeRenderObserver;
  141438. /**
  141439. * Back compatibility with callback before the onBeforeRenderObservable existed.
  141440. * The set callback will be triggered just before rendering the layer.
  141441. */
  141442. set onBeforeRender(callback: () => void);
  141443. /**
  141444. * An event triggered after rendering the scene
  141445. */
  141446. onAfterRenderObservable: Observable<Layer>;
  141447. private _onAfterRenderObserver;
  141448. /**
  141449. * Back compatibility with callback before the onAfterRenderObservable existed.
  141450. * The set callback will be triggered just after rendering the layer.
  141451. */
  141452. set onAfterRender(callback: () => void);
  141453. /**
  141454. * Instantiates a new layer.
  141455. * This represents a full screen 2d layer.
  141456. * This can be useful to display a picture in the background of your scene for instance.
  141457. * @see https://www.babylonjs-playground.com/#08A2BS#1
  141458. * @param name Define the name of the layer in the scene
  141459. * @param imgUrl Define the url of the texture to display in the layer
  141460. * @param scene Define the scene the layer belongs to
  141461. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  141462. * @param color Defines a color for the layer
  141463. */
  141464. constructor(
  141465. /**
  141466. * Define the name of the layer.
  141467. */
  141468. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  141469. private _createIndexBuffer;
  141470. /** @hidden */
  141471. _rebuild(): void;
  141472. /**
  141473. * Renders the layer in the scene.
  141474. */
  141475. render(): void;
  141476. /**
  141477. * Disposes and releases the associated ressources.
  141478. */
  141479. dispose(): void;
  141480. }
  141481. }
  141482. declare module BABYLON {
  141483. /** @hidden */
  141484. export var lensFlarePixelShader: {
  141485. name: string;
  141486. shader: string;
  141487. };
  141488. }
  141489. declare module BABYLON {
  141490. /** @hidden */
  141491. export var lensFlareVertexShader: {
  141492. name: string;
  141493. shader: string;
  141494. };
  141495. }
  141496. declare module BABYLON {
  141497. /**
  141498. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  141499. * It is usually composed of several `lensFlare`.
  141500. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141501. */
  141502. export class LensFlareSystem {
  141503. /**
  141504. * Define the name of the lens flare system
  141505. */
  141506. name: string;
  141507. /**
  141508. * List of lens flares used in this system.
  141509. */
  141510. lensFlares: LensFlare[];
  141511. /**
  141512. * Define a limit from the border the lens flare can be visible.
  141513. */
  141514. borderLimit: number;
  141515. /**
  141516. * Define a viewport border we do not want to see the lens flare in.
  141517. */
  141518. viewportBorder: number;
  141519. /**
  141520. * Define a predicate which could limit the list of meshes able to occlude the effect.
  141521. */
  141522. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  141523. /**
  141524. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  141525. */
  141526. layerMask: number;
  141527. /**
  141528. * Define the id of the lens flare system in the scene.
  141529. * (equal to name by default)
  141530. */
  141531. id: string;
  141532. private _scene;
  141533. private _emitter;
  141534. private _vertexBuffers;
  141535. private _indexBuffer;
  141536. private _effect;
  141537. private _positionX;
  141538. private _positionY;
  141539. private _isEnabled;
  141540. /** @hidden */
  141541. static _SceneComponentInitialization: (scene: Scene) => void;
  141542. /**
  141543. * Instantiates a lens flare system.
  141544. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  141545. * It is usually composed of several `lensFlare`.
  141546. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141547. * @param name Define the name of the lens flare system in the scene
  141548. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  141549. * @param scene Define the scene the lens flare system belongs to
  141550. */
  141551. constructor(
  141552. /**
  141553. * Define the name of the lens flare system
  141554. */
  141555. name: string, emitter: any, scene: Scene);
  141556. /**
  141557. * Define if the lens flare system is enabled.
  141558. */
  141559. get isEnabled(): boolean;
  141560. set isEnabled(value: boolean);
  141561. /**
  141562. * Get the scene the effects belongs to.
  141563. * @returns the scene holding the lens flare system
  141564. */
  141565. getScene(): Scene;
  141566. /**
  141567. * Get the emitter of the lens flare system.
  141568. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  141569. * @returns the emitter of the lens flare system
  141570. */
  141571. getEmitter(): any;
  141572. /**
  141573. * Set the emitter of the lens flare system.
  141574. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  141575. * @param newEmitter Define the new emitter of the system
  141576. */
  141577. setEmitter(newEmitter: any): void;
  141578. /**
  141579. * Get the lens flare system emitter position.
  141580. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  141581. * @returns the position
  141582. */
  141583. getEmitterPosition(): Vector3;
  141584. /**
  141585. * @hidden
  141586. */
  141587. computeEffectivePosition(globalViewport: Viewport): boolean;
  141588. /** @hidden */
  141589. _isVisible(): boolean;
  141590. /**
  141591. * @hidden
  141592. */
  141593. render(): boolean;
  141594. /**
  141595. * Dispose and release the lens flare with its associated resources.
  141596. */
  141597. dispose(): void;
  141598. /**
  141599. * Parse a lens flare system from a JSON repressentation
  141600. * @param parsedLensFlareSystem Define the JSON to parse
  141601. * @param scene Define the scene the parsed system should be instantiated in
  141602. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  141603. * @returns the parsed system
  141604. */
  141605. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  141606. /**
  141607. * Serialize the current Lens Flare System into a JSON representation.
  141608. * @returns the serialized JSON
  141609. */
  141610. serialize(): any;
  141611. }
  141612. }
  141613. declare module BABYLON {
  141614. /**
  141615. * This represents one of the lens effect in a `lensFlareSystem`.
  141616. * It controls one of the indiviual texture used in the effect.
  141617. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141618. */
  141619. export class LensFlare {
  141620. /**
  141621. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  141622. */
  141623. size: number;
  141624. /**
  141625. * 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.
  141626. */
  141627. position: number;
  141628. /**
  141629. * Define the lens color.
  141630. */
  141631. color: Color3;
  141632. /**
  141633. * Define the lens texture.
  141634. */
  141635. texture: Nullable<Texture>;
  141636. /**
  141637. * Define the alpha mode to render this particular lens.
  141638. */
  141639. alphaMode: number;
  141640. private _system;
  141641. /**
  141642. * Creates a new Lens Flare.
  141643. * This represents one of the lens effect in a `lensFlareSystem`.
  141644. * It controls one of the indiviual texture used in the effect.
  141645. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141646. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  141647. * @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.
  141648. * @param color Define the lens color
  141649. * @param imgUrl Define the lens texture url
  141650. * @param system Define the `lensFlareSystem` this flare is part of
  141651. * @returns The newly created Lens Flare
  141652. */
  141653. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  141654. /**
  141655. * Instantiates a new Lens Flare.
  141656. * This represents one of the lens effect in a `lensFlareSystem`.
  141657. * It controls one of the indiviual texture used in the effect.
  141658. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141659. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  141660. * @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.
  141661. * @param color Define the lens color
  141662. * @param imgUrl Define the lens texture url
  141663. * @param system Define the `lensFlareSystem` this flare is part of
  141664. */
  141665. constructor(
  141666. /**
  141667. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  141668. */
  141669. size: number,
  141670. /**
  141671. * 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.
  141672. */
  141673. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  141674. /**
  141675. * Dispose and release the lens flare with its associated resources.
  141676. */
  141677. dispose(): void;
  141678. }
  141679. }
  141680. declare module BABYLON {
  141681. interface AbstractScene {
  141682. /**
  141683. * The list of lens flare system added to the scene
  141684. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  141685. */
  141686. lensFlareSystems: Array<LensFlareSystem>;
  141687. /**
  141688. * Removes the given lens flare system from this scene.
  141689. * @param toRemove The lens flare system to remove
  141690. * @returns The index of the removed lens flare system
  141691. */
  141692. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  141693. /**
  141694. * Adds the given lens flare system to this scene
  141695. * @param newLensFlareSystem The lens flare system to add
  141696. */
  141697. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  141698. /**
  141699. * Gets a lens flare system using its name
  141700. * @param name defines the name to look for
  141701. * @returns the lens flare system or null if not found
  141702. */
  141703. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  141704. /**
  141705. * Gets a lens flare system using its id
  141706. * @param id defines the id to look for
  141707. * @returns the lens flare system or null if not found
  141708. */
  141709. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  141710. }
  141711. /**
  141712. * Defines the lens flare scene component responsible to manage any lens flares
  141713. * in a given scene.
  141714. */
  141715. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  141716. /**
  141717. * The component name helpfull to identify the component in the list of scene components.
  141718. */
  141719. readonly name: string;
  141720. /**
  141721. * The scene the component belongs to.
  141722. */
  141723. scene: Scene;
  141724. /**
  141725. * Creates a new instance of the component for the given scene
  141726. * @param scene Defines the scene to register the component in
  141727. */
  141728. constructor(scene: Scene);
  141729. /**
  141730. * Registers the component in a given scene
  141731. */
  141732. register(): void;
  141733. /**
  141734. * Rebuilds the elements related to this component in case of
  141735. * context lost for instance.
  141736. */
  141737. rebuild(): void;
  141738. /**
  141739. * Adds all the elements from the container to the scene
  141740. * @param container the container holding the elements
  141741. */
  141742. addFromContainer(container: AbstractScene): void;
  141743. /**
  141744. * Removes all the elements in the container from the scene
  141745. * @param container contains the elements to remove
  141746. * @param dispose if the removed element should be disposed (default: false)
  141747. */
  141748. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  141749. /**
  141750. * Serializes the component data to the specified json object
  141751. * @param serializationObject The object to serialize to
  141752. */
  141753. serialize(serializationObject: any): void;
  141754. /**
  141755. * Disposes the component and the associated ressources.
  141756. */
  141757. dispose(): void;
  141758. private _draw;
  141759. }
  141760. }
  141761. declare module BABYLON {
  141762. /** @hidden */
  141763. export var depthPixelShader: {
  141764. name: string;
  141765. shader: string;
  141766. };
  141767. }
  141768. declare module BABYLON {
  141769. /** @hidden */
  141770. export var depthVertexShader: {
  141771. name: string;
  141772. shader: string;
  141773. };
  141774. }
  141775. declare module BABYLON {
  141776. /**
  141777. * This represents a depth renderer in Babylon.
  141778. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  141779. */
  141780. export class DepthRenderer {
  141781. private _scene;
  141782. private _depthMap;
  141783. private _effect;
  141784. private readonly _storeNonLinearDepth;
  141785. private readonly _clearColor;
  141786. /** Get if the depth renderer is using packed depth or not */
  141787. readonly isPacked: boolean;
  141788. private _cachedDefines;
  141789. private _camera;
  141790. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  141791. enabled: boolean;
  141792. /**
  141793. * Specifiess that the depth renderer will only be used within
  141794. * the camera it is created for.
  141795. * This can help forcing its rendering during the camera processing.
  141796. */
  141797. useOnlyInActiveCamera: boolean;
  141798. /** @hidden */
  141799. static _SceneComponentInitialization: (scene: Scene) => void;
  141800. /**
  141801. * Instantiates a depth renderer
  141802. * @param scene The scene the renderer belongs to
  141803. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  141804. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  141805. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  141806. */
  141807. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  141808. /**
  141809. * Creates the depth rendering effect and checks if the effect is ready.
  141810. * @param subMesh The submesh to be used to render the depth map of
  141811. * @param useInstances If multiple world instances should be used
  141812. * @returns if the depth renderer is ready to render the depth map
  141813. */
  141814. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141815. /**
  141816. * Gets the texture which the depth map will be written to.
  141817. * @returns The depth map texture
  141818. */
  141819. getDepthMap(): RenderTargetTexture;
  141820. /**
  141821. * Disposes of the depth renderer.
  141822. */
  141823. dispose(): void;
  141824. }
  141825. }
  141826. declare module BABYLON {
  141827. /** @hidden */
  141828. export var minmaxReduxPixelShader: {
  141829. name: string;
  141830. shader: string;
  141831. };
  141832. }
  141833. declare module BABYLON {
  141834. /**
  141835. * This class computes a min/max reduction from a texture: it means it computes the minimum
  141836. * and maximum values from all values of the texture.
  141837. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  141838. * The source values are read from the red channel of the texture.
  141839. */
  141840. export class MinMaxReducer {
  141841. /**
  141842. * Observable triggered when the computation has been performed
  141843. */
  141844. onAfterReductionPerformed: Observable<{
  141845. min: number;
  141846. max: number;
  141847. }>;
  141848. protected _camera: Camera;
  141849. protected _sourceTexture: Nullable<RenderTargetTexture>;
  141850. protected _reductionSteps: Nullable<Array<PostProcess>>;
  141851. protected _postProcessManager: PostProcessManager;
  141852. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  141853. protected _forceFullscreenViewport: boolean;
  141854. /**
  141855. * Creates a min/max reducer
  141856. * @param camera The camera to use for the post processes
  141857. */
  141858. constructor(camera: Camera);
  141859. /**
  141860. * Gets the texture used to read the values from.
  141861. */
  141862. get sourceTexture(): Nullable<RenderTargetTexture>;
  141863. /**
  141864. * Sets the source texture to read the values from.
  141865. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  141866. * because in such textures '1' value must not be taken into account to compute the maximum
  141867. * as this value is used to clear the texture.
  141868. * Note that the computation is not activated by calling this function, you must call activate() for that!
  141869. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  141870. * @param depthRedux Indicates if the texture is a depth texture or not
  141871. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  141872. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141873. */
  141874. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141875. /**
  141876. * Defines the refresh rate of the computation.
  141877. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  141878. */
  141879. get refreshRate(): number;
  141880. set refreshRate(value: number);
  141881. protected _activated: boolean;
  141882. /**
  141883. * Gets the activation status of the reducer
  141884. */
  141885. get activated(): boolean;
  141886. /**
  141887. * Activates the reduction computation.
  141888. * When activated, the observers registered in onAfterReductionPerformed are
  141889. * called after the compuation is performed
  141890. */
  141891. activate(): void;
  141892. /**
  141893. * Deactivates the reduction computation.
  141894. */
  141895. deactivate(): void;
  141896. /**
  141897. * Disposes the min/max reducer
  141898. * @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.
  141899. */
  141900. dispose(disposeAll?: boolean): void;
  141901. }
  141902. }
  141903. declare module BABYLON {
  141904. /**
  141905. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  141906. */
  141907. export class DepthReducer extends MinMaxReducer {
  141908. private _depthRenderer;
  141909. private _depthRendererId;
  141910. /**
  141911. * Gets the depth renderer used for the computation.
  141912. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  141913. */
  141914. get depthRenderer(): Nullable<DepthRenderer>;
  141915. /**
  141916. * Creates a depth reducer
  141917. * @param camera The camera used to render the depth texture
  141918. */
  141919. constructor(camera: Camera);
  141920. /**
  141921. * Sets the depth renderer to use to generate the depth map
  141922. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  141923. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  141924. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  141925. */
  141926. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  141927. /** @hidden */
  141928. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  141929. /**
  141930. * Activates the reduction computation.
  141931. * When activated, the observers registered in onAfterReductionPerformed are
  141932. * called after the compuation is performed
  141933. */
  141934. activate(): void;
  141935. /**
  141936. * Deactivates the reduction computation.
  141937. */
  141938. deactivate(): void;
  141939. /**
  141940. * Disposes the depth reducer
  141941. * @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.
  141942. */
  141943. dispose(disposeAll?: boolean): void;
  141944. }
  141945. }
  141946. declare module BABYLON {
  141947. /**
  141948. * A CSM implementation allowing casting shadows on large scenes.
  141949. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  141950. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  141951. */
  141952. export class CascadedShadowGenerator extends ShadowGenerator {
  141953. private static readonly frustumCornersNDCSpace;
  141954. /**
  141955. * Name of the CSM class
  141956. */
  141957. static CLASSNAME: string;
  141958. /**
  141959. * Defines the default number of cascades used by the CSM.
  141960. */
  141961. static readonly DEFAULT_CASCADES_COUNT: number;
  141962. /**
  141963. * Defines the minimum number of cascades used by the CSM.
  141964. */
  141965. static readonly MIN_CASCADES_COUNT: number;
  141966. /**
  141967. * Defines the maximum number of cascades used by the CSM.
  141968. */
  141969. static readonly MAX_CASCADES_COUNT: number;
  141970. protected _validateFilter(filter: number): number;
  141971. /**
  141972. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  141973. */
  141974. penumbraDarkness: number;
  141975. private _numCascades;
  141976. /**
  141977. * Gets or set the number of cascades used by the CSM.
  141978. */
  141979. get numCascades(): number;
  141980. set numCascades(value: number);
  141981. /**
  141982. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  141983. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  141984. */
  141985. stabilizeCascades: boolean;
  141986. private _freezeShadowCastersBoundingInfo;
  141987. private _freezeShadowCastersBoundingInfoObservable;
  141988. /**
  141989. * Enables or disables the shadow casters bounding info computation.
  141990. * If your shadow casters don't move, you can disable this feature.
  141991. * If it is enabled, the bounding box computation is done every frame.
  141992. */
  141993. get freezeShadowCastersBoundingInfo(): boolean;
  141994. set freezeShadowCastersBoundingInfo(freeze: boolean);
  141995. private _scbiMin;
  141996. private _scbiMax;
  141997. protected _computeShadowCastersBoundingInfo(): void;
  141998. protected _shadowCastersBoundingInfo: BoundingInfo;
  141999. /**
  142000. * Gets or sets the shadow casters bounding info.
  142001. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  142002. * so that the system won't overwrite the bounds you provide
  142003. */
  142004. get shadowCastersBoundingInfo(): BoundingInfo;
  142005. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  142006. protected _breaksAreDirty: boolean;
  142007. protected _minDistance: number;
  142008. protected _maxDistance: number;
  142009. /**
  142010. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  142011. *
  142012. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  142013. * If you don't know these values, simply leave them to their defaults and don't call this function.
  142014. * @param min minimal distance for the breaks (default to 0.)
  142015. * @param max maximal distance for the breaks (default to 1.)
  142016. */
  142017. setMinMaxDistance(min: number, max: number): void;
  142018. /** Gets the minimal distance used in the cascade break computation */
  142019. get minDistance(): number;
  142020. /** Gets the maximal distance used in the cascade break computation */
  142021. get maxDistance(): number;
  142022. /**
  142023. * Gets the class name of that object
  142024. * @returns "CascadedShadowGenerator"
  142025. */
  142026. getClassName(): string;
  142027. private _cascadeMinExtents;
  142028. private _cascadeMaxExtents;
  142029. /**
  142030. * Gets a cascade minimum extents
  142031. * @param cascadeIndex index of the cascade
  142032. * @returns the minimum cascade extents
  142033. */
  142034. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  142035. /**
  142036. * Gets a cascade maximum extents
  142037. * @param cascadeIndex index of the cascade
  142038. * @returns the maximum cascade extents
  142039. */
  142040. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  142041. private _cascades;
  142042. private _currentLayer;
  142043. private _viewSpaceFrustumsZ;
  142044. private _viewMatrices;
  142045. private _projectionMatrices;
  142046. private _transformMatrices;
  142047. private _transformMatricesAsArray;
  142048. private _frustumLengths;
  142049. private _lightSizeUVCorrection;
  142050. private _depthCorrection;
  142051. private _frustumCornersWorldSpace;
  142052. private _frustumCenter;
  142053. private _shadowCameraPos;
  142054. private _shadowMaxZ;
  142055. /**
  142056. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  142057. * It defaults to camera.maxZ
  142058. */
  142059. get shadowMaxZ(): number;
  142060. /**
  142061. * Sets the shadow max z distance.
  142062. */
  142063. set shadowMaxZ(value: number);
  142064. protected _debug: boolean;
  142065. /**
  142066. * Gets or sets the debug flag.
  142067. * When enabled, the cascades are materialized by different colors on the screen.
  142068. */
  142069. get debug(): boolean;
  142070. set debug(dbg: boolean);
  142071. private _depthClamp;
  142072. /**
  142073. * Gets or sets the depth clamping value.
  142074. *
  142075. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  142076. * to account for the shadow casters far away.
  142077. *
  142078. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  142079. */
  142080. get depthClamp(): boolean;
  142081. set depthClamp(value: boolean);
  142082. private _cascadeBlendPercentage;
  142083. /**
  142084. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  142085. * It defaults to 0.1 (10% blending).
  142086. */
  142087. get cascadeBlendPercentage(): number;
  142088. set cascadeBlendPercentage(value: number);
  142089. private _lambda;
  142090. /**
  142091. * Gets or set the lambda parameter.
  142092. * This parameter is used to split the camera frustum and create the cascades.
  142093. * 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.
  142094. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  142095. */
  142096. get lambda(): number;
  142097. set lambda(value: number);
  142098. /**
  142099. * Gets the view matrix corresponding to a given cascade
  142100. * @param cascadeNum cascade to retrieve the view matrix from
  142101. * @returns the cascade view matrix
  142102. */
  142103. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  142104. /**
  142105. * Gets the projection matrix corresponding to a given cascade
  142106. * @param cascadeNum cascade to retrieve the projection matrix from
  142107. * @returns the cascade projection matrix
  142108. */
  142109. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  142110. /**
  142111. * Gets the transformation matrix corresponding to a given cascade
  142112. * @param cascadeNum cascade to retrieve the transformation matrix from
  142113. * @returns the cascade transformation matrix
  142114. */
  142115. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  142116. private _depthRenderer;
  142117. /**
  142118. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  142119. *
  142120. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  142121. *
  142122. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  142123. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  142124. * @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
  142125. */
  142126. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  142127. private _depthReducer;
  142128. private _autoCalcDepthBounds;
  142129. /**
  142130. * Gets or sets the autoCalcDepthBounds property.
  142131. *
  142132. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  142133. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  142134. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  142135. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  142136. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  142137. */
  142138. get autoCalcDepthBounds(): boolean;
  142139. set autoCalcDepthBounds(value: boolean);
  142140. /**
  142141. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  142142. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  142143. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  142144. * for setting the refresh rate on the renderer yourself!
  142145. */
  142146. get autoCalcDepthBoundsRefreshRate(): number;
  142147. set autoCalcDepthBoundsRefreshRate(value: number);
  142148. /**
  142149. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  142150. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  142151. * you change the camera near/far planes!
  142152. */
  142153. splitFrustum(): void;
  142154. private _splitFrustum;
  142155. private _computeMatrices;
  142156. private _computeFrustumInWorldSpace;
  142157. private _computeCascadeFrustum;
  142158. /**
  142159. * Support test.
  142160. */
  142161. static get IsSupported(): boolean;
  142162. /** @hidden */
  142163. static _SceneComponentInitialization: (scene: Scene) => void;
  142164. /**
  142165. * Creates a Cascaded Shadow Generator object.
  142166. * A ShadowGenerator is the required tool to use the shadows.
  142167. * Each directional light casting shadows needs to use its own ShadowGenerator.
  142168. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  142169. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  142170. * @param light The directional light object generating the shadows.
  142171. * @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.
  142172. */
  142173. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  142174. protected _initializeGenerator(): void;
  142175. protected _createTargetRenderTexture(): void;
  142176. protected _initializeShadowMap(): void;
  142177. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  142178. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  142179. /**
  142180. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  142181. * @param defines Defines of the material we want to update
  142182. * @param lightIndex Index of the light in the enabled light list of the material
  142183. */
  142184. prepareDefines(defines: any, lightIndex: number): void;
  142185. /**
  142186. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  142187. * defined in the generator but impacting the effect).
  142188. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  142189. * @param effect The effect we are binfing the information for
  142190. */
  142191. bindShadowLight(lightIndex: string, effect: Effect): void;
  142192. /**
  142193. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  142194. * (eq to view projection * shadow projection matrices)
  142195. * @returns The transform matrix used to create the shadow map
  142196. */
  142197. getTransformMatrix(): Matrix;
  142198. /**
  142199. * Disposes the ShadowGenerator.
  142200. * Returns nothing.
  142201. */
  142202. dispose(): void;
  142203. /**
  142204. * Serializes the shadow generator setup to a json object.
  142205. * @returns The serialized JSON object
  142206. */
  142207. serialize(): any;
  142208. /**
  142209. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  142210. * @param parsedShadowGenerator The JSON object to parse
  142211. * @param scene The scene to create the shadow map for
  142212. * @returns The parsed shadow generator
  142213. */
  142214. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  142215. }
  142216. }
  142217. declare module BABYLON {
  142218. /**
  142219. * Defines the shadow generator component responsible to manage any shadow generators
  142220. * in a given scene.
  142221. */
  142222. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  142223. /**
  142224. * The component name helpfull to identify the component in the list of scene components.
  142225. */
  142226. readonly name: string;
  142227. /**
  142228. * The scene the component belongs to.
  142229. */
  142230. scene: Scene;
  142231. /**
  142232. * Creates a new instance of the component for the given scene
  142233. * @param scene Defines the scene to register the component in
  142234. */
  142235. constructor(scene: Scene);
  142236. /**
  142237. * Registers the component in a given scene
  142238. */
  142239. register(): void;
  142240. /**
  142241. * Rebuilds the elements related to this component in case of
  142242. * context lost for instance.
  142243. */
  142244. rebuild(): void;
  142245. /**
  142246. * Serializes the component data to the specified json object
  142247. * @param serializationObject The object to serialize to
  142248. */
  142249. serialize(serializationObject: any): void;
  142250. /**
  142251. * Adds all the elements from the container to the scene
  142252. * @param container the container holding the elements
  142253. */
  142254. addFromContainer(container: AbstractScene): void;
  142255. /**
  142256. * Removes all the elements in the container from the scene
  142257. * @param container contains the elements to remove
  142258. * @param dispose if the removed element should be disposed (default: false)
  142259. */
  142260. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  142261. /**
  142262. * Rebuilds the elements related to this component in case of
  142263. * context lost for instance.
  142264. */
  142265. dispose(): void;
  142266. private _gatherRenderTargets;
  142267. }
  142268. }
  142269. declare module BABYLON {
  142270. /**
  142271. * A point light is a light defined by an unique point in world space.
  142272. * The light is emitted in every direction from this point.
  142273. * A good example of a point light is a standard light bulb.
  142274. * Documentation: https://doc.babylonjs.com/babylon101/lights
  142275. */
  142276. export class PointLight extends ShadowLight {
  142277. private _shadowAngle;
  142278. /**
  142279. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142280. * This specifies what angle the shadow will use to be created.
  142281. *
  142282. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  142283. */
  142284. get shadowAngle(): number;
  142285. /**
  142286. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142287. * This specifies what angle the shadow will use to be created.
  142288. *
  142289. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  142290. */
  142291. set shadowAngle(value: number);
  142292. /**
  142293. * Gets the direction if it has been set.
  142294. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142295. */
  142296. get direction(): Vector3;
  142297. /**
  142298. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  142299. */
  142300. set direction(value: Vector3);
  142301. /**
  142302. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  142303. * A PointLight emits the light in every direction.
  142304. * It can cast shadows.
  142305. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  142306. * ```javascript
  142307. * var pointLight = new PointLight("pl", camera.position, scene);
  142308. * ```
  142309. * Documentation : https://doc.babylonjs.com/babylon101/lights
  142310. * @param name The light friendly name
  142311. * @param position The position of the point light in the scene
  142312. * @param scene The scene the lights belongs to
  142313. */
  142314. constructor(name: string, position: Vector3, scene: Scene);
  142315. /**
  142316. * Returns the string "PointLight"
  142317. * @returns the class name
  142318. */
  142319. getClassName(): string;
  142320. /**
  142321. * Returns the integer 0.
  142322. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  142323. */
  142324. getTypeID(): number;
  142325. /**
  142326. * Specifies wether or not the shadowmap should be a cube texture.
  142327. * @returns true if the shadowmap needs to be a cube texture.
  142328. */
  142329. needCube(): boolean;
  142330. /**
  142331. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  142332. * @param faceIndex The index of the face we are computed the direction to generate shadow
  142333. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  142334. */
  142335. getShadowDirection(faceIndex?: number): Vector3;
  142336. /**
  142337. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  142338. * - fov = PI / 2
  142339. * - aspect ratio : 1.0
  142340. * - z-near and far equal to the active camera minZ and maxZ.
  142341. * Returns the PointLight.
  142342. */
  142343. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  142344. protected _buildUniformLayout(): void;
  142345. /**
  142346. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  142347. * @param effect The effect to update
  142348. * @param lightIndex The index of the light in the effect to update
  142349. * @returns The point light
  142350. */
  142351. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  142352. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  142353. /**
  142354. * Prepares the list of defines specific to the light type.
  142355. * @param defines the list of defines
  142356. * @param lightIndex defines the index of the light for the effect
  142357. */
  142358. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  142359. }
  142360. }
  142361. declare module BABYLON {
  142362. /**
  142363. * Header information of HDR texture files.
  142364. */
  142365. export interface HDRInfo {
  142366. /**
  142367. * The height of the texture in pixels.
  142368. */
  142369. height: number;
  142370. /**
  142371. * The width of the texture in pixels.
  142372. */
  142373. width: number;
  142374. /**
  142375. * The index of the beginning of the data in the binary file.
  142376. */
  142377. dataPosition: number;
  142378. }
  142379. /**
  142380. * This groups tools to convert HDR texture to native colors array.
  142381. */
  142382. export class HDRTools {
  142383. private static Ldexp;
  142384. private static Rgbe2float;
  142385. private static readStringLine;
  142386. /**
  142387. * Reads header information from an RGBE texture stored in a native array.
  142388. * More information on this format are available here:
  142389. * https://en.wikipedia.org/wiki/RGBE_image_format
  142390. *
  142391. * @param uint8array The binary file stored in native array.
  142392. * @return The header information.
  142393. */
  142394. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  142395. /**
  142396. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  142397. * This RGBE texture needs to store the information as a panorama.
  142398. *
  142399. * More information on this format are available here:
  142400. * https://en.wikipedia.org/wiki/RGBE_image_format
  142401. *
  142402. * @param buffer The binary file stored in an array buffer.
  142403. * @param size The expected size of the extracted cubemap.
  142404. * @return The Cube Map information.
  142405. */
  142406. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  142407. /**
  142408. * Returns the pixels data extracted from an RGBE texture.
  142409. * This pixels will be stored left to right up to down in the R G B order in one array.
  142410. *
  142411. * More information on this format are available here:
  142412. * https://en.wikipedia.org/wiki/RGBE_image_format
  142413. *
  142414. * @param uint8array The binary file stored in an array buffer.
  142415. * @param hdrInfo The header information of the file.
  142416. * @return The pixels data in RGB right to left up to down order.
  142417. */
  142418. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  142419. private static RGBE_ReadPixels_RLE;
  142420. private static RGBE_ReadPixels_NOT_RLE;
  142421. }
  142422. }
  142423. declare module BABYLON {
  142424. /**
  142425. * Effect Render Options
  142426. */
  142427. export interface IEffectRendererOptions {
  142428. /**
  142429. * Defines the vertices positions.
  142430. */
  142431. positions?: number[];
  142432. /**
  142433. * Defines the indices.
  142434. */
  142435. indices?: number[];
  142436. }
  142437. /**
  142438. * Helper class to render one or more effects.
  142439. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  142440. */
  142441. export class EffectRenderer {
  142442. private engine;
  142443. private static _DefaultOptions;
  142444. private _vertexBuffers;
  142445. private _indexBuffer;
  142446. private _fullscreenViewport;
  142447. /**
  142448. * Creates an effect renderer
  142449. * @param engine the engine to use for rendering
  142450. * @param options defines the options of the effect renderer
  142451. */
  142452. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  142453. /**
  142454. * Sets the current viewport in normalized coordinates 0-1
  142455. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  142456. */
  142457. setViewport(viewport?: Viewport): void;
  142458. /**
  142459. * Binds the embedded attributes buffer to the effect.
  142460. * @param effect Defines the effect to bind the attributes for
  142461. */
  142462. bindBuffers(effect: Effect): void;
  142463. /**
  142464. * Sets the current effect wrapper to use during draw.
  142465. * The effect needs to be ready before calling this api.
  142466. * This also sets the default full screen position attribute.
  142467. * @param effectWrapper Defines the effect to draw with
  142468. */
  142469. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  142470. /**
  142471. * Restores engine states
  142472. */
  142473. restoreStates(): void;
  142474. /**
  142475. * Draws a full screen quad.
  142476. */
  142477. draw(): void;
  142478. private isRenderTargetTexture;
  142479. /**
  142480. * renders one or more effects to a specified texture
  142481. * @param effectWrapper the effect to renderer
  142482. * @param outputTexture texture to draw to, if null it will render to the screen.
  142483. */
  142484. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  142485. /**
  142486. * Disposes of the effect renderer
  142487. */
  142488. dispose(): void;
  142489. }
  142490. /**
  142491. * Options to create an EffectWrapper
  142492. */
  142493. interface EffectWrapperCreationOptions {
  142494. /**
  142495. * Engine to use to create the effect
  142496. */
  142497. engine: ThinEngine;
  142498. /**
  142499. * Fragment shader for the effect
  142500. */
  142501. fragmentShader: string;
  142502. /**
  142503. * Use the shader store instead of direct source code
  142504. */
  142505. useShaderStore?: boolean;
  142506. /**
  142507. * Vertex shader for the effect
  142508. */
  142509. vertexShader?: string;
  142510. /**
  142511. * Attributes to use in the shader
  142512. */
  142513. attributeNames?: Array<string>;
  142514. /**
  142515. * Uniforms to use in the shader
  142516. */
  142517. uniformNames?: Array<string>;
  142518. /**
  142519. * Texture sampler names to use in the shader
  142520. */
  142521. samplerNames?: Array<string>;
  142522. /**
  142523. * Defines to use in the shader
  142524. */
  142525. defines?: Array<string>;
  142526. /**
  142527. * Callback when effect is compiled
  142528. */
  142529. onCompiled?: Nullable<(effect: Effect) => void>;
  142530. /**
  142531. * The friendly name of the effect displayed in Spector.
  142532. */
  142533. name?: string;
  142534. }
  142535. /**
  142536. * Wraps an effect to be used for rendering
  142537. */
  142538. export class EffectWrapper {
  142539. /**
  142540. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  142541. */
  142542. onApplyObservable: Observable<{}>;
  142543. /**
  142544. * The underlying effect
  142545. */
  142546. effect: Effect;
  142547. /**
  142548. * Creates an effect to be renderer
  142549. * @param creationOptions options to create the effect
  142550. */
  142551. constructor(creationOptions: EffectWrapperCreationOptions);
  142552. /**
  142553. * Disposes of the effect wrapper
  142554. */
  142555. dispose(): void;
  142556. }
  142557. }
  142558. declare module BABYLON {
  142559. /** @hidden */
  142560. export var hdrFilteringVertexShader: {
  142561. name: string;
  142562. shader: string;
  142563. };
  142564. }
  142565. declare module BABYLON {
  142566. /** @hidden */
  142567. export var hdrFilteringPixelShader: {
  142568. name: string;
  142569. shader: string;
  142570. };
  142571. }
  142572. declare module BABYLON {
  142573. /**
  142574. * Options for texture filtering
  142575. */
  142576. interface IHDRFilteringOptions {
  142577. /**
  142578. * Scales pixel intensity for the input HDR map.
  142579. */
  142580. hdrScale?: number;
  142581. /**
  142582. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  142583. */
  142584. quality?: number;
  142585. }
  142586. /**
  142587. * Filters HDR maps to get correct renderings of PBR reflections
  142588. */
  142589. export class HDRFiltering {
  142590. private _engine;
  142591. private _effectRenderer;
  142592. private _effectWrapper;
  142593. private _lodGenerationOffset;
  142594. private _lodGenerationScale;
  142595. /**
  142596. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  142597. * you care about baking speed.
  142598. */
  142599. quality: number;
  142600. /**
  142601. * Scales pixel intensity for the input HDR map.
  142602. */
  142603. hdrScale: number;
  142604. /**
  142605. * Instantiates HDR filter for reflection maps
  142606. *
  142607. * @param engine Thin engine
  142608. * @param options Options
  142609. */
  142610. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  142611. private _createRenderTarget;
  142612. private _prefilterInternal;
  142613. private _createEffect;
  142614. /**
  142615. * Get a value indicating if the filter is ready to be used
  142616. * @param texture Texture to filter
  142617. * @returns true if the filter is ready
  142618. */
  142619. isReady(texture: BaseTexture): boolean;
  142620. /**
  142621. * Prefilters a cube texture to have mipmap levels representing roughness values.
  142622. * Prefiltering will be invoked at the end of next rendering pass.
  142623. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  142624. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  142625. * @param texture Texture to filter
  142626. * @param onFinished Callback when filtering is done
  142627. * @return Promise called when prefiltering is done
  142628. */
  142629. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  142630. }
  142631. }
  142632. declare module BABYLON {
  142633. /**
  142634. * This represents a texture coming from an HDR input.
  142635. *
  142636. * The only supported format is currently panorama picture stored in RGBE format.
  142637. * Example of such files can be found on HDRLib: http://hdrlib.com/
  142638. */
  142639. export class HDRCubeTexture extends BaseTexture {
  142640. private static _facesMapping;
  142641. private _generateHarmonics;
  142642. private _noMipmap;
  142643. private _prefilterOnLoad;
  142644. private _textureMatrix;
  142645. private _size;
  142646. private _onLoad;
  142647. private _onError;
  142648. /**
  142649. * The texture URL.
  142650. */
  142651. url: string;
  142652. protected _isBlocking: boolean;
  142653. /**
  142654. * Sets wether or not the texture is blocking during loading.
  142655. */
  142656. set isBlocking(value: boolean);
  142657. /**
  142658. * Gets wether or not the texture is blocking during loading.
  142659. */
  142660. get isBlocking(): boolean;
  142661. protected _rotationY: number;
  142662. /**
  142663. * Sets texture matrix rotation angle around Y axis in radians.
  142664. */
  142665. set rotationY(value: number);
  142666. /**
  142667. * Gets texture matrix rotation angle around Y axis radians.
  142668. */
  142669. get rotationY(): number;
  142670. /**
  142671. * Gets or sets the center of the bounding box associated with the cube texture
  142672. * It must define where the camera used to render the texture was set
  142673. */
  142674. boundingBoxPosition: Vector3;
  142675. private _boundingBoxSize;
  142676. /**
  142677. * Gets or sets the size of the bounding box associated with the cube texture
  142678. * When defined, the cubemap will switch to local mode
  142679. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  142680. * @example https://www.babylonjs-playground.com/#RNASML
  142681. */
  142682. set boundingBoxSize(value: Vector3);
  142683. get boundingBoxSize(): Vector3;
  142684. /**
  142685. * Instantiates an HDRTexture from the following parameters.
  142686. *
  142687. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  142688. * @param sceneOrEngine The scene or engine the texture will be used in
  142689. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142690. * @param noMipmap Forces to not generate the mipmap if true
  142691. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  142692. * @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)
  142693. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  142694. */
  142695. 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>);
  142696. /**
  142697. * Get the current class name of the texture useful for serialization or dynamic coding.
  142698. * @returns "HDRCubeTexture"
  142699. */
  142700. getClassName(): string;
  142701. /**
  142702. * Occurs when the file is raw .hdr file.
  142703. */
  142704. private loadTexture;
  142705. clone(): HDRCubeTexture;
  142706. delayLoad(): void;
  142707. /**
  142708. * Get the texture reflection matrix used to rotate/transform the reflection.
  142709. * @returns the reflection matrix
  142710. */
  142711. getReflectionTextureMatrix(): Matrix;
  142712. /**
  142713. * Set the texture reflection matrix used to rotate/transform the reflection.
  142714. * @param value Define the reflection matrix to set
  142715. */
  142716. setReflectionTextureMatrix(value: Matrix): void;
  142717. /**
  142718. * Parses a JSON representation of an HDR Texture in order to create the texture
  142719. * @param parsedTexture Define the JSON representation
  142720. * @param scene Define the scene the texture should be created in
  142721. * @param rootUrl Define the root url in case we need to load relative dependencies
  142722. * @returns the newly created texture after parsing
  142723. */
  142724. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  142725. serialize(): any;
  142726. }
  142727. }
  142728. declare module BABYLON {
  142729. /**
  142730. * Class used to control physics engine
  142731. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142732. */
  142733. export class PhysicsEngine implements IPhysicsEngine {
  142734. private _physicsPlugin;
  142735. /**
  142736. * Global value used to control the smallest number supported by the simulation
  142737. */
  142738. static Epsilon: number;
  142739. private _impostors;
  142740. private _joints;
  142741. private _subTimeStep;
  142742. /**
  142743. * Gets the gravity vector used by the simulation
  142744. */
  142745. gravity: Vector3;
  142746. /**
  142747. * Factory used to create the default physics plugin.
  142748. * @returns The default physics plugin
  142749. */
  142750. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  142751. /**
  142752. * Creates a new Physics Engine
  142753. * @param gravity defines the gravity vector used by the simulation
  142754. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  142755. */
  142756. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  142757. /**
  142758. * Sets the gravity vector used by the simulation
  142759. * @param gravity defines the gravity vector to use
  142760. */
  142761. setGravity(gravity: Vector3): void;
  142762. /**
  142763. * Set the time step of the physics engine.
  142764. * Default is 1/60.
  142765. * To slow it down, enter 1/600 for example.
  142766. * To speed it up, 1/30
  142767. * @param newTimeStep defines the new timestep to apply to this world.
  142768. */
  142769. setTimeStep(newTimeStep?: number): void;
  142770. /**
  142771. * Get the time step of the physics engine.
  142772. * @returns the current time step
  142773. */
  142774. getTimeStep(): number;
  142775. /**
  142776. * Set the sub time step of the physics engine.
  142777. * Default is 0 meaning there is no sub steps
  142778. * To increase physics resolution precision, set a small value (like 1 ms)
  142779. * @param subTimeStep defines the new sub timestep used for physics resolution.
  142780. */
  142781. setSubTimeStep(subTimeStep?: number): void;
  142782. /**
  142783. * Get the sub time step of the physics engine.
  142784. * @returns the current sub time step
  142785. */
  142786. getSubTimeStep(): number;
  142787. /**
  142788. * Release all resources
  142789. */
  142790. dispose(): void;
  142791. /**
  142792. * Gets the name of the current physics plugin
  142793. * @returns the name of the plugin
  142794. */
  142795. getPhysicsPluginName(): string;
  142796. /**
  142797. * Adding a new impostor for the impostor tracking.
  142798. * This will be done by the impostor itself.
  142799. * @param impostor the impostor to add
  142800. */
  142801. addImpostor(impostor: PhysicsImpostor): void;
  142802. /**
  142803. * Remove an impostor from the engine.
  142804. * This impostor and its mesh will not longer be updated by the physics engine.
  142805. * @param impostor the impostor to remove
  142806. */
  142807. removeImpostor(impostor: PhysicsImpostor): void;
  142808. /**
  142809. * Add a joint to the physics engine
  142810. * @param mainImpostor defines the main impostor to which the joint is added.
  142811. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  142812. * @param joint defines the joint that will connect both impostors.
  142813. */
  142814. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142815. /**
  142816. * Removes a joint from the simulation
  142817. * @param mainImpostor defines the impostor used with the joint
  142818. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  142819. * @param joint defines the joint to remove
  142820. */
  142821. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  142822. /**
  142823. * Called by the scene. No need to call it.
  142824. * @param delta defines the timespam between frames
  142825. */
  142826. _step(delta: number): void;
  142827. /**
  142828. * Gets the current plugin used to run the simulation
  142829. * @returns current plugin
  142830. */
  142831. getPhysicsPlugin(): IPhysicsEnginePlugin;
  142832. /**
  142833. * Gets the list of physic impostors
  142834. * @returns an array of PhysicsImpostor
  142835. */
  142836. getImpostors(): Array<PhysicsImpostor>;
  142837. /**
  142838. * Gets the impostor for a physics enabled object
  142839. * @param object defines the object impersonated by the impostor
  142840. * @returns the PhysicsImpostor or null if not found
  142841. */
  142842. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  142843. /**
  142844. * Gets the impostor for a physics body object
  142845. * @param body defines physics body used by the impostor
  142846. * @returns the PhysicsImpostor or null if not found
  142847. */
  142848. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  142849. /**
  142850. * Does a raycast in the physics world
  142851. * @param from when should the ray start?
  142852. * @param to when should the ray end?
  142853. * @returns PhysicsRaycastResult
  142854. */
  142855. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142856. }
  142857. }
  142858. declare module BABYLON {
  142859. /** @hidden */
  142860. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  142861. private _useDeltaForWorldStep;
  142862. world: any;
  142863. name: string;
  142864. private _physicsMaterials;
  142865. private _fixedTimeStep;
  142866. private _cannonRaycastResult;
  142867. private _raycastResult;
  142868. private _physicsBodysToRemoveAfterStep;
  142869. private _firstFrame;
  142870. BJSCANNON: any;
  142871. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  142872. setGravity(gravity: Vector3): void;
  142873. setTimeStep(timeStep: number): void;
  142874. getTimeStep(): number;
  142875. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142876. private _removeMarkedPhysicsBodiesFromWorld;
  142877. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142878. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142879. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142880. private _processChildMeshes;
  142881. removePhysicsBody(impostor: PhysicsImpostor): void;
  142882. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142883. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142884. private _addMaterial;
  142885. private _checkWithEpsilon;
  142886. private _createShape;
  142887. private _createHeightmap;
  142888. private _minus90X;
  142889. private _plus90X;
  142890. private _tmpPosition;
  142891. private _tmpDeltaPosition;
  142892. private _tmpUnityRotation;
  142893. private _updatePhysicsBodyTransformation;
  142894. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142895. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142896. isSupported(): boolean;
  142897. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142898. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142899. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142900. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142901. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142902. getBodyMass(impostor: PhysicsImpostor): number;
  142903. getBodyFriction(impostor: PhysicsImpostor): number;
  142904. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142905. getBodyRestitution(impostor: PhysicsImpostor): number;
  142906. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142907. sleepBody(impostor: PhysicsImpostor): void;
  142908. wakeUpBody(impostor: PhysicsImpostor): void;
  142909. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  142910. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  142911. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  142912. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142913. getRadius(impostor: PhysicsImpostor): number;
  142914. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142915. dispose(): void;
  142916. private _extendNamespace;
  142917. /**
  142918. * Does a raycast in the physics world
  142919. * @param from when should the ray start?
  142920. * @param to when should the ray end?
  142921. * @returns PhysicsRaycastResult
  142922. */
  142923. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142924. }
  142925. }
  142926. declare module BABYLON {
  142927. /** @hidden */
  142928. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  142929. private _useDeltaForWorldStep;
  142930. world: any;
  142931. name: string;
  142932. BJSOIMO: any;
  142933. private _raycastResult;
  142934. private _fixedTimeStep;
  142935. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  142936. setGravity(gravity: Vector3): void;
  142937. setTimeStep(timeStep: number): void;
  142938. getTimeStep(): number;
  142939. private _tmpImpostorsArray;
  142940. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  142941. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142942. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  142943. generatePhysicsBody(impostor: PhysicsImpostor): void;
  142944. private _tmpPositionVector;
  142945. removePhysicsBody(impostor: PhysicsImpostor): void;
  142946. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  142947. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  142948. isSupported(): boolean;
  142949. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  142950. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  142951. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142952. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  142953. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142954. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  142955. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  142956. getBodyMass(impostor: PhysicsImpostor): number;
  142957. getBodyFriction(impostor: PhysicsImpostor): number;
  142958. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  142959. getBodyRestitution(impostor: PhysicsImpostor): number;
  142960. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  142961. sleepBody(impostor: PhysicsImpostor): void;
  142962. wakeUpBody(impostor: PhysicsImpostor): void;
  142963. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  142964. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  142965. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  142966. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  142967. getRadius(impostor: PhysicsImpostor): number;
  142968. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  142969. dispose(): void;
  142970. /**
  142971. * Does a raycast in the physics world
  142972. * @param from when should the ray start?
  142973. * @param to when should the ray end?
  142974. * @returns PhysicsRaycastResult
  142975. */
  142976. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  142977. }
  142978. }
  142979. declare module BABYLON {
  142980. /**
  142981. * AmmoJS Physics plugin
  142982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  142983. * @see https://github.com/kripken/ammo.js/
  142984. */
  142985. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  142986. private _useDeltaForWorldStep;
  142987. /**
  142988. * Reference to the Ammo library
  142989. */
  142990. bjsAMMO: any;
  142991. /**
  142992. * Created ammoJS world which physics bodies are added to
  142993. */
  142994. world: any;
  142995. /**
  142996. * Name of the plugin
  142997. */
  142998. name: string;
  142999. private _timeStep;
  143000. private _fixedTimeStep;
  143001. private _maxSteps;
  143002. private _tmpQuaternion;
  143003. private _tmpAmmoTransform;
  143004. private _tmpAmmoQuaternion;
  143005. private _tmpAmmoConcreteContactResultCallback;
  143006. private _collisionConfiguration;
  143007. private _dispatcher;
  143008. private _overlappingPairCache;
  143009. private _solver;
  143010. private _softBodySolver;
  143011. private _tmpAmmoVectorA;
  143012. private _tmpAmmoVectorB;
  143013. private _tmpAmmoVectorC;
  143014. private _tmpAmmoVectorD;
  143015. private _tmpContactCallbackResult;
  143016. private _tmpAmmoVectorRCA;
  143017. private _tmpAmmoVectorRCB;
  143018. private _raycastResult;
  143019. private _tmpContactPoint;
  143020. private static readonly DISABLE_COLLISION_FLAG;
  143021. private static readonly KINEMATIC_FLAG;
  143022. private static readonly DISABLE_DEACTIVATION_FLAG;
  143023. /**
  143024. * Initializes the ammoJS plugin
  143025. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  143026. * @param ammoInjection can be used to inject your own ammo reference
  143027. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  143028. */
  143029. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  143030. /**
  143031. * Sets the gravity of the physics world (m/(s^2))
  143032. * @param gravity Gravity to set
  143033. */
  143034. setGravity(gravity: Vector3): void;
  143035. /**
  143036. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  143037. * @param timeStep timestep to use in seconds
  143038. */
  143039. setTimeStep(timeStep: number): void;
  143040. /**
  143041. * 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)
  143042. * @param fixedTimeStep fixedTimeStep to use in seconds
  143043. */
  143044. setFixedTimeStep(fixedTimeStep: number): void;
  143045. /**
  143046. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  143047. * @param maxSteps the maximum number of steps by the physics engine per frame
  143048. */
  143049. setMaxSteps(maxSteps: number): void;
  143050. /**
  143051. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  143052. * @returns the current timestep in seconds
  143053. */
  143054. getTimeStep(): number;
  143055. /**
  143056. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  143057. */
  143058. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  143059. private _isImpostorInContact;
  143060. private _isImpostorPairInContact;
  143061. private _stepSimulation;
  143062. /**
  143063. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  143064. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  143065. * After the step the babylon meshes are set to the position of the physics imposters
  143066. * @param delta amount of time to step forward
  143067. * @param impostors array of imposters to update before/after the step
  143068. */
  143069. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  143070. /**
  143071. * Update babylon mesh to match physics world object
  143072. * @param impostor imposter to match
  143073. */
  143074. private _afterSoftStep;
  143075. /**
  143076. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  143077. * @param impostor imposter to match
  143078. */
  143079. private _ropeStep;
  143080. /**
  143081. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  143082. * @param impostor imposter to match
  143083. */
  143084. private _softbodyOrClothStep;
  143085. private _tmpMatrix;
  143086. /**
  143087. * Applies an impulse on the imposter
  143088. * @param impostor imposter to apply impulse to
  143089. * @param force amount of force to be applied to the imposter
  143090. * @param contactPoint the location to apply the impulse on the imposter
  143091. */
  143092. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143093. /**
  143094. * Applies a force on the imposter
  143095. * @param impostor imposter to apply force
  143096. * @param force amount of force to be applied to the imposter
  143097. * @param contactPoint the location to apply the force on the imposter
  143098. */
  143099. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  143100. /**
  143101. * Creates a physics body using the plugin
  143102. * @param impostor the imposter to create the physics body on
  143103. */
  143104. generatePhysicsBody(impostor: PhysicsImpostor): void;
  143105. /**
  143106. * Removes the physics body from the imposter and disposes of the body's memory
  143107. * @param impostor imposter to remove the physics body from
  143108. */
  143109. removePhysicsBody(impostor: PhysicsImpostor): void;
  143110. /**
  143111. * Generates a joint
  143112. * @param impostorJoint the imposter joint to create the joint with
  143113. */
  143114. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  143115. /**
  143116. * Removes a joint
  143117. * @param impostorJoint the imposter joint to remove the joint from
  143118. */
  143119. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  143120. private _addMeshVerts;
  143121. /**
  143122. * Initialise the soft body vertices to match its object's (mesh) vertices
  143123. * Softbody vertices (nodes) are in world space and to match this
  143124. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  143125. * @param impostor to create the softbody for
  143126. */
  143127. private _softVertexData;
  143128. /**
  143129. * Create an impostor's soft body
  143130. * @param impostor to create the softbody for
  143131. */
  143132. private _createSoftbody;
  143133. /**
  143134. * Create cloth for an impostor
  143135. * @param impostor to create the softbody for
  143136. */
  143137. private _createCloth;
  143138. /**
  143139. * Create rope for an impostor
  143140. * @param impostor to create the softbody for
  143141. */
  143142. private _createRope;
  143143. /**
  143144. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  143145. * @param impostor to create the custom physics shape for
  143146. */
  143147. private _createCustom;
  143148. private _addHullVerts;
  143149. private _createShape;
  143150. /**
  143151. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  143152. * @param impostor imposter containing the physics body and babylon object
  143153. */
  143154. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  143155. /**
  143156. * Sets the babylon object's position/rotation from the physics body's position/rotation
  143157. * @param impostor imposter containing the physics body and babylon object
  143158. * @param newPosition new position
  143159. * @param newRotation new rotation
  143160. */
  143161. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  143162. /**
  143163. * If this plugin is supported
  143164. * @returns true if its supported
  143165. */
  143166. isSupported(): boolean;
  143167. /**
  143168. * Sets the linear velocity of the physics body
  143169. * @param impostor imposter to set the velocity on
  143170. * @param velocity velocity to set
  143171. */
  143172. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143173. /**
  143174. * Sets the angular velocity of the physics body
  143175. * @param impostor imposter to set the velocity on
  143176. * @param velocity velocity to set
  143177. */
  143178. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  143179. /**
  143180. * gets the linear velocity
  143181. * @param impostor imposter to get linear velocity from
  143182. * @returns linear velocity
  143183. */
  143184. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143185. /**
  143186. * gets the angular velocity
  143187. * @param impostor imposter to get angular velocity from
  143188. * @returns angular velocity
  143189. */
  143190. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  143191. /**
  143192. * Sets the mass of physics body
  143193. * @param impostor imposter to set the mass on
  143194. * @param mass mass to set
  143195. */
  143196. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  143197. /**
  143198. * Gets the mass of the physics body
  143199. * @param impostor imposter to get the mass from
  143200. * @returns mass
  143201. */
  143202. getBodyMass(impostor: PhysicsImpostor): number;
  143203. /**
  143204. * Gets friction of the impostor
  143205. * @param impostor impostor to get friction from
  143206. * @returns friction value
  143207. */
  143208. getBodyFriction(impostor: PhysicsImpostor): number;
  143209. /**
  143210. * Sets friction of the impostor
  143211. * @param impostor impostor to set friction on
  143212. * @param friction friction value
  143213. */
  143214. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  143215. /**
  143216. * Gets restitution of the impostor
  143217. * @param impostor impostor to get restitution from
  143218. * @returns restitution value
  143219. */
  143220. getBodyRestitution(impostor: PhysicsImpostor): number;
  143221. /**
  143222. * Sets resitution of the impostor
  143223. * @param impostor impostor to set resitution on
  143224. * @param restitution resitution value
  143225. */
  143226. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  143227. /**
  143228. * Gets pressure inside the impostor
  143229. * @param impostor impostor to get pressure from
  143230. * @returns pressure value
  143231. */
  143232. getBodyPressure(impostor: PhysicsImpostor): number;
  143233. /**
  143234. * Sets pressure inside a soft body impostor
  143235. * Cloth and rope must remain 0 pressure
  143236. * @param impostor impostor to set pressure on
  143237. * @param pressure pressure value
  143238. */
  143239. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  143240. /**
  143241. * Gets stiffness of the impostor
  143242. * @param impostor impostor to get stiffness from
  143243. * @returns pressure value
  143244. */
  143245. getBodyStiffness(impostor: PhysicsImpostor): number;
  143246. /**
  143247. * Sets stiffness of the impostor
  143248. * @param impostor impostor to set stiffness on
  143249. * @param stiffness stiffness value from 0 to 1
  143250. */
  143251. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  143252. /**
  143253. * Gets velocityIterations of the impostor
  143254. * @param impostor impostor to get velocity iterations from
  143255. * @returns velocityIterations value
  143256. */
  143257. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  143258. /**
  143259. * Sets velocityIterations of the impostor
  143260. * @param impostor impostor to set velocity iterations on
  143261. * @param velocityIterations velocityIterations value
  143262. */
  143263. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  143264. /**
  143265. * Gets positionIterations of the impostor
  143266. * @param impostor impostor to get position iterations from
  143267. * @returns positionIterations value
  143268. */
  143269. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  143270. /**
  143271. * Sets positionIterations of the impostor
  143272. * @param impostor impostor to set position on
  143273. * @param positionIterations positionIterations value
  143274. */
  143275. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  143276. /**
  143277. * Append an anchor to a cloth object
  143278. * @param impostor is the cloth impostor to add anchor to
  143279. * @param otherImpostor is the rigid impostor to anchor to
  143280. * @param width ratio across width from 0 to 1
  143281. * @param height ratio up height from 0 to 1
  143282. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  143283. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  143284. */
  143285. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  143286. /**
  143287. * Append an hook to a rope object
  143288. * @param impostor is the rope impostor to add hook to
  143289. * @param otherImpostor is the rigid impostor to hook to
  143290. * @param length ratio along the rope from 0 to 1
  143291. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  143292. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  143293. */
  143294. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  143295. /**
  143296. * Sleeps the physics body and stops it from being active
  143297. * @param impostor impostor to sleep
  143298. */
  143299. sleepBody(impostor: PhysicsImpostor): void;
  143300. /**
  143301. * Activates the physics body
  143302. * @param impostor impostor to activate
  143303. */
  143304. wakeUpBody(impostor: PhysicsImpostor): void;
  143305. /**
  143306. * Updates the distance parameters of the joint
  143307. * @param joint joint to update
  143308. * @param maxDistance maximum distance of the joint
  143309. * @param minDistance minimum distance of the joint
  143310. */
  143311. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  143312. /**
  143313. * Sets a motor on the joint
  143314. * @param joint joint to set motor on
  143315. * @param speed speed of the motor
  143316. * @param maxForce maximum force of the motor
  143317. * @param motorIndex index of the motor
  143318. */
  143319. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  143320. /**
  143321. * Sets the motors limit
  143322. * @param joint joint to set limit on
  143323. * @param upperLimit upper limit
  143324. * @param lowerLimit lower limit
  143325. */
  143326. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  143327. /**
  143328. * Syncs the position and rotation of a mesh with the impostor
  143329. * @param mesh mesh to sync
  143330. * @param impostor impostor to update the mesh with
  143331. */
  143332. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  143333. /**
  143334. * Gets the radius of the impostor
  143335. * @param impostor impostor to get radius from
  143336. * @returns the radius
  143337. */
  143338. getRadius(impostor: PhysicsImpostor): number;
  143339. /**
  143340. * Gets the box size of the impostor
  143341. * @param impostor impostor to get box size from
  143342. * @param result the resulting box size
  143343. */
  143344. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  143345. /**
  143346. * Disposes of the impostor
  143347. */
  143348. dispose(): void;
  143349. /**
  143350. * Does a raycast in the physics world
  143351. * @param from when should the ray start?
  143352. * @param to when should the ray end?
  143353. * @returns PhysicsRaycastResult
  143354. */
  143355. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  143356. }
  143357. }
  143358. declare module BABYLON {
  143359. interface AbstractScene {
  143360. /**
  143361. * The list of reflection probes added to the scene
  143362. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  143363. */
  143364. reflectionProbes: Array<ReflectionProbe>;
  143365. /**
  143366. * Removes the given reflection probe from this scene.
  143367. * @param toRemove The reflection probe to remove
  143368. * @returns The index of the removed reflection probe
  143369. */
  143370. removeReflectionProbe(toRemove: ReflectionProbe): number;
  143371. /**
  143372. * Adds the given reflection probe to this scene.
  143373. * @param newReflectionProbe The reflection probe to add
  143374. */
  143375. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  143376. }
  143377. /**
  143378. * Class used to generate realtime reflection / refraction cube textures
  143379. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  143380. */
  143381. export class ReflectionProbe {
  143382. /** defines the name of the probe */
  143383. name: string;
  143384. private _scene;
  143385. private _renderTargetTexture;
  143386. private _projectionMatrix;
  143387. private _viewMatrix;
  143388. private _target;
  143389. private _add;
  143390. private _attachedMesh;
  143391. private _invertYAxis;
  143392. /** Gets or sets probe position (center of the cube map) */
  143393. position: Vector3;
  143394. /**
  143395. * Creates a new reflection probe
  143396. * @param name defines the name of the probe
  143397. * @param size defines the texture resolution (for each face)
  143398. * @param scene defines the hosting scene
  143399. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  143400. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  143401. */
  143402. constructor(
  143403. /** defines the name of the probe */
  143404. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  143405. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  143406. get samples(): number;
  143407. set samples(value: number);
  143408. /** Gets or sets the refresh rate to use (on every frame by default) */
  143409. get refreshRate(): number;
  143410. set refreshRate(value: number);
  143411. /**
  143412. * Gets the hosting scene
  143413. * @returns a Scene
  143414. */
  143415. getScene(): Scene;
  143416. /** Gets the internal CubeTexture used to render to */
  143417. get cubeTexture(): RenderTargetTexture;
  143418. /** Gets the list of meshes to render */
  143419. get renderList(): Nullable<AbstractMesh[]>;
  143420. /**
  143421. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  143422. * @param mesh defines the mesh to attach to
  143423. */
  143424. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  143425. /**
  143426. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  143427. * @param renderingGroupId The rendering group id corresponding to its index
  143428. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  143429. */
  143430. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  143431. /**
  143432. * Clean all associated resources
  143433. */
  143434. dispose(): void;
  143435. /**
  143436. * Converts the reflection probe information to a readable string for debug purpose.
  143437. * @param fullDetails Supports for multiple levels of logging within scene loading
  143438. * @returns the human readable reflection probe info
  143439. */
  143440. toString(fullDetails?: boolean): string;
  143441. /**
  143442. * Get the class name of the relfection probe.
  143443. * @returns "ReflectionProbe"
  143444. */
  143445. getClassName(): string;
  143446. /**
  143447. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  143448. * @returns The JSON representation of the texture
  143449. */
  143450. serialize(): any;
  143451. /**
  143452. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  143453. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  143454. * @param scene Define the scene the parsed reflection probe should be instantiated in
  143455. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  143456. * @returns The parsed reflection probe if successful
  143457. */
  143458. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  143459. }
  143460. }
  143461. declare module BABYLON {
  143462. /** @hidden */
  143463. export var _BabylonLoaderRegistered: boolean;
  143464. /**
  143465. * Helps setting up some configuration for the babylon file loader.
  143466. */
  143467. export class BabylonFileLoaderConfiguration {
  143468. /**
  143469. * The loader does not allow injecting custom physix engine into the plugins.
  143470. * Unfortunately in ES6, we need to manually inject them into the plugin.
  143471. * So you could set this variable to your engine import to make it work.
  143472. */
  143473. static LoaderInjectedPhysicsEngine: any;
  143474. }
  143475. }
  143476. declare module BABYLON {
  143477. /**
  143478. * The Physically based simple base material of BJS.
  143479. *
  143480. * This enables better naming and convention enforcements on top of the pbrMaterial.
  143481. * It is used as the base class for both the specGloss and metalRough conventions.
  143482. */
  143483. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  143484. /**
  143485. * Number of Simultaneous lights allowed on the material.
  143486. */
  143487. maxSimultaneousLights: number;
  143488. /**
  143489. * If sets to true, disables all the lights affecting the material.
  143490. */
  143491. disableLighting: boolean;
  143492. /**
  143493. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  143494. */
  143495. environmentTexture: BaseTexture;
  143496. /**
  143497. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  143498. */
  143499. invertNormalMapX: boolean;
  143500. /**
  143501. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  143502. */
  143503. invertNormalMapY: boolean;
  143504. /**
  143505. * Normal map used in the model.
  143506. */
  143507. normalTexture: BaseTexture;
  143508. /**
  143509. * Emissivie color used to self-illuminate the model.
  143510. */
  143511. emissiveColor: Color3;
  143512. /**
  143513. * Emissivie texture used to self-illuminate the model.
  143514. */
  143515. emissiveTexture: BaseTexture;
  143516. /**
  143517. * Occlusion Channel Strenght.
  143518. */
  143519. occlusionStrength: number;
  143520. /**
  143521. * Occlusion Texture of the material (adding extra occlusion effects).
  143522. */
  143523. occlusionTexture: BaseTexture;
  143524. /**
  143525. * Defines the alpha limits in alpha test mode.
  143526. */
  143527. alphaCutOff: number;
  143528. /**
  143529. * Gets the current double sided mode.
  143530. */
  143531. get doubleSided(): boolean;
  143532. /**
  143533. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  143534. */
  143535. set doubleSided(value: boolean);
  143536. /**
  143537. * Stores the pre-calculated light information of a mesh in a texture.
  143538. */
  143539. lightmapTexture: BaseTexture;
  143540. /**
  143541. * If true, the light map contains occlusion information instead of lighting info.
  143542. */
  143543. useLightmapAsShadowmap: boolean;
  143544. /**
  143545. * Instantiates a new PBRMaterial instance.
  143546. *
  143547. * @param name The material name
  143548. * @param scene The scene the material will be use in.
  143549. */
  143550. constructor(name: string, scene: Scene);
  143551. getClassName(): string;
  143552. }
  143553. }
  143554. declare module BABYLON {
  143555. /**
  143556. * The PBR material of BJS following the metal roughness convention.
  143557. *
  143558. * This fits to the PBR convention in the GLTF definition:
  143559. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  143560. */
  143561. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  143562. /**
  143563. * The base color has two different interpretations depending on the value of metalness.
  143564. * When the material is a metal, the base color is the specific measured reflectance value
  143565. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  143566. * of the material.
  143567. */
  143568. baseColor: Color3;
  143569. /**
  143570. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  143571. * well as opacity information in the alpha channel.
  143572. */
  143573. baseTexture: BaseTexture;
  143574. /**
  143575. * Specifies the metallic scalar value of the material.
  143576. * Can also be used to scale the metalness values of the metallic texture.
  143577. */
  143578. metallic: number;
  143579. /**
  143580. * Specifies the roughness scalar value of the material.
  143581. * Can also be used to scale the roughness values of the metallic texture.
  143582. */
  143583. roughness: number;
  143584. /**
  143585. * Texture containing both the metallic value in the B channel and the
  143586. * roughness value in the G channel to keep better precision.
  143587. */
  143588. metallicRoughnessTexture: BaseTexture;
  143589. /**
  143590. * Instantiates a new PBRMetalRoughnessMaterial instance.
  143591. *
  143592. * @param name The material name
  143593. * @param scene The scene the material will be use in.
  143594. */
  143595. constructor(name: string, scene: Scene);
  143596. /**
  143597. * Return the currrent class name of the material.
  143598. */
  143599. getClassName(): string;
  143600. /**
  143601. * Makes a duplicate of the current material.
  143602. * @param name - name to use for the new material.
  143603. */
  143604. clone(name: string): PBRMetallicRoughnessMaterial;
  143605. /**
  143606. * Serialize the material to a parsable JSON object.
  143607. */
  143608. serialize(): any;
  143609. /**
  143610. * Parses a JSON object correponding to the serialize function.
  143611. */
  143612. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  143613. }
  143614. }
  143615. declare module BABYLON {
  143616. /**
  143617. * The PBR material of BJS following the specular glossiness convention.
  143618. *
  143619. * This fits to the PBR convention in the GLTF definition:
  143620. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  143621. */
  143622. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  143623. /**
  143624. * Specifies the diffuse color of the material.
  143625. */
  143626. diffuseColor: Color3;
  143627. /**
  143628. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  143629. * channel.
  143630. */
  143631. diffuseTexture: BaseTexture;
  143632. /**
  143633. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  143634. */
  143635. specularColor: Color3;
  143636. /**
  143637. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  143638. */
  143639. glossiness: number;
  143640. /**
  143641. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  143642. */
  143643. specularGlossinessTexture: BaseTexture;
  143644. /**
  143645. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  143646. *
  143647. * @param name The material name
  143648. * @param scene The scene the material will be use in.
  143649. */
  143650. constructor(name: string, scene: Scene);
  143651. /**
  143652. * Return the currrent class name of the material.
  143653. */
  143654. getClassName(): string;
  143655. /**
  143656. * Makes a duplicate of the current material.
  143657. * @param name - name to use for the new material.
  143658. */
  143659. clone(name: string): PBRSpecularGlossinessMaterial;
  143660. /**
  143661. * Serialize the material to a parsable JSON object.
  143662. */
  143663. serialize(): any;
  143664. /**
  143665. * Parses a JSON object correponding to the serialize function.
  143666. */
  143667. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  143668. }
  143669. }
  143670. declare module BABYLON {
  143671. /**
  143672. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  143673. * It can help converting any input color in a desired output one. This can then be used to create effects
  143674. * from sepia, black and white to sixties or futuristic rendering...
  143675. *
  143676. * The only supported format is currently 3dl.
  143677. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  143678. */
  143679. export class ColorGradingTexture extends BaseTexture {
  143680. /**
  143681. * The texture URL.
  143682. */
  143683. url: string;
  143684. /**
  143685. * Empty line regex stored for GC.
  143686. */
  143687. private static _noneEmptyLineRegex;
  143688. private _textureMatrix;
  143689. private _onLoad;
  143690. /**
  143691. * Instantiates a ColorGradingTexture from the following parameters.
  143692. *
  143693. * @param url The location of the color gradind data (currently only supporting 3dl)
  143694. * @param sceneOrEngine The scene or engine the texture will be used in
  143695. * @param onLoad defines a callback triggered when the texture has been loaded
  143696. */
  143697. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  143698. /**
  143699. * Fires the onload event from the constructor if requested.
  143700. */
  143701. private _triggerOnLoad;
  143702. /**
  143703. * Returns the texture matrix used in most of the material.
  143704. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  143705. */
  143706. getTextureMatrix(): Matrix;
  143707. /**
  143708. * Occurs when the file being loaded is a .3dl LUT file.
  143709. */
  143710. private load3dlTexture;
  143711. /**
  143712. * Starts the loading process of the texture.
  143713. */
  143714. private loadTexture;
  143715. /**
  143716. * Clones the color gradind texture.
  143717. */
  143718. clone(): ColorGradingTexture;
  143719. /**
  143720. * Called during delayed load for textures.
  143721. */
  143722. delayLoad(): void;
  143723. /**
  143724. * Parses a color grading texture serialized by Babylon.
  143725. * @param parsedTexture The texture information being parsedTexture
  143726. * @param scene The scene to load the texture in
  143727. * @param rootUrl The root url of the data assets to load
  143728. * @return A color gradind texture
  143729. */
  143730. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  143731. /**
  143732. * Serializes the LUT texture to json format.
  143733. */
  143734. serialize(): any;
  143735. }
  143736. }
  143737. declare module BABYLON {
  143738. /**
  143739. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  143740. */
  143741. export class EquiRectangularCubeTexture extends BaseTexture {
  143742. /** The six faces of the cube. */
  143743. private static _FacesMapping;
  143744. private _noMipmap;
  143745. private _onLoad;
  143746. private _onError;
  143747. /** The size of the cubemap. */
  143748. private _size;
  143749. /** The buffer of the image. */
  143750. private _buffer;
  143751. /** The width of the input image. */
  143752. private _width;
  143753. /** The height of the input image. */
  143754. private _height;
  143755. /** The URL to the image. */
  143756. url: string;
  143757. /**
  143758. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  143759. * @param url The location of the image
  143760. * @param scene The scene the texture will be used in
  143761. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  143762. * @param noMipmap Forces to not generate the mipmap if true
  143763. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  143764. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  143765. * @param onLoad — defines a callback called when texture is loaded
  143766. * @param onError — defines a callback called if there is an error
  143767. */
  143768. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  143769. /**
  143770. * Load the image data, by putting the image on a canvas and extracting its buffer.
  143771. */
  143772. private loadImage;
  143773. /**
  143774. * Convert the image buffer into a cubemap and create a CubeTexture.
  143775. */
  143776. private loadTexture;
  143777. /**
  143778. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  143779. * @param buffer The ArrayBuffer that should be converted.
  143780. * @returns The buffer as Float32Array.
  143781. */
  143782. private getFloat32ArrayFromArrayBuffer;
  143783. /**
  143784. * Get the current class name of the texture useful for serialization or dynamic coding.
  143785. * @returns "EquiRectangularCubeTexture"
  143786. */
  143787. getClassName(): string;
  143788. /**
  143789. * Create a clone of the current EquiRectangularCubeTexture and return it.
  143790. * @returns A clone of the current EquiRectangularCubeTexture.
  143791. */
  143792. clone(): EquiRectangularCubeTexture;
  143793. }
  143794. }
  143795. declare module BABYLON {
  143796. /**
  143797. * Defines the options related to the creation of an HtmlElementTexture
  143798. */
  143799. export interface IHtmlElementTextureOptions {
  143800. /**
  143801. * Defines wether mip maps should be created or not.
  143802. */
  143803. generateMipMaps?: boolean;
  143804. /**
  143805. * Defines the sampling mode of the texture.
  143806. */
  143807. samplingMode?: number;
  143808. /**
  143809. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  143810. */
  143811. engine: Nullable<ThinEngine>;
  143812. /**
  143813. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  143814. */
  143815. scene: Nullable<Scene>;
  143816. }
  143817. /**
  143818. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  143819. * To be as efficient as possible depending on your constraints nothing aside the first upload
  143820. * is automatically managed.
  143821. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  143822. * in your application.
  143823. *
  143824. * As the update is not automatic, you need to call them manually.
  143825. */
  143826. export class HtmlElementTexture extends BaseTexture {
  143827. /**
  143828. * The texture URL.
  143829. */
  143830. element: HTMLVideoElement | HTMLCanvasElement;
  143831. private static readonly DefaultOptions;
  143832. private _textureMatrix;
  143833. private _isVideo;
  143834. private _generateMipMaps;
  143835. private _samplingMode;
  143836. /**
  143837. * Instantiates a HtmlElementTexture from the following parameters.
  143838. *
  143839. * @param name Defines the name of the texture
  143840. * @param element Defines the video or canvas the texture is filled with
  143841. * @param options Defines the other none mandatory texture creation options
  143842. */
  143843. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  143844. private _createInternalTexture;
  143845. /**
  143846. * Returns the texture matrix used in most of the material.
  143847. */
  143848. getTextureMatrix(): Matrix;
  143849. /**
  143850. * Updates the content of the texture.
  143851. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  143852. */
  143853. update(invertY?: Nullable<boolean>): void;
  143854. }
  143855. }
  143856. declare module BABYLON {
  143857. /**
  143858. * Based on jsTGALoader - Javascript loader for TGA file
  143859. * By Vincent Thibault
  143860. * @see http://blog.robrowser.com/javascript-tga-loader.html
  143861. */
  143862. export class TGATools {
  143863. private static _TYPE_INDEXED;
  143864. private static _TYPE_RGB;
  143865. private static _TYPE_GREY;
  143866. private static _TYPE_RLE_INDEXED;
  143867. private static _TYPE_RLE_RGB;
  143868. private static _TYPE_RLE_GREY;
  143869. private static _ORIGIN_MASK;
  143870. private static _ORIGIN_SHIFT;
  143871. private static _ORIGIN_BL;
  143872. private static _ORIGIN_BR;
  143873. private static _ORIGIN_UL;
  143874. private static _ORIGIN_UR;
  143875. /**
  143876. * Gets the header of a TGA file
  143877. * @param data defines the TGA data
  143878. * @returns the header
  143879. */
  143880. static GetTGAHeader(data: Uint8Array): any;
  143881. /**
  143882. * Uploads TGA content to a Babylon Texture
  143883. * @hidden
  143884. */
  143885. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  143886. /** @hidden */
  143887. 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;
  143888. /** @hidden */
  143889. 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;
  143890. /** @hidden */
  143891. 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;
  143892. /** @hidden */
  143893. 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;
  143894. /** @hidden */
  143895. 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;
  143896. /** @hidden */
  143897. 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;
  143898. }
  143899. }
  143900. declare module BABYLON {
  143901. /**
  143902. * Implementation of the TGA Texture Loader.
  143903. * @hidden
  143904. */
  143905. export class _TGATextureLoader implements IInternalTextureLoader {
  143906. /**
  143907. * Defines wether the loader supports cascade loading the different faces.
  143908. */
  143909. readonly supportCascades: boolean;
  143910. /**
  143911. * This returns if the loader support the current file information.
  143912. * @param extension defines the file extension of the file being loaded
  143913. * @returns true if the loader can load the specified file
  143914. */
  143915. canLoad(extension: string): boolean;
  143916. /**
  143917. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  143918. * @param data contains the texture data
  143919. * @param texture defines the BabylonJS internal texture
  143920. * @param createPolynomials will be true if polynomials have been requested
  143921. * @param onLoad defines the callback to trigger once the texture is ready
  143922. * @param onError defines the callback to trigger in case of error
  143923. */
  143924. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  143925. /**
  143926. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  143927. * @param data contains the texture data
  143928. * @param texture defines the BabylonJS internal texture
  143929. * @param callback defines the method to call once ready to upload
  143930. */
  143931. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  143932. }
  143933. }
  143934. declare module BABYLON {
  143935. /**
  143936. * Info about the .basis files
  143937. */
  143938. class BasisFileInfo {
  143939. /**
  143940. * If the file has alpha
  143941. */
  143942. hasAlpha: boolean;
  143943. /**
  143944. * Info about each image of the basis file
  143945. */
  143946. images: Array<{
  143947. levels: Array<{
  143948. width: number;
  143949. height: number;
  143950. transcodedPixels: ArrayBufferView;
  143951. }>;
  143952. }>;
  143953. }
  143954. /**
  143955. * Result of transcoding a basis file
  143956. */
  143957. class TranscodeResult {
  143958. /**
  143959. * Info about the .basis file
  143960. */
  143961. fileInfo: BasisFileInfo;
  143962. /**
  143963. * Format to use when loading the file
  143964. */
  143965. format: number;
  143966. }
  143967. /**
  143968. * Configuration options for the Basis transcoder
  143969. */
  143970. export class BasisTranscodeConfiguration {
  143971. /**
  143972. * Supported compression formats used to determine the supported output format of the transcoder
  143973. */
  143974. supportedCompressionFormats?: {
  143975. /**
  143976. * etc1 compression format
  143977. */
  143978. etc1?: boolean;
  143979. /**
  143980. * s3tc compression format
  143981. */
  143982. s3tc?: boolean;
  143983. /**
  143984. * pvrtc compression format
  143985. */
  143986. pvrtc?: boolean;
  143987. /**
  143988. * etc2 compression format
  143989. */
  143990. etc2?: boolean;
  143991. };
  143992. /**
  143993. * If mipmap levels should be loaded for transcoded images (Default: true)
  143994. */
  143995. loadMipmapLevels?: boolean;
  143996. /**
  143997. * Index of a single image to load (Default: all images)
  143998. */
  143999. loadSingleImage?: number;
  144000. }
  144001. /**
  144002. * Used to load .Basis files
  144003. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  144004. */
  144005. export class BasisTools {
  144006. private static _IgnoreSupportedFormats;
  144007. /**
  144008. * URL to use when loading the basis transcoder
  144009. */
  144010. static JSModuleURL: string;
  144011. /**
  144012. * URL to use when loading the wasm module for the transcoder
  144013. */
  144014. static WasmModuleURL: string;
  144015. /**
  144016. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  144017. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  144018. * @returns internal format corresponding to the Basis format
  144019. */
  144020. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  144021. private static _WorkerPromise;
  144022. private static _Worker;
  144023. private static _actionId;
  144024. private static _CreateWorkerAsync;
  144025. /**
  144026. * Transcodes a loaded image file to compressed pixel data
  144027. * @param data image data to transcode
  144028. * @param config configuration options for the transcoding
  144029. * @returns a promise resulting in the transcoded image
  144030. */
  144031. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  144032. /**
  144033. * Loads a texture from the transcode result
  144034. * @param texture texture load to
  144035. * @param transcodeResult the result of transcoding the basis file to load from
  144036. */
  144037. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  144038. }
  144039. }
  144040. declare module BABYLON {
  144041. /**
  144042. * Loader for .basis file format
  144043. */
  144044. export class _BasisTextureLoader implements IInternalTextureLoader {
  144045. /**
  144046. * Defines whether the loader supports cascade loading the different faces.
  144047. */
  144048. readonly supportCascades: boolean;
  144049. /**
  144050. * This returns if the loader support the current file information.
  144051. * @param extension defines the file extension of the file being loaded
  144052. * @returns true if the loader can load the specified file
  144053. */
  144054. canLoad(extension: string): boolean;
  144055. /**
  144056. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  144057. * @param data contains the texture data
  144058. * @param texture defines the BabylonJS internal texture
  144059. * @param createPolynomials will be true if polynomials have been requested
  144060. * @param onLoad defines the callback to trigger once the texture is ready
  144061. * @param onError defines the callback to trigger in case of error
  144062. */
  144063. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  144064. /**
  144065. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  144066. * @param data contains the texture data
  144067. * @param texture defines the BabylonJS internal texture
  144068. * @param callback defines the method to call once ready to upload
  144069. */
  144070. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  144071. }
  144072. }
  144073. declare module BABYLON {
  144074. /**
  144075. * Defines the basic options interface of a TexturePacker Frame
  144076. */
  144077. export interface ITexturePackerFrame {
  144078. /**
  144079. * The frame ID
  144080. */
  144081. id: number;
  144082. /**
  144083. * The frames Scale
  144084. */
  144085. scale: Vector2;
  144086. /**
  144087. * The Frames offset
  144088. */
  144089. offset: Vector2;
  144090. }
  144091. /**
  144092. * This is a support class for frame Data on texture packer sets.
  144093. */
  144094. export class TexturePackerFrame implements ITexturePackerFrame {
  144095. /**
  144096. * The frame ID
  144097. */
  144098. id: number;
  144099. /**
  144100. * The frames Scale
  144101. */
  144102. scale: Vector2;
  144103. /**
  144104. * The Frames offset
  144105. */
  144106. offset: Vector2;
  144107. /**
  144108. * Initializes a texture package frame.
  144109. * @param id The numerical frame identifier
  144110. * @param scale Scalar Vector2 for UV frame
  144111. * @param offset Vector2 for the frame position in UV units.
  144112. * @returns TexturePackerFrame
  144113. */
  144114. constructor(id: number, scale: Vector2, offset: Vector2);
  144115. }
  144116. }
  144117. declare module BABYLON {
  144118. /**
  144119. * Defines the basic options interface of a TexturePacker
  144120. */
  144121. export interface ITexturePackerOptions {
  144122. /**
  144123. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  144124. */
  144125. map?: string[];
  144126. /**
  144127. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  144128. */
  144129. uvsIn?: string;
  144130. /**
  144131. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  144132. */
  144133. uvsOut?: string;
  144134. /**
  144135. * number representing the layout style. Defaults to LAYOUT_STRIP
  144136. */
  144137. layout?: number;
  144138. /**
  144139. * number of columns if using custom column count layout(2). This defaults to 4.
  144140. */
  144141. colnum?: number;
  144142. /**
  144143. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  144144. */
  144145. updateInputMeshes?: boolean;
  144146. /**
  144147. * boolean flag to dispose all the source textures. Defaults to true.
  144148. */
  144149. disposeSources?: boolean;
  144150. /**
  144151. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  144152. */
  144153. fillBlanks?: boolean;
  144154. /**
  144155. * string value representing the context fill style color. Defaults to 'black'.
  144156. */
  144157. customFillColor?: string;
  144158. /**
  144159. * Width and Height Value of each Frame in the TexturePacker Sets
  144160. */
  144161. frameSize?: number;
  144162. /**
  144163. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  144164. */
  144165. paddingRatio?: number;
  144166. /**
  144167. * Number that declares the fill method for the padding gutter.
  144168. */
  144169. paddingMode?: number;
  144170. /**
  144171. * If in SUBUV_COLOR padding mode what color to use.
  144172. */
  144173. paddingColor?: Color3 | Color4;
  144174. }
  144175. /**
  144176. * Defines the basic interface of a TexturePacker JSON File
  144177. */
  144178. export interface ITexturePackerJSON {
  144179. /**
  144180. * The frame ID
  144181. */
  144182. name: string;
  144183. /**
  144184. * The base64 channel data
  144185. */
  144186. sets: any;
  144187. /**
  144188. * The options of the Packer
  144189. */
  144190. options: ITexturePackerOptions;
  144191. /**
  144192. * The frame data of the Packer
  144193. */
  144194. frames: Array<number>;
  144195. }
  144196. /**
  144197. * This is a support class that generates a series of packed texture sets.
  144198. * @see https://doc.babylonjs.com/babylon101/materials
  144199. */
  144200. export class TexturePacker {
  144201. /** Packer Layout Constant 0 */
  144202. static readonly LAYOUT_STRIP: number;
  144203. /** Packer Layout Constant 1 */
  144204. static readonly LAYOUT_POWER2: number;
  144205. /** Packer Layout Constant 2 */
  144206. static readonly LAYOUT_COLNUM: number;
  144207. /** Packer Layout Constant 0 */
  144208. static readonly SUBUV_WRAP: number;
  144209. /** Packer Layout Constant 1 */
  144210. static readonly SUBUV_EXTEND: number;
  144211. /** Packer Layout Constant 2 */
  144212. static readonly SUBUV_COLOR: number;
  144213. /** The Name of the Texture Package */
  144214. name: string;
  144215. /** The scene scope of the TexturePacker */
  144216. scene: Scene;
  144217. /** The Meshes to target */
  144218. meshes: AbstractMesh[];
  144219. /** Arguments passed with the Constructor */
  144220. options: ITexturePackerOptions;
  144221. /** The promise that is started upon initialization */
  144222. promise: Nullable<Promise<TexturePacker | string>>;
  144223. /** The Container object for the channel sets that are generated */
  144224. sets: object;
  144225. /** The Container array for the frames that are generated */
  144226. frames: TexturePackerFrame[];
  144227. /** The expected number of textures the system is parsing. */
  144228. private _expecting;
  144229. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  144230. private _paddingValue;
  144231. /**
  144232. * Initializes a texture package series from an array of meshes or a single mesh.
  144233. * @param name The name of the package
  144234. * @param meshes The target meshes to compose the package from
  144235. * @param options The arguments that texture packer should follow while building.
  144236. * @param scene The scene which the textures are scoped to.
  144237. * @returns TexturePacker
  144238. */
  144239. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  144240. /**
  144241. * Starts the package process
  144242. * @param resolve The promises resolution function
  144243. * @returns TexturePacker
  144244. */
  144245. private _createFrames;
  144246. /**
  144247. * Calculates the Size of the Channel Sets
  144248. * @returns Vector2
  144249. */
  144250. private _calculateSize;
  144251. /**
  144252. * Calculates the UV data for the frames.
  144253. * @param baseSize the base frameSize
  144254. * @param padding the base frame padding
  144255. * @param dtSize size of the Dynamic Texture for that channel
  144256. * @param dtUnits is 1/dtSize
  144257. * @param update flag to update the input meshes
  144258. */
  144259. private _calculateMeshUVFrames;
  144260. /**
  144261. * Calculates the frames Offset.
  144262. * @param index of the frame
  144263. * @returns Vector2
  144264. */
  144265. private _getFrameOffset;
  144266. /**
  144267. * Updates a Mesh to the frame data
  144268. * @param mesh that is the target
  144269. * @param frameID or the frame index
  144270. */
  144271. private _updateMeshUV;
  144272. /**
  144273. * Updates a Meshes materials to use the texture packer channels
  144274. * @param m is the mesh to target
  144275. * @param force all channels on the packer to be set.
  144276. */
  144277. private _updateTextureReferences;
  144278. /**
  144279. * Public method to set a Mesh to a frame
  144280. * @param m that is the target
  144281. * @param frameID or the frame index
  144282. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  144283. */
  144284. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  144285. /**
  144286. * Starts the async promise to compile the texture packer.
  144287. * @returns Promise<void>
  144288. */
  144289. processAsync(): Promise<void>;
  144290. /**
  144291. * Disposes all textures associated with this packer
  144292. */
  144293. dispose(): void;
  144294. /**
  144295. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  144296. * @param imageType is the image type to use.
  144297. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  144298. */
  144299. download(imageType?: string, quality?: number): void;
  144300. /**
  144301. * Public method to load a texturePacker JSON file.
  144302. * @param data of the JSON file in string format.
  144303. */
  144304. updateFromJSON(data: string): void;
  144305. }
  144306. }
  144307. declare module BABYLON {
  144308. /**
  144309. * 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.
  144310. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  144311. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  144312. */
  144313. export class CustomProceduralTexture extends ProceduralTexture {
  144314. private _animate;
  144315. private _time;
  144316. private _config;
  144317. private _texturePath;
  144318. /**
  144319. * Instantiates a new Custom Procedural Texture.
  144320. * 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.
  144321. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  144322. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  144323. * @param name Define the name of the texture
  144324. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  144325. * @param size Define the size of the texture to create
  144326. * @param scene Define the scene the texture belongs to
  144327. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  144328. * @param generateMipMaps Define if the texture should creates mip maps or not
  144329. */
  144330. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  144331. private _loadJson;
  144332. /**
  144333. * Is the texture ready to be used ? (rendered at least once)
  144334. * @returns true if ready, otherwise, false.
  144335. */
  144336. isReady(): boolean;
  144337. /**
  144338. * Render the texture to its associated render target.
  144339. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  144340. */
  144341. render(useCameraPostProcess?: boolean): void;
  144342. /**
  144343. * Update the list of dependant textures samplers in the shader.
  144344. */
  144345. updateTextures(): void;
  144346. /**
  144347. * Update the uniform values of the procedural texture in the shader.
  144348. */
  144349. updateShaderUniforms(): void;
  144350. /**
  144351. * Define if the texture animates or not.
  144352. */
  144353. get animate(): boolean;
  144354. set animate(value: boolean);
  144355. }
  144356. }
  144357. declare module BABYLON {
  144358. /** @hidden */
  144359. export var noisePixelShader: {
  144360. name: string;
  144361. shader: string;
  144362. };
  144363. }
  144364. declare module BABYLON {
  144365. /**
  144366. * Class used to generate noise procedural textures
  144367. */
  144368. export class NoiseProceduralTexture extends ProceduralTexture {
  144369. /** Gets or sets the start time (default is 0) */
  144370. time: number;
  144371. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  144372. brightness: number;
  144373. /** Defines the number of octaves to process */
  144374. octaves: number;
  144375. /** Defines the level of persistence (0.8 by default) */
  144376. persistence: number;
  144377. /** Gets or sets animation speed factor (default is 1) */
  144378. animationSpeedFactor: number;
  144379. /**
  144380. * Creates a new NoiseProceduralTexture
  144381. * @param name defines the name fo the texture
  144382. * @param size defines the size of the texture (default is 256)
  144383. * @param scene defines the hosting scene
  144384. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  144385. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  144386. */
  144387. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  144388. private _updateShaderUniforms;
  144389. protected _getDefines(): string;
  144390. /** Generate the current state of the procedural texture */
  144391. render(useCameraPostProcess?: boolean): void;
  144392. /**
  144393. * Serializes this noise procedural texture
  144394. * @returns a serialized noise procedural texture object
  144395. */
  144396. serialize(): any;
  144397. /**
  144398. * Clone the texture.
  144399. * @returns the cloned texture
  144400. */
  144401. clone(): NoiseProceduralTexture;
  144402. /**
  144403. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  144404. * @param parsedTexture defines parsed texture data
  144405. * @param scene defines the current scene
  144406. * @param rootUrl defines the root URL containing noise procedural texture information
  144407. * @returns a parsed NoiseProceduralTexture
  144408. */
  144409. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  144410. }
  144411. }
  144412. declare module BABYLON {
  144413. /**
  144414. * Raw cube texture where the raw buffers are passed in
  144415. */
  144416. export class RawCubeTexture extends CubeTexture {
  144417. /**
  144418. * Creates a cube texture where the raw buffers are passed in.
  144419. * @param scene defines the scene the texture is attached to
  144420. * @param data defines the array of data to use to create each face
  144421. * @param size defines the size of the textures
  144422. * @param format defines the format of the data
  144423. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  144424. * @param generateMipMaps defines if the engine should generate the mip levels
  144425. * @param invertY defines if data must be stored with Y axis inverted
  144426. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  144427. * @param compression defines the compression used (null by default)
  144428. */
  144429. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  144430. /**
  144431. * Updates the raw cube texture.
  144432. * @param data defines the data to store
  144433. * @param format defines the data format
  144434. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  144435. * @param invertY defines if data must be stored with Y axis inverted
  144436. * @param compression defines the compression used (null by default)
  144437. * @param level defines which level of the texture to update
  144438. */
  144439. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  144440. /**
  144441. * Updates a raw cube texture with RGBD encoded data.
  144442. * @param data defines the array of data [mipmap][face] to use to create each face
  144443. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  144444. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  144445. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  144446. * @returns a promsie that resolves when the operation is complete
  144447. */
  144448. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  144449. /**
  144450. * Clones the raw cube texture.
  144451. * @return a new cube texture
  144452. */
  144453. clone(): CubeTexture;
  144454. /** @hidden */
  144455. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  144456. }
  144457. }
  144458. declare module BABYLON {
  144459. /**
  144460. * Class used to store 2D array textures containing user data
  144461. */
  144462. export class RawTexture2DArray extends Texture {
  144463. /** Gets or sets the texture format to use */
  144464. format: number;
  144465. /**
  144466. * Create a new RawTexture2DArray
  144467. * @param data defines the data of the texture
  144468. * @param width defines the width of the texture
  144469. * @param height defines the height of the texture
  144470. * @param depth defines the number of layers of the texture
  144471. * @param format defines the texture format to use
  144472. * @param scene defines the hosting scene
  144473. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  144474. * @param invertY defines if texture must be stored with Y axis inverted
  144475. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  144476. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  144477. */
  144478. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  144479. /** Gets or sets the texture format to use */
  144480. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  144481. /**
  144482. * Update the texture with new data
  144483. * @param data defines the data to store in the texture
  144484. */
  144485. update(data: ArrayBufferView): void;
  144486. }
  144487. }
  144488. declare module BABYLON {
  144489. /**
  144490. * Class used to store 3D textures containing user data
  144491. */
  144492. export class RawTexture3D extends Texture {
  144493. /** Gets or sets the texture format to use */
  144494. format: number;
  144495. /**
  144496. * Create a new RawTexture3D
  144497. * @param data defines the data of the texture
  144498. * @param width defines the width of the texture
  144499. * @param height defines the height of the texture
  144500. * @param depth defines the depth of the texture
  144501. * @param format defines the texture format to use
  144502. * @param scene defines the hosting scene
  144503. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  144504. * @param invertY defines if texture must be stored with Y axis inverted
  144505. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  144506. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  144507. */
  144508. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  144509. /** Gets or sets the texture format to use */
  144510. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  144511. /**
  144512. * Update the texture with new data
  144513. * @param data defines the data to store in the texture
  144514. */
  144515. update(data: ArrayBufferView): void;
  144516. }
  144517. }
  144518. declare module BABYLON {
  144519. /**
  144520. * Creates a refraction texture used by refraction channel of the standard material.
  144521. * It is like a mirror but to see through a material.
  144522. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  144523. */
  144524. export class RefractionTexture extends RenderTargetTexture {
  144525. /**
  144526. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  144527. * 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.
  144528. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  144529. */
  144530. refractionPlane: Plane;
  144531. /**
  144532. * Define how deep under the surface we should see.
  144533. */
  144534. depth: number;
  144535. /**
  144536. * Creates a refraction texture used by refraction channel of the standard material.
  144537. * It is like a mirror but to see through a material.
  144538. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  144539. * @param name Define the texture name
  144540. * @param size Define the size of the underlying texture
  144541. * @param scene Define the scene the refraction belongs to
  144542. * @param generateMipMaps Define if we need to generate mips level for the refraction
  144543. */
  144544. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  144545. /**
  144546. * Clone the refraction texture.
  144547. * @returns the cloned texture
  144548. */
  144549. clone(): RefractionTexture;
  144550. /**
  144551. * Serialize the texture to a JSON representation you could use in Parse later on
  144552. * @returns the serialized JSON representation
  144553. */
  144554. serialize(): any;
  144555. }
  144556. }
  144557. declare module BABYLON {
  144558. /**
  144559. * Block used to add support for vertex skinning (bones)
  144560. */
  144561. export class BonesBlock extends NodeMaterialBlock {
  144562. /**
  144563. * Creates a new BonesBlock
  144564. * @param name defines the block name
  144565. */
  144566. constructor(name: string);
  144567. /**
  144568. * Initialize the block and prepare the context for build
  144569. * @param state defines the state that will be used for the build
  144570. */
  144571. initialize(state: NodeMaterialBuildState): void;
  144572. /**
  144573. * Gets the current class name
  144574. * @returns the class name
  144575. */
  144576. getClassName(): string;
  144577. /**
  144578. * Gets the matrix indices input component
  144579. */
  144580. get matricesIndices(): NodeMaterialConnectionPoint;
  144581. /**
  144582. * Gets the matrix weights input component
  144583. */
  144584. get matricesWeights(): NodeMaterialConnectionPoint;
  144585. /**
  144586. * Gets the extra matrix indices input component
  144587. */
  144588. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  144589. /**
  144590. * Gets the extra matrix weights input component
  144591. */
  144592. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  144593. /**
  144594. * Gets the world input component
  144595. */
  144596. get world(): NodeMaterialConnectionPoint;
  144597. /**
  144598. * Gets the output component
  144599. */
  144600. get output(): NodeMaterialConnectionPoint;
  144601. autoConfigure(material: NodeMaterial): void;
  144602. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  144603. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144604. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144605. protected _buildBlock(state: NodeMaterialBuildState): this;
  144606. }
  144607. }
  144608. declare module BABYLON {
  144609. /**
  144610. * Block used to add support for instances
  144611. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  144612. */
  144613. export class InstancesBlock extends NodeMaterialBlock {
  144614. /**
  144615. * Creates a new InstancesBlock
  144616. * @param name defines the block name
  144617. */
  144618. constructor(name: string);
  144619. /**
  144620. * Gets the current class name
  144621. * @returns the class name
  144622. */
  144623. getClassName(): string;
  144624. /**
  144625. * Gets the first world row input component
  144626. */
  144627. get world0(): NodeMaterialConnectionPoint;
  144628. /**
  144629. * Gets the second world row input component
  144630. */
  144631. get world1(): NodeMaterialConnectionPoint;
  144632. /**
  144633. * Gets the third world row input component
  144634. */
  144635. get world2(): NodeMaterialConnectionPoint;
  144636. /**
  144637. * Gets the forth world row input component
  144638. */
  144639. get world3(): NodeMaterialConnectionPoint;
  144640. /**
  144641. * Gets the world input component
  144642. */
  144643. get world(): NodeMaterialConnectionPoint;
  144644. /**
  144645. * Gets the output component
  144646. */
  144647. get output(): NodeMaterialConnectionPoint;
  144648. /**
  144649. * Gets the isntanceID component
  144650. */
  144651. get instanceID(): NodeMaterialConnectionPoint;
  144652. autoConfigure(material: NodeMaterial): void;
  144653. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  144654. protected _buildBlock(state: NodeMaterialBuildState): this;
  144655. }
  144656. }
  144657. declare module BABYLON {
  144658. /**
  144659. * Block used to add morph targets support to vertex shader
  144660. */
  144661. export class MorphTargetsBlock extends NodeMaterialBlock {
  144662. private _repeatableContentAnchor;
  144663. /**
  144664. * Create a new MorphTargetsBlock
  144665. * @param name defines the block name
  144666. */
  144667. constructor(name: string);
  144668. /**
  144669. * Gets the current class name
  144670. * @returns the class name
  144671. */
  144672. getClassName(): string;
  144673. /**
  144674. * Gets the position input component
  144675. */
  144676. get position(): NodeMaterialConnectionPoint;
  144677. /**
  144678. * Gets the normal input component
  144679. */
  144680. get normal(): NodeMaterialConnectionPoint;
  144681. /**
  144682. * Gets the tangent input component
  144683. */
  144684. get tangent(): NodeMaterialConnectionPoint;
  144685. /**
  144686. * Gets the tangent input component
  144687. */
  144688. get uv(): NodeMaterialConnectionPoint;
  144689. /**
  144690. * Gets the position output component
  144691. */
  144692. get positionOutput(): NodeMaterialConnectionPoint;
  144693. /**
  144694. * Gets the normal output component
  144695. */
  144696. get normalOutput(): NodeMaterialConnectionPoint;
  144697. /**
  144698. * Gets the tangent output component
  144699. */
  144700. get tangentOutput(): NodeMaterialConnectionPoint;
  144701. /**
  144702. * Gets the tangent output component
  144703. */
  144704. get uvOutput(): NodeMaterialConnectionPoint;
  144705. initialize(state: NodeMaterialBuildState): void;
  144706. autoConfigure(material: NodeMaterial): void;
  144707. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144708. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144709. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  144710. protected _buildBlock(state: NodeMaterialBuildState): this;
  144711. }
  144712. }
  144713. declare module BABYLON {
  144714. /**
  144715. * Block used to get data information from a light
  144716. */
  144717. export class LightInformationBlock extends NodeMaterialBlock {
  144718. private _lightDataUniformName;
  144719. private _lightColorUniformName;
  144720. private _lightTypeDefineName;
  144721. /**
  144722. * Gets or sets the light associated with this block
  144723. */
  144724. light: Nullable<Light>;
  144725. /**
  144726. * Creates a new LightInformationBlock
  144727. * @param name defines the block name
  144728. */
  144729. constructor(name: string);
  144730. /**
  144731. * Gets the current class name
  144732. * @returns the class name
  144733. */
  144734. getClassName(): string;
  144735. /**
  144736. * Gets the world position input component
  144737. */
  144738. get worldPosition(): NodeMaterialConnectionPoint;
  144739. /**
  144740. * Gets the direction output component
  144741. */
  144742. get direction(): NodeMaterialConnectionPoint;
  144743. /**
  144744. * Gets the direction output component
  144745. */
  144746. get color(): NodeMaterialConnectionPoint;
  144747. /**
  144748. * Gets the direction output component
  144749. */
  144750. get intensity(): NodeMaterialConnectionPoint;
  144751. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144752. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144753. protected _buildBlock(state: NodeMaterialBuildState): this;
  144754. serialize(): any;
  144755. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144756. }
  144757. }
  144758. declare module BABYLON {
  144759. /**
  144760. * Block used to add image processing support to fragment shader
  144761. */
  144762. export class ImageProcessingBlock extends NodeMaterialBlock {
  144763. /**
  144764. * Create a new ImageProcessingBlock
  144765. * @param name defines the block name
  144766. */
  144767. constructor(name: string);
  144768. /**
  144769. * Gets the current class name
  144770. * @returns the class name
  144771. */
  144772. getClassName(): string;
  144773. /**
  144774. * Gets the color input component
  144775. */
  144776. get color(): NodeMaterialConnectionPoint;
  144777. /**
  144778. * Gets the output component
  144779. */
  144780. get output(): NodeMaterialConnectionPoint;
  144781. /**
  144782. * Initialize the block and prepare the context for build
  144783. * @param state defines the state that will be used for the build
  144784. */
  144785. initialize(state: NodeMaterialBuildState): void;
  144786. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  144787. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144788. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144789. protected _buildBlock(state: NodeMaterialBuildState): this;
  144790. }
  144791. }
  144792. declare module BABYLON {
  144793. /**
  144794. * Block used to pertub normals based on a normal map
  144795. */
  144796. export class PerturbNormalBlock extends NodeMaterialBlock {
  144797. private _tangentSpaceParameterName;
  144798. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144799. invertX: boolean;
  144800. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  144801. invertY: boolean;
  144802. /**
  144803. * Create a new PerturbNormalBlock
  144804. * @param name defines the block name
  144805. */
  144806. constructor(name: string);
  144807. /**
  144808. * Gets the current class name
  144809. * @returns the class name
  144810. */
  144811. getClassName(): string;
  144812. /**
  144813. * Gets the world position input component
  144814. */
  144815. get worldPosition(): NodeMaterialConnectionPoint;
  144816. /**
  144817. * Gets the world normal input component
  144818. */
  144819. get worldNormal(): NodeMaterialConnectionPoint;
  144820. /**
  144821. * Gets the world tangent input component
  144822. */
  144823. get worldTangent(): NodeMaterialConnectionPoint;
  144824. /**
  144825. * Gets the uv input component
  144826. */
  144827. get uv(): NodeMaterialConnectionPoint;
  144828. /**
  144829. * Gets the normal map color input component
  144830. */
  144831. get normalMapColor(): NodeMaterialConnectionPoint;
  144832. /**
  144833. * Gets the strength input component
  144834. */
  144835. get strength(): NodeMaterialConnectionPoint;
  144836. /**
  144837. * Gets the output component
  144838. */
  144839. get output(): NodeMaterialConnectionPoint;
  144840. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144841. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  144842. autoConfigure(material: NodeMaterial): void;
  144843. protected _buildBlock(state: NodeMaterialBuildState): this;
  144844. protected _dumpPropertiesCode(): string;
  144845. serialize(): any;
  144846. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144847. }
  144848. }
  144849. declare module BABYLON {
  144850. /**
  144851. * Block used to discard a pixel if a value is smaller than a cutoff
  144852. */
  144853. export class DiscardBlock extends NodeMaterialBlock {
  144854. /**
  144855. * Create a new DiscardBlock
  144856. * @param name defines the block name
  144857. */
  144858. constructor(name: string);
  144859. /**
  144860. * Gets the current class name
  144861. * @returns the class name
  144862. */
  144863. getClassName(): string;
  144864. /**
  144865. * Gets the color input component
  144866. */
  144867. get value(): NodeMaterialConnectionPoint;
  144868. /**
  144869. * Gets the cutoff input component
  144870. */
  144871. get cutoff(): NodeMaterialConnectionPoint;
  144872. protected _buildBlock(state: NodeMaterialBuildState): this;
  144873. }
  144874. }
  144875. declare module BABYLON {
  144876. /**
  144877. * Block used to test if the fragment shader is front facing
  144878. */
  144879. export class FrontFacingBlock extends NodeMaterialBlock {
  144880. /**
  144881. * Creates a new FrontFacingBlock
  144882. * @param name defines the block name
  144883. */
  144884. constructor(name: string);
  144885. /**
  144886. * Gets the current class name
  144887. * @returns the class name
  144888. */
  144889. getClassName(): string;
  144890. /**
  144891. * Gets the output component
  144892. */
  144893. get output(): NodeMaterialConnectionPoint;
  144894. protected _buildBlock(state: NodeMaterialBuildState): this;
  144895. }
  144896. }
  144897. declare module BABYLON {
  144898. /**
  144899. * Block used to get the derivative value on x and y of a given input
  144900. */
  144901. export class DerivativeBlock extends NodeMaterialBlock {
  144902. /**
  144903. * Create a new DerivativeBlock
  144904. * @param name defines the block name
  144905. */
  144906. constructor(name: string);
  144907. /**
  144908. * Gets the current class name
  144909. * @returns the class name
  144910. */
  144911. getClassName(): string;
  144912. /**
  144913. * Gets the input component
  144914. */
  144915. get input(): NodeMaterialConnectionPoint;
  144916. /**
  144917. * Gets the derivative output on x
  144918. */
  144919. get dx(): NodeMaterialConnectionPoint;
  144920. /**
  144921. * Gets the derivative output on y
  144922. */
  144923. get dy(): NodeMaterialConnectionPoint;
  144924. protected _buildBlock(state: NodeMaterialBuildState): this;
  144925. }
  144926. }
  144927. declare module BABYLON {
  144928. /**
  144929. * Block used to make gl_FragCoord available
  144930. */
  144931. export class FragCoordBlock extends NodeMaterialBlock {
  144932. /**
  144933. * Creates a new FragCoordBlock
  144934. * @param name defines the block name
  144935. */
  144936. constructor(name: string);
  144937. /**
  144938. * Gets the current class name
  144939. * @returns the class name
  144940. */
  144941. getClassName(): string;
  144942. /**
  144943. * Gets the xy component
  144944. */
  144945. get xy(): NodeMaterialConnectionPoint;
  144946. /**
  144947. * Gets the xyz component
  144948. */
  144949. get xyz(): NodeMaterialConnectionPoint;
  144950. /**
  144951. * Gets the xyzw component
  144952. */
  144953. get xyzw(): NodeMaterialConnectionPoint;
  144954. /**
  144955. * Gets the x component
  144956. */
  144957. get x(): NodeMaterialConnectionPoint;
  144958. /**
  144959. * Gets the y component
  144960. */
  144961. get y(): NodeMaterialConnectionPoint;
  144962. /**
  144963. * Gets the z component
  144964. */
  144965. get z(): NodeMaterialConnectionPoint;
  144966. /**
  144967. * Gets the w component
  144968. */
  144969. get output(): NodeMaterialConnectionPoint;
  144970. protected writeOutputs(state: NodeMaterialBuildState): string;
  144971. protected _buildBlock(state: NodeMaterialBuildState): this;
  144972. }
  144973. }
  144974. declare module BABYLON {
  144975. /**
  144976. * Block used to get the screen sizes
  144977. */
  144978. export class ScreenSizeBlock extends NodeMaterialBlock {
  144979. private _varName;
  144980. private _scene;
  144981. /**
  144982. * Creates a new ScreenSizeBlock
  144983. * @param name defines the block name
  144984. */
  144985. constructor(name: string);
  144986. /**
  144987. * Gets the current class name
  144988. * @returns the class name
  144989. */
  144990. getClassName(): string;
  144991. /**
  144992. * Gets the xy component
  144993. */
  144994. get xy(): NodeMaterialConnectionPoint;
  144995. /**
  144996. * Gets the x component
  144997. */
  144998. get x(): NodeMaterialConnectionPoint;
  144999. /**
  145000. * Gets the y component
  145001. */
  145002. get y(): NodeMaterialConnectionPoint;
  145003. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145004. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  145005. protected _buildBlock(state: NodeMaterialBuildState): this;
  145006. }
  145007. }
  145008. declare module BABYLON {
  145009. /**
  145010. * Block used to add support for scene fog
  145011. */
  145012. export class FogBlock extends NodeMaterialBlock {
  145013. private _fogDistanceName;
  145014. private _fogParameters;
  145015. /**
  145016. * Create a new FogBlock
  145017. * @param name defines the block name
  145018. */
  145019. constructor(name: string);
  145020. /**
  145021. * Gets the current class name
  145022. * @returns the class name
  145023. */
  145024. getClassName(): string;
  145025. /**
  145026. * Gets the world position input component
  145027. */
  145028. get worldPosition(): NodeMaterialConnectionPoint;
  145029. /**
  145030. * Gets the view input component
  145031. */
  145032. get view(): NodeMaterialConnectionPoint;
  145033. /**
  145034. * Gets the color input component
  145035. */
  145036. get input(): NodeMaterialConnectionPoint;
  145037. /**
  145038. * Gets the fog color input component
  145039. */
  145040. get fogColor(): NodeMaterialConnectionPoint;
  145041. /**
  145042. * Gets the output component
  145043. */
  145044. get output(): NodeMaterialConnectionPoint;
  145045. autoConfigure(material: NodeMaterial): void;
  145046. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145047. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145048. protected _buildBlock(state: NodeMaterialBuildState): this;
  145049. }
  145050. }
  145051. declare module BABYLON {
  145052. /**
  145053. * Block used to add light in the fragment shader
  145054. */
  145055. export class LightBlock extends NodeMaterialBlock {
  145056. private _lightId;
  145057. /**
  145058. * Gets or sets the light associated with this block
  145059. */
  145060. light: Nullable<Light>;
  145061. /**
  145062. * Create a new LightBlock
  145063. * @param name defines the block name
  145064. */
  145065. constructor(name: string);
  145066. /**
  145067. * Gets the current class name
  145068. * @returns the class name
  145069. */
  145070. getClassName(): string;
  145071. /**
  145072. * Gets the world position input component
  145073. */
  145074. get worldPosition(): NodeMaterialConnectionPoint;
  145075. /**
  145076. * Gets the world normal input component
  145077. */
  145078. get worldNormal(): NodeMaterialConnectionPoint;
  145079. /**
  145080. * Gets the camera (or eye) position component
  145081. */
  145082. get cameraPosition(): NodeMaterialConnectionPoint;
  145083. /**
  145084. * Gets the glossiness component
  145085. */
  145086. get glossiness(): NodeMaterialConnectionPoint;
  145087. /**
  145088. * Gets the glossinness power component
  145089. */
  145090. get glossPower(): NodeMaterialConnectionPoint;
  145091. /**
  145092. * Gets the diffuse color component
  145093. */
  145094. get diffuseColor(): NodeMaterialConnectionPoint;
  145095. /**
  145096. * Gets the specular color component
  145097. */
  145098. get specularColor(): NodeMaterialConnectionPoint;
  145099. /**
  145100. * Gets the view matrix component
  145101. */
  145102. get view(): NodeMaterialConnectionPoint;
  145103. /**
  145104. * Gets the diffuse output component
  145105. */
  145106. get diffuseOutput(): NodeMaterialConnectionPoint;
  145107. /**
  145108. * Gets the specular output component
  145109. */
  145110. get specularOutput(): NodeMaterialConnectionPoint;
  145111. /**
  145112. * Gets the shadow output component
  145113. */
  145114. get shadow(): NodeMaterialConnectionPoint;
  145115. autoConfigure(material: NodeMaterial): void;
  145116. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145117. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145118. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145119. private _injectVertexCode;
  145120. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  145121. serialize(): any;
  145122. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145123. }
  145124. }
  145125. declare module BABYLON {
  145126. /**
  145127. * Block used to read a reflection texture from a sampler
  145128. */
  145129. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  145130. /**
  145131. * Create a new ReflectionTextureBlock
  145132. * @param name defines the block name
  145133. */
  145134. constructor(name: string);
  145135. /**
  145136. * Gets the current class name
  145137. * @returns the class name
  145138. */
  145139. getClassName(): string;
  145140. /**
  145141. * Gets the world position input component
  145142. */
  145143. get position(): NodeMaterialConnectionPoint;
  145144. /**
  145145. * Gets the world position input component
  145146. */
  145147. get worldPosition(): NodeMaterialConnectionPoint;
  145148. /**
  145149. * Gets the world normal input component
  145150. */
  145151. get worldNormal(): NodeMaterialConnectionPoint;
  145152. /**
  145153. * Gets the world input component
  145154. */
  145155. get world(): NodeMaterialConnectionPoint;
  145156. /**
  145157. * Gets the camera (or eye) position component
  145158. */
  145159. get cameraPosition(): NodeMaterialConnectionPoint;
  145160. /**
  145161. * Gets the view input component
  145162. */
  145163. get view(): NodeMaterialConnectionPoint;
  145164. /**
  145165. * Gets the rgb output component
  145166. */
  145167. get rgb(): NodeMaterialConnectionPoint;
  145168. /**
  145169. * Gets the rgba output component
  145170. */
  145171. get rgba(): NodeMaterialConnectionPoint;
  145172. /**
  145173. * Gets the r output component
  145174. */
  145175. get r(): NodeMaterialConnectionPoint;
  145176. /**
  145177. * Gets the g output component
  145178. */
  145179. get g(): NodeMaterialConnectionPoint;
  145180. /**
  145181. * Gets the b output component
  145182. */
  145183. get b(): NodeMaterialConnectionPoint;
  145184. /**
  145185. * Gets the a output component
  145186. */
  145187. get a(): NodeMaterialConnectionPoint;
  145188. autoConfigure(material: NodeMaterial): void;
  145189. protected _buildBlock(state: NodeMaterialBuildState): this;
  145190. }
  145191. }
  145192. declare module BABYLON {
  145193. /**
  145194. * Block used to add 2 vectors
  145195. */
  145196. export class AddBlock extends NodeMaterialBlock {
  145197. /**
  145198. * Creates a new AddBlock
  145199. * @param name defines the block name
  145200. */
  145201. constructor(name: string);
  145202. /**
  145203. * Gets the current class name
  145204. * @returns the class name
  145205. */
  145206. getClassName(): string;
  145207. /**
  145208. * Gets the left operand input component
  145209. */
  145210. get left(): NodeMaterialConnectionPoint;
  145211. /**
  145212. * Gets the right operand input component
  145213. */
  145214. get right(): NodeMaterialConnectionPoint;
  145215. /**
  145216. * Gets the output component
  145217. */
  145218. get output(): NodeMaterialConnectionPoint;
  145219. protected _buildBlock(state: NodeMaterialBuildState): this;
  145220. }
  145221. }
  145222. declare module BABYLON {
  145223. /**
  145224. * Block used to scale a vector by a float
  145225. */
  145226. export class ScaleBlock extends NodeMaterialBlock {
  145227. /**
  145228. * Creates a new ScaleBlock
  145229. * @param name defines the block name
  145230. */
  145231. constructor(name: string);
  145232. /**
  145233. * Gets the current class name
  145234. * @returns the class name
  145235. */
  145236. getClassName(): string;
  145237. /**
  145238. * Gets the input component
  145239. */
  145240. get input(): NodeMaterialConnectionPoint;
  145241. /**
  145242. * Gets the factor input component
  145243. */
  145244. get factor(): NodeMaterialConnectionPoint;
  145245. /**
  145246. * Gets the output component
  145247. */
  145248. get output(): NodeMaterialConnectionPoint;
  145249. protected _buildBlock(state: NodeMaterialBuildState): this;
  145250. }
  145251. }
  145252. declare module BABYLON {
  145253. /**
  145254. * Block used to clamp a float
  145255. */
  145256. export class ClampBlock extends NodeMaterialBlock {
  145257. /** Gets or sets the minimum range */
  145258. minimum: number;
  145259. /** Gets or sets the maximum range */
  145260. maximum: number;
  145261. /**
  145262. * Creates a new ClampBlock
  145263. * @param name defines the block name
  145264. */
  145265. constructor(name: string);
  145266. /**
  145267. * Gets the current class name
  145268. * @returns the class name
  145269. */
  145270. getClassName(): string;
  145271. /**
  145272. * Gets the value input component
  145273. */
  145274. get value(): NodeMaterialConnectionPoint;
  145275. /**
  145276. * Gets the output component
  145277. */
  145278. get output(): NodeMaterialConnectionPoint;
  145279. protected _buildBlock(state: NodeMaterialBuildState): this;
  145280. protected _dumpPropertiesCode(): string;
  145281. serialize(): any;
  145282. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145283. }
  145284. }
  145285. declare module BABYLON {
  145286. /**
  145287. * Block used to apply a cross product between 2 vectors
  145288. */
  145289. export class CrossBlock extends NodeMaterialBlock {
  145290. /**
  145291. * Creates a new CrossBlock
  145292. * @param name defines the block name
  145293. */
  145294. constructor(name: string);
  145295. /**
  145296. * Gets the current class name
  145297. * @returns the class name
  145298. */
  145299. getClassName(): string;
  145300. /**
  145301. * Gets the left operand input component
  145302. */
  145303. get left(): NodeMaterialConnectionPoint;
  145304. /**
  145305. * Gets the right operand input component
  145306. */
  145307. get right(): NodeMaterialConnectionPoint;
  145308. /**
  145309. * Gets the output component
  145310. */
  145311. get output(): NodeMaterialConnectionPoint;
  145312. protected _buildBlock(state: NodeMaterialBuildState): this;
  145313. }
  145314. }
  145315. declare module BABYLON {
  145316. /**
  145317. * Block used to apply a dot product between 2 vectors
  145318. */
  145319. export class DotBlock extends NodeMaterialBlock {
  145320. /**
  145321. * Creates a new DotBlock
  145322. * @param name defines the block name
  145323. */
  145324. constructor(name: string);
  145325. /**
  145326. * Gets the current class name
  145327. * @returns the class name
  145328. */
  145329. getClassName(): string;
  145330. /**
  145331. * Gets the left operand input component
  145332. */
  145333. get left(): NodeMaterialConnectionPoint;
  145334. /**
  145335. * Gets the right operand input component
  145336. */
  145337. get right(): NodeMaterialConnectionPoint;
  145338. /**
  145339. * Gets the output component
  145340. */
  145341. get output(): NodeMaterialConnectionPoint;
  145342. protected _buildBlock(state: NodeMaterialBuildState): this;
  145343. }
  145344. }
  145345. declare module BABYLON {
  145346. /**
  145347. * Block used to normalize a vector
  145348. */
  145349. export class NormalizeBlock extends NodeMaterialBlock {
  145350. /**
  145351. * Creates a new NormalizeBlock
  145352. * @param name defines the block name
  145353. */
  145354. constructor(name: string);
  145355. /**
  145356. * Gets the current class name
  145357. * @returns the class name
  145358. */
  145359. getClassName(): string;
  145360. /**
  145361. * Gets the input component
  145362. */
  145363. get input(): NodeMaterialConnectionPoint;
  145364. /**
  145365. * Gets the output component
  145366. */
  145367. get output(): NodeMaterialConnectionPoint;
  145368. protected _buildBlock(state: NodeMaterialBuildState): this;
  145369. }
  145370. }
  145371. declare module BABYLON {
  145372. /**
  145373. * Block used to create a Color3/4 out of individual inputs (one for each component)
  145374. */
  145375. export class ColorMergerBlock extends NodeMaterialBlock {
  145376. /**
  145377. * Create a new ColorMergerBlock
  145378. * @param name defines the block name
  145379. */
  145380. constructor(name: string);
  145381. /**
  145382. * Gets the current class name
  145383. * @returns the class name
  145384. */
  145385. getClassName(): string;
  145386. /**
  145387. * Gets the rgb component (input)
  145388. */
  145389. get rgbIn(): NodeMaterialConnectionPoint;
  145390. /**
  145391. * Gets the r component (input)
  145392. */
  145393. get r(): NodeMaterialConnectionPoint;
  145394. /**
  145395. * Gets the g component (input)
  145396. */
  145397. get g(): NodeMaterialConnectionPoint;
  145398. /**
  145399. * Gets the b component (input)
  145400. */
  145401. get b(): NodeMaterialConnectionPoint;
  145402. /**
  145403. * Gets the a component (input)
  145404. */
  145405. get a(): NodeMaterialConnectionPoint;
  145406. /**
  145407. * Gets the rgba component (output)
  145408. */
  145409. get rgba(): NodeMaterialConnectionPoint;
  145410. /**
  145411. * Gets the rgb component (output)
  145412. */
  145413. get rgbOut(): NodeMaterialConnectionPoint;
  145414. /**
  145415. * Gets the rgb component (output)
  145416. * @deprecated Please use rgbOut instead.
  145417. */
  145418. get rgb(): NodeMaterialConnectionPoint;
  145419. protected _buildBlock(state: NodeMaterialBuildState): this;
  145420. }
  145421. }
  145422. declare module BABYLON {
  145423. /**
  145424. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  145425. */
  145426. export class VectorSplitterBlock extends NodeMaterialBlock {
  145427. /**
  145428. * Create a new VectorSplitterBlock
  145429. * @param name defines the block name
  145430. */
  145431. constructor(name: string);
  145432. /**
  145433. * Gets the current class name
  145434. * @returns the class name
  145435. */
  145436. getClassName(): string;
  145437. /**
  145438. * Gets the xyzw component (input)
  145439. */
  145440. get xyzw(): NodeMaterialConnectionPoint;
  145441. /**
  145442. * Gets the xyz component (input)
  145443. */
  145444. get xyzIn(): NodeMaterialConnectionPoint;
  145445. /**
  145446. * Gets the xy component (input)
  145447. */
  145448. get xyIn(): NodeMaterialConnectionPoint;
  145449. /**
  145450. * Gets the xyz component (output)
  145451. */
  145452. get xyzOut(): NodeMaterialConnectionPoint;
  145453. /**
  145454. * Gets the xy component (output)
  145455. */
  145456. get xyOut(): NodeMaterialConnectionPoint;
  145457. /**
  145458. * Gets the x component (output)
  145459. */
  145460. get x(): NodeMaterialConnectionPoint;
  145461. /**
  145462. * Gets the y component (output)
  145463. */
  145464. get y(): NodeMaterialConnectionPoint;
  145465. /**
  145466. * Gets the z component (output)
  145467. */
  145468. get z(): NodeMaterialConnectionPoint;
  145469. /**
  145470. * Gets the w component (output)
  145471. */
  145472. get w(): NodeMaterialConnectionPoint;
  145473. protected _inputRename(name: string): string;
  145474. protected _outputRename(name: string): string;
  145475. protected _buildBlock(state: NodeMaterialBuildState): this;
  145476. }
  145477. }
  145478. declare module BABYLON {
  145479. /**
  145480. * Block used to lerp between 2 values
  145481. */
  145482. export class LerpBlock extends NodeMaterialBlock {
  145483. /**
  145484. * Creates a new LerpBlock
  145485. * @param name defines the block name
  145486. */
  145487. constructor(name: string);
  145488. /**
  145489. * Gets the current class name
  145490. * @returns the class name
  145491. */
  145492. getClassName(): string;
  145493. /**
  145494. * Gets the left operand input component
  145495. */
  145496. get left(): NodeMaterialConnectionPoint;
  145497. /**
  145498. * Gets the right operand input component
  145499. */
  145500. get right(): NodeMaterialConnectionPoint;
  145501. /**
  145502. * Gets the gradient operand input component
  145503. */
  145504. get gradient(): NodeMaterialConnectionPoint;
  145505. /**
  145506. * Gets the output component
  145507. */
  145508. get output(): NodeMaterialConnectionPoint;
  145509. protected _buildBlock(state: NodeMaterialBuildState): this;
  145510. }
  145511. }
  145512. declare module BABYLON {
  145513. /**
  145514. * Block used to divide 2 vectors
  145515. */
  145516. export class DivideBlock extends NodeMaterialBlock {
  145517. /**
  145518. * Creates a new DivideBlock
  145519. * @param name defines the block name
  145520. */
  145521. constructor(name: string);
  145522. /**
  145523. * Gets the current class name
  145524. * @returns the class name
  145525. */
  145526. getClassName(): string;
  145527. /**
  145528. * Gets the left operand input component
  145529. */
  145530. get left(): NodeMaterialConnectionPoint;
  145531. /**
  145532. * Gets the right operand input component
  145533. */
  145534. get right(): NodeMaterialConnectionPoint;
  145535. /**
  145536. * Gets the output component
  145537. */
  145538. get output(): NodeMaterialConnectionPoint;
  145539. protected _buildBlock(state: NodeMaterialBuildState): this;
  145540. }
  145541. }
  145542. declare module BABYLON {
  145543. /**
  145544. * Block used to subtract 2 vectors
  145545. */
  145546. export class SubtractBlock extends NodeMaterialBlock {
  145547. /**
  145548. * Creates a new SubtractBlock
  145549. * @param name defines the block name
  145550. */
  145551. constructor(name: string);
  145552. /**
  145553. * Gets the current class name
  145554. * @returns the class name
  145555. */
  145556. getClassName(): string;
  145557. /**
  145558. * Gets the left operand input component
  145559. */
  145560. get left(): NodeMaterialConnectionPoint;
  145561. /**
  145562. * Gets the right operand input component
  145563. */
  145564. get right(): NodeMaterialConnectionPoint;
  145565. /**
  145566. * Gets the output component
  145567. */
  145568. get output(): NodeMaterialConnectionPoint;
  145569. protected _buildBlock(state: NodeMaterialBuildState): this;
  145570. }
  145571. }
  145572. declare module BABYLON {
  145573. /**
  145574. * Block used to step a value
  145575. */
  145576. export class StepBlock extends NodeMaterialBlock {
  145577. /**
  145578. * Creates a new StepBlock
  145579. * @param name defines the block name
  145580. */
  145581. constructor(name: string);
  145582. /**
  145583. * Gets the current class name
  145584. * @returns the class name
  145585. */
  145586. getClassName(): string;
  145587. /**
  145588. * Gets the value operand input component
  145589. */
  145590. get value(): NodeMaterialConnectionPoint;
  145591. /**
  145592. * Gets the edge operand input component
  145593. */
  145594. get edge(): NodeMaterialConnectionPoint;
  145595. /**
  145596. * Gets the output component
  145597. */
  145598. get output(): NodeMaterialConnectionPoint;
  145599. protected _buildBlock(state: NodeMaterialBuildState): this;
  145600. }
  145601. }
  145602. declare module BABYLON {
  145603. /**
  145604. * Block used to get the opposite (1 - x) of a value
  145605. */
  145606. export class OneMinusBlock extends NodeMaterialBlock {
  145607. /**
  145608. * Creates a new OneMinusBlock
  145609. * @param name defines the block name
  145610. */
  145611. constructor(name: string);
  145612. /**
  145613. * Gets the current class name
  145614. * @returns the class name
  145615. */
  145616. getClassName(): string;
  145617. /**
  145618. * Gets the input component
  145619. */
  145620. get input(): NodeMaterialConnectionPoint;
  145621. /**
  145622. * Gets the output component
  145623. */
  145624. get output(): NodeMaterialConnectionPoint;
  145625. protected _buildBlock(state: NodeMaterialBuildState): this;
  145626. }
  145627. }
  145628. declare module BABYLON {
  145629. /**
  145630. * Block used to get the view direction
  145631. */
  145632. export class ViewDirectionBlock extends NodeMaterialBlock {
  145633. /**
  145634. * Creates a new ViewDirectionBlock
  145635. * @param name defines the block name
  145636. */
  145637. constructor(name: string);
  145638. /**
  145639. * Gets the current class name
  145640. * @returns the class name
  145641. */
  145642. getClassName(): string;
  145643. /**
  145644. * Gets the world position component
  145645. */
  145646. get worldPosition(): NodeMaterialConnectionPoint;
  145647. /**
  145648. * Gets the camera position component
  145649. */
  145650. get cameraPosition(): NodeMaterialConnectionPoint;
  145651. /**
  145652. * Gets the output component
  145653. */
  145654. get output(): NodeMaterialConnectionPoint;
  145655. autoConfigure(material: NodeMaterial): void;
  145656. protected _buildBlock(state: NodeMaterialBuildState): this;
  145657. }
  145658. }
  145659. declare module BABYLON {
  145660. /**
  145661. * Block used to compute fresnel value
  145662. */
  145663. export class FresnelBlock extends NodeMaterialBlock {
  145664. /**
  145665. * Create a new FresnelBlock
  145666. * @param name defines the block name
  145667. */
  145668. constructor(name: string);
  145669. /**
  145670. * Gets the current class name
  145671. * @returns the class name
  145672. */
  145673. getClassName(): string;
  145674. /**
  145675. * Gets the world normal input component
  145676. */
  145677. get worldNormal(): NodeMaterialConnectionPoint;
  145678. /**
  145679. * Gets the view direction input component
  145680. */
  145681. get viewDirection(): NodeMaterialConnectionPoint;
  145682. /**
  145683. * Gets the bias input component
  145684. */
  145685. get bias(): NodeMaterialConnectionPoint;
  145686. /**
  145687. * Gets the camera (or eye) position component
  145688. */
  145689. get power(): NodeMaterialConnectionPoint;
  145690. /**
  145691. * Gets the fresnel output component
  145692. */
  145693. get fresnel(): NodeMaterialConnectionPoint;
  145694. autoConfigure(material: NodeMaterial): void;
  145695. protected _buildBlock(state: NodeMaterialBuildState): this;
  145696. }
  145697. }
  145698. declare module BABYLON {
  145699. /**
  145700. * Block used to get the max of 2 values
  145701. */
  145702. export class MaxBlock extends NodeMaterialBlock {
  145703. /**
  145704. * Creates a new MaxBlock
  145705. * @param name defines the block name
  145706. */
  145707. constructor(name: string);
  145708. /**
  145709. * Gets the current class name
  145710. * @returns the class name
  145711. */
  145712. getClassName(): string;
  145713. /**
  145714. * Gets the left operand input component
  145715. */
  145716. get left(): NodeMaterialConnectionPoint;
  145717. /**
  145718. * Gets the right operand input component
  145719. */
  145720. get right(): NodeMaterialConnectionPoint;
  145721. /**
  145722. * Gets the output component
  145723. */
  145724. get output(): NodeMaterialConnectionPoint;
  145725. protected _buildBlock(state: NodeMaterialBuildState): this;
  145726. }
  145727. }
  145728. declare module BABYLON {
  145729. /**
  145730. * Block used to get the min of 2 values
  145731. */
  145732. export class MinBlock extends NodeMaterialBlock {
  145733. /**
  145734. * Creates a new MinBlock
  145735. * @param name defines the block name
  145736. */
  145737. constructor(name: string);
  145738. /**
  145739. * Gets the current class name
  145740. * @returns the class name
  145741. */
  145742. getClassName(): string;
  145743. /**
  145744. * Gets the left operand input component
  145745. */
  145746. get left(): NodeMaterialConnectionPoint;
  145747. /**
  145748. * Gets the right operand input component
  145749. */
  145750. get right(): NodeMaterialConnectionPoint;
  145751. /**
  145752. * Gets the output component
  145753. */
  145754. get output(): NodeMaterialConnectionPoint;
  145755. protected _buildBlock(state: NodeMaterialBuildState): this;
  145756. }
  145757. }
  145758. declare module BABYLON {
  145759. /**
  145760. * Block used to get the distance between 2 values
  145761. */
  145762. export class DistanceBlock extends NodeMaterialBlock {
  145763. /**
  145764. * Creates a new DistanceBlock
  145765. * @param name defines the block name
  145766. */
  145767. constructor(name: string);
  145768. /**
  145769. * Gets the current class name
  145770. * @returns the class name
  145771. */
  145772. getClassName(): string;
  145773. /**
  145774. * Gets the left operand input component
  145775. */
  145776. get left(): NodeMaterialConnectionPoint;
  145777. /**
  145778. * Gets the right operand input component
  145779. */
  145780. get right(): NodeMaterialConnectionPoint;
  145781. /**
  145782. * Gets the output component
  145783. */
  145784. get output(): NodeMaterialConnectionPoint;
  145785. protected _buildBlock(state: NodeMaterialBuildState): this;
  145786. }
  145787. }
  145788. declare module BABYLON {
  145789. /**
  145790. * Block used to get the length of a vector
  145791. */
  145792. export class LengthBlock extends NodeMaterialBlock {
  145793. /**
  145794. * Creates a new LengthBlock
  145795. * @param name defines the block name
  145796. */
  145797. constructor(name: string);
  145798. /**
  145799. * Gets the current class name
  145800. * @returns the class name
  145801. */
  145802. getClassName(): string;
  145803. /**
  145804. * Gets the value input component
  145805. */
  145806. get value(): NodeMaterialConnectionPoint;
  145807. /**
  145808. * Gets the output component
  145809. */
  145810. get output(): NodeMaterialConnectionPoint;
  145811. protected _buildBlock(state: NodeMaterialBuildState): this;
  145812. }
  145813. }
  145814. declare module BABYLON {
  145815. /**
  145816. * Block used to get negative version of a value (i.e. x * -1)
  145817. */
  145818. export class NegateBlock extends NodeMaterialBlock {
  145819. /**
  145820. * Creates a new NegateBlock
  145821. * @param name defines the block name
  145822. */
  145823. constructor(name: string);
  145824. /**
  145825. * Gets the current class name
  145826. * @returns the class name
  145827. */
  145828. getClassName(): string;
  145829. /**
  145830. * Gets the value input component
  145831. */
  145832. get value(): NodeMaterialConnectionPoint;
  145833. /**
  145834. * Gets the output component
  145835. */
  145836. get output(): NodeMaterialConnectionPoint;
  145837. protected _buildBlock(state: NodeMaterialBuildState): this;
  145838. }
  145839. }
  145840. declare module BABYLON {
  145841. /**
  145842. * Block used to get the value of the first parameter raised to the power of the second
  145843. */
  145844. export class PowBlock extends NodeMaterialBlock {
  145845. /**
  145846. * Creates a new PowBlock
  145847. * @param name defines the block name
  145848. */
  145849. constructor(name: string);
  145850. /**
  145851. * Gets the current class name
  145852. * @returns the class name
  145853. */
  145854. getClassName(): string;
  145855. /**
  145856. * Gets the value operand input component
  145857. */
  145858. get value(): NodeMaterialConnectionPoint;
  145859. /**
  145860. * Gets the power operand input component
  145861. */
  145862. get power(): NodeMaterialConnectionPoint;
  145863. /**
  145864. * Gets the output component
  145865. */
  145866. get output(): NodeMaterialConnectionPoint;
  145867. protected _buildBlock(state: NodeMaterialBuildState): this;
  145868. }
  145869. }
  145870. declare module BABYLON {
  145871. /**
  145872. * Block used to get a random number
  145873. */
  145874. export class RandomNumberBlock extends NodeMaterialBlock {
  145875. /**
  145876. * Creates a new RandomNumberBlock
  145877. * @param name defines the block name
  145878. */
  145879. constructor(name: string);
  145880. /**
  145881. * Gets the current class name
  145882. * @returns the class name
  145883. */
  145884. getClassName(): string;
  145885. /**
  145886. * Gets the seed input component
  145887. */
  145888. get seed(): NodeMaterialConnectionPoint;
  145889. /**
  145890. * Gets the output component
  145891. */
  145892. get output(): NodeMaterialConnectionPoint;
  145893. protected _buildBlock(state: NodeMaterialBuildState): this;
  145894. }
  145895. }
  145896. declare module BABYLON {
  145897. /**
  145898. * Block used to compute arc tangent of 2 values
  145899. */
  145900. export class ArcTan2Block extends NodeMaterialBlock {
  145901. /**
  145902. * Creates a new ArcTan2Block
  145903. * @param name defines the block name
  145904. */
  145905. constructor(name: string);
  145906. /**
  145907. * Gets the current class name
  145908. * @returns the class name
  145909. */
  145910. getClassName(): string;
  145911. /**
  145912. * Gets the x operand input component
  145913. */
  145914. get x(): NodeMaterialConnectionPoint;
  145915. /**
  145916. * Gets the y operand input component
  145917. */
  145918. get y(): NodeMaterialConnectionPoint;
  145919. /**
  145920. * Gets the output component
  145921. */
  145922. get output(): NodeMaterialConnectionPoint;
  145923. protected _buildBlock(state: NodeMaterialBuildState): this;
  145924. }
  145925. }
  145926. declare module BABYLON {
  145927. /**
  145928. * Block used to smooth step a value
  145929. */
  145930. export class SmoothStepBlock extends NodeMaterialBlock {
  145931. /**
  145932. * Creates a new SmoothStepBlock
  145933. * @param name defines the block name
  145934. */
  145935. constructor(name: string);
  145936. /**
  145937. * Gets the current class name
  145938. * @returns the class name
  145939. */
  145940. getClassName(): string;
  145941. /**
  145942. * Gets the value operand input component
  145943. */
  145944. get value(): NodeMaterialConnectionPoint;
  145945. /**
  145946. * Gets the first edge operand input component
  145947. */
  145948. get edge0(): NodeMaterialConnectionPoint;
  145949. /**
  145950. * Gets the second edge operand input component
  145951. */
  145952. get edge1(): NodeMaterialConnectionPoint;
  145953. /**
  145954. * Gets the output component
  145955. */
  145956. get output(): NodeMaterialConnectionPoint;
  145957. protected _buildBlock(state: NodeMaterialBuildState): this;
  145958. }
  145959. }
  145960. declare module BABYLON {
  145961. /**
  145962. * Block used to get the reciprocal (1 / x) of a value
  145963. */
  145964. export class ReciprocalBlock extends NodeMaterialBlock {
  145965. /**
  145966. * Creates a new ReciprocalBlock
  145967. * @param name defines the block name
  145968. */
  145969. constructor(name: string);
  145970. /**
  145971. * Gets the current class name
  145972. * @returns the class name
  145973. */
  145974. getClassName(): string;
  145975. /**
  145976. * Gets the input component
  145977. */
  145978. get input(): NodeMaterialConnectionPoint;
  145979. /**
  145980. * Gets the output component
  145981. */
  145982. get output(): NodeMaterialConnectionPoint;
  145983. protected _buildBlock(state: NodeMaterialBuildState): this;
  145984. }
  145985. }
  145986. declare module BABYLON {
  145987. /**
  145988. * Block used to replace a color by another one
  145989. */
  145990. export class ReplaceColorBlock extends NodeMaterialBlock {
  145991. /**
  145992. * Creates a new ReplaceColorBlock
  145993. * @param name defines the block name
  145994. */
  145995. constructor(name: string);
  145996. /**
  145997. * Gets the current class name
  145998. * @returns the class name
  145999. */
  146000. getClassName(): string;
  146001. /**
  146002. * Gets the value input component
  146003. */
  146004. get value(): NodeMaterialConnectionPoint;
  146005. /**
  146006. * Gets the reference input component
  146007. */
  146008. get reference(): NodeMaterialConnectionPoint;
  146009. /**
  146010. * Gets the distance input component
  146011. */
  146012. get distance(): NodeMaterialConnectionPoint;
  146013. /**
  146014. * Gets the replacement input component
  146015. */
  146016. get replacement(): NodeMaterialConnectionPoint;
  146017. /**
  146018. * Gets the output component
  146019. */
  146020. get output(): NodeMaterialConnectionPoint;
  146021. protected _buildBlock(state: NodeMaterialBuildState): this;
  146022. }
  146023. }
  146024. declare module BABYLON {
  146025. /**
  146026. * Block used to posterize a value
  146027. * @see https://en.wikipedia.org/wiki/Posterization
  146028. */
  146029. export class PosterizeBlock extends NodeMaterialBlock {
  146030. /**
  146031. * Creates a new PosterizeBlock
  146032. * @param name defines the block name
  146033. */
  146034. constructor(name: string);
  146035. /**
  146036. * Gets the current class name
  146037. * @returns the class name
  146038. */
  146039. getClassName(): string;
  146040. /**
  146041. * Gets the value input component
  146042. */
  146043. get value(): NodeMaterialConnectionPoint;
  146044. /**
  146045. * Gets the steps input component
  146046. */
  146047. get steps(): NodeMaterialConnectionPoint;
  146048. /**
  146049. * Gets the output component
  146050. */
  146051. get output(): NodeMaterialConnectionPoint;
  146052. protected _buildBlock(state: NodeMaterialBuildState): this;
  146053. }
  146054. }
  146055. declare module BABYLON {
  146056. /**
  146057. * Operations supported by the Wave block
  146058. */
  146059. export enum WaveBlockKind {
  146060. /** SawTooth */
  146061. SawTooth = 0,
  146062. /** Square */
  146063. Square = 1,
  146064. /** Triangle */
  146065. Triangle = 2
  146066. }
  146067. /**
  146068. * Block used to apply wave operation to floats
  146069. */
  146070. export class WaveBlock extends NodeMaterialBlock {
  146071. /**
  146072. * Gets or sets the kibnd of wave to be applied by the block
  146073. */
  146074. kind: WaveBlockKind;
  146075. /**
  146076. * Creates a new WaveBlock
  146077. * @param name defines the block name
  146078. */
  146079. constructor(name: string);
  146080. /**
  146081. * Gets the current class name
  146082. * @returns the class name
  146083. */
  146084. getClassName(): string;
  146085. /**
  146086. * Gets the input component
  146087. */
  146088. get input(): NodeMaterialConnectionPoint;
  146089. /**
  146090. * Gets the output component
  146091. */
  146092. get output(): NodeMaterialConnectionPoint;
  146093. protected _buildBlock(state: NodeMaterialBuildState): this;
  146094. serialize(): any;
  146095. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146096. }
  146097. }
  146098. declare module BABYLON {
  146099. /**
  146100. * Class used to store a color step for the GradientBlock
  146101. */
  146102. export class GradientBlockColorStep {
  146103. private _step;
  146104. /**
  146105. * Gets value indicating which step this color is associated with (between 0 and 1)
  146106. */
  146107. get step(): number;
  146108. /**
  146109. * Sets a value indicating which step this color is associated with (between 0 and 1)
  146110. */
  146111. set step(val: number);
  146112. private _color;
  146113. /**
  146114. * Gets the color associated with this step
  146115. */
  146116. get color(): Color3;
  146117. /**
  146118. * Sets the color associated with this step
  146119. */
  146120. set color(val: Color3);
  146121. /**
  146122. * Creates a new GradientBlockColorStep
  146123. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  146124. * @param color defines the color associated with this step
  146125. */
  146126. constructor(step: number, color: Color3);
  146127. }
  146128. /**
  146129. * Block used to return a color from a gradient based on an input value between 0 and 1
  146130. */
  146131. export class GradientBlock extends NodeMaterialBlock {
  146132. /**
  146133. * Gets or sets the list of color steps
  146134. */
  146135. colorSteps: GradientBlockColorStep[];
  146136. /** Gets an observable raised when the value is changed */
  146137. onValueChangedObservable: Observable<GradientBlock>;
  146138. /** calls observable when the value is changed*/
  146139. colorStepsUpdated(): void;
  146140. /**
  146141. * Creates a new GradientBlock
  146142. * @param name defines the block name
  146143. */
  146144. constructor(name: string);
  146145. /**
  146146. * Gets the current class name
  146147. * @returns the class name
  146148. */
  146149. getClassName(): string;
  146150. /**
  146151. * Gets the gradient input component
  146152. */
  146153. get gradient(): NodeMaterialConnectionPoint;
  146154. /**
  146155. * Gets the output component
  146156. */
  146157. get output(): NodeMaterialConnectionPoint;
  146158. private _writeColorConstant;
  146159. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146160. serialize(): any;
  146161. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146162. protected _dumpPropertiesCode(): string;
  146163. }
  146164. }
  146165. declare module BABYLON {
  146166. /**
  146167. * Block used to normalize lerp between 2 values
  146168. */
  146169. export class NLerpBlock extends NodeMaterialBlock {
  146170. /**
  146171. * Creates a new NLerpBlock
  146172. * @param name defines the block name
  146173. */
  146174. constructor(name: string);
  146175. /**
  146176. * Gets the current class name
  146177. * @returns the class name
  146178. */
  146179. getClassName(): string;
  146180. /**
  146181. * Gets the left operand input component
  146182. */
  146183. get left(): NodeMaterialConnectionPoint;
  146184. /**
  146185. * Gets the right operand input component
  146186. */
  146187. get right(): NodeMaterialConnectionPoint;
  146188. /**
  146189. * Gets the gradient operand input component
  146190. */
  146191. get gradient(): NodeMaterialConnectionPoint;
  146192. /**
  146193. * Gets the output component
  146194. */
  146195. get output(): NodeMaterialConnectionPoint;
  146196. protected _buildBlock(state: NodeMaterialBuildState): this;
  146197. }
  146198. }
  146199. declare module BABYLON {
  146200. /**
  146201. * block used to Generate a Worley Noise 3D Noise Pattern
  146202. */
  146203. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  146204. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  146205. manhattanDistance: boolean;
  146206. /**
  146207. * Creates a new WorleyNoise3DBlock
  146208. * @param name defines the block name
  146209. */
  146210. constructor(name: string);
  146211. /**
  146212. * Gets the current class name
  146213. * @returns the class name
  146214. */
  146215. getClassName(): string;
  146216. /**
  146217. * Gets the seed input component
  146218. */
  146219. get seed(): NodeMaterialConnectionPoint;
  146220. /**
  146221. * Gets the jitter input component
  146222. */
  146223. get jitter(): NodeMaterialConnectionPoint;
  146224. /**
  146225. * Gets the output component
  146226. */
  146227. get output(): NodeMaterialConnectionPoint;
  146228. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146229. /**
  146230. * Exposes the properties to the UI?
  146231. */
  146232. protected _dumpPropertiesCode(): string;
  146233. /**
  146234. * Exposes the properties to the Seralize?
  146235. */
  146236. serialize(): any;
  146237. /**
  146238. * Exposes the properties to the deseralize?
  146239. */
  146240. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146241. }
  146242. }
  146243. declare module BABYLON {
  146244. /**
  146245. * block used to Generate a Simplex Perlin 3d Noise Pattern
  146246. */
  146247. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  146248. /**
  146249. * Creates a new SimplexPerlin3DBlock
  146250. * @param name defines the block name
  146251. */
  146252. constructor(name: string);
  146253. /**
  146254. * Gets the current class name
  146255. * @returns the class name
  146256. */
  146257. getClassName(): string;
  146258. /**
  146259. * Gets the seed operand input component
  146260. */
  146261. get seed(): NodeMaterialConnectionPoint;
  146262. /**
  146263. * Gets the output component
  146264. */
  146265. get output(): NodeMaterialConnectionPoint;
  146266. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  146267. }
  146268. }
  146269. declare module BABYLON {
  146270. /**
  146271. * Block used to blend normals
  146272. */
  146273. export class NormalBlendBlock extends NodeMaterialBlock {
  146274. /**
  146275. * Creates a new NormalBlendBlock
  146276. * @param name defines the block name
  146277. */
  146278. constructor(name: string);
  146279. /**
  146280. * Gets the current class name
  146281. * @returns the class name
  146282. */
  146283. getClassName(): string;
  146284. /**
  146285. * Gets the first input component
  146286. */
  146287. get normalMap0(): NodeMaterialConnectionPoint;
  146288. /**
  146289. * Gets the second input component
  146290. */
  146291. get normalMap1(): NodeMaterialConnectionPoint;
  146292. /**
  146293. * Gets the output component
  146294. */
  146295. get output(): NodeMaterialConnectionPoint;
  146296. protected _buildBlock(state: NodeMaterialBuildState): this;
  146297. }
  146298. }
  146299. declare module BABYLON {
  146300. /**
  146301. * Block used to rotate a 2d vector by a given angle
  146302. */
  146303. export class Rotate2dBlock extends NodeMaterialBlock {
  146304. /**
  146305. * Creates a new Rotate2dBlock
  146306. * @param name defines the block name
  146307. */
  146308. constructor(name: string);
  146309. /**
  146310. * Gets the current class name
  146311. * @returns the class name
  146312. */
  146313. getClassName(): string;
  146314. /**
  146315. * Gets the input vector
  146316. */
  146317. get input(): NodeMaterialConnectionPoint;
  146318. /**
  146319. * Gets the input angle
  146320. */
  146321. get angle(): NodeMaterialConnectionPoint;
  146322. /**
  146323. * Gets the output component
  146324. */
  146325. get output(): NodeMaterialConnectionPoint;
  146326. autoConfigure(material: NodeMaterial): void;
  146327. protected _buildBlock(state: NodeMaterialBuildState): this;
  146328. }
  146329. }
  146330. declare module BABYLON {
  146331. /**
  146332. * Block used to get the reflected vector from a direction and a normal
  146333. */
  146334. export class ReflectBlock extends NodeMaterialBlock {
  146335. /**
  146336. * Creates a new ReflectBlock
  146337. * @param name defines the block name
  146338. */
  146339. constructor(name: string);
  146340. /**
  146341. * Gets the current class name
  146342. * @returns the class name
  146343. */
  146344. getClassName(): string;
  146345. /**
  146346. * Gets the incident component
  146347. */
  146348. get incident(): NodeMaterialConnectionPoint;
  146349. /**
  146350. * Gets the normal component
  146351. */
  146352. get normal(): NodeMaterialConnectionPoint;
  146353. /**
  146354. * Gets the output component
  146355. */
  146356. get output(): NodeMaterialConnectionPoint;
  146357. protected _buildBlock(state: NodeMaterialBuildState): this;
  146358. }
  146359. }
  146360. declare module BABYLON {
  146361. /**
  146362. * Block used to get the refracted vector from a direction and a normal
  146363. */
  146364. export class RefractBlock extends NodeMaterialBlock {
  146365. /**
  146366. * Creates a new RefractBlock
  146367. * @param name defines the block name
  146368. */
  146369. constructor(name: string);
  146370. /**
  146371. * Gets the current class name
  146372. * @returns the class name
  146373. */
  146374. getClassName(): string;
  146375. /**
  146376. * Gets the incident component
  146377. */
  146378. get incident(): NodeMaterialConnectionPoint;
  146379. /**
  146380. * Gets the normal component
  146381. */
  146382. get normal(): NodeMaterialConnectionPoint;
  146383. /**
  146384. * Gets the index of refraction component
  146385. */
  146386. get ior(): NodeMaterialConnectionPoint;
  146387. /**
  146388. * Gets the output component
  146389. */
  146390. get output(): NodeMaterialConnectionPoint;
  146391. protected _buildBlock(state: NodeMaterialBuildState): this;
  146392. }
  146393. }
  146394. declare module BABYLON {
  146395. /**
  146396. * Block used to desaturate a color
  146397. */
  146398. export class DesaturateBlock extends NodeMaterialBlock {
  146399. /**
  146400. * Creates a new DesaturateBlock
  146401. * @param name defines the block name
  146402. */
  146403. constructor(name: string);
  146404. /**
  146405. * Gets the current class name
  146406. * @returns the class name
  146407. */
  146408. getClassName(): string;
  146409. /**
  146410. * Gets the color operand input component
  146411. */
  146412. get color(): NodeMaterialConnectionPoint;
  146413. /**
  146414. * Gets the level operand input component
  146415. */
  146416. get level(): NodeMaterialConnectionPoint;
  146417. /**
  146418. * Gets the output component
  146419. */
  146420. get output(): NodeMaterialConnectionPoint;
  146421. protected _buildBlock(state: NodeMaterialBuildState): this;
  146422. }
  146423. }
  146424. declare module BABYLON {
  146425. /**
  146426. * Block used to implement the ambient occlusion module of the PBR material
  146427. */
  146428. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  146429. /**
  146430. * Create a new AmbientOcclusionBlock
  146431. * @param name defines the block name
  146432. */
  146433. constructor(name: string);
  146434. /**
  146435. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  146436. */
  146437. useAmbientInGrayScale: boolean;
  146438. /**
  146439. * Initialize the block and prepare the context for build
  146440. * @param state defines the state that will be used for the build
  146441. */
  146442. initialize(state: NodeMaterialBuildState): void;
  146443. /**
  146444. * Gets the current class name
  146445. * @returns the class name
  146446. */
  146447. getClassName(): string;
  146448. /**
  146449. * Gets the texture input component
  146450. */
  146451. get texture(): NodeMaterialConnectionPoint;
  146452. /**
  146453. * Gets the texture intensity component
  146454. */
  146455. get intensity(): NodeMaterialConnectionPoint;
  146456. /**
  146457. * Gets the direct light intensity input component
  146458. */
  146459. get directLightIntensity(): NodeMaterialConnectionPoint;
  146460. /**
  146461. * Gets the ambient occlusion object output component
  146462. */
  146463. get ambientOcc(): NodeMaterialConnectionPoint;
  146464. /**
  146465. * Gets the main code of the block (fragment side)
  146466. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  146467. * @returns the shader code
  146468. */
  146469. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  146470. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146471. protected _buildBlock(state: NodeMaterialBuildState): this;
  146472. protected _dumpPropertiesCode(): string;
  146473. serialize(): any;
  146474. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146475. }
  146476. }
  146477. declare module BABYLON {
  146478. /**
  146479. * Block used to implement the reflection module of the PBR material
  146480. */
  146481. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  146482. /** @hidden */
  146483. _defineLODReflectionAlpha: string;
  146484. /** @hidden */
  146485. _defineLinearSpecularReflection: string;
  146486. private _vEnvironmentIrradianceName;
  146487. /** @hidden */
  146488. _vReflectionMicrosurfaceInfosName: string;
  146489. /** @hidden */
  146490. _vReflectionInfosName: string;
  146491. /** @hidden */
  146492. _vReflectionFilteringInfoName: string;
  146493. private _scene;
  146494. /**
  146495. * The three properties below are set by the main PBR block prior to calling methods of this class.
  146496. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  146497. * It's less burden on the user side in the editor part.
  146498. */
  146499. /** @hidden */
  146500. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  146501. /** @hidden */
  146502. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  146503. /** @hidden */
  146504. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  146505. /**
  146506. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  146507. * diffuse part of the IBL.
  146508. */
  146509. useSphericalHarmonics: boolean;
  146510. /**
  146511. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  146512. */
  146513. forceIrradianceInFragment: boolean;
  146514. /**
  146515. * Create a new ReflectionBlock
  146516. * @param name defines the block name
  146517. */
  146518. constructor(name: string);
  146519. /**
  146520. * Gets the current class name
  146521. * @returns the class name
  146522. */
  146523. getClassName(): string;
  146524. /**
  146525. * Gets the position input component
  146526. */
  146527. get position(): NodeMaterialConnectionPoint;
  146528. /**
  146529. * Gets the world position input component
  146530. */
  146531. get worldPosition(): NodeMaterialConnectionPoint;
  146532. /**
  146533. * Gets the world normal input component
  146534. */
  146535. get worldNormal(): NodeMaterialConnectionPoint;
  146536. /**
  146537. * Gets the world input component
  146538. */
  146539. get world(): NodeMaterialConnectionPoint;
  146540. /**
  146541. * Gets the camera (or eye) position component
  146542. */
  146543. get cameraPosition(): NodeMaterialConnectionPoint;
  146544. /**
  146545. * Gets the view input component
  146546. */
  146547. get view(): NodeMaterialConnectionPoint;
  146548. /**
  146549. * Gets the color input component
  146550. */
  146551. get color(): NodeMaterialConnectionPoint;
  146552. /**
  146553. * Gets the reflection object output component
  146554. */
  146555. get reflection(): NodeMaterialConnectionPoint;
  146556. /**
  146557. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  146558. */
  146559. get hasTexture(): boolean;
  146560. /**
  146561. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  146562. */
  146563. get reflectionColor(): string;
  146564. protected _getTexture(): Nullable<BaseTexture>;
  146565. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146566. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146567. /**
  146568. * Gets the code to inject in the vertex shader
  146569. * @param state current state of the node material building
  146570. * @returns the shader code
  146571. */
  146572. handleVertexSide(state: NodeMaterialBuildState): string;
  146573. /**
  146574. * Gets the main code of the block (fragment side)
  146575. * @param state current state of the node material building
  146576. * @param normalVarName name of the existing variable corresponding to the normal
  146577. * @returns the shader code
  146578. */
  146579. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  146580. protected _buildBlock(state: NodeMaterialBuildState): this;
  146581. protected _dumpPropertiesCode(): string;
  146582. serialize(): any;
  146583. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146584. }
  146585. }
  146586. declare module BABYLON {
  146587. /**
  146588. * Block used to implement the sheen module of the PBR material
  146589. */
  146590. export class SheenBlock extends NodeMaterialBlock {
  146591. /**
  146592. * Create a new SheenBlock
  146593. * @param name defines the block name
  146594. */
  146595. constructor(name: string);
  146596. /**
  146597. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  146598. * It allows the strength of the sheen effect to not depend on the base color of the material,
  146599. * making it easier to setup and tweak the effect
  146600. */
  146601. albedoScaling: boolean;
  146602. /**
  146603. * Defines if the sheen is linked to the sheen color.
  146604. */
  146605. linkSheenWithAlbedo: boolean;
  146606. /**
  146607. * Initialize the block and prepare the context for build
  146608. * @param state defines the state that will be used for the build
  146609. */
  146610. initialize(state: NodeMaterialBuildState): void;
  146611. /**
  146612. * Gets the current class name
  146613. * @returns the class name
  146614. */
  146615. getClassName(): string;
  146616. /**
  146617. * Gets the intensity input component
  146618. */
  146619. get intensity(): NodeMaterialConnectionPoint;
  146620. /**
  146621. * Gets the color input component
  146622. */
  146623. get color(): NodeMaterialConnectionPoint;
  146624. /**
  146625. * Gets the roughness input component
  146626. */
  146627. get roughness(): NodeMaterialConnectionPoint;
  146628. /**
  146629. * Gets the sheen object output component
  146630. */
  146631. get sheen(): NodeMaterialConnectionPoint;
  146632. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146633. /**
  146634. * Gets the main code of the block (fragment side)
  146635. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146636. * @returns the shader code
  146637. */
  146638. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  146639. protected _buildBlock(state: NodeMaterialBuildState): this;
  146640. protected _dumpPropertiesCode(): string;
  146641. serialize(): any;
  146642. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146643. }
  146644. }
  146645. declare module BABYLON {
  146646. /**
  146647. * Block used to implement the reflectivity module of the PBR material
  146648. */
  146649. export class ReflectivityBlock extends NodeMaterialBlock {
  146650. private _metallicReflectanceColor;
  146651. private _metallicF0Factor;
  146652. /** @hidden */
  146653. _vMetallicReflectanceFactorsName: string;
  146654. /**
  146655. * The property below is set by the main PBR block prior to calling methods of this class.
  146656. */
  146657. /** @hidden */
  146658. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  146659. /**
  146660. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  146661. */
  146662. useAmbientOcclusionFromMetallicTextureRed: boolean;
  146663. /**
  146664. * Specifies if the metallic texture contains the metallness information in its blue channel.
  146665. */
  146666. useMetallnessFromMetallicTextureBlue: boolean;
  146667. /**
  146668. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  146669. */
  146670. useRoughnessFromMetallicTextureAlpha: boolean;
  146671. /**
  146672. * Specifies if the metallic texture contains the roughness information in its green channel.
  146673. */
  146674. useRoughnessFromMetallicTextureGreen: boolean;
  146675. /**
  146676. * Create a new ReflectivityBlock
  146677. * @param name defines the block name
  146678. */
  146679. constructor(name: string);
  146680. /**
  146681. * Initialize the block and prepare the context for build
  146682. * @param state defines the state that will be used for the build
  146683. */
  146684. initialize(state: NodeMaterialBuildState): void;
  146685. /**
  146686. * Gets the current class name
  146687. * @returns the class name
  146688. */
  146689. getClassName(): string;
  146690. /**
  146691. * Gets the metallic input component
  146692. */
  146693. get metallic(): NodeMaterialConnectionPoint;
  146694. /**
  146695. * Gets the roughness input component
  146696. */
  146697. get roughness(): NodeMaterialConnectionPoint;
  146698. /**
  146699. * Gets the texture input component
  146700. */
  146701. get texture(): NodeMaterialConnectionPoint;
  146702. /**
  146703. * Gets the reflectivity object output component
  146704. */
  146705. get reflectivity(): NodeMaterialConnectionPoint;
  146706. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146707. /**
  146708. * Gets the main code of the block (fragment side)
  146709. * @param state current state of the node material building
  146710. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  146711. * @returns the shader code
  146712. */
  146713. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  146714. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146715. protected _buildBlock(state: NodeMaterialBuildState): this;
  146716. protected _dumpPropertiesCode(): string;
  146717. serialize(): any;
  146718. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  146719. }
  146720. }
  146721. declare module BABYLON {
  146722. /**
  146723. * Block used to implement the anisotropy module of the PBR material
  146724. */
  146725. export class AnisotropyBlock extends NodeMaterialBlock {
  146726. /**
  146727. * The two properties below are set by the main PBR block prior to calling methods of this class.
  146728. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  146729. * It's less burden on the user side in the editor part.
  146730. */
  146731. /** @hidden */
  146732. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  146733. /** @hidden */
  146734. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  146735. /**
  146736. * Create a new AnisotropyBlock
  146737. * @param name defines the block name
  146738. */
  146739. constructor(name: string);
  146740. /**
  146741. * Initialize the block and prepare the context for build
  146742. * @param state defines the state that will be used for the build
  146743. */
  146744. initialize(state: NodeMaterialBuildState): void;
  146745. /**
  146746. * Gets the current class name
  146747. * @returns the class name
  146748. */
  146749. getClassName(): string;
  146750. /**
  146751. * Gets the intensity input component
  146752. */
  146753. get intensity(): NodeMaterialConnectionPoint;
  146754. /**
  146755. * Gets the direction input component
  146756. */
  146757. get direction(): NodeMaterialConnectionPoint;
  146758. /**
  146759. * Gets the texture input component
  146760. */
  146761. get texture(): NodeMaterialConnectionPoint;
  146762. /**
  146763. * Gets the uv input component
  146764. */
  146765. get uv(): NodeMaterialConnectionPoint;
  146766. /**
  146767. * Gets the worldTangent input component
  146768. */
  146769. get worldTangent(): NodeMaterialConnectionPoint;
  146770. /**
  146771. * Gets the anisotropy object output component
  146772. */
  146773. get anisotropy(): NodeMaterialConnectionPoint;
  146774. private _generateTBNSpace;
  146775. /**
  146776. * Gets the main code of the block (fragment side)
  146777. * @param state current state of the node material building
  146778. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146779. * @returns the shader code
  146780. */
  146781. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  146782. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146783. protected _buildBlock(state: NodeMaterialBuildState): this;
  146784. }
  146785. }
  146786. declare module BABYLON {
  146787. /**
  146788. * Block used to implement the clear coat module of the PBR material
  146789. */
  146790. export class ClearCoatBlock extends NodeMaterialBlock {
  146791. private _scene;
  146792. /**
  146793. * Create a new ClearCoatBlock
  146794. * @param name defines the block name
  146795. */
  146796. constructor(name: string);
  146797. /**
  146798. * Initialize the block and prepare the context for build
  146799. * @param state defines the state that will be used for the build
  146800. */
  146801. initialize(state: NodeMaterialBuildState): void;
  146802. /**
  146803. * Gets the current class name
  146804. * @returns the class name
  146805. */
  146806. getClassName(): string;
  146807. /**
  146808. * Gets the intensity input component
  146809. */
  146810. get intensity(): NodeMaterialConnectionPoint;
  146811. /**
  146812. * Gets the roughness input component
  146813. */
  146814. get roughness(): NodeMaterialConnectionPoint;
  146815. /**
  146816. * Gets the ior input component
  146817. */
  146818. get ior(): NodeMaterialConnectionPoint;
  146819. /**
  146820. * Gets the texture input component
  146821. */
  146822. get texture(): NodeMaterialConnectionPoint;
  146823. /**
  146824. * Gets the bump texture input component
  146825. */
  146826. get bumpTexture(): NodeMaterialConnectionPoint;
  146827. /**
  146828. * Gets the uv input component
  146829. */
  146830. get uv(): NodeMaterialConnectionPoint;
  146831. /**
  146832. * Gets the tint color input component
  146833. */
  146834. get tintColor(): NodeMaterialConnectionPoint;
  146835. /**
  146836. * Gets the tint "at distance" input component
  146837. */
  146838. get tintAtDistance(): NodeMaterialConnectionPoint;
  146839. /**
  146840. * Gets the tint thickness input component
  146841. */
  146842. get tintThickness(): NodeMaterialConnectionPoint;
  146843. /**
  146844. * Gets the world tangent input component
  146845. */
  146846. get worldTangent(): NodeMaterialConnectionPoint;
  146847. /**
  146848. * Gets the clear coat object output component
  146849. */
  146850. get clearcoat(): NodeMaterialConnectionPoint;
  146851. autoConfigure(material: NodeMaterial): void;
  146852. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146853. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  146854. private _generateTBNSpace;
  146855. /**
  146856. * Gets the main code of the block (fragment side)
  146857. * @param state current state of the node material building
  146858. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  146859. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146860. * @param worldPosVarName name of the variable holding the world position
  146861. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  146862. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  146863. * @param worldNormalVarName name of the variable holding the world normal
  146864. * @returns the shader code
  146865. */
  146866. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  146867. protected _buildBlock(state: NodeMaterialBuildState): this;
  146868. }
  146869. }
  146870. declare module BABYLON {
  146871. /**
  146872. * Block used to implement the sub surface module of the PBR material
  146873. */
  146874. export class SubSurfaceBlock extends NodeMaterialBlock {
  146875. /**
  146876. * Create a new SubSurfaceBlock
  146877. * @param name defines the block name
  146878. */
  146879. constructor(name: string);
  146880. /**
  146881. * Stores the intensity of the different subsurface effects in the thickness texture.
  146882. * * the green channel is the translucency intensity.
  146883. * * the blue channel is the scattering intensity.
  146884. * * the alpha channel is the refraction intensity.
  146885. */
  146886. useMaskFromThicknessTexture: boolean;
  146887. /**
  146888. * Initialize the block and prepare the context for build
  146889. * @param state defines the state that will be used for the build
  146890. */
  146891. initialize(state: NodeMaterialBuildState): void;
  146892. /**
  146893. * Gets the current class name
  146894. * @returns the class name
  146895. */
  146896. getClassName(): string;
  146897. /**
  146898. * Gets the min thickness input component
  146899. */
  146900. get minThickness(): NodeMaterialConnectionPoint;
  146901. /**
  146902. * Gets the max thickness input component
  146903. */
  146904. get maxThickness(): NodeMaterialConnectionPoint;
  146905. /**
  146906. * Gets the thickness texture component
  146907. */
  146908. get thicknessTexture(): NodeMaterialConnectionPoint;
  146909. /**
  146910. * Gets the tint color input component
  146911. */
  146912. get tintColor(): NodeMaterialConnectionPoint;
  146913. /**
  146914. * Gets the translucency intensity input component
  146915. */
  146916. get translucencyIntensity(): NodeMaterialConnectionPoint;
  146917. /**
  146918. * Gets the translucency diffusion distance input component
  146919. */
  146920. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  146921. /**
  146922. * Gets the refraction object parameters
  146923. */
  146924. get refraction(): NodeMaterialConnectionPoint;
  146925. /**
  146926. * Gets the sub surface object output component
  146927. */
  146928. get subsurface(): NodeMaterialConnectionPoint;
  146929. autoConfigure(material: NodeMaterial): void;
  146930. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  146931. /**
  146932. * Gets the main code of the block (fragment side)
  146933. * @param state current state of the node material building
  146934. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  146935. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  146936. * @param worldPosVarName name of the variable holding the world position
  146937. * @returns the shader code
  146938. */
  146939. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  146940. protected _buildBlock(state: NodeMaterialBuildState): this;
  146941. }
  146942. }
  146943. declare module BABYLON {
  146944. /**
  146945. * Block used to implement the PBR metallic/roughness model
  146946. */
  146947. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  146948. /**
  146949. * Gets or sets the light associated with this block
  146950. */
  146951. light: Nullable<Light>;
  146952. private _lightId;
  146953. private _scene;
  146954. private _environmentBRDFTexture;
  146955. private _environmentBrdfSamplerName;
  146956. private _vNormalWName;
  146957. private _invertNormalName;
  146958. /**
  146959. * Create a new ReflectionBlock
  146960. * @param name defines the block name
  146961. */
  146962. constructor(name: string);
  146963. /**
  146964. * Intensity of the direct lights e.g. the four lights available in your scene.
  146965. * This impacts both the direct diffuse and specular highlights.
  146966. */
  146967. directIntensity: number;
  146968. /**
  146969. * Intensity of the environment e.g. how much the environment will light the object
  146970. * either through harmonics for rough material or through the refelction for shiny ones.
  146971. */
  146972. environmentIntensity: number;
  146973. /**
  146974. * This is a special control allowing the reduction of the specular highlights coming from the
  146975. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  146976. */
  146977. specularIntensity: number;
  146978. /**
  146979. * Defines the falloff type used in this material.
  146980. * It by default is Physical.
  146981. */
  146982. lightFalloff: number;
  146983. /**
  146984. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  146985. */
  146986. useAlphaFromAlbedoTexture: boolean;
  146987. /**
  146988. * Specifies that alpha test should be used
  146989. */
  146990. useAlphaTest: boolean;
  146991. /**
  146992. * Defines the alpha limits in alpha test mode.
  146993. */
  146994. alphaTestCutoff: number;
  146995. /**
  146996. * Specifies that alpha blending should be used
  146997. */
  146998. useAlphaBlending: boolean;
  146999. /**
  147000. * Defines if the alpha value should be determined via the rgb values.
  147001. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  147002. */
  147003. opacityRGB: boolean;
  147004. /**
  147005. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  147006. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  147007. */
  147008. useRadianceOverAlpha: boolean;
  147009. /**
  147010. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  147011. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  147012. */
  147013. useSpecularOverAlpha: boolean;
  147014. /**
  147015. * Enables specular anti aliasing in the PBR shader.
  147016. * It will both interacts on the Geometry for analytical and IBL lighting.
  147017. * It also prefilter the roughness map based on the bump values.
  147018. */
  147019. enableSpecularAntiAliasing: boolean;
  147020. /**
  147021. * Enables realtime filtering on the texture.
  147022. */
  147023. realTimeFiltering: boolean;
  147024. /**
  147025. * Quality switch for realtime filtering
  147026. */
  147027. realTimeFilteringQuality: number;
  147028. /**
  147029. * Defines if the material uses energy conservation.
  147030. */
  147031. useEnergyConservation: boolean;
  147032. /**
  147033. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  147034. * too much the area relying on ambient texture to define their ambient occlusion.
  147035. */
  147036. useRadianceOcclusion: boolean;
  147037. /**
  147038. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  147039. * makes the reflect vector face the model (under horizon).
  147040. */
  147041. useHorizonOcclusion: boolean;
  147042. /**
  147043. * If set to true, no lighting calculations will be applied.
  147044. */
  147045. unlit: boolean;
  147046. /**
  147047. * Force normal to face away from face.
  147048. */
  147049. forceNormalForward: boolean;
  147050. /**
  147051. * Defines the material debug mode.
  147052. * It helps seeing only some components of the material while troubleshooting.
  147053. */
  147054. debugMode: number;
  147055. /**
  147056. * Specify from where on screen the debug mode should start.
  147057. * The value goes from -1 (full screen) to 1 (not visible)
  147058. * It helps with side by side comparison against the final render
  147059. * This defaults to 0
  147060. */
  147061. debugLimit: number;
  147062. /**
  147063. * As the default viewing range might not be enough (if the ambient is really small for instance)
  147064. * You can use the factor to better multiply the final value.
  147065. */
  147066. debugFactor: number;
  147067. /**
  147068. * Initialize the block and prepare the context for build
  147069. * @param state defines the state that will be used for the build
  147070. */
  147071. initialize(state: NodeMaterialBuildState): void;
  147072. /**
  147073. * Gets the current class name
  147074. * @returns the class name
  147075. */
  147076. getClassName(): string;
  147077. /**
  147078. * Gets the world position input component
  147079. */
  147080. get worldPosition(): NodeMaterialConnectionPoint;
  147081. /**
  147082. * Gets the world normal input component
  147083. */
  147084. get worldNormal(): NodeMaterialConnectionPoint;
  147085. /**
  147086. * Gets the perturbed normal input component
  147087. */
  147088. get perturbedNormal(): NodeMaterialConnectionPoint;
  147089. /**
  147090. * Gets the camera position input component
  147091. */
  147092. get cameraPosition(): NodeMaterialConnectionPoint;
  147093. /**
  147094. * Gets the base color input component
  147095. */
  147096. get baseColor(): NodeMaterialConnectionPoint;
  147097. /**
  147098. * Gets the opacity texture input component
  147099. */
  147100. get opacityTexture(): NodeMaterialConnectionPoint;
  147101. /**
  147102. * Gets the ambient color input component
  147103. */
  147104. get ambientColor(): NodeMaterialConnectionPoint;
  147105. /**
  147106. * Gets the reflectivity object parameters
  147107. */
  147108. get reflectivity(): NodeMaterialConnectionPoint;
  147109. /**
  147110. * Gets the ambient occlusion object parameters
  147111. */
  147112. get ambientOcc(): NodeMaterialConnectionPoint;
  147113. /**
  147114. * Gets the reflection object parameters
  147115. */
  147116. get reflection(): NodeMaterialConnectionPoint;
  147117. /**
  147118. * Gets the sheen object parameters
  147119. */
  147120. get sheen(): NodeMaterialConnectionPoint;
  147121. /**
  147122. * Gets the clear coat object parameters
  147123. */
  147124. get clearcoat(): NodeMaterialConnectionPoint;
  147125. /**
  147126. * Gets the sub surface object parameters
  147127. */
  147128. get subsurface(): NodeMaterialConnectionPoint;
  147129. /**
  147130. * Gets the anisotropy object parameters
  147131. */
  147132. get anisotropy(): NodeMaterialConnectionPoint;
  147133. /**
  147134. * Gets the view matrix parameter
  147135. */
  147136. get view(): NodeMaterialConnectionPoint;
  147137. /**
  147138. * Gets the ambient output component
  147139. */
  147140. get ambient(): NodeMaterialConnectionPoint;
  147141. /**
  147142. * Gets the diffuse output component
  147143. */
  147144. get diffuse(): NodeMaterialConnectionPoint;
  147145. /**
  147146. * Gets the specular output component
  147147. */
  147148. get specular(): NodeMaterialConnectionPoint;
  147149. /**
  147150. * Gets the sheen output component
  147151. */
  147152. get sheenDir(): NodeMaterialConnectionPoint;
  147153. /**
  147154. * Gets the clear coat output component
  147155. */
  147156. get clearcoatDir(): NodeMaterialConnectionPoint;
  147157. /**
  147158. * Gets the indirect diffuse output component
  147159. */
  147160. get diffuseIndirect(): NodeMaterialConnectionPoint;
  147161. /**
  147162. * Gets the indirect specular output component
  147163. */
  147164. get specularIndirect(): NodeMaterialConnectionPoint;
  147165. /**
  147166. * Gets the indirect sheen output component
  147167. */
  147168. get sheenIndirect(): NodeMaterialConnectionPoint;
  147169. /**
  147170. * Gets the indirect clear coat output component
  147171. */
  147172. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  147173. /**
  147174. * Gets the refraction output component
  147175. */
  147176. get refraction(): NodeMaterialConnectionPoint;
  147177. /**
  147178. * Gets the global lighting output component
  147179. */
  147180. get lighting(): NodeMaterialConnectionPoint;
  147181. /**
  147182. * Gets the shadow output component
  147183. */
  147184. get shadow(): NodeMaterialConnectionPoint;
  147185. /**
  147186. * Gets the alpha output component
  147187. */
  147188. get alpha(): NodeMaterialConnectionPoint;
  147189. autoConfigure(material: NodeMaterial): void;
  147190. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  147191. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  147192. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  147193. private _injectVertexCode;
  147194. /**
  147195. * Gets the code corresponding to the albedo/opacity module
  147196. * @returns the shader code
  147197. */
  147198. getAlbedoOpacityCode(): string;
  147199. protected _buildBlock(state: NodeMaterialBuildState): this;
  147200. protected _dumpPropertiesCode(): string;
  147201. serialize(): any;
  147202. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  147203. }
  147204. }
  147205. declare module BABYLON {
  147206. /**
  147207. * Block used to compute value of one parameter modulo another
  147208. */
  147209. export class ModBlock extends NodeMaterialBlock {
  147210. /**
  147211. * Creates a new ModBlock
  147212. * @param name defines the block name
  147213. */
  147214. constructor(name: string);
  147215. /**
  147216. * Gets the current class name
  147217. * @returns the class name
  147218. */
  147219. getClassName(): string;
  147220. /**
  147221. * Gets the left operand input component
  147222. */
  147223. get left(): NodeMaterialConnectionPoint;
  147224. /**
  147225. * Gets the right operand input component
  147226. */
  147227. get right(): NodeMaterialConnectionPoint;
  147228. /**
  147229. * Gets the output component
  147230. */
  147231. get output(): NodeMaterialConnectionPoint;
  147232. protected _buildBlock(state: NodeMaterialBuildState): this;
  147233. }
  147234. }
  147235. declare module BABYLON {
  147236. /**
  147237. * Configuration for Draco compression
  147238. */
  147239. export interface IDracoCompressionConfiguration {
  147240. /**
  147241. * Configuration for the decoder.
  147242. */
  147243. decoder: {
  147244. /**
  147245. * The url to the WebAssembly module.
  147246. */
  147247. wasmUrl?: string;
  147248. /**
  147249. * The url to the WebAssembly binary.
  147250. */
  147251. wasmBinaryUrl?: string;
  147252. /**
  147253. * The url to the fallback JavaScript module.
  147254. */
  147255. fallbackUrl?: string;
  147256. };
  147257. }
  147258. /**
  147259. * Draco compression (https://google.github.io/draco/)
  147260. *
  147261. * This class wraps the Draco module.
  147262. *
  147263. * **Encoder**
  147264. *
  147265. * The encoder is not currently implemented.
  147266. *
  147267. * **Decoder**
  147268. *
  147269. * 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.
  147270. *
  147271. * To update the configuration, use the following code:
  147272. * ```javascript
  147273. * DracoCompression.Configuration = {
  147274. * decoder: {
  147275. * wasmUrl: "<url to the WebAssembly library>",
  147276. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  147277. * fallbackUrl: "<url to the fallback JavaScript library>",
  147278. * }
  147279. * };
  147280. * ```
  147281. *
  147282. * 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.
  147283. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  147284. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  147285. *
  147286. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  147287. * ```javascript
  147288. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  147289. * ```
  147290. *
  147291. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  147292. */
  147293. export class DracoCompression implements IDisposable {
  147294. private _workerPoolPromise?;
  147295. private _decoderModulePromise?;
  147296. /**
  147297. * The configuration. Defaults to the following urls:
  147298. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  147299. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  147300. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  147301. */
  147302. static Configuration: IDracoCompressionConfiguration;
  147303. /**
  147304. * Returns true if the decoder configuration is available.
  147305. */
  147306. static get DecoderAvailable(): boolean;
  147307. /**
  147308. * Default number of workers to create when creating the draco compression object.
  147309. */
  147310. static DefaultNumWorkers: number;
  147311. private static GetDefaultNumWorkers;
  147312. private static _Default;
  147313. /**
  147314. * Default instance for the draco compression object.
  147315. */
  147316. static get Default(): DracoCompression;
  147317. /**
  147318. * Constructor
  147319. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  147320. */
  147321. constructor(numWorkers?: number);
  147322. /**
  147323. * Stop all async operations and release resources.
  147324. */
  147325. dispose(): void;
  147326. /**
  147327. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  147328. * @returns a promise that resolves when ready
  147329. */
  147330. whenReadyAsync(): Promise<void>;
  147331. /**
  147332. * Decode Draco compressed mesh data to vertex data.
  147333. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  147334. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  147335. * @returns A promise that resolves with the decoded vertex data
  147336. */
  147337. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  147338. [kind: string]: number;
  147339. }): Promise<VertexData>;
  147340. }
  147341. }
  147342. declare module BABYLON {
  147343. /**
  147344. * Class for building Constructive Solid Geometry
  147345. */
  147346. export class CSG {
  147347. private polygons;
  147348. /**
  147349. * The world matrix
  147350. */
  147351. matrix: Matrix;
  147352. /**
  147353. * Stores the position
  147354. */
  147355. position: Vector3;
  147356. /**
  147357. * Stores the rotation
  147358. */
  147359. rotation: Vector3;
  147360. /**
  147361. * Stores the rotation quaternion
  147362. */
  147363. rotationQuaternion: Nullable<Quaternion>;
  147364. /**
  147365. * Stores the scaling vector
  147366. */
  147367. scaling: Vector3;
  147368. /**
  147369. * Convert the Mesh to CSG
  147370. * @param mesh The Mesh to convert to CSG
  147371. * @returns A new CSG from the Mesh
  147372. */
  147373. static FromMesh(mesh: Mesh): CSG;
  147374. /**
  147375. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  147376. * @param polygons Polygons used to construct a CSG solid
  147377. */
  147378. private static FromPolygons;
  147379. /**
  147380. * Clones, or makes a deep copy, of the CSG
  147381. * @returns A new CSG
  147382. */
  147383. clone(): CSG;
  147384. /**
  147385. * Unions this CSG with another CSG
  147386. * @param csg The CSG to union against this CSG
  147387. * @returns The unioned CSG
  147388. */
  147389. union(csg: CSG): CSG;
  147390. /**
  147391. * Unions this CSG with another CSG in place
  147392. * @param csg The CSG to union against this CSG
  147393. */
  147394. unionInPlace(csg: CSG): void;
  147395. /**
  147396. * Subtracts this CSG with another CSG
  147397. * @param csg The CSG to subtract against this CSG
  147398. * @returns A new CSG
  147399. */
  147400. subtract(csg: CSG): CSG;
  147401. /**
  147402. * Subtracts this CSG with another CSG in place
  147403. * @param csg The CSG to subtact against this CSG
  147404. */
  147405. subtractInPlace(csg: CSG): void;
  147406. /**
  147407. * Intersect this CSG with another CSG
  147408. * @param csg The CSG to intersect against this CSG
  147409. * @returns A new CSG
  147410. */
  147411. intersect(csg: CSG): CSG;
  147412. /**
  147413. * Intersects this CSG with another CSG in place
  147414. * @param csg The CSG to intersect against this CSG
  147415. */
  147416. intersectInPlace(csg: CSG): void;
  147417. /**
  147418. * Return a new CSG solid with solid and empty space switched. This solid is
  147419. * not modified.
  147420. * @returns A new CSG solid with solid and empty space switched
  147421. */
  147422. inverse(): CSG;
  147423. /**
  147424. * Inverses the CSG in place
  147425. */
  147426. inverseInPlace(): void;
  147427. /**
  147428. * This is used to keep meshes transformations so they can be restored
  147429. * when we build back a Babylon Mesh
  147430. * NB : All CSG operations are performed in world coordinates
  147431. * @param csg The CSG to copy the transform attributes from
  147432. * @returns This CSG
  147433. */
  147434. copyTransformAttributes(csg: CSG): CSG;
  147435. /**
  147436. * Build Raw mesh from CSG
  147437. * Coordinates here are in world space
  147438. * @param name The name of the mesh geometry
  147439. * @param scene The Scene
  147440. * @param keepSubMeshes Specifies if the submeshes should be kept
  147441. * @returns A new Mesh
  147442. */
  147443. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  147444. /**
  147445. * Build Mesh from CSG taking material and transforms into account
  147446. * @param name The name of the Mesh
  147447. * @param material The material of the Mesh
  147448. * @param scene The Scene
  147449. * @param keepSubMeshes Specifies if submeshes should be kept
  147450. * @returns The new Mesh
  147451. */
  147452. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  147453. }
  147454. }
  147455. declare module BABYLON {
  147456. /**
  147457. * Class used to create a trail following a mesh
  147458. */
  147459. export class TrailMesh extends Mesh {
  147460. private _generator;
  147461. private _autoStart;
  147462. private _running;
  147463. private _diameter;
  147464. private _length;
  147465. private _sectionPolygonPointsCount;
  147466. private _sectionVectors;
  147467. private _sectionNormalVectors;
  147468. private _beforeRenderObserver;
  147469. /**
  147470. * @constructor
  147471. * @param name The value used by scene.getMeshByName() to do a lookup.
  147472. * @param generator The mesh or transform node to generate a trail.
  147473. * @param scene The scene to add this mesh to.
  147474. * @param diameter Diameter of trailing mesh. Default is 1.
  147475. * @param length Length of trailing mesh. Default is 60.
  147476. * @param autoStart Automatically start trailing mesh. Default true.
  147477. */
  147478. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  147479. /**
  147480. * "TrailMesh"
  147481. * @returns "TrailMesh"
  147482. */
  147483. getClassName(): string;
  147484. private _createMesh;
  147485. /**
  147486. * Start trailing mesh.
  147487. */
  147488. start(): void;
  147489. /**
  147490. * Stop trailing mesh.
  147491. */
  147492. stop(): void;
  147493. /**
  147494. * Update trailing mesh geometry.
  147495. */
  147496. update(): void;
  147497. /**
  147498. * Returns a new TrailMesh object.
  147499. * @param name is a string, the name given to the new mesh
  147500. * @param newGenerator use new generator object for cloned trail mesh
  147501. * @returns a new mesh
  147502. */
  147503. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  147504. /**
  147505. * Serializes this trail mesh
  147506. * @param serializationObject object to write serialization to
  147507. */
  147508. serialize(serializationObject: any): void;
  147509. /**
  147510. * Parses a serialized trail mesh
  147511. * @param parsedMesh the serialized mesh
  147512. * @param scene the scene to create the trail mesh in
  147513. * @returns the created trail mesh
  147514. */
  147515. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  147516. }
  147517. }
  147518. declare module BABYLON {
  147519. /**
  147520. * Class containing static functions to help procedurally build meshes
  147521. */
  147522. export class TiledBoxBuilder {
  147523. /**
  147524. * Creates a box mesh
  147525. * 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)
  147526. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147527. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147528. * * 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
  147529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147530. * @param name defines the name of the mesh
  147531. * @param options defines the options used to create the mesh
  147532. * @param scene defines the hosting scene
  147533. * @returns the box mesh
  147534. */
  147535. static CreateTiledBox(name: string, options: {
  147536. pattern?: number;
  147537. width?: number;
  147538. height?: number;
  147539. depth?: number;
  147540. tileSize?: number;
  147541. tileWidth?: number;
  147542. tileHeight?: number;
  147543. alignHorizontal?: number;
  147544. alignVertical?: number;
  147545. faceUV?: Vector4[];
  147546. faceColors?: Color4[];
  147547. sideOrientation?: number;
  147548. updatable?: boolean;
  147549. }, scene?: Nullable<Scene>): Mesh;
  147550. }
  147551. }
  147552. declare module BABYLON {
  147553. /**
  147554. * Class containing static functions to help procedurally build meshes
  147555. */
  147556. export class TorusKnotBuilder {
  147557. /**
  147558. * Creates a torus knot mesh
  147559. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  147560. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  147561. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  147562. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  147563. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147564. * * 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
  147565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147566. * @param name defines the name of the mesh
  147567. * @param options defines the options used to create the mesh
  147568. * @param scene defines the hosting scene
  147569. * @returns the torus knot mesh
  147570. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  147571. */
  147572. static CreateTorusKnot(name: string, options: {
  147573. radius?: number;
  147574. tube?: number;
  147575. radialSegments?: number;
  147576. tubularSegments?: number;
  147577. p?: number;
  147578. q?: number;
  147579. updatable?: boolean;
  147580. sideOrientation?: number;
  147581. frontUVs?: Vector4;
  147582. backUVs?: Vector4;
  147583. }, scene: any): Mesh;
  147584. }
  147585. }
  147586. declare module BABYLON {
  147587. /**
  147588. * Polygon
  147589. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  147590. */
  147591. export class Polygon {
  147592. /**
  147593. * Creates a rectangle
  147594. * @param xmin bottom X coord
  147595. * @param ymin bottom Y coord
  147596. * @param xmax top X coord
  147597. * @param ymax top Y coord
  147598. * @returns points that make the resulting rectation
  147599. */
  147600. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  147601. /**
  147602. * Creates a circle
  147603. * @param radius radius of circle
  147604. * @param cx scale in x
  147605. * @param cy scale in y
  147606. * @param numberOfSides number of sides that make up the circle
  147607. * @returns points that make the resulting circle
  147608. */
  147609. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  147610. /**
  147611. * Creates a polygon from input string
  147612. * @param input Input polygon data
  147613. * @returns the parsed points
  147614. */
  147615. static Parse(input: string): Vector2[];
  147616. /**
  147617. * Starts building a polygon from x and y coordinates
  147618. * @param x x coordinate
  147619. * @param y y coordinate
  147620. * @returns the started path2
  147621. */
  147622. static StartingAt(x: number, y: number): Path2;
  147623. }
  147624. /**
  147625. * Builds a polygon
  147626. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  147627. */
  147628. export class PolygonMeshBuilder {
  147629. private _points;
  147630. private _outlinepoints;
  147631. private _holes;
  147632. private _name;
  147633. private _scene;
  147634. private _epoints;
  147635. private _eholes;
  147636. private _addToepoint;
  147637. /**
  147638. * Babylon reference to the earcut plugin.
  147639. */
  147640. bjsEarcut: any;
  147641. /**
  147642. * Creates a PolygonMeshBuilder
  147643. * @param name name of the builder
  147644. * @param contours Path of the polygon
  147645. * @param scene scene to add to when creating the mesh
  147646. * @param earcutInjection can be used to inject your own earcut reference
  147647. */
  147648. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  147649. /**
  147650. * Adds a whole within the polygon
  147651. * @param hole Array of points defining the hole
  147652. * @returns this
  147653. */
  147654. addHole(hole: Vector2[]): PolygonMeshBuilder;
  147655. /**
  147656. * Creates the polygon
  147657. * @param updatable If the mesh should be updatable
  147658. * @param depth The depth of the mesh created
  147659. * @returns the created mesh
  147660. */
  147661. build(updatable?: boolean, depth?: number): Mesh;
  147662. /**
  147663. * Creates the polygon
  147664. * @param depth The depth of the mesh created
  147665. * @returns the created VertexData
  147666. */
  147667. buildVertexData(depth?: number): VertexData;
  147668. /**
  147669. * Adds a side to the polygon
  147670. * @param positions points that make the polygon
  147671. * @param normals normals of the polygon
  147672. * @param uvs uvs of the polygon
  147673. * @param indices indices of the polygon
  147674. * @param bounds bounds of the polygon
  147675. * @param points points of the polygon
  147676. * @param depth depth of the polygon
  147677. * @param flip flip of the polygon
  147678. */
  147679. private addSide;
  147680. }
  147681. }
  147682. declare module BABYLON {
  147683. /**
  147684. * Class containing static functions to help procedurally build meshes
  147685. */
  147686. export class PolygonBuilder {
  147687. /**
  147688. * Creates a polygon mesh
  147689. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147690. * * 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
  147691. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147693. * * 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)
  147694. * * Remember you can only change the shape positions, not their number when updating a polygon
  147695. * @param name defines the name of the mesh
  147696. * @param options defines the options used to create the mesh
  147697. * @param scene defines the hosting scene
  147698. * @param earcutInjection can be used to inject your own earcut reference
  147699. * @returns the polygon mesh
  147700. */
  147701. static CreatePolygon(name: string, options: {
  147702. shape: Vector3[];
  147703. holes?: Vector3[][];
  147704. depth?: number;
  147705. faceUV?: Vector4[];
  147706. faceColors?: Color4[];
  147707. updatable?: boolean;
  147708. sideOrientation?: number;
  147709. frontUVs?: Vector4;
  147710. backUVs?: Vector4;
  147711. wrap?: boolean;
  147712. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147713. /**
  147714. * Creates an extruded polygon mesh, with depth in the Y direction.
  147715. * * 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)
  147716. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147717. * @param name defines the name of the mesh
  147718. * @param options defines the options used to create the mesh
  147719. * @param scene defines the hosting scene
  147720. * @param earcutInjection can be used to inject your own earcut reference
  147721. * @returns the polygon mesh
  147722. */
  147723. static ExtrudePolygon(name: string, options: {
  147724. shape: Vector3[];
  147725. holes?: Vector3[][];
  147726. depth?: number;
  147727. faceUV?: Vector4[];
  147728. faceColors?: Color4[];
  147729. updatable?: boolean;
  147730. sideOrientation?: number;
  147731. frontUVs?: Vector4;
  147732. backUVs?: Vector4;
  147733. wrap?: boolean;
  147734. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147735. }
  147736. }
  147737. declare module BABYLON {
  147738. /**
  147739. * Class containing static functions to help procedurally build meshes
  147740. */
  147741. export class LatheBuilder {
  147742. /**
  147743. * Creates lathe mesh.
  147744. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  147745. * * 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
  147746. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  147747. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  147748. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  147749. * * 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
  147750. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  147751. * * 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
  147752. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147753. * * 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
  147754. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147756. * @param name defines the name of the mesh
  147757. * @param options defines the options used to create the mesh
  147758. * @param scene defines the hosting scene
  147759. * @returns the lathe mesh
  147760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  147761. */
  147762. static CreateLathe(name: string, options: {
  147763. shape: Vector3[];
  147764. radius?: number;
  147765. tessellation?: number;
  147766. clip?: number;
  147767. arc?: number;
  147768. closed?: boolean;
  147769. updatable?: boolean;
  147770. sideOrientation?: number;
  147771. frontUVs?: Vector4;
  147772. backUVs?: Vector4;
  147773. cap?: number;
  147774. invertUV?: boolean;
  147775. }, scene?: Nullable<Scene>): Mesh;
  147776. }
  147777. }
  147778. declare module BABYLON {
  147779. /**
  147780. * Class containing static functions to help procedurally build meshes
  147781. */
  147782. export class TiledPlaneBuilder {
  147783. /**
  147784. * Creates a tiled plane mesh
  147785. * * The parameter `pattern` will, depending on value, do nothing or
  147786. * * * flip (reflect about central vertical) alternate tiles across and up
  147787. * * * flip every tile on alternate rows
  147788. * * * rotate (180 degs) alternate tiles across and up
  147789. * * * rotate every tile on alternate rows
  147790. * * * flip and rotate alternate tiles across and up
  147791. * * * flip and rotate every tile on alternate rows
  147792. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  147793. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  147794. * * 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
  147795. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147796. * * 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)
  147797. * * 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)
  147798. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147799. * @param name defines the name of the mesh
  147800. * @param options defines the options used to create the mesh
  147801. * @param scene defines the hosting scene
  147802. * @returns the box mesh
  147803. */
  147804. static CreateTiledPlane(name: string, options: {
  147805. pattern?: number;
  147806. tileSize?: number;
  147807. tileWidth?: number;
  147808. tileHeight?: number;
  147809. size?: number;
  147810. width?: number;
  147811. height?: number;
  147812. alignHorizontal?: number;
  147813. alignVertical?: number;
  147814. sideOrientation?: number;
  147815. frontUVs?: Vector4;
  147816. backUVs?: Vector4;
  147817. updatable?: boolean;
  147818. }, scene?: Nullable<Scene>): Mesh;
  147819. }
  147820. }
  147821. declare module BABYLON {
  147822. /**
  147823. * Class containing static functions to help procedurally build meshes
  147824. */
  147825. export class TubeBuilder {
  147826. /**
  147827. * Creates a tube mesh.
  147828. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147829. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147830. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147831. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147832. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147833. * * 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)
  147834. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147835. * * 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
  147836. * * 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
  147837. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147838. * * 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
  147839. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147841. * @param name defines the name of the mesh
  147842. * @param options defines the options used to create the mesh
  147843. * @param scene defines the hosting scene
  147844. * @returns the tube mesh
  147845. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147846. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147847. */
  147848. static CreateTube(name: string, options: {
  147849. path: Vector3[];
  147850. radius?: number;
  147851. tessellation?: number;
  147852. radiusFunction?: {
  147853. (i: number, distance: number): number;
  147854. };
  147855. cap?: number;
  147856. arc?: number;
  147857. updatable?: boolean;
  147858. sideOrientation?: number;
  147859. frontUVs?: Vector4;
  147860. backUVs?: Vector4;
  147861. instance?: Mesh;
  147862. invertUV?: boolean;
  147863. }, scene?: Nullable<Scene>): Mesh;
  147864. }
  147865. }
  147866. declare module BABYLON {
  147867. /**
  147868. * Class containing static functions to help procedurally build meshes
  147869. */
  147870. export class IcoSphereBuilder {
  147871. /**
  147872. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  147873. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  147874. * * 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`)
  147875. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  147876. * * 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
  147877. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147878. * * 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
  147879. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147880. * @param name defines the name of the mesh
  147881. * @param options defines the options used to create the mesh
  147882. * @param scene defines the hosting scene
  147883. * @returns the icosahedron mesh
  147884. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  147885. */
  147886. static CreateIcoSphere(name: string, options: {
  147887. radius?: number;
  147888. radiusX?: number;
  147889. radiusY?: number;
  147890. radiusZ?: number;
  147891. flat?: boolean;
  147892. subdivisions?: number;
  147893. sideOrientation?: number;
  147894. frontUVs?: Vector4;
  147895. backUVs?: Vector4;
  147896. updatable?: boolean;
  147897. }, scene?: Nullable<Scene>): Mesh;
  147898. }
  147899. }
  147900. declare module BABYLON {
  147901. /**
  147902. * Class containing static functions to help procedurally build meshes
  147903. */
  147904. export class DecalBuilder {
  147905. /**
  147906. * Creates a decal mesh.
  147907. * 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
  147908. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147909. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147910. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147911. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147912. * @param name defines the name of the mesh
  147913. * @param sourceMesh defines the mesh where the decal must be applied
  147914. * @param options defines the options used to create the mesh
  147915. * @param scene defines the hosting scene
  147916. * @returns the decal mesh
  147917. * @see https://doc.babylonjs.com/how_to/decals
  147918. */
  147919. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147920. position?: Vector3;
  147921. normal?: Vector3;
  147922. size?: Vector3;
  147923. angle?: number;
  147924. }): Mesh;
  147925. }
  147926. }
  147927. declare module BABYLON {
  147928. /**
  147929. * Class containing static functions to help procedurally build meshes
  147930. */
  147931. export class MeshBuilder {
  147932. /**
  147933. * Creates a box mesh
  147934. * * The parameter `size` sets the size (float) of each box side (default 1)
  147935. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  147936. * * 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)
  147937. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147939. * * 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
  147940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147941. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  147942. * @param name defines the name of the mesh
  147943. * @param options defines the options used to create the mesh
  147944. * @param scene defines the hosting scene
  147945. * @returns the box mesh
  147946. */
  147947. static CreateBox(name: string, options: {
  147948. size?: number;
  147949. width?: number;
  147950. height?: number;
  147951. depth?: number;
  147952. faceUV?: Vector4[];
  147953. faceColors?: Color4[];
  147954. sideOrientation?: number;
  147955. frontUVs?: Vector4;
  147956. backUVs?: Vector4;
  147957. wrap?: boolean;
  147958. topBaseAt?: number;
  147959. bottomBaseAt?: number;
  147960. updatable?: boolean;
  147961. }, scene?: Nullable<Scene>): Mesh;
  147962. /**
  147963. * Creates a tiled box mesh
  147964. * * faceTiles sets the pattern, tile size and number of tiles for a face
  147965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147966. * @param name defines the name of the mesh
  147967. * @param options defines the options used to create the mesh
  147968. * @param scene defines the hosting scene
  147969. * @returns the tiled box mesh
  147970. */
  147971. static CreateTiledBox(name: string, options: {
  147972. pattern?: number;
  147973. size?: number;
  147974. width?: number;
  147975. height?: number;
  147976. depth: number;
  147977. tileSize?: number;
  147978. tileWidth?: number;
  147979. tileHeight?: number;
  147980. faceUV?: Vector4[];
  147981. faceColors?: Color4[];
  147982. alignHorizontal?: number;
  147983. alignVertical?: number;
  147984. sideOrientation?: number;
  147985. updatable?: boolean;
  147986. }, scene?: Nullable<Scene>): Mesh;
  147987. /**
  147988. * Creates a sphere mesh
  147989. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  147990. * * 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`)
  147991. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  147992. * * 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
  147993. * * 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)
  147994. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147995. * * 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
  147996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147997. * @param name defines the name of the mesh
  147998. * @param options defines the options used to create the mesh
  147999. * @param scene defines the hosting scene
  148000. * @returns the sphere mesh
  148001. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  148002. */
  148003. static CreateSphere(name: string, options: {
  148004. segments?: number;
  148005. diameter?: number;
  148006. diameterX?: number;
  148007. diameterY?: number;
  148008. diameterZ?: number;
  148009. arc?: number;
  148010. slice?: number;
  148011. sideOrientation?: number;
  148012. frontUVs?: Vector4;
  148013. backUVs?: Vector4;
  148014. updatable?: boolean;
  148015. }, scene?: Nullable<Scene>): Mesh;
  148016. /**
  148017. * Creates a plane polygonal mesh. By default, this is a disc
  148018. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  148019. * * 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
  148020. * * 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
  148021. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148022. * * 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
  148023. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148024. * @param name defines the name of the mesh
  148025. * @param options defines the options used to create the mesh
  148026. * @param scene defines the hosting scene
  148027. * @returns the plane polygonal mesh
  148028. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  148029. */
  148030. static CreateDisc(name: string, options: {
  148031. radius?: number;
  148032. tessellation?: number;
  148033. arc?: number;
  148034. updatable?: boolean;
  148035. sideOrientation?: number;
  148036. frontUVs?: Vector4;
  148037. backUVs?: Vector4;
  148038. }, scene?: Nullable<Scene>): Mesh;
  148039. /**
  148040. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  148041. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  148042. * * 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`)
  148043. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  148044. * * 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
  148045. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148046. * * 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
  148047. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148048. * @param name defines the name of the mesh
  148049. * @param options defines the options used to create the mesh
  148050. * @param scene defines the hosting scene
  148051. * @returns the icosahedron mesh
  148052. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  148053. */
  148054. static CreateIcoSphere(name: string, options: {
  148055. radius?: number;
  148056. radiusX?: number;
  148057. radiusY?: number;
  148058. radiusZ?: number;
  148059. flat?: boolean;
  148060. subdivisions?: number;
  148061. sideOrientation?: number;
  148062. frontUVs?: Vector4;
  148063. backUVs?: Vector4;
  148064. updatable?: boolean;
  148065. }, scene?: Nullable<Scene>): Mesh;
  148066. /**
  148067. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148068. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  148069. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  148070. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  148071. * * 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
  148072. * * 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
  148073. * * 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
  148074. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148075. * * 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
  148076. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148077. * * 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
  148078. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  148079. * * 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
  148080. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  148081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148082. * @param name defines the name of the mesh
  148083. * @param options defines the options used to create the mesh
  148084. * @param scene defines the hosting scene
  148085. * @returns the ribbon mesh
  148086. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  148087. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148088. */
  148089. static CreateRibbon(name: string, options: {
  148090. pathArray: Vector3[][];
  148091. closeArray?: boolean;
  148092. closePath?: boolean;
  148093. offset?: number;
  148094. updatable?: boolean;
  148095. sideOrientation?: number;
  148096. frontUVs?: Vector4;
  148097. backUVs?: Vector4;
  148098. instance?: Mesh;
  148099. invertUV?: boolean;
  148100. uvs?: Vector2[];
  148101. colors?: Color4[];
  148102. }, scene?: Nullable<Scene>): Mesh;
  148103. /**
  148104. * Creates a cylinder or a cone mesh
  148105. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  148106. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  148107. * * 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.
  148108. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  148109. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  148110. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  148111. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  148112. * * 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).
  148113. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  148114. * * 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).
  148115. * * 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
  148116. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  148117. * * 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
  148118. * * 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.
  148119. * * If `enclose` is false, a ring surface is one element.
  148120. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  148121. * * 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
  148122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148123. * * 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
  148124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148125. * @param name defines the name of the mesh
  148126. * @param options defines the options used to create the mesh
  148127. * @param scene defines the hosting scene
  148128. * @returns the cylinder mesh
  148129. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  148130. */
  148131. static CreateCylinder(name: string, options: {
  148132. height?: number;
  148133. diameterTop?: number;
  148134. diameterBottom?: number;
  148135. diameter?: number;
  148136. tessellation?: number;
  148137. subdivisions?: number;
  148138. arc?: number;
  148139. faceColors?: Color4[];
  148140. faceUV?: Vector4[];
  148141. updatable?: boolean;
  148142. hasRings?: boolean;
  148143. enclose?: boolean;
  148144. cap?: number;
  148145. sideOrientation?: number;
  148146. frontUVs?: Vector4;
  148147. backUVs?: Vector4;
  148148. }, scene?: Nullable<Scene>): Mesh;
  148149. /**
  148150. * Creates a torus mesh
  148151. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  148152. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  148153. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  148154. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148155. * * 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
  148156. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148157. * @param name defines the name of the mesh
  148158. * @param options defines the options used to create the mesh
  148159. * @param scene defines the hosting scene
  148160. * @returns the torus mesh
  148161. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  148162. */
  148163. static CreateTorus(name: string, options: {
  148164. diameter?: number;
  148165. thickness?: number;
  148166. tessellation?: number;
  148167. updatable?: boolean;
  148168. sideOrientation?: number;
  148169. frontUVs?: Vector4;
  148170. backUVs?: Vector4;
  148171. }, scene?: Nullable<Scene>): Mesh;
  148172. /**
  148173. * Creates a torus knot mesh
  148174. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  148175. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  148176. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  148177. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  148178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148179. * * 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
  148180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148181. * @param name defines the name of the mesh
  148182. * @param options defines the options used to create the mesh
  148183. * @param scene defines the hosting scene
  148184. * @returns the torus knot mesh
  148185. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  148186. */
  148187. static CreateTorusKnot(name: string, options: {
  148188. radius?: number;
  148189. tube?: number;
  148190. radialSegments?: number;
  148191. tubularSegments?: number;
  148192. p?: number;
  148193. q?: number;
  148194. updatable?: boolean;
  148195. sideOrientation?: number;
  148196. frontUVs?: Vector4;
  148197. backUVs?: Vector4;
  148198. }, scene?: Nullable<Scene>): Mesh;
  148199. /**
  148200. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  148201. * * 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
  148202. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  148203. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  148204. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  148205. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  148206. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  148207. * * 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
  148208. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  148209. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148210. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  148211. * @param name defines the name of the new line system
  148212. * @param options defines the options used to create the line system
  148213. * @param scene defines the hosting scene
  148214. * @returns a new line system mesh
  148215. */
  148216. static CreateLineSystem(name: string, options: {
  148217. lines: Vector3[][];
  148218. updatable?: boolean;
  148219. instance?: Nullable<LinesMesh>;
  148220. colors?: Nullable<Color4[][]>;
  148221. useVertexAlpha?: boolean;
  148222. }, scene: Nullable<Scene>): LinesMesh;
  148223. /**
  148224. * Creates a line mesh
  148225. * 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
  148226. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  148227. * * The parameter `points` is an array successive Vector3
  148228. * * 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
  148229. * * The optional parameter `colors` is an array of successive Color4, one per line point
  148230. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  148231. * * When updating an instance, remember that only point positions can change, not the number of points
  148232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148233. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  148234. * @param name defines the name of the new line system
  148235. * @param options defines the options used to create the line system
  148236. * @param scene defines the hosting scene
  148237. * @returns a new line mesh
  148238. */
  148239. static CreateLines(name: string, options: {
  148240. points: Vector3[];
  148241. updatable?: boolean;
  148242. instance?: Nullable<LinesMesh>;
  148243. colors?: Color4[];
  148244. useVertexAlpha?: boolean;
  148245. }, scene?: Nullable<Scene>): LinesMesh;
  148246. /**
  148247. * Creates a dashed line mesh
  148248. * * 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
  148249. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  148250. * * The parameter `points` is an array successive Vector3
  148251. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  148252. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  148253. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  148254. * * 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
  148255. * * When updating an instance, remember that only point positions can change, not the number of points
  148256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148257. * @param name defines the name of the mesh
  148258. * @param options defines the options used to create the mesh
  148259. * @param scene defines the hosting scene
  148260. * @returns the dashed line mesh
  148261. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  148262. */
  148263. static CreateDashedLines(name: string, options: {
  148264. points: Vector3[];
  148265. dashSize?: number;
  148266. gapSize?: number;
  148267. dashNb?: number;
  148268. updatable?: boolean;
  148269. instance?: LinesMesh;
  148270. }, scene?: Nullable<Scene>): LinesMesh;
  148271. /**
  148272. * 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.
  148273. * * 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.
  148274. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  148275. * * 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.
  148276. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  148277. * * 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
  148278. * * 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
  148279. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  148280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148281. * * 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
  148282. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  148283. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148284. * @param name defines the name of the mesh
  148285. * @param options defines the options used to create the mesh
  148286. * @param scene defines the hosting scene
  148287. * @returns the extruded shape mesh
  148288. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148289. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  148290. */
  148291. static ExtrudeShape(name: string, options: {
  148292. shape: Vector3[];
  148293. path: Vector3[];
  148294. scale?: number;
  148295. rotation?: number;
  148296. cap?: number;
  148297. updatable?: boolean;
  148298. sideOrientation?: number;
  148299. frontUVs?: Vector4;
  148300. backUVs?: Vector4;
  148301. instance?: Mesh;
  148302. invertUV?: boolean;
  148303. }, scene?: Nullable<Scene>): Mesh;
  148304. /**
  148305. * Creates an custom extruded shape mesh.
  148306. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  148307. * * 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.
  148308. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  148309. * * 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
  148310. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  148311. * * 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
  148312. * * It must returns a float value that will be the scale value applied to the shape on each path point
  148313. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  148314. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  148315. * * 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
  148316. * * 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
  148317. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  148318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148319. * * 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
  148320. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148321. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148322. * @param name defines the name of the mesh
  148323. * @param options defines the options used to create the mesh
  148324. * @param scene defines the hosting scene
  148325. * @returns the custom extruded shape mesh
  148326. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  148327. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148328. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  148329. */
  148330. static ExtrudeShapeCustom(name: string, options: {
  148331. shape: Vector3[];
  148332. path: Vector3[];
  148333. scaleFunction?: any;
  148334. rotationFunction?: any;
  148335. ribbonCloseArray?: boolean;
  148336. ribbonClosePath?: boolean;
  148337. cap?: number;
  148338. updatable?: boolean;
  148339. sideOrientation?: number;
  148340. frontUVs?: Vector4;
  148341. backUVs?: Vector4;
  148342. instance?: Mesh;
  148343. invertUV?: boolean;
  148344. }, scene?: Nullable<Scene>): Mesh;
  148345. /**
  148346. * Creates lathe mesh.
  148347. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  148348. * * 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
  148349. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  148350. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  148351. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  148352. * * 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
  148353. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  148354. * * 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
  148355. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148356. * * 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
  148357. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148358. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148359. * @param name defines the name of the mesh
  148360. * @param options defines the options used to create the mesh
  148361. * @param scene defines the hosting scene
  148362. * @returns the lathe mesh
  148363. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  148364. */
  148365. static CreateLathe(name: string, options: {
  148366. shape: Vector3[];
  148367. radius?: number;
  148368. tessellation?: number;
  148369. clip?: number;
  148370. arc?: number;
  148371. closed?: boolean;
  148372. updatable?: boolean;
  148373. sideOrientation?: number;
  148374. frontUVs?: Vector4;
  148375. backUVs?: Vector4;
  148376. cap?: number;
  148377. invertUV?: boolean;
  148378. }, scene?: Nullable<Scene>): Mesh;
  148379. /**
  148380. * Creates a tiled plane mesh
  148381. * * You can set a limited pattern arrangement with the tiles
  148382. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148383. * * 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
  148384. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148385. * @param name defines the name of the mesh
  148386. * @param options defines the options used to create the mesh
  148387. * @param scene defines the hosting scene
  148388. * @returns the plane mesh
  148389. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  148390. */
  148391. static CreateTiledPlane(name: string, options: {
  148392. pattern?: number;
  148393. tileSize?: number;
  148394. tileWidth?: number;
  148395. tileHeight?: number;
  148396. size?: number;
  148397. width?: number;
  148398. height?: number;
  148399. alignHorizontal?: number;
  148400. alignVertical?: number;
  148401. sideOrientation?: number;
  148402. frontUVs?: Vector4;
  148403. backUVs?: Vector4;
  148404. updatable?: boolean;
  148405. }, scene?: Nullable<Scene>): Mesh;
  148406. /**
  148407. * Creates a plane mesh
  148408. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  148409. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  148410. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  148411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148412. * * 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
  148413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148414. * @param name defines the name of the mesh
  148415. * @param options defines the options used to create the mesh
  148416. * @param scene defines the hosting scene
  148417. * @returns the plane mesh
  148418. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  148419. */
  148420. static CreatePlane(name: string, options: {
  148421. size?: number;
  148422. width?: number;
  148423. height?: number;
  148424. sideOrientation?: number;
  148425. frontUVs?: Vector4;
  148426. backUVs?: Vector4;
  148427. updatable?: boolean;
  148428. sourcePlane?: Plane;
  148429. }, scene?: Nullable<Scene>): Mesh;
  148430. /**
  148431. * Creates a ground mesh
  148432. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  148433. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  148434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148435. * @param name defines the name of the mesh
  148436. * @param options defines the options used to create the mesh
  148437. * @param scene defines the hosting scene
  148438. * @returns the ground mesh
  148439. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  148440. */
  148441. static CreateGround(name: string, options: {
  148442. width?: number;
  148443. height?: number;
  148444. subdivisions?: number;
  148445. subdivisionsX?: number;
  148446. subdivisionsY?: number;
  148447. updatable?: boolean;
  148448. }, scene?: Nullable<Scene>): Mesh;
  148449. /**
  148450. * Creates a tiled ground mesh
  148451. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  148452. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  148453. * * 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
  148454. * * 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
  148455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148456. * @param name defines the name of the mesh
  148457. * @param options defines the options used to create the mesh
  148458. * @param scene defines the hosting scene
  148459. * @returns the tiled ground mesh
  148460. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  148461. */
  148462. static CreateTiledGround(name: string, options: {
  148463. xmin: number;
  148464. zmin: number;
  148465. xmax: number;
  148466. zmax: number;
  148467. subdivisions?: {
  148468. w: number;
  148469. h: number;
  148470. };
  148471. precision?: {
  148472. w: number;
  148473. h: number;
  148474. };
  148475. updatable?: boolean;
  148476. }, scene?: Nullable<Scene>): Mesh;
  148477. /**
  148478. * Creates a ground mesh from a height map
  148479. * * The parameter `url` sets the URL of the height map image resource.
  148480. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  148481. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  148482. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  148483. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  148484. * * 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.
  148485. * * 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).
  148486. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  148487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  148488. * @param name defines the name of the mesh
  148489. * @param url defines the url to the height map
  148490. * @param options defines the options used to create the mesh
  148491. * @param scene defines the hosting scene
  148492. * @returns the ground mesh
  148493. * @see https://doc.babylonjs.com/babylon101/height_map
  148494. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  148495. */
  148496. static CreateGroundFromHeightMap(name: string, url: string, options: {
  148497. width?: number;
  148498. height?: number;
  148499. subdivisions?: number;
  148500. minHeight?: number;
  148501. maxHeight?: number;
  148502. colorFilter?: Color3;
  148503. alphaFilter?: number;
  148504. updatable?: boolean;
  148505. onReady?: (mesh: GroundMesh) => void;
  148506. }, scene?: Nullable<Scene>): GroundMesh;
  148507. /**
  148508. * Creates a polygon mesh
  148509. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  148510. * * 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
  148511. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  148512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148513. * * 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)
  148514. * * Remember you can only change the shape positions, not their number when updating a polygon
  148515. * @param name defines the name of the mesh
  148516. * @param options defines the options used to create the mesh
  148517. * @param scene defines the hosting scene
  148518. * @param earcutInjection can be used to inject your own earcut reference
  148519. * @returns the polygon mesh
  148520. */
  148521. static CreatePolygon(name: string, options: {
  148522. shape: Vector3[];
  148523. holes?: Vector3[][];
  148524. depth?: number;
  148525. faceUV?: Vector4[];
  148526. faceColors?: Color4[];
  148527. updatable?: boolean;
  148528. sideOrientation?: number;
  148529. frontUVs?: Vector4;
  148530. backUVs?: Vector4;
  148531. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148532. /**
  148533. * Creates an extruded polygon mesh, with depth in the Y direction.
  148534. * * 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)
  148535. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  148536. * @param name defines the name of the mesh
  148537. * @param options defines the options used to create the mesh
  148538. * @param scene defines the hosting scene
  148539. * @param earcutInjection can be used to inject your own earcut reference
  148540. * @returns the polygon mesh
  148541. */
  148542. static ExtrudePolygon(name: string, options: {
  148543. shape: Vector3[];
  148544. holes?: Vector3[][];
  148545. depth?: number;
  148546. faceUV?: Vector4[];
  148547. faceColors?: Color4[];
  148548. updatable?: boolean;
  148549. sideOrientation?: number;
  148550. frontUVs?: Vector4;
  148551. backUVs?: Vector4;
  148552. wrap?: boolean;
  148553. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  148554. /**
  148555. * Creates a tube mesh.
  148556. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  148557. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  148558. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  148559. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  148560. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  148561. * * 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)
  148562. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  148563. * * 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
  148564. * * 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
  148565. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148566. * * 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
  148567. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  148568. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148569. * @param name defines the name of the mesh
  148570. * @param options defines the options used to create the mesh
  148571. * @param scene defines the hosting scene
  148572. * @returns the tube mesh
  148573. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  148574. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  148575. */
  148576. static CreateTube(name: string, options: {
  148577. path: Vector3[];
  148578. radius?: number;
  148579. tessellation?: number;
  148580. radiusFunction?: {
  148581. (i: number, distance: number): number;
  148582. };
  148583. cap?: number;
  148584. arc?: number;
  148585. updatable?: boolean;
  148586. sideOrientation?: number;
  148587. frontUVs?: Vector4;
  148588. backUVs?: Vector4;
  148589. instance?: Mesh;
  148590. invertUV?: boolean;
  148591. }, scene?: Nullable<Scene>): Mesh;
  148592. /**
  148593. * Creates a polyhedron mesh
  148594. * * 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
  148595. * * The parameter `size` (positive float, default 1) sets the polygon size
  148596. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  148597. * * 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`
  148598. * * 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
  148599. * * 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)`)
  148600. * * 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
  148601. * * 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
  148602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  148603. * * 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
  148604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  148605. * @param name defines the name of the mesh
  148606. * @param options defines the options used to create the mesh
  148607. * @param scene defines the hosting scene
  148608. * @returns the polyhedron mesh
  148609. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  148610. */
  148611. static CreatePolyhedron(name: string, options: {
  148612. type?: number;
  148613. size?: number;
  148614. sizeX?: number;
  148615. sizeY?: number;
  148616. sizeZ?: number;
  148617. custom?: any;
  148618. faceUV?: Vector4[];
  148619. faceColors?: Color4[];
  148620. flat?: boolean;
  148621. updatable?: boolean;
  148622. sideOrientation?: number;
  148623. frontUVs?: Vector4;
  148624. backUVs?: Vector4;
  148625. }, scene?: Nullable<Scene>): Mesh;
  148626. /**
  148627. * Creates a decal mesh.
  148628. * 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
  148629. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  148630. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  148631. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  148632. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  148633. * @param name defines the name of the mesh
  148634. * @param sourceMesh defines the mesh where the decal must be applied
  148635. * @param options defines the options used to create the mesh
  148636. * @param scene defines the hosting scene
  148637. * @returns the decal mesh
  148638. * @see https://doc.babylonjs.com/how_to/decals
  148639. */
  148640. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  148641. position?: Vector3;
  148642. normal?: Vector3;
  148643. size?: Vector3;
  148644. angle?: number;
  148645. }): Mesh;
  148646. /**
  148647. * Creates a Capsule Mesh
  148648. * @param name defines the name of the mesh.
  148649. * @param options the constructors options used to shape the mesh.
  148650. * @param scene defines the scene the mesh is scoped to.
  148651. * @returns the capsule mesh
  148652. * @see https://doc.babylonjs.com/how_to/capsule_shape
  148653. */
  148654. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  148655. }
  148656. }
  148657. declare module BABYLON {
  148658. /**
  148659. * A simplifier interface for future simplification implementations
  148660. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148661. */
  148662. export interface ISimplifier {
  148663. /**
  148664. * Simplification of a given mesh according to the given settings.
  148665. * Since this requires computation, it is assumed that the function runs async.
  148666. * @param settings The settings of the simplification, including quality and distance
  148667. * @param successCallback A callback that will be called after the mesh was simplified.
  148668. * @param errorCallback in case of an error, this callback will be called. optional.
  148669. */
  148670. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  148671. }
  148672. /**
  148673. * Expected simplification settings.
  148674. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  148675. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148676. */
  148677. export interface ISimplificationSettings {
  148678. /**
  148679. * Gets or sets the expected quality
  148680. */
  148681. quality: number;
  148682. /**
  148683. * Gets or sets the distance when this optimized version should be used
  148684. */
  148685. distance: number;
  148686. /**
  148687. * Gets an already optimized mesh
  148688. */
  148689. optimizeMesh?: boolean;
  148690. }
  148691. /**
  148692. * Class used to specify simplification options
  148693. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148694. */
  148695. export class SimplificationSettings implements ISimplificationSettings {
  148696. /** expected quality */
  148697. quality: number;
  148698. /** distance when this optimized version should be used */
  148699. distance: number;
  148700. /** already optimized mesh */
  148701. optimizeMesh?: boolean | undefined;
  148702. /**
  148703. * Creates a SimplificationSettings
  148704. * @param quality expected quality
  148705. * @param distance distance when this optimized version should be used
  148706. * @param optimizeMesh already optimized mesh
  148707. */
  148708. constructor(
  148709. /** expected quality */
  148710. quality: number,
  148711. /** distance when this optimized version should be used */
  148712. distance: number,
  148713. /** already optimized mesh */
  148714. optimizeMesh?: boolean | undefined);
  148715. }
  148716. /**
  148717. * Interface used to define a simplification task
  148718. */
  148719. export interface ISimplificationTask {
  148720. /**
  148721. * Array of settings
  148722. */
  148723. settings: Array<ISimplificationSettings>;
  148724. /**
  148725. * Simplification type
  148726. */
  148727. simplificationType: SimplificationType;
  148728. /**
  148729. * Mesh to simplify
  148730. */
  148731. mesh: Mesh;
  148732. /**
  148733. * Callback called on success
  148734. */
  148735. successCallback?: () => void;
  148736. /**
  148737. * Defines if parallel processing can be used
  148738. */
  148739. parallelProcessing: boolean;
  148740. }
  148741. /**
  148742. * Queue used to order the simplification tasks
  148743. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148744. */
  148745. export class SimplificationQueue {
  148746. private _simplificationArray;
  148747. /**
  148748. * Gets a boolean indicating that the process is still running
  148749. */
  148750. running: boolean;
  148751. /**
  148752. * Creates a new queue
  148753. */
  148754. constructor();
  148755. /**
  148756. * Adds a new simplification task
  148757. * @param task defines a task to add
  148758. */
  148759. addTask(task: ISimplificationTask): void;
  148760. /**
  148761. * Execute next task
  148762. */
  148763. executeNext(): void;
  148764. /**
  148765. * Execute a simplification task
  148766. * @param task defines the task to run
  148767. */
  148768. runSimplification(task: ISimplificationTask): void;
  148769. private getSimplifier;
  148770. }
  148771. /**
  148772. * The implemented types of simplification
  148773. * At the moment only Quadratic Error Decimation is implemented
  148774. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148775. */
  148776. export enum SimplificationType {
  148777. /** Quadratic error decimation */
  148778. QUADRATIC = 0
  148779. }
  148780. /**
  148781. * An implementation of the Quadratic Error simplification algorithm.
  148782. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  148783. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  148784. * @author RaananW
  148785. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148786. */
  148787. export class QuadraticErrorSimplification implements ISimplifier {
  148788. private _mesh;
  148789. private triangles;
  148790. private vertices;
  148791. private references;
  148792. private _reconstructedMesh;
  148793. /** Gets or sets the number pf sync interations */
  148794. syncIterations: number;
  148795. /** Gets or sets the aggressiveness of the simplifier */
  148796. aggressiveness: number;
  148797. /** Gets or sets the number of allowed iterations for decimation */
  148798. decimationIterations: number;
  148799. /** Gets or sets the espilon to use for bounding box computation */
  148800. boundingBoxEpsilon: number;
  148801. /**
  148802. * Creates a new QuadraticErrorSimplification
  148803. * @param _mesh defines the target mesh
  148804. */
  148805. constructor(_mesh: Mesh);
  148806. /**
  148807. * Simplification of a given mesh according to the given settings.
  148808. * Since this requires computation, it is assumed that the function runs async.
  148809. * @param settings The settings of the simplification, including quality and distance
  148810. * @param successCallback A callback that will be called after the mesh was simplified.
  148811. */
  148812. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  148813. private runDecimation;
  148814. private initWithMesh;
  148815. private init;
  148816. private reconstructMesh;
  148817. private initDecimatedMesh;
  148818. private isFlipped;
  148819. private updateTriangles;
  148820. private identifyBorder;
  148821. private updateMesh;
  148822. private vertexError;
  148823. private calculateError;
  148824. }
  148825. }
  148826. declare module BABYLON {
  148827. interface Scene {
  148828. /** @hidden (Backing field) */
  148829. _simplificationQueue: SimplificationQueue;
  148830. /**
  148831. * Gets or sets the simplification queue attached to the scene
  148832. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  148833. */
  148834. simplificationQueue: SimplificationQueue;
  148835. }
  148836. interface Mesh {
  148837. /**
  148838. * Simplify the mesh according to the given array of settings.
  148839. * Function will return immediately and will simplify async
  148840. * @param settings a collection of simplification settings
  148841. * @param parallelProcessing should all levels calculate parallel or one after the other
  148842. * @param simplificationType the type of simplification to run
  148843. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  148844. * @returns the current mesh
  148845. */
  148846. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  148847. }
  148848. /**
  148849. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  148850. * created in a scene
  148851. */
  148852. export class SimplicationQueueSceneComponent implements ISceneComponent {
  148853. /**
  148854. * The component name helpfull to identify the component in the list of scene components.
  148855. */
  148856. readonly name: string;
  148857. /**
  148858. * The scene the component belongs to.
  148859. */
  148860. scene: Scene;
  148861. /**
  148862. * Creates a new instance of the component for the given scene
  148863. * @param scene Defines the scene to register the component in
  148864. */
  148865. constructor(scene: Scene);
  148866. /**
  148867. * Registers the component in a given scene
  148868. */
  148869. register(): void;
  148870. /**
  148871. * Rebuilds the elements related to this component in case of
  148872. * context lost for instance.
  148873. */
  148874. rebuild(): void;
  148875. /**
  148876. * Disposes the component and the associated ressources
  148877. */
  148878. dispose(): void;
  148879. private _beforeCameraUpdate;
  148880. }
  148881. }
  148882. declare module BABYLON {
  148883. interface Mesh {
  148884. /**
  148885. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  148886. */
  148887. thinInstanceEnablePicking: boolean;
  148888. /**
  148889. * Creates a new thin instance
  148890. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  148891. * @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
  148892. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  148893. */
  148894. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  148895. /**
  148896. * Adds the transformation (matrix) of the current mesh as a thin instance
  148897. * @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
  148898. * @returns the thin instance index number
  148899. */
  148900. thinInstanceAddSelf(refresh: boolean): number;
  148901. /**
  148902. * Registers a custom attribute to be used with thin instances
  148903. * @param kind name of the attribute
  148904. * @param stride size in floats of the attribute
  148905. */
  148906. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  148907. /**
  148908. * Sets the matrix of a thin instance
  148909. * @param index index of the thin instance
  148910. * @param matrix matrix to set
  148911. * @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
  148912. */
  148913. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  148914. /**
  148915. * Sets the value of a custom attribute for a thin instance
  148916. * @param kind name of the attribute
  148917. * @param index index of the thin instance
  148918. * @param value value to set
  148919. * @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
  148920. */
  148921. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  148922. /**
  148923. * 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.
  148924. */
  148925. thinInstanceCount: number;
  148926. /**
  148927. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  148928. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  148929. * @param buffer buffer to set
  148930. * @param stride size in floats of each value of the buffer
  148931. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  148932. */
  148933. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  148934. /**
  148935. * Gets the list of world matrices
  148936. * @return an array containing all the world matrices from the thin instances
  148937. */
  148938. thinInstanceGetWorldMatrices(): Matrix[];
  148939. /**
  148940. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  148941. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148942. */
  148943. thinInstanceBufferUpdated(kind: string): void;
  148944. /**
  148945. * Applies a partial update to a buffer directly on the GPU
  148946. * 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
  148947. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  148948. * @param data the data to set in the GPU buffer
  148949. * @param offset the offset in the GPU buffer where to update the data
  148950. */
  148951. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  148952. /**
  148953. * Refreshes the bounding info, taking into account all the thin instances defined
  148954. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  148955. */
  148956. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  148957. /** @hidden */
  148958. _thinInstanceInitializeUserStorage(): void;
  148959. /** @hidden */
  148960. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  148961. /** @hidden */
  148962. _userThinInstanceBuffersStorage: {
  148963. data: {
  148964. [key: string]: Float32Array;
  148965. };
  148966. sizes: {
  148967. [key: string]: number;
  148968. };
  148969. vertexBuffers: {
  148970. [key: string]: Nullable<VertexBuffer>;
  148971. };
  148972. strides: {
  148973. [key: string]: number;
  148974. };
  148975. };
  148976. }
  148977. }
  148978. declare module BABYLON {
  148979. /**
  148980. * Navigation plugin interface to add navigation constrained by a navigation mesh
  148981. */
  148982. export interface INavigationEnginePlugin {
  148983. /**
  148984. * plugin name
  148985. */
  148986. name: string;
  148987. /**
  148988. * Creates a navigation mesh
  148989. * @param meshes array of all the geometry used to compute the navigatio mesh
  148990. * @param parameters bunch of parameters used to filter geometry
  148991. */
  148992. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  148993. /**
  148994. * Create a navigation mesh debug mesh
  148995. * @param scene is where the mesh will be added
  148996. * @returns debug display mesh
  148997. */
  148998. createDebugNavMesh(scene: Scene): Mesh;
  148999. /**
  149000. * Get a navigation mesh constrained position, closest to the parameter position
  149001. * @param position world position
  149002. * @returns the closest point to position constrained by the navigation mesh
  149003. */
  149004. getClosestPoint(position: Vector3): Vector3;
  149005. /**
  149006. * Get a navigation mesh constrained position, closest to the parameter position
  149007. * @param position world position
  149008. * @param result output the closest point to position constrained by the navigation mesh
  149009. */
  149010. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149011. /**
  149012. * Get a navigation mesh constrained position, within a particular radius
  149013. * @param position world position
  149014. * @param maxRadius the maximum distance to the constrained world position
  149015. * @returns the closest point to position constrained by the navigation mesh
  149016. */
  149017. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149018. /**
  149019. * Get a navigation mesh constrained position, within a particular radius
  149020. * @param position world position
  149021. * @param maxRadius the maximum distance to the constrained world position
  149022. * @param result output the closest point to position constrained by the navigation mesh
  149023. */
  149024. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149025. /**
  149026. * Compute the final position from a segment made of destination-position
  149027. * @param position world position
  149028. * @param destination world position
  149029. * @returns the resulting point along the navmesh
  149030. */
  149031. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149032. /**
  149033. * Compute the final position from a segment made of destination-position
  149034. * @param position world position
  149035. * @param destination world position
  149036. * @param result output the resulting point along the navmesh
  149037. */
  149038. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149039. /**
  149040. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149041. * @param start world position
  149042. * @param end world position
  149043. * @returns array containing world position composing the path
  149044. */
  149045. computePath(start: Vector3, end: Vector3): Vector3[];
  149046. /**
  149047. * If this plugin is supported
  149048. * @returns true if plugin is supported
  149049. */
  149050. isSupported(): boolean;
  149051. /**
  149052. * Create a new Crowd so you can add agents
  149053. * @param maxAgents the maximum agent count in the crowd
  149054. * @param maxAgentRadius the maximum radius an agent can have
  149055. * @param scene to attach the crowd to
  149056. * @returns the crowd you can add agents to
  149057. */
  149058. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149059. /**
  149060. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149061. * The queries will try to find a solution within those bounds
  149062. * default is (1,1,1)
  149063. * @param extent x,y,z value that define the extent around the queries point of reference
  149064. */
  149065. setDefaultQueryExtent(extent: Vector3): void;
  149066. /**
  149067. * Get the Bounding box extent specified by setDefaultQueryExtent
  149068. * @returns the box extent values
  149069. */
  149070. getDefaultQueryExtent(): Vector3;
  149071. /**
  149072. * build the navmesh from a previously saved state using getNavmeshData
  149073. * @param data the Uint8Array returned by getNavmeshData
  149074. */
  149075. buildFromNavmeshData(data: Uint8Array): void;
  149076. /**
  149077. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  149078. * @returns data the Uint8Array that can be saved and reused
  149079. */
  149080. getNavmeshData(): Uint8Array;
  149081. /**
  149082. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149083. * @param result output the box extent values
  149084. */
  149085. getDefaultQueryExtentToRef(result: Vector3): void;
  149086. /**
  149087. * Release all resources
  149088. */
  149089. dispose(): void;
  149090. }
  149091. /**
  149092. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  149093. */
  149094. export interface ICrowd {
  149095. /**
  149096. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  149097. * You can attach anything to that node. The node position is updated in the scene update tick.
  149098. * @param pos world position that will be constrained by the navigation mesh
  149099. * @param parameters agent parameters
  149100. * @param transform hooked to the agent that will be update by the scene
  149101. * @returns agent index
  149102. */
  149103. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  149104. /**
  149105. * Returns the agent position in world space
  149106. * @param index agent index returned by addAgent
  149107. * @returns world space position
  149108. */
  149109. getAgentPosition(index: number): Vector3;
  149110. /**
  149111. * Gets the agent position result in world space
  149112. * @param index agent index returned by addAgent
  149113. * @param result output world space position
  149114. */
  149115. getAgentPositionToRef(index: number, result: Vector3): void;
  149116. /**
  149117. * Gets the agent velocity in world space
  149118. * @param index agent index returned by addAgent
  149119. * @returns world space velocity
  149120. */
  149121. getAgentVelocity(index: number): Vector3;
  149122. /**
  149123. * Gets the agent velocity result in world space
  149124. * @param index agent index returned by addAgent
  149125. * @param result output world space velocity
  149126. */
  149127. getAgentVelocityToRef(index: number, result: Vector3): void;
  149128. /**
  149129. * Gets the agent next target point on the path
  149130. * @param index agent index returned by addAgent
  149131. * @returns world space position
  149132. */
  149133. getAgentNextTargetPath(index: number): Vector3;
  149134. /**
  149135. * Gets the agent next target point on the path
  149136. * @param index agent index returned by addAgent
  149137. * @param result output world space position
  149138. */
  149139. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  149140. /**
  149141. * remove a particular agent previously created
  149142. * @param index agent index returned by addAgent
  149143. */
  149144. removeAgent(index: number): void;
  149145. /**
  149146. * get the list of all agents attached to this crowd
  149147. * @returns list of agent indices
  149148. */
  149149. getAgents(): number[];
  149150. /**
  149151. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  149152. * @param deltaTime in seconds
  149153. */
  149154. update(deltaTime: number): void;
  149155. /**
  149156. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  149157. * @param index agent index returned by addAgent
  149158. * @param destination targeted world position
  149159. */
  149160. agentGoto(index: number, destination: Vector3): void;
  149161. /**
  149162. * Teleport the agent to a new position
  149163. * @param index agent index returned by addAgent
  149164. * @param destination targeted world position
  149165. */
  149166. agentTeleport(index: number, destination: Vector3): void;
  149167. /**
  149168. * Update agent parameters
  149169. * @param index agent index returned by addAgent
  149170. * @param parameters agent parameters
  149171. */
  149172. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  149173. /**
  149174. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149175. * The queries will try to find a solution within those bounds
  149176. * default is (1,1,1)
  149177. * @param extent x,y,z value that define the extent around the queries point of reference
  149178. */
  149179. setDefaultQueryExtent(extent: Vector3): void;
  149180. /**
  149181. * Get the Bounding box extent specified by setDefaultQueryExtent
  149182. * @returns the box extent values
  149183. */
  149184. getDefaultQueryExtent(): Vector3;
  149185. /**
  149186. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149187. * @param result output the box extent values
  149188. */
  149189. getDefaultQueryExtentToRef(result: Vector3): void;
  149190. /**
  149191. * Release all resources
  149192. */
  149193. dispose(): void;
  149194. }
  149195. /**
  149196. * Configures an agent
  149197. */
  149198. export interface IAgentParameters {
  149199. /**
  149200. * Agent radius. [Limit: >= 0]
  149201. */
  149202. radius: number;
  149203. /**
  149204. * Agent height. [Limit: > 0]
  149205. */
  149206. height: number;
  149207. /**
  149208. * Maximum allowed acceleration. [Limit: >= 0]
  149209. */
  149210. maxAcceleration: number;
  149211. /**
  149212. * Maximum allowed speed. [Limit: >= 0]
  149213. */
  149214. maxSpeed: number;
  149215. /**
  149216. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  149217. */
  149218. collisionQueryRange: number;
  149219. /**
  149220. * The path visibility optimization range. [Limit: > 0]
  149221. */
  149222. pathOptimizationRange: number;
  149223. /**
  149224. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  149225. */
  149226. separationWeight: number;
  149227. }
  149228. /**
  149229. * Configures the navigation mesh creation
  149230. */
  149231. export interface INavMeshParameters {
  149232. /**
  149233. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  149234. */
  149235. cs: number;
  149236. /**
  149237. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  149238. */
  149239. ch: number;
  149240. /**
  149241. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  149242. */
  149243. walkableSlopeAngle: number;
  149244. /**
  149245. * Minimum floor to 'ceiling' height that will still allow the floor area to
  149246. * be considered walkable. [Limit: >= 3] [Units: vx]
  149247. */
  149248. walkableHeight: number;
  149249. /**
  149250. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  149251. */
  149252. walkableClimb: number;
  149253. /**
  149254. * The distance to erode/shrink the walkable area of the heightfield away from
  149255. * obstructions. [Limit: >=0] [Units: vx]
  149256. */
  149257. walkableRadius: number;
  149258. /**
  149259. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  149260. */
  149261. maxEdgeLen: number;
  149262. /**
  149263. * The maximum distance a simplfied contour's border edges should deviate
  149264. * the original raw contour. [Limit: >=0] [Units: vx]
  149265. */
  149266. maxSimplificationError: number;
  149267. /**
  149268. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  149269. */
  149270. minRegionArea: number;
  149271. /**
  149272. * Any regions with a span count smaller than this value will, if possible,
  149273. * be merged with larger regions. [Limit: >=0] [Units: vx]
  149274. */
  149275. mergeRegionArea: number;
  149276. /**
  149277. * The maximum number of vertices allowed for polygons generated during the
  149278. * contour to polygon conversion process. [Limit: >= 3]
  149279. */
  149280. maxVertsPerPoly: number;
  149281. /**
  149282. * Sets the sampling distance to use when generating the detail mesh.
  149283. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  149284. */
  149285. detailSampleDist: number;
  149286. /**
  149287. * The maximum distance the detail mesh surface should deviate from heightfield
  149288. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  149289. */
  149290. detailSampleMaxError: number;
  149291. }
  149292. }
  149293. declare module BABYLON {
  149294. /**
  149295. * RecastJS navigation plugin
  149296. */
  149297. export class RecastJSPlugin implements INavigationEnginePlugin {
  149298. /**
  149299. * Reference to the Recast library
  149300. */
  149301. bjsRECAST: any;
  149302. /**
  149303. * plugin name
  149304. */
  149305. name: string;
  149306. /**
  149307. * the first navmesh created. We might extend this to support multiple navmeshes
  149308. */
  149309. navMesh: any;
  149310. /**
  149311. * Initializes the recastJS plugin
  149312. * @param recastInjection can be used to inject your own recast reference
  149313. */
  149314. constructor(recastInjection?: any);
  149315. /**
  149316. * Creates a navigation mesh
  149317. * @param meshes array of all the geometry used to compute the navigatio mesh
  149318. * @param parameters bunch of parameters used to filter geometry
  149319. */
  149320. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  149321. /**
  149322. * Create a navigation mesh debug mesh
  149323. * @param scene is where the mesh will be added
  149324. * @returns debug display mesh
  149325. */
  149326. createDebugNavMesh(scene: Scene): Mesh;
  149327. /**
  149328. * Get a navigation mesh constrained position, closest to the parameter position
  149329. * @param position world position
  149330. * @returns the closest point to position constrained by the navigation mesh
  149331. */
  149332. getClosestPoint(position: Vector3): Vector3;
  149333. /**
  149334. * Get a navigation mesh constrained position, closest to the parameter position
  149335. * @param position world position
  149336. * @param result output the closest point to position constrained by the navigation mesh
  149337. */
  149338. getClosestPointToRef(position: Vector3, result: Vector3): void;
  149339. /**
  149340. * Get a navigation mesh constrained position, within a particular radius
  149341. * @param position world position
  149342. * @param maxRadius the maximum distance to the constrained world position
  149343. * @returns the closest point to position constrained by the navigation mesh
  149344. */
  149345. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  149346. /**
  149347. * Get a navigation mesh constrained position, within a particular radius
  149348. * @param position world position
  149349. * @param maxRadius the maximum distance to the constrained world position
  149350. * @param result output the closest point to position constrained by the navigation mesh
  149351. */
  149352. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  149353. /**
  149354. * Compute the final position from a segment made of destination-position
  149355. * @param position world position
  149356. * @param destination world position
  149357. * @returns the resulting point along the navmesh
  149358. */
  149359. moveAlong(position: Vector3, destination: Vector3): Vector3;
  149360. /**
  149361. * Compute the final position from a segment made of destination-position
  149362. * @param position world position
  149363. * @param destination world position
  149364. * @param result output the resulting point along the navmesh
  149365. */
  149366. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  149367. /**
  149368. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  149369. * @param start world position
  149370. * @param end world position
  149371. * @returns array containing world position composing the path
  149372. */
  149373. computePath(start: Vector3, end: Vector3): Vector3[];
  149374. /**
  149375. * Create a new Crowd so you can add agents
  149376. * @param maxAgents the maximum agent count in the crowd
  149377. * @param maxAgentRadius the maximum radius an agent can have
  149378. * @param scene to attach the crowd to
  149379. * @returns the crowd you can add agents to
  149380. */
  149381. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  149382. /**
  149383. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149384. * The queries will try to find a solution within those bounds
  149385. * default is (1,1,1)
  149386. * @param extent x,y,z value that define the extent around the queries point of reference
  149387. */
  149388. setDefaultQueryExtent(extent: Vector3): void;
  149389. /**
  149390. * Get the Bounding box extent specified by setDefaultQueryExtent
  149391. * @returns the box extent values
  149392. */
  149393. getDefaultQueryExtent(): Vector3;
  149394. /**
  149395. * build the navmesh from a previously saved state using getNavmeshData
  149396. * @param data the Uint8Array returned by getNavmeshData
  149397. */
  149398. buildFromNavmeshData(data: Uint8Array): void;
  149399. /**
  149400. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  149401. * @returns data the Uint8Array that can be saved and reused
  149402. */
  149403. getNavmeshData(): Uint8Array;
  149404. /**
  149405. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149406. * @param result output the box extent values
  149407. */
  149408. getDefaultQueryExtentToRef(result: Vector3): void;
  149409. /**
  149410. * Disposes
  149411. */
  149412. dispose(): void;
  149413. /**
  149414. * If this plugin is supported
  149415. * @returns true if plugin is supported
  149416. */
  149417. isSupported(): boolean;
  149418. }
  149419. /**
  149420. * Recast detour crowd implementation
  149421. */
  149422. export class RecastJSCrowd implements ICrowd {
  149423. /**
  149424. * Recast/detour plugin
  149425. */
  149426. bjsRECASTPlugin: RecastJSPlugin;
  149427. /**
  149428. * Link to the detour crowd
  149429. */
  149430. recastCrowd: any;
  149431. /**
  149432. * One transform per agent
  149433. */
  149434. transforms: TransformNode[];
  149435. /**
  149436. * All agents created
  149437. */
  149438. agents: number[];
  149439. /**
  149440. * Link to the scene is kept to unregister the crowd from the scene
  149441. */
  149442. private _scene;
  149443. /**
  149444. * Observer for crowd updates
  149445. */
  149446. private _onBeforeAnimationsObserver;
  149447. /**
  149448. * Constructor
  149449. * @param plugin recastJS plugin
  149450. * @param maxAgents the maximum agent count in the crowd
  149451. * @param maxAgentRadius the maximum radius an agent can have
  149452. * @param scene to attach the crowd to
  149453. * @returns the crowd you can add agents to
  149454. */
  149455. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  149456. /**
  149457. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  149458. * You can attach anything to that node. The node position is updated in the scene update tick.
  149459. * @param pos world position that will be constrained by the navigation mesh
  149460. * @param parameters agent parameters
  149461. * @param transform hooked to the agent that will be update by the scene
  149462. * @returns agent index
  149463. */
  149464. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  149465. /**
  149466. * Returns the agent position in world space
  149467. * @param index agent index returned by addAgent
  149468. * @returns world space position
  149469. */
  149470. getAgentPosition(index: number): Vector3;
  149471. /**
  149472. * Returns the agent position result in world space
  149473. * @param index agent index returned by addAgent
  149474. * @param result output world space position
  149475. */
  149476. getAgentPositionToRef(index: number, result: Vector3): void;
  149477. /**
  149478. * Returns the agent velocity in world space
  149479. * @param index agent index returned by addAgent
  149480. * @returns world space velocity
  149481. */
  149482. getAgentVelocity(index: number): Vector3;
  149483. /**
  149484. * Returns the agent velocity result in world space
  149485. * @param index agent index returned by addAgent
  149486. * @param result output world space velocity
  149487. */
  149488. getAgentVelocityToRef(index: number, result: Vector3): void;
  149489. /**
  149490. * Returns the agent next target point on the path
  149491. * @param index agent index returned by addAgent
  149492. * @returns world space position
  149493. */
  149494. getAgentNextTargetPath(index: number): Vector3;
  149495. /**
  149496. * Returns the agent next target point on the path
  149497. * @param index agent index returned by addAgent
  149498. * @param result output world space position
  149499. */
  149500. getAgentNextTargetPathToRef(index: number, result: Vector3): void;
  149501. /**
  149502. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  149503. * @param index agent index returned by addAgent
  149504. * @param destination targeted world position
  149505. */
  149506. agentGoto(index: number, destination: Vector3): void;
  149507. /**
  149508. * Teleport the agent to a new position
  149509. * @param index agent index returned by addAgent
  149510. * @param destination targeted world position
  149511. */
  149512. agentTeleport(index: number, destination: Vector3): void;
  149513. /**
  149514. * Update agent parameters
  149515. * @param index agent index returned by addAgent
  149516. * @param parameters agent parameters
  149517. */
  149518. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  149519. /**
  149520. * remove a particular agent previously created
  149521. * @param index agent index returned by addAgent
  149522. */
  149523. removeAgent(index: number): void;
  149524. /**
  149525. * get the list of all agents attached to this crowd
  149526. * @returns list of agent indices
  149527. */
  149528. getAgents(): number[];
  149529. /**
  149530. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  149531. * @param deltaTime in seconds
  149532. */
  149533. update(deltaTime: number): void;
  149534. /**
  149535. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  149536. * The queries will try to find a solution within those bounds
  149537. * default is (1,1,1)
  149538. * @param extent x,y,z value that define the extent around the queries point of reference
  149539. */
  149540. setDefaultQueryExtent(extent: Vector3): void;
  149541. /**
  149542. * Get the Bounding box extent specified by setDefaultQueryExtent
  149543. * @returns the box extent values
  149544. */
  149545. getDefaultQueryExtent(): Vector3;
  149546. /**
  149547. * Get the Bounding box extent result specified by setDefaultQueryExtent
  149548. * @param result output the box extent values
  149549. */
  149550. getDefaultQueryExtentToRef(result: Vector3): void;
  149551. /**
  149552. * Release all resources
  149553. */
  149554. dispose(): void;
  149555. }
  149556. }
  149557. declare module BABYLON {
  149558. /**
  149559. * Class used to enable access to IndexedDB
  149560. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  149561. */
  149562. export class Database implements IOfflineProvider {
  149563. private _callbackManifestChecked;
  149564. private _currentSceneUrl;
  149565. private _db;
  149566. private _enableSceneOffline;
  149567. private _enableTexturesOffline;
  149568. private _manifestVersionFound;
  149569. private _mustUpdateRessources;
  149570. private _hasReachedQuota;
  149571. private _isSupported;
  149572. private _idbFactory;
  149573. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  149574. private static IsUASupportingBlobStorage;
  149575. /**
  149576. * Gets a boolean indicating if Database storate is enabled (off by default)
  149577. */
  149578. static IDBStorageEnabled: boolean;
  149579. /**
  149580. * Gets a boolean indicating if scene must be saved in the database
  149581. */
  149582. get enableSceneOffline(): boolean;
  149583. /**
  149584. * Gets a boolean indicating if textures must be saved in the database
  149585. */
  149586. get enableTexturesOffline(): boolean;
  149587. /**
  149588. * Creates a new Database
  149589. * @param urlToScene defines the url to load the scene
  149590. * @param callbackManifestChecked defines the callback to use when manifest is checked
  149591. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  149592. */
  149593. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  149594. private static _ParseURL;
  149595. private static _ReturnFullUrlLocation;
  149596. private _checkManifestFile;
  149597. /**
  149598. * Open the database and make it available
  149599. * @param successCallback defines the callback to call on success
  149600. * @param errorCallback defines the callback to call on error
  149601. */
  149602. open(successCallback: () => void, errorCallback: () => void): void;
  149603. /**
  149604. * Loads an image from the database
  149605. * @param url defines the url to load from
  149606. * @param image defines the target DOM image
  149607. */
  149608. loadImage(url: string, image: HTMLImageElement): void;
  149609. private _loadImageFromDBAsync;
  149610. private _saveImageIntoDBAsync;
  149611. private _checkVersionFromDB;
  149612. private _loadVersionFromDBAsync;
  149613. private _saveVersionIntoDBAsync;
  149614. /**
  149615. * Loads a file from database
  149616. * @param url defines the URL to load from
  149617. * @param sceneLoaded defines a callback to call on success
  149618. * @param progressCallBack defines a callback to call when progress changed
  149619. * @param errorCallback defines a callback to call on error
  149620. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  149621. */
  149622. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  149623. private _loadFileAsync;
  149624. private _saveFileAsync;
  149625. /**
  149626. * Validates if xhr data is correct
  149627. * @param xhr defines the request to validate
  149628. * @param dataType defines the expected data type
  149629. * @returns true if data is correct
  149630. */
  149631. private static _ValidateXHRData;
  149632. }
  149633. }
  149634. declare module BABYLON {
  149635. /** @hidden */
  149636. export var gpuUpdateParticlesPixelShader: {
  149637. name: string;
  149638. shader: string;
  149639. };
  149640. }
  149641. declare module BABYLON {
  149642. /** @hidden */
  149643. export var gpuUpdateParticlesVertexShader: {
  149644. name: string;
  149645. shader: string;
  149646. };
  149647. }
  149648. declare module BABYLON {
  149649. /** @hidden */
  149650. export var clipPlaneFragmentDeclaration2: {
  149651. name: string;
  149652. shader: string;
  149653. };
  149654. }
  149655. declare module BABYLON {
  149656. /** @hidden */
  149657. export var gpuRenderParticlesPixelShader: {
  149658. name: string;
  149659. shader: string;
  149660. };
  149661. }
  149662. declare module BABYLON {
  149663. /** @hidden */
  149664. export var clipPlaneVertexDeclaration2: {
  149665. name: string;
  149666. shader: string;
  149667. };
  149668. }
  149669. declare module BABYLON {
  149670. /** @hidden */
  149671. export var gpuRenderParticlesVertexShader: {
  149672. name: string;
  149673. shader: string;
  149674. };
  149675. }
  149676. declare module BABYLON {
  149677. /**
  149678. * This represents a GPU particle system in Babylon
  149679. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  149680. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  149681. */
  149682. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  149683. /**
  149684. * The layer mask we are rendering the particles through.
  149685. */
  149686. layerMask: number;
  149687. private _capacity;
  149688. private _activeCount;
  149689. private _currentActiveCount;
  149690. private _accumulatedCount;
  149691. private _renderEffect;
  149692. private _updateEffect;
  149693. private _buffer0;
  149694. private _buffer1;
  149695. private _spriteBuffer;
  149696. private _updateVAO;
  149697. private _renderVAO;
  149698. private _targetIndex;
  149699. private _sourceBuffer;
  149700. private _targetBuffer;
  149701. private _currentRenderId;
  149702. private _started;
  149703. private _stopped;
  149704. private _timeDelta;
  149705. private _randomTexture;
  149706. private _randomTexture2;
  149707. private _attributesStrideSize;
  149708. private _updateEffectOptions;
  149709. private _randomTextureSize;
  149710. private _actualFrame;
  149711. private _customEffect;
  149712. private readonly _rawTextureWidth;
  149713. /**
  149714. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  149715. */
  149716. static get IsSupported(): boolean;
  149717. /**
  149718. * An event triggered when the system is disposed.
  149719. */
  149720. onDisposeObservable: Observable<IParticleSystem>;
  149721. /**
  149722. * An event triggered when the system is stopped
  149723. */
  149724. onStoppedObservable: Observable<IParticleSystem>;
  149725. /**
  149726. * Gets the maximum number of particles active at the same time.
  149727. * @returns The max number of active particles.
  149728. */
  149729. getCapacity(): number;
  149730. /**
  149731. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  149732. * to override the particles.
  149733. */
  149734. forceDepthWrite: boolean;
  149735. /**
  149736. * Gets or set the number of active particles
  149737. */
  149738. get activeParticleCount(): number;
  149739. set activeParticleCount(value: number);
  149740. private _preWarmDone;
  149741. /**
  149742. * Specifies if the particles are updated in emitter local space or world space.
  149743. */
  149744. isLocal: boolean;
  149745. /** Gets or sets a matrix to use to compute projection */
  149746. defaultProjectionMatrix: Matrix;
  149747. /**
  149748. * Is this system ready to be used/rendered
  149749. * @return true if the system is ready
  149750. */
  149751. isReady(): boolean;
  149752. /**
  149753. * Gets if the system has been started. (Note: this will still be true after stop is called)
  149754. * @returns True if it has been started, otherwise false.
  149755. */
  149756. isStarted(): boolean;
  149757. /**
  149758. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  149759. * @returns True if it has been stopped, otherwise false.
  149760. */
  149761. isStopped(): boolean;
  149762. /**
  149763. * Gets a boolean indicating that the system is stopping
  149764. * @returns true if the system is currently stopping
  149765. */
  149766. isStopping(): boolean;
  149767. /**
  149768. * Gets the number of particles active at the same time.
  149769. * @returns The number of active particles.
  149770. */
  149771. getActiveCount(): number;
  149772. /**
  149773. * Starts the particle system and begins to emit
  149774. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  149775. */
  149776. start(delay?: number): void;
  149777. /**
  149778. * Stops the particle system.
  149779. */
  149780. stop(): void;
  149781. /**
  149782. * Remove all active particles
  149783. */
  149784. reset(): void;
  149785. /**
  149786. * Returns the string "GPUParticleSystem"
  149787. * @returns a string containing the class name
  149788. */
  149789. getClassName(): string;
  149790. /**
  149791. * Gets the custom effect used to render the particles
  149792. * @param blendMode Blend mode for which the effect should be retrieved
  149793. * @returns The effect
  149794. */
  149795. getCustomEffect(blendMode?: number): Nullable<Effect>;
  149796. /**
  149797. * Sets the custom effect used to render the particles
  149798. * @param effect The effect to set
  149799. * @param blendMode Blend mode for which the effect should be set
  149800. */
  149801. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  149802. /** @hidden */
  149803. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  149804. /**
  149805. * Observable that will be called just before the particles are drawn
  149806. */
  149807. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  149808. /**
  149809. * Gets the name of the particle vertex shader
  149810. */
  149811. get vertexShaderName(): string;
  149812. private _colorGradientsTexture;
  149813. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  149814. /**
  149815. * Adds a new color gradient
  149816. * @param gradient defines the gradient to use (between 0 and 1)
  149817. * @param color1 defines the color to affect to the specified gradient
  149818. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  149819. * @returns the current particle system
  149820. */
  149821. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  149822. private _refreshColorGradient;
  149823. /** Force the system to rebuild all gradients that need to be resync */
  149824. forceRefreshGradients(): void;
  149825. /**
  149826. * Remove a specific color gradient
  149827. * @param gradient defines the gradient to remove
  149828. * @returns the current particle system
  149829. */
  149830. removeColorGradient(gradient: number): GPUParticleSystem;
  149831. private _angularSpeedGradientsTexture;
  149832. private _sizeGradientsTexture;
  149833. private _velocityGradientsTexture;
  149834. private _limitVelocityGradientsTexture;
  149835. private _dragGradientsTexture;
  149836. private _addFactorGradient;
  149837. /**
  149838. * Adds a new size gradient
  149839. * @param gradient defines the gradient to use (between 0 and 1)
  149840. * @param factor defines the size factor to affect to the specified gradient
  149841. * @returns the current particle system
  149842. */
  149843. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  149844. /**
  149845. * Remove a specific size gradient
  149846. * @param gradient defines the gradient to remove
  149847. * @returns the current particle system
  149848. */
  149849. removeSizeGradient(gradient: number): GPUParticleSystem;
  149850. private _refreshFactorGradient;
  149851. /**
  149852. * Adds a new angular speed gradient
  149853. * @param gradient defines the gradient to use (between 0 and 1)
  149854. * @param factor defines the angular speed to affect to the specified gradient
  149855. * @returns the current particle system
  149856. */
  149857. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  149858. /**
  149859. * Remove a specific angular speed gradient
  149860. * @param gradient defines the gradient to remove
  149861. * @returns the current particle system
  149862. */
  149863. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  149864. /**
  149865. * Adds a new velocity gradient
  149866. * @param gradient defines the gradient to use (between 0 and 1)
  149867. * @param factor defines the velocity to affect to the specified gradient
  149868. * @returns the current particle system
  149869. */
  149870. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149871. /**
  149872. * Remove a specific velocity gradient
  149873. * @param gradient defines the gradient to remove
  149874. * @returns the current particle system
  149875. */
  149876. removeVelocityGradient(gradient: number): GPUParticleSystem;
  149877. /**
  149878. * Adds a new limit velocity gradient
  149879. * @param gradient defines the gradient to use (between 0 and 1)
  149880. * @param factor defines the limit velocity value to affect to the specified gradient
  149881. * @returns the current particle system
  149882. */
  149883. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  149884. /**
  149885. * Remove a specific limit velocity gradient
  149886. * @param gradient defines the gradient to remove
  149887. * @returns the current particle system
  149888. */
  149889. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  149890. /**
  149891. * Adds a new drag gradient
  149892. * @param gradient defines the gradient to use (between 0 and 1)
  149893. * @param factor defines the drag value to affect to the specified gradient
  149894. * @returns the current particle system
  149895. */
  149896. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  149897. /**
  149898. * Remove a specific drag gradient
  149899. * @param gradient defines the gradient to remove
  149900. * @returns the current particle system
  149901. */
  149902. removeDragGradient(gradient: number): GPUParticleSystem;
  149903. /**
  149904. * Not supported by GPUParticleSystem
  149905. * @param gradient defines the gradient to use (between 0 and 1)
  149906. * @param factor defines the emit rate value to affect to the specified gradient
  149907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149908. * @returns the current particle system
  149909. */
  149910. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149911. /**
  149912. * Not supported by GPUParticleSystem
  149913. * @param gradient defines the gradient to remove
  149914. * @returns the current particle system
  149915. */
  149916. removeEmitRateGradient(gradient: number): IParticleSystem;
  149917. /**
  149918. * Not supported by GPUParticleSystem
  149919. * @param gradient defines the gradient to use (between 0 and 1)
  149920. * @param factor defines the start size value to affect to the specified gradient
  149921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149922. * @returns the current particle system
  149923. */
  149924. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149925. /**
  149926. * Not supported by GPUParticleSystem
  149927. * @param gradient defines the gradient to remove
  149928. * @returns the current particle system
  149929. */
  149930. removeStartSizeGradient(gradient: number): IParticleSystem;
  149931. /**
  149932. * Not supported by GPUParticleSystem
  149933. * @param gradient defines the gradient to use (between 0 and 1)
  149934. * @param min defines the color remap minimal range
  149935. * @param max defines the color remap maximal range
  149936. * @returns the current particle system
  149937. */
  149938. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149939. /**
  149940. * Not supported by GPUParticleSystem
  149941. * @param gradient defines the gradient to remove
  149942. * @returns the current particle system
  149943. */
  149944. removeColorRemapGradient(): IParticleSystem;
  149945. /**
  149946. * Not supported by GPUParticleSystem
  149947. * @param gradient defines the gradient to use (between 0 and 1)
  149948. * @param min defines the alpha remap minimal range
  149949. * @param max defines the alpha remap maximal range
  149950. * @returns the current particle system
  149951. */
  149952. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  149953. /**
  149954. * Not supported by GPUParticleSystem
  149955. * @param gradient defines the gradient to remove
  149956. * @returns the current particle system
  149957. */
  149958. removeAlphaRemapGradient(): IParticleSystem;
  149959. /**
  149960. * Not supported by GPUParticleSystem
  149961. * @param gradient defines the gradient to use (between 0 and 1)
  149962. * @param color defines the color to affect to the specified gradient
  149963. * @returns the current particle system
  149964. */
  149965. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  149966. /**
  149967. * Not supported by GPUParticleSystem
  149968. * @param gradient defines the gradient to remove
  149969. * @returns the current particle system
  149970. */
  149971. removeRampGradient(): IParticleSystem;
  149972. /**
  149973. * Not supported by GPUParticleSystem
  149974. * @returns the list of ramp gradients
  149975. */
  149976. getRampGradients(): Nullable<Array<Color3Gradient>>;
  149977. /**
  149978. * Not supported by GPUParticleSystem
  149979. * Gets or sets a boolean indicating that ramp gradients must be used
  149980. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  149981. */
  149982. get useRampGradients(): boolean;
  149983. set useRampGradients(value: boolean);
  149984. /**
  149985. * Not supported by GPUParticleSystem
  149986. * @param gradient defines the gradient to use (between 0 and 1)
  149987. * @param factor defines the life time factor to affect to the specified gradient
  149988. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  149989. * @returns the current particle system
  149990. */
  149991. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  149992. /**
  149993. * Not supported by GPUParticleSystem
  149994. * @param gradient defines the gradient to remove
  149995. * @returns the current particle system
  149996. */
  149997. removeLifeTimeGradient(gradient: number): IParticleSystem;
  149998. /**
  149999. * Instantiates a GPU particle system.
  150000. * 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.
  150001. * @param name The name of the particle system
  150002. * @param options The options used to create the system
  150003. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  150004. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  150005. * @param customEffect a custom effect used to change the way particles are rendered by default
  150006. */
  150007. constructor(name: string, options: Partial<{
  150008. capacity: number;
  150009. randomTextureSize: number;
  150010. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  150011. protected _reset(): void;
  150012. private _createUpdateVAO;
  150013. private _createRenderVAO;
  150014. private _initialize;
  150015. /** @hidden */
  150016. _recreateUpdateEffect(): void;
  150017. private _getEffect;
  150018. /**
  150019. * Fill the defines array according to the current settings of the particle system
  150020. * @param defines Array to be updated
  150021. * @param blendMode blend mode to take into account when updating the array
  150022. */
  150023. fillDefines(defines: Array<string>, blendMode?: number): void;
  150024. /**
  150025. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  150026. * @param uniforms Uniforms array to fill
  150027. * @param attributes Attributes array to fill
  150028. * @param samplers Samplers array to fill
  150029. */
  150030. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  150031. /** @hidden */
  150032. _recreateRenderEffect(): Effect;
  150033. /**
  150034. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  150035. * @param preWarm defines if we are in the pre-warmimg phase
  150036. */
  150037. animate(preWarm?: boolean): void;
  150038. private _createFactorGradientTexture;
  150039. private _createSizeGradientTexture;
  150040. private _createAngularSpeedGradientTexture;
  150041. private _createVelocityGradientTexture;
  150042. private _createLimitVelocityGradientTexture;
  150043. private _createDragGradientTexture;
  150044. private _createColorGradientTexture;
  150045. /**
  150046. * Renders the particle system in its current state
  150047. * @param preWarm defines if the system should only update the particles but not render them
  150048. * @returns the current number of particles
  150049. */
  150050. render(preWarm?: boolean): number;
  150051. /**
  150052. * Rebuilds the particle system
  150053. */
  150054. rebuild(): void;
  150055. private _releaseBuffers;
  150056. private _releaseVAOs;
  150057. /**
  150058. * Disposes the particle system and free the associated resources
  150059. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  150060. */
  150061. dispose(disposeTexture?: boolean): void;
  150062. /**
  150063. * Clones the particle system.
  150064. * @param name The name of the cloned object
  150065. * @param newEmitter The new emitter to use
  150066. * @returns the cloned particle system
  150067. */
  150068. clone(name: string, newEmitter: any): GPUParticleSystem;
  150069. /**
  150070. * Serializes the particle system to a JSON object
  150071. * @param serializeTexture defines if the texture must be serialized as well
  150072. * @returns the JSON object
  150073. */
  150074. serialize(serializeTexture?: boolean): any;
  150075. /**
  150076. * Parses a JSON object to create a GPU particle system.
  150077. * @param parsedParticleSystem The JSON object to parse
  150078. * @param sceneOrEngine The scene or the engine to create the particle system in
  150079. * @param rootUrl The root url to use to load external dependencies like texture
  150080. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  150081. * @returns the parsed GPU particle system
  150082. */
  150083. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  150084. }
  150085. }
  150086. declare module BABYLON {
  150087. /**
  150088. * Represents a set of particle systems working together to create a specific effect
  150089. */
  150090. export class ParticleSystemSet implements IDisposable {
  150091. /**
  150092. * Gets or sets base Assets URL
  150093. */
  150094. static BaseAssetsUrl: string;
  150095. private _emitterCreationOptions;
  150096. private _emitterNode;
  150097. /**
  150098. * Gets the particle system list
  150099. */
  150100. systems: IParticleSystem[];
  150101. /**
  150102. * Gets the emitter node used with this set
  150103. */
  150104. get emitterNode(): Nullable<TransformNode>;
  150105. /**
  150106. * Creates a new emitter mesh as a sphere
  150107. * @param options defines the options used to create the sphere
  150108. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  150109. * @param scene defines the hosting scene
  150110. */
  150111. setEmitterAsSphere(options: {
  150112. diameter: number;
  150113. segments: number;
  150114. color: Color3;
  150115. }, renderingGroupId: number, scene: Scene): void;
  150116. /**
  150117. * Starts all particle systems of the set
  150118. * @param emitter defines an optional mesh to use as emitter for the particle systems
  150119. */
  150120. start(emitter?: AbstractMesh): void;
  150121. /**
  150122. * Release all associated resources
  150123. */
  150124. dispose(): void;
  150125. /**
  150126. * Serialize the set into a JSON compatible object
  150127. * @param serializeTexture defines if the texture must be serialized as well
  150128. * @returns a JSON compatible representation of the set
  150129. */
  150130. serialize(serializeTexture?: boolean): any;
  150131. /**
  150132. * Parse a new ParticleSystemSet from a serialized source
  150133. * @param data defines a JSON compatible representation of the set
  150134. * @param scene defines the hosting scene
  150135. * @param gpu defines if we want GPU particles or CPU particles
  150136. * @returns a new ParticleSystemSet
  150137. */
  150138. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  150139. }
  150140. }
  150141. declare module BABYLON {
  150142. /**
  150143. * This class is made for on one-liner static method to help creating particle system set.
  150144. */
  150145. export class ParticleHelper {
  150146. /**
  150147. * Gets or sets base Assets URL
  150148. */
  150149. static BaseAssetsUrl: string;
  150150. /** Define the Url to load snippets */
  150151. static SnippetUrl: string;
  150152. /**
  150153. * Create a default particle system that you can tweak
  150154. * @param emitter defines the emitter to use
  150155. * @param capacity defines the system capacity (default is 500 particles)
  150156. * @param scene defines the hosting scene
  150157. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  150158. * @returns the new Particle system
  150159. */
  150160. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  150161. /**
  150162. * This is the main static method (one-liner) of this helper to create different particle systems
  150163. * @param type This string represents the type to the particle system to create
  150164. * @param scene The scene where the particle system should live
  150165. * @param gpu If the system will use gpu
  150166. * @returns the ParticleSystemSet created
  150167. */
  150168. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  150169. /**
  150170. * Static function used to export a particle system to a ParticleSystemSet variable.
  150171. * Please note that the emitter shape is not exported
  150172. * @param systems defines the particle systems to export
  150173. * @returns the created particle system set
  150174. */
  150175. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  150176. /**
  150177. * Creates a particle system from a snippet saved in a remote file
  150178. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  150179. * @param url defines the url to load from
  150180. * @param scene defines the hosting scene
  150181. * @param gpu If the system will use gpu
  150182. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  150183. * @returns a promise that will resolve to the new particle system
  150184. */
  150185. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  150186. /**
  150187. * Creates a particle system from a snippet saved by the particle system editor
  150188. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  150189. * @param scene defines the hosting scene
  150190. * @param gpu If the system will use gpu
  150191. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  150192. * @returns a promise that will resolve to the new particle system
  150193. */
  150194. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  150195. }
  150196. }
  150197. declare module BABYLON {
  150198. interface Engine {
  150199. /**
  150200. * Create an effect to use with particle systems.
  150201. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  150202. * the particle system for which you want to create a custom effect in the last parameter
  150203. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  150204. * @param uniformsNames defines a list of attribute names
  150205. * @param samplers defines an array of string used to represent textures
  150206. * @param defines defines the string containing the defines to use to compile the shaders
  150207. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  150208. * @param onCompiled defines a function to call when the effect creation is successful
  150209. * @param onError defines a function to call when the effect creation has failed
  150210. * @param particleSystem the particle system you want to create the effect for
  150211. * @returns the new Effect
  150212. */
  150213. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  150214. }
  150215. interface Mesh {
  150216. /**
  150217. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  150218. * @returns an array of IParticleSystem
  150219. */
  150220. getEmittedParticleSystems(): IParticleSystem[];
  150221. /**
  150222. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  150223. * @returns an array of IParticleSystem
  150224. */
  150225. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  150226. }
  150227. }
  150228. declare module BABYLON {
  150229. /** Defines the 4 color options */
  150230. export enum PointColor {
  150231. /** color value */
  150232. Color = 2,
  150233. /** uv value */
  150234. UV = 1,
  150235. /** random value */
  150236. Random = 0,
  150237. /** stated value */
  150238. Stated = 3
  150239. }
  150240. /**
  150241. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  150242. * 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.
  150243. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  150244. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  150245. *
  150246. * Full documentation here : TO BE ENTERED
  150247. */
  150248. export class PointsCloudSystem implements IDisposable {
  150249. /**
  150250. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  150251. * Example : var p = SPS.particles[i];
  150252. */
  150253. particles: CloudPoint[];
  150254. /**
  150255. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  150256. */
  150257. nbParticles: number;
  150258. /**
  150259. * This a counter for your own usage. It's not set by any SPS functions.
  150260. */
  150261. counter: number;
  150262. /**
  150263. * The PCS name. This name is also given to the underlying mesh.
  150264. */
  150265. name: string;
  150266. /**
  150267. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  150268. */
  150269. mesh: Mesh;
  150270. /**
  150271. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  150272. * Please read :
  150273. */
  150274. vars: any;
  150275. /**
  150276. * @hidden
  150277. */
  150278. _size: number;
  150279. private _scene;
  150280. private _promises;
  150281. private _positions;
  150282. private _indices;
  150283. private _normals;
  150284. private _colors;
  150285. private _uvs;
  150286. private _indices32;
  150287. private _positions32;
  150288. private _colors32;
  150289. private _uvs32;
  150290. private _updatable;
  150291. private _isVisibilityBoxLocked;
  150292. private _alwaysVisible;
  150293. private _groups;
  150294. private _groupCounter;
  150295. private _computeParticleColor;
  150296. private _computeParticleTexture;
  150297. private _computeParticleRotation;
  150298. private _computeBoundingBox;
  150299. private _isReady;
  150300. /**
  150301. * Creates a PCS (Points Cloud System) object
  150302. * @param name (String) is the PCS name, this will be the underlying mesh name
  150303. * @param pointSize (number) is the size for each point
  150304. * @param scene (Scene) is the scene in which the PCS is added
  150305. * @param options defines the options of the PCS e.g.
  150306. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  150307. */
  150308. constructor(name: string, pointSize: number, scene: Scene, options?: {
  150309. updatable?: boolean;
  150310. });
  150311. /**
  150312. * Builds the PCS underlying mesh. Returns a standard Mesh.
  150313. * If no points were added to the PCS, the returned mesh is just a single point.
  150314. * @returns a promise for the created mesh
  150315. */
  150316. buildMeshAsync(): Promise<Mesh>;
  150317. /**
  150318. * @hidden
  150319. */
  150320. private _buildMesh;
  150321. private _addParticle;
  150322. private _randomUnitVector;
  150323. private _getColorIndicesForCoord;
  150324. private _setPointsColorOrUV;
  150325. private _colorFromTexture;
  150326. private _calculateDensity;
  150327. /**
  150328. * Adds points to the PCS in random positions within a unit sphere
  150329. * @param nb (positive integer) the number of particles to be created from this model
  150330. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  150331. * @returns the number of groups in the system
  150332. */
  150333. addPoints(nb: number, pointFunction?: any): number;
  150334. /**
  150335. * Adds points to the PCS from the surface of the model shape
  150336. * @param mesh is any Mesh object that will be used as a surface model for the points
  150337. * @param nb (positive integer) the number of particles to be created from this model
  150338. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  150339. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  150340. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  150341. * @returns the number of groups in the system
  150342. */
  150343. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  150344. /**
  150345. * Adds points to the PCS inside the model shape
  150346. * @param mesh is any Mesh object that will be used as a surface model for the points
  150347. * @param nb (positive integer) the number of particles to be created from this model
  150348. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  150349. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  150350. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  150351. * @returns the number of groups in the system
  150352. */
  150353. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  150354. /**
  150355. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  150356. * This method calls `updateParticle()` for each particle of the SPS.
  150357. * For an animated SPS, it is usually called within the render loop.
  150358. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  150359. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  150360. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  150361. * @returns the PCS.
  150362. */
  150363. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  150364. /**
  150365. * Disposes the PCS.
  150366. */
  150367. dispose(): void;
  150368. /**
  150369. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  150370. * doc :
  150371. * @returns the PCS.
  150372. */
  150373. refreshVisibleSize(): PointsCloudSystem;
  150374. /**
  150375. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  150376. * @param size the size (float) of the visibility box
  150377. * note : this doesn't lock the PCS mesh bounding box.
  150378. * doc :
  150379. */
  150380. setVisibilityBox(size: number): void;
  150381. /**
  150382. * Gets whether the PCS is always visible or not
  150383. * doc :
  150384. */
  150385. get isAlwaysVisible(): boolean;
  150386. /**
  150387. * Sets the PCS as always visible or not
  150388. * doc :
  150389. */
  150390. set isAlwaysVisible(val: boolean);
  150391. /**
  150392. * Tells to `setParticles()` to compute the particle rotations or not
  150393. * Default value : false. The PCS is faster when it's set to false
  150394. * Note : particle rotations are only applied to parent particles
  150395. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  150396. */
  150397. set computeParticleRotation(val: boolean);
  150398. /**
  150399. * Tells to `setParticles()` to compute the particle colors or not.
  150400. * Default value : true. The PCS is faster when it's set to false.
  150401. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  150402. */
  150403. set computeParticleColor(val: boolean);
  150404. set computeParticleTexture(val: boolean);
  150405. /**
  150406. * Gets if `setParticles()` computes the particle colors or not.
  150407. * Default value : false. The PCS is faster when it's set to false.
  150408. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  150409. */
  150410. get computeParticleColor(): boolean;
  150411. /**
  150412. * Gets if `setParticles()` computes the particle textures or not.
  150413. * Default value : false. The PCS is faster when it's set to false.
  150414. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  150415. */
  150416. get computeParticleTexture(): boolean;
  150417. /**
  150418. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  150419. */
  150420. set computeBoundingBox(val: boolean);
  150421. /**
  150422. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  150423. */
  150424. get computeBoundingBox(): boolean;
  150425. /**
  150426. * This function does nothing. It may be overwritten to set all the particle first values.
  150427. * The PCS doesn't call this function, you may have to call it by your own.
  150428. * doc :
  150429. */
  150430. initParticles(): void;
  150431. /**
  150432. * This function does nothing. It may be overwritten to recycle a particle
  150433. * The PCS doesn't call this function, you can to call it
  150434. * doc :
  150435. * @param particle The particle to recycle
  150436. * @returns the recycled particle
  150437. */
  150438. recycleParticle(particle: CloudPoint): CloudPoint;
  150439. /**
  150440. * Updates a particle : this function should be overwritten by the user.
  150441. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  150442. * doc :
  150443. * @example : just set a particle position or velocity and recycle conditions
  150444. * @param particle The particle to update
  150445. * @returns the updated particle
  150446. */
  150447. updateParticle(particle: CloudPoint): CloudPoint;
  150448. /**
  150449. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  150450. * This does nothing and may be overwritten by the user.
  150451. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  150452. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  150453. * @param update the boolean update value actually passed to setParticles()
  150454. */
  150455. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  150456. /**
  150457. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  150458. * This will be passed three parameters.
  150459. * This does nothing and may be overwritten by the user.
  150460. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  150461. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  150462. * @param update the boolean update value actually passed to setParticles()
  150463. */
  150464. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  150465. }
  150466. }
  150467. declare module BABYLON {
  150468. /**
  150469. * Represents one particle of a points cloud system.
  150470. */
  150471. export class CloudPoint {
  150472. /**
  150473. * particle global index
  150474. */
  150475. idx: number;
  150476. /**
  150477. * The color of the particle
  150478. */
  150479. color: Nullable<Color4>;
  150480. /**
  150481. * The world space position of the particle.
  150482. */
  150483. position: Vector3;
  150484. /**
  150485. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  150486. */
  150487. rotation: Vector3;
  150488. /**
  150489. * The world space rotation quaternion of the particle.
  150490. */
  150491. rotationQuaternion: Nullable<Quaternion>;
  150492. /**
  150493. * The uv of the particle.
  150494. */
  150495. uv: Nullable<Vector2>;
  150496. /**
  150497. * The current speed of the particle.
  150498. */
  150499. velocity: Vector3;
  150500. /**
  150501. * The pivot point in the particle local space.
  150502. */
  150503. pivot: Vector3;
  150504. /**
  150505. * Must the particle be translated from its pivot point in its local space ?
  150506. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  150507. * Default : false
  150508. */
  150509. translateFromPivot: boolean;
  150510. /**
  150511. * Index of this particle in the global "positions" array (Internal use)
  150512. * @hidden
  150513. */
  150514. _pos: number;
  150515. /**
  150516. * @hidden Index of this particle in the global "indices" array (Internal use)
  150517. */
  150518. _ind: number;
  150519. /**
  150520. * Group this particle belongs to
  150521. */
  150522. _group: PointsGroup;
  150523. /**
  150524. * Group id of this particle
  150525. */
  150526. groupId: number;
  150527. /**
  150528. * Index of the particle in its group id (Internal use)
  150529. */
  150530. idxInGroup: number;
  150531. /**
  150532. * @hidden Particle BoundingInfo object (Internal use)
  150533. */
  150534. _boundingInfo: BoundingInfo;
  150535. /**
  150536. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  150537. */
  150538. _pcs: PointsCloudSystem;
  150539. /**
  150540. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  150541. */
  150542. _stillInvisible: boolean;
  150543. /**
  150544. * @hidden Last computed particle rotation matrix
  150545. */
  150546. _rotationMatrix: number[];
  150547. /**
  150548. * Parent particle Id, if any.
  150549. * Default null.
  150550. */
  150551. parentId: Nullable<number>;
  150552. /**
  150553. * @hidden Internal global position in the PCS.
  150554. */
  150555. _globalPosition: Vector3;
  150556. /**
  150557. * Creates a Point Cloud object.
  150558. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  150559. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  150560. * @param group (PointsGroup) is the group the particle belongs to
  150561. * @param groupId (integer) is the group identifier in the PCS.
  150562. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  150563. * @param pcs defines the PCS it is associated to
  150564. */
  150565. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  150566. /**
  150567. * get point size
  150568. */
  150569. get size(): Vector3;
  150570. /**
  150571. * Set point size
  150572. */
  150573. set size(scale: Vector3);
  150574. /**
  150575. * Legacy support, changed quaternion to rotationQuaternion
  150576. */
  150577. get quaternion(): Nullable<Quaternion>;
  150578. /**
  150579. * Legacy support, changed quaternion to rotationQuaternion
  150580. */
  150581. set quaternion(q: Nullable<Quaternion>);
  150582. /**
  150583. * Returns a boolean. True if the particle intersects a mesh, else false
  150584. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  150585. * @param target is the object (point or mesh) what the intersection is computed against
  150586. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  150587. * @returns true if it intersects
  150588. */
  150589. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  150590. /**
  150591. * get the rotation matrix of the particle
  150592. * @hidden
  150593. */
  150594. getRotationMatrix(m: Matrix): void;
  150595. }
  150596. /**
  150597. * Represents a group of points in a points cloud system
  150598. * * PCS internal tool, don't use it manually.
  150599. */
  150600. export class PointsGroup {
  150601. /**
  150602. * The group id
  150603. * @hidden
  150604. */
  150605. groupID: number;
  150606. /**
  150607. * image data for group (internal use)
  150608. * @hidden
  150609. */
  150610. _groupImageData: Nullable<ArrayBufferView>;
  150611. /**
  150612. * Image Width (internal use)
  150613. * @hidden
  150614. */
  150615. _groupImgWidth: number;
  150616. /**
  150617. * Image Height (internal use)
  150618. * @hidden
  150619. */
  150620. _groupImgHeight: number;
  150621. /**
  150622. * Custom position function (internal use)
  150623. * @hidden
  150624. */
  150625. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  150626. /**
  150627. * density per facet for surface points
  150628. * @hidden
  150629. */
  150630. _groupDensity: number[];
  150631. /**
  150632. * Only when points are colored by texture carries pointer to texture list array
  150633. * @hidden
  150634. */
  150635. _textureNb: number;
  150636. /**
  150637. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  150638. * PCS internal tool, don't use it manually.
  150639. * @hidden
  150640. */
  150641. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  150642. }
  150643. }
  150644. declare module BABYLON {
  150645. interface Scene {
  150646. /** @hidden (Backing field) */
  150647. _physicsEngine: Nullable<IPhysicsEngine>;
  150648. /** @hidden */
  150649. _physicsTimeAccumulator: number;
  150650. /**
  150651. * Gets the current physics engine
  150652. * @returns a IPhysicsEngine or null if none attached
  150653. */
  150654. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  150655. /**
  150656. * Enables physics to the current scene
  150657. * @param gravity defines the scene's gravity for the physics engine
  150658. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  150659. * @return a boolean indicating if the physics engine was initialized
  150660. */
  150661. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  150662. /**
  150663. * Disables and disposes the physics engine associated with the scene
  150664. */
  150665. disablePhysicsEngine(): void;
  150666. /**
  150667. * Gets a boolean indicating if there is an active physics engine
  150668. * @returns a boolean indicating if there is an active physics engine
  150669. */
  150670. isPhysicsEnabled(): boolean;
  150671. /**
  150672. * Deletes a physics compound impostor
  150673. * @param compound defines the compound to delete
  150674. */
  150675. deleteCompoundImpostor(compound: any): void;
  150676. /**
  150677. * An event triggered when physic simulation is about to be run
  150678. */
  150679. onBeforePhysicsObservable: Observable<Scene>;
  150680. /**
  150681. * An event triggered when physic simulation has been done
  150682. */
  150683. onAfterPhysicsObservable: Observable<Scene>;
  150684. }
  150685. interface AbstractMesh {
  150686. /** @hidden */
  150687. _physicsImpostor: Nullable<PhysicsImpostor>;
  150688. /**
  150689. * Gets or sets impostor used for physic simulation
  150690. * @see https://doc.babylonjs.com/features/physics_engine
  150691. */
  150692. physicsImpostor: Nullable<PhysicsImpostor>;
  150693. /**
  150694. * Gets the current physics impostor
  150695. * @see https://doc.babylonjs.com/features/physics_engine
  150696. * @returns a physics impostor or null
  150697. */
  150698. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  150699. /** Apply a physic impulse to the mesh
  150700. * @param force defines the force to apply
  150701. * @param contactPoint defines where to apply the force
  150702. * @returns the current mesh
  150703. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  150704. */
  150705. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  150706. /**
  150707. * Creates a physic joint between two meshes
  150708. * @param otherMesh defines the other mesh to use
  150709. * @param pivot1 defines the pivot to use on this mesh
  150710. * @param pivot2 defines the pivot to use on the other mesh
  150711. * @param options defines additional options (can be plugin dependent)
  150712. * @returns the current mesh
  150713. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  150714. */
  150715. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  150716. /** @hidden */
  150717. _disposePhysicsObserver: Nullable<Observer<Node>>;
  150718. }
  150719. /**
  150720. * Defines the physics engine scene component responsible to manage a physics engine
  150721. */
  150722. export class PhysicsEngineSceneComponent implements ISceneComponent {
  150723. /**
  150724. * The component name helpful to identify the component in the list of scene components.
  150725. */
  150726. readonly name: string;
  150727. /**
  150728. * The scene the component belongs to.
  150729. */
  150730. scene: Scene;
  150731. /**
  150732. * Creates a new instance of the component for the given scene
  150733. * @param scene Defines the scene to register the component in
  150734. */
  150735. constructor(scene: Scene);
  150736. /**
  150737. * Registers the component in a given scene
  150738. */
  150739. register(): void;
  150740. /**
  150741. * Rebuilds the elements related to this component in case of
  150742. * context lost for instance.
  150743. */
  150744. rebuild(): void;
  150745. /**
  150746. * Disposes the component and the associated ressources
  150747. */
  150748. dispose(): void;
  150749. }
  150750. }
  150751. declare module BABYLON {
  150752. /**
  150753. * A helper for physics simulations
  150754. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150755. */
  150756. export class PhysicsHelper {
  150757. private _scene;
  150758. private _physicsEngine;
  150759. /**
  150760. * Initializes the Physics helper
  150761. * @param scene Babylon.js scene
  150762. */
  150763. constructor(scene: Scene);
  150764. /**
  150765. * Applies a radial explosion impulse
  150766. * @param origin the origin of the explosion
  150767. * @param radiusOrEventOptions the radius or the options of radial explosion
  150768. * @param strength the explosion strength
  150769. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150770. * @returns A physics radial explosion event, or null
  150771. */
  150772. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150773. /**
  150774. * Applies a radial explosion force
  150775. * @param origin the origin of the explosion
  150776. * @param radiusOrEventOptions the radius or the options of radial explosion
  150777. * @param strength the explosion strength
  150778. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150779. * @returns A physics radial explosion event, or null
  150780. */
  150781. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  150782. /**
  150783. * Creates a gravitational field
  150784. * @param origin the origin of the explosion
  150785. * @param radiusOrEventOptions the radius or the options of radial explosion
  150786. * @param strength the explosion strength
  150787. * @param falloff possible options: Constant & Linear. Defaults to Constant
  150788. * @returns A physics gravitational field event, or null
  150789. */
  150790. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  150791. /**
  150792. * Creates a physics updraft event
  150793. * @param origin the origin of the updraft
  150794. * @param radiusOrEventOptions the radius or the options of the updraft
  150795. * @param strength the strength of the updraft
  150796. * @param height the height of the updraft
  150797. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  150798. * @returns A physics updraft event, or null
  150799. */
  150800. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  150801. /**
  150802. * Creates a physics vortex event
  150803. * @param origin the of the vortex
  150804. * @param radiusOrEventOptions the radius or the options of the vortex
  150805. * @param strength the strength of the vortex
  150806. * @param height the height of the vortex
  150807. * @returns a Physics vortex event, or null
  150808. * A physics vortex event or null
  150809. */
  150810. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  150811. }
  150812. /**
  150813. * Represents a physics radial explosion event
  150814. */
  150815. class PhysicsRadialExplosionEvent {
  150816. private _scene;
  150817. private _options;
  150818. private _sphere;
  150819. private _dataFetched;
  150820. /**
  150821. * Initializes a radial explosioin event
  150822. * @param _scene BabylonJS scene
  150823. * @param _options The options for the vortex event
  150824. */
  150825. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  150826. /**
  150827. * Returns the data related to the radial explosion event (sphere).
  150828. * @returns The radial explosion event data
  150829. */
  150830. getData(): PhysicsRadialExplosionEventData;
  150831. /**
  150832. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  150833. * @param impostor A physics imposter
  150834. * @param origin the origin of the explosion
  150835. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  150836. */
  150837. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  150838. /**
  150839. * Triggers affecterd impostors callbacks
  150840. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  150841. */
  150842. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  150843. /**
  150844. * Disposes the sphere.
  150845. * @param force Specifies if the sphere should be disposed by force
  150846. */
  150847. dispose(force?: boolean): void;
  150848. /*** Helpers ***/
  150849. private _prepareSphere;
  150850. private _intersectsWithSphere;
  150851. }
  150852. /**
  150853. * Represents a gravitational field event
  150854. */
  150855. class PhysicsGravitationalFieldEvent {
  150856. private _physicsHelper;
  150857. private _scene;
  150858. private _origin;
  150859. private _options;
  150860. private _tickCallback;
  150861. private _sphere;
  150862. private _dataFetched;
  150863. /**
  150864. * Initializes the physics gravitational field event
  150865. * @param _physicsHelper A physics helper
  150866. * @param _scene BabylonJS scene
  150867. * @param _origin The origin position of the gravitational field event
  150868. * @param _options The options for the vortex event
  150869. */
  150870. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  150871. /**
  150872. * Returns the data related to the gravitational field event (sphere).
  150873. * @returns A gravitational field event
  150874. */
  150875. getData(): PhysicsGravitationalFieldEventData;
  150876. /**
  150877. * Enables the gravitational field.
  150878. */
  150879. enable(): void;
  150880. /**
  150881. * Disables the gravitational field.
  150882. */
  150883. disable(): void;
  150884. /**
  150885. * Disposes the sphere.
  150886. * @param force The force to dispose from the gravitational field event
  150887. */
  150888. dispose(force?: boolean): void;
  150889. private _tick;
  150890. }
  150891. /**
  150892. * Represents a physics updraft event
  150893. */
  150894. class PhysicsUpdraftEvent {
  150895. private _scene;
  150896. private _origin;
  150897. private _options;
  150898. private _physicsEngine;
  150899. private _originTop;
  150900. private _originDirection;
  150901. private _tickCallback;
  150902. private _cylinder;
  150903. private _cylinderPosition;
  150904. private _dataFetched;
  150905. /**
  150906. * Initializes the physics updraft event
  150907. * @param _scene BabylonJS scene
  150908. * @param _origin The origin position of the updraft
  150909. * @param _options The options for the updraft event
  150910. */
  150911. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  150912. /**
  150913. * Returns the data related to the updraft event (cylinder).
  150914. * @returns A physics updraft event
  150915. */
  150916. getData(): PhysicsUpdraftEventData;
  150917. /**
  150918. * Enables the updraft.
  150919. */
  150920. enable(): void;
  150921. /**
  150922. * Disables the updraft.
  150923. */
  150924. disable(): void;
  150925. /**
  150926. * Disposes the cylinder.
  150927. * @param force Specifies if the updraft should be disposed by force
  150928. */
  150929. dispose(force?: boolean): void;
  150930. private getImpostorHitData;
  150931. private _tick;
  150932. /*** Helpers ***/
  150933. private _prepareCylinder;
  150934. private _intersectsWithCylinder;
  150935. }
  150936. /**
  150937. * Represents a physics vortex event
  150938. */
  150939. class PhysicsVortexEvent {
  150940. private _scene;
  150941. private _origin;
  150942. private _options;
  150943. private _physicsEngine;
  150944. private _originTop;
  150945. private _tickCallback;
  150946. private _cylinder;
  150947. private _cylinderPosition;
  150948. private _dataFetched;
  150949. /**
  150950. * Initializes the physics vortex event
  150951. * @param _scene The BabylonJS scene
  150952. * @param _origin The origin position of the vortex
  150953. * @param _options The options for the vortex event
  150954. */
  150955. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  150956. /**
  150957. * Returns the data related to the vortex event (cylinder).
  150958. * @returns The physics vortex event data
  150959. */
  150960. getData(): PhysicsVortexEventData;
  150961. /**
  150962. * Enables the vortex.
  150963. */
  150964. enable(): void;
  150965. /**
  150966. * Disables the cortex.
  150967. */
  150968. disable(): void;
  150969. /**
  150970. * Disposes the sphere.
  150971. * @param force
  150972. */
  150973. dispose(force?: boolean): void;
  150974. private getImpostorHitData;
  150975. private _tick;
  150976. /*** Helpers ***/
  150977. private _prepareCylinder;
  150978. private _intersectsWithCylinder;
  150979. }
  150980. /**
  150981. * Options fot the radial explosion event
  150982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  150983. */
  150984. export class PhysicsRadialExplosionEventOptions {
  150985. /**
  150986. * The radius of the sphere for the radial explosion.
  150987. */
  150988. radius: number;
  150989. /**
  150990. * The strenth of the explosion.
  150991. */
  150992. strength: number;
  150993. /**
  150994. * The strenght of the force in correspondence to the distance of the affected object
  150995. */
  150996. falloff: PhysicsRadialImpulseFalloff;
  150997. /**
  150998. * Sphere options for the radial explosion.
  150999. */
  151000. sphere: {
  151001. segments: number;
  151002. diameter: number;
  151003. };
  151004. /**
  151005. * Sphere options for the radial explosion.
  151006. */
  151007. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  151008. }
  151009. /**
  151010. * Options fot the updraft event
  151011. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151012. */
  151013. export class PhysicsUpdraftEventOptions {
  151014. /**
  151015. * The radius of the cylinder for the vortex
  151016. */
  151017. radius: number;
  151018. /**
  151019. * The strenth of the updraft.
  151020. */
  151021. strength: number;
  151022. /**
  151023. * The height of the cylinder for the updraft.
  151024. */
  151025. height: number;
  151026. /**
  151027. * The mode for the the updraft.
  151028. */
  151029. updraftMode: PhysicsUpdraftMode;
  151030. }
  151031. /**
  151032. * Options fot the vortex event
  151033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151034. */
  151035. export class PhysicsVortexEventOptions {
  151036. /**
  151037. * The radius of the cylinder for the vortex
  151038. */
  151039. radius: number;
  151040. /**
  151041. * The strenth of the vortex.
  151042. */
  151043. strength: number;
  151044. /**
  151045. * The height of the cylinder for the vortex.
  151046. */
  151047. height: number;
  151048. /**
  151049. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  151050. */
  151051. centripetalForceThreshold: number;
  151052. /**
  151053. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  151054. */
  151055. centripetalForceMultiplier: number;
  151056. /**
  151057. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  151058. */
  151059. centrifugalForceMultiplier: number;
  151060. /**
  151061. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  151062. */
  151063. updraftForceMultiplier: number;
  151064. }
  151065. /**
  151066. * The strenght of the force in correspondence to the distance of the affected object
  151067. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151068. */
  151069. export enum PhysicsRadialImpulseFalloff {
  151070. /** Defines that impulse is constant in strength across it's whole radius */
  151071. Constant = 0,
  151072. /** Defines that impulse gets weaker if it's further from the origin */
  151073. Linear = 1
  151074. }
  151075. /**
  151076. * The strength of the force in correspondence to the distance of the affected object
  151077. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151078. */
  151079. export enum PhysicsUpdraftMode {
  151080. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  151081. Center = 0,
  151082. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  151083. Perpendicular = 1
  151084. }
  151085. /**
  151086. * Interface for a physics hit data
  151087. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151088. */
  151089. export interface PhysicsHitData {
  151090. /**
  151091. * The force applied at the contact point
  151092. */
  151093. force: Vector3;
  151094. /**
  151095. * The contact point
  151096. */
  151097. contactPoint: Vector3;
  151098. /**
  151099. * The distance from the origin to the contact point
  151100. */
  151101. distanceFromOrigin: number;
  151102. }
  151103. /**
  151104. * Interface for radial explosion event data
  151105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151106. */
  151107. export interface PhysicsRadialExplosionEventData {
  151108. /**
  151109. * A sphere used for the radial explosion event
  151110. */
  151111. sphere: Mesh;
  151112. }
  151113. /**
  151114. * Interface for gravitational field event data
  151115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151116. */
  151117. export interface PhysicsGravitationalFieldEventData {
  151118. /**
  151119. * A sphere mesh used for the gravitational field event
  151120. */
  151121. sphere: Mesh;
  151122. }
  151123. /**
  151124. * Interface for updraft event data
  151125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151126. */
  151127. export interface PhysicsUpdraftEventData {
  151128. /**
  151129. * A cylinder used for the updraft event
  151130. */
  151131. cylinder: Mesh;
  151132. }
  151133. /**
  151134. * Interface for vortex event data
  151135. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151136. */
  151137. export interface PhysicsVortexEventData {
  151138. /**
  151139. * A cylinder used for the vortex event
  151140. */
  151141. cylinder: Mesh;
  151142. }
  151143. /**
  151144. * Interface for an affected physics impostor
  151145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  151146. */
  151147. export interface PhysicsAffectedImpostorWithData {
  151148. /**
  151149. * The impostor affected by the effect
  151150. */
  151151. impostor: PhysicsImpostor;
  151152. /**
  151153. * The data about the hit/horce from the explosion
  151154. */
  151155. hitData: PhysicsHitData;
  151156. }
  151157. }
  151158. declare module BABYLON {
  151159. /** @hidden */
  151160. export var blackAndWhitePixelShader: {
  151161. name: string;
  151162. shader: string;
  151163. };
  151164. }
  151165. declare module BABYLON {
  151166. /**
  151167. * Post process used to render in black and white
  151168. */
  151169. export class BlackAndWhitePostProcess extends PostProcess {
  151170. /**
  151171. * Linear about to convert he result to black and white (default: 1)
  151172. */
  151173. degree: number;
  151174. /**
  151175. * Gets a string identifying the name of the class
  151176. * @returns "BlackAndWhitePostProcess" string
  151177. */
  151178. getClassName(): string;
  151179. /**
  151180. * Creates a black and white post process
  151181. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  151182. * @param name The name of the effect.
  151183. * @param options The required width/height ratio to downsize to before computing the render pass.
  151184. * @param camera The camera to apply the render pass to.
  151185. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151186. * @param engine The engine which the post process will be applied. (default: current engine)
  151187. * @param reusable If the post process can be reused on the same frame. (default: false)
  151188. */
  151189. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151190. /** @hidden */
  151191. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  151192. }
  151193. }
  151194. declare module BABYLON {
  151195. /**
  151196. * This represents a set of one or more post processes in Babylon.
  151197. * A post process can be used to apply a shader to a texture after it is rendered.
  151198. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151199. */
  151200. export class PostProcessRenderEffect {
  151201. private _postProcesses;
  151202. private _getPostProcesses;
  151203. private _singleInstance;
  151204. private _cameras;
  151205. private _indicesForCamera;
  151206. /**
  151207. * Name of the effect
  151208. * @hidden
  151209. */
  151210. _name: string;
  151211. /**
  151212. * Instantiates a post process render effect.
  151213. * A post process can be used to apply a shader to a texture after it is rendered.
  151214. * @param engine The engine the effect is tied to
  151215. * @param name The name of the effect
  151216. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  151217. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  151218. */
  151219. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  151220. /**
  151221. * Checks if all the post processes in the effect are supported.
  151222. */
  151223. get isSupported(): boolean;
  151224. /**
  151225. * Updates the current state of the effect
  151226. * @hidden
  151227. */
  151228. _update(): void;
  151229. /**
  151230. * Attaches the effect on cameras
  151231. * @param cameras The camera to attach to.
  151232. * @hidden
  151233. */
  151234. _attachCameras(cameras: Camera): void;
  151235. /**
  151236. * Attaches the effect on cameras
  151237. * @param cameras The camera to attach to.
  151238. * @hidden
  151239. */
  151240. _attachCameras(cameras: Camera[]): void;
  151241. /**
  151242. * Detaches the effect on cameras
  151243. * @param cameras The camera to detatch from.
  151244. * @hidden
  151245. */
  151246. _detachCameras(cameras: Camera): void;
  151247. /**
  151248. * Detatches the effect on cameras
  151249. * @param cameras The camera to detatch from.
  151250. * @hidden
  151251. */
  151252. _detachCameras(cameras: Camera[]): void;
  151253. /**
  151254. * Enables the effect on given cameras
  151255. * @param cameras The camera to enable.
  151256. * @hidden
  151257. */
  151258. _enable(cameras: Camera): void;
  151259. /**
  151260. * Enables the effect on given cameras
  151261. * @param cameras The camera to enable.
  151262. * @hidden
  151263. */
  151264. _enable(cameras: Nullable<Camera[]>): void;
  151265. /**
  151266. * Disables the effect on the given cameras
  151267. * @param cameras The camera to disable.
  151268. * @hidden
  151269. */
  151270. _disable(cameras: Camera): void;
  151271. /**
  151272. * Disables the effect on the given cameras
  151273. * @param cameras The camera to disable.
  151274. * @hidden
  151275. */
  151276. _disable(cameras: Nullable<Camera[]>): void;
  151277. /**
  151278. * Gets a list of the post processes contained in the effect.
  151279. * @param camera The camera to get the post processes on.
  151280. * @returns The list of the post processes in the effect.
  151281. */
  151282. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  151283. }
  151284. }
  151285. declare module BABYLON {
  151286. /** @hidden */
  151287. export var extractHighlightsPixelShader: {
  151288. name: string;
  151289. shader: string;
  151290. };
  151291. }
  151292. declare module BABYLON {
  151293. /**
  151294. * 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.
  151295. */
  151296. export class ExtractHighlightsPostProcess extends PostProcess {
  151297. /**
  151298. * The luminance threshold, pixels below this value will be set to black.
  151299. */
  151300. threshold: number;
  151301. /** @hidden */
  151302. _exposure: number;
  151303. /**
  151304. * Post process which has the input texture to be used when performing highlight extraction
  151305. * @hidden
  151306. */
  151307. _inputPostProcess: Nullable<PostProcess>;
  151308. /**
  151309. * Gets a string identifying the name of the class
  151310. * @returns "ExtractHighlightsPostProcess" string
  151311. */
  151312. getClassName(): string;
  151313. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151314. }
  151315. }
  151316. declare module BABYLON {
  151317. /** @hidden */
  151318. export var bloomMergePixelShader: {
  151319. name: string;
  151320. shader: string;
  151321. };
  151322. }
  151323. declare module BABYLON {
  151324. /**
  151325. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  151326. */
  151327. export class BloomMergePostProcess extends PostProcess {
  151328. /** Weight of the bloom to be added to the original input. */
  151329. weight: number;
  151330. /**
  151331. * Gets a string identifying the name of the class
  151332. * @returns "BloomMergePostProcess" string
  151333. */
  151334. getClassName(): string;
  151335. /**
  151336. * Creates a new instance of @see BloomMergePostProcess
  151337. * @param name The name of the effect.
  151338. * @param originalFromInput Post process which's input will be used for the merge.
  151339. * @param blurred Blurred highlights post process which's output will be used.
  151340. * @param weight Weight of the bloom to be added to the original input.
  151341. * @param options The required width/height ratio to downsize to before computing the render pass.
  151342. * @param camera The camera to apply the render pass to.
  151343. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151344. * @param engine The engine which the post process will be applied. (default: current engine)
  151345. * @param reusable If the post process can be reused on the same frame. (default: false)
  151346. * @param textureType Type of textures used when performing the post process. (default: 0)
  151347. * @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)
  151348. */
  151349. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  151350. /** Weight of the bloom to be added to the original input. */
  151351. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151352. }
  151353. }
  151354. declare module BABYLON {
  151355. /**
  151356. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  151357. */
  151358. export class BloomEffect extends PostProcessRenderEffect {
  151359. private bloomScale;
  151360. /**
  151361. * @hidden Internal
  151362. */
  151363. _effects: Array<PostProcess>;
  151364. /**
  151365. * @hidden Internal
  151366. */
  151367. _downscale: ExtractHighlightsPostProcess;
  151368. private _blurX;
  151369. private _blurY;
  151370. private _merge;
  151371. /**
  151372. * The luminance threshold to find bright areas of the image to bloom.
  151373. */
  151374. get threshold(): number;
  151375. set threshold(value: number);
  151376. /**
  151377. * The strength of the bloom.
  151378. */
  151379. get weight(): number;
  151380. set weight(value: number);
  151381. /**
  151382. * Specifies the size of the bloom blur kernel, relative to the final output size
  151383. */
  151384. get kernel(): number;
  151385. set kernel(value: number);
  151386. /**
  151387. * Creates a new instance of @see BloomEffect
  151388. * @param scene The scene the effect belongs to.
  151389. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  151390. * @param bloomKernel The size of the kernel to be used when applying the blur.
  151391. * @param bloomWeight The the strength of bloom.
  151392. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  151393. * @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)
  151394. */
  151395. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  151396. /**
  151397. * Disposes each of the internal effects for a given camera.
  151398. * @param camera The camera to dispose the effect on.
  151399. */
  151400. disposeEffects(camera: Camera): void;
  151401. /**
  151402. * @hidden Internal
  151403. */
  151404. _updateEffects(): void;
  151405. /**
  151406. * Internal
  151407. * @returns if all the contained post processes are ready.
  151408. * @hidden
  151409. */
  151410. _isReady(): boolean;
  151411. }
  151412. }
  151413. declare module BABYLON {
  151414. /** @hidden */
  151415. export var chromaticAberrationPixelShader: {
  151416. name: string;
  151417. shader: string;
  151418. };
  151419. }
  151420. declare module BABYLON {
  151421. /**
  151422. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  151423. */
  151424. export class ChromaticAberrationPostProcess extends PostProcess {
  151425. /**
  151426. * The amount of seperation of rgb channels (default: 30)
  151427. */
  151428. aberrationAmount: number;
  151429. /**
  151430. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  151431. */
  151432. radialIntensity: number;
  151433. /**
  151434. * 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))
  151435. */
  151436. direction: Vector2;
  151437. /**
  151438. * 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))
  151439. */
  151440. centerPosition: Vector2;
  151441. /** The width of the screen to apply the effect on */
  151442. screenWidth: number;
  151443. /** The height of the screen to apply the effect on */
  151444. screenHeight: number;
  151445. /**
  151446. * Gets a string identifying the name of the class
  151447. * @returns "ChromaticAberrationPostProcess" string
  151448. */
  151449. getClassName(): string;
  151450. /**
  151451. * Creates a new instance ChromaticAberrationPostProcess
  151452. * @param name The name of the effect.
  151453. * @param screenWidth The width of the screen to apply the effect on.
  151454. * @param screenHeight The height of the screen to apply the effect on.
  151455. * @param options The required width/height ratio to downsize to before computing the render pass.
  151456. * @param camera The camera to apply the render pass to.
  151457. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151458. * @param engine The engine which the post process will be applied. (default: current engine)
  151459. * @param reusable If the post process can be reused on the same frame. (default: false)
  151460. * @param textureType Type of textures used when performing the post process. (default: 0)
  151461. * @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)
  151462. */
  151463. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151464. /** @hidden */
  151465. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  151466. }
  151467. }
  151468. declare module BABYLON {
  151469. /** @hidden */
  151470. export var circleOfConfusionPixelShader: {
  151471. name: string;
  151472. shader: string;
  151473. };
  151474. }
  151475. declare module BABYLON {
  151476. /**
  151477. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  151478. */
  151479. export class CircleOfConfusionPostProcess extends PostProcess {
  151480. /**
  151481. * 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.
  151482. */
  151483. lensSize: number;
  151484. /**
  151485. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  151486. */
  151487. fStop: number;
  151488. /**
  151489. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  151490. */
  151491. focusDistance: number;
  151492. /**
  151493. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  151494. */
  151495. focalLength: number;
  151496. /**
  151497. * Gets a string identifying the name of the class
  151498. * @returns "CircleOfConfusionPostProcess" string
  151499. */
  151500. getClassName(): string;
  151501. private _depthTexture;
  151502. /**
  151503. * Creates a new instance CircleOfConfusionPostProcess
  151504. * @param name The name of the effect.
  151505. * @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.
  151506. * @param options The required width/height ratio to downsize to before computing the render pass.
  151507. * @param camera The camera to apply the render pass to.
  151508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151509. * @param engine The engine which the post process will be applied. (default: current engine)
  151510. * @param reusable If the post process can be reused on the same frame. (default: false)
  151511. * @param textureType Type of textures used when performing the post process. (default: 0)
  151512. * @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)
  151513. */
  151514. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151515. /**
  151516. * 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.
  151517. */
  151518. set depthTexture(value: RenderTargetTexture);
  151519. }
  151520. }
  151521. declare module BABYLON {
  151522. /** @hidden */
  151523. export var colorCorrectionPixelShader: {
  151524. name: string;
  151525. shader: string;
  151526. };
  151527. }
  151528. declare module BABYLON {
  151529. /**
  151530. *
  151531. * This post-process allows the modification of rendered colors by using
  151532. * a 'look-up table' (LUT). This effect is also called Color Grading.
  151533. *
  151534. * The object needs to be provided an url to a texture containing the color
  151535. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  151536. * Use an image editing software to tweak the LUT to match your needs.
  151537. *
  151538. * For an example of a color LUT, see here:
  151539. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  151540. * For explanations on color grading, see here:
  151541. * @see http://udn.epicgames.com/Three/ColorGrading.html
  151542. *
  151543. */
  151544. export class ColorCorrectionPostProcess extends PostProcess {
  151545. private _colorTableTexture;
  151546. /**
  151547. * Gets the color table url used to create the LUT texture
  151548. */
  151549. colorTableUrl: string;
  151550. /**
  151551. * Gets a string identifying the name of the class
  151552. * @returns "ColorCorrectionPostProcess" string
  151553. */
  151554. getClassName(): string;
  151555. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151556. /** @hidden */
  151557. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  151558. }
  151559. }
  151560. declare module BABYLON {
  151561. /** @hidden */
  151562. export var convolutionPixelShader: {
  151563. name: string;
  151564. shader: string;
  151565. };
  151566. }
  151567. declare module BABYLON {
  151568. /**
  151569. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  151570. * input texture to perform effects such as edge detection or sharpening
  151571. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  151572. */
  151573. export class ConvolutionPostProcess extends PostProcess {
  151574. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  151575. kernel: number[];
  151576. /**
  151577. * Gets a string identifying the name of the class
  151578. * @returns "ConvolutionPostProcess" string
  151579. */
  151580. getClassName(): string;
  151581. /**
  151582. * Creates a new instance ConvolutionPostProcess
  151583. * @param name The name of the effect.
  151584. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  151585. * @param options The required width/height ratio to downsize to before computing the render pass.
  151586. * @param camera The camera to apply the render pass to.
  151587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151588. * @param engine The engine which the post process will be applied. (default: current engine)
  151589. * @param reusable If the post process can be reused on the same frame. (default: false)
  151590. * @param textureType Type of textures used when performing the post process. (default: 0)
  151591. */
  151592. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151593. /** @hidden */
  151594. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  151595. /**
  151596. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151597. */
  151598. static EdgeDetect0Kernel: number[];
  151599. /**
  151600. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151601. */
  151602. static EdgeDetect1Kernel: number[];
  151603. /**
  151604. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151605. */
  151606. static EdgeDetect2Kernel: number[];
  151607. /**
  151608. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151609. */
  151610. static SharpenKernel: number[];
  151611. /**
  151612. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151613. */
  151614. static EmbossKernel: number[];
  151615. /**
  151616. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  151617. */
  151618. static GaussianKernel: number[];
  151619. }
  151620. }
  151621. declare module BABYLON {
  151622. /**
  151623. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  151624. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  151625. * based on samples that have a large difference in distance than the center pixel.
  151626. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  151627. */
  151628. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  151629. /**
  151630. * The direction the blur should be applied
  151631. */
  151632. direction: Vector2;
  151633. /**
  151634. * Gets a string identifying the name of the class
  151635. * @returns "DepthOfFieldBlurPostProcess" string
  151636. */
  151637. getClassName(): string;
  151638. /**
  151639. * Creates a new instance CircleOfConfusionPostProcess
  151640. * @param name The name of the effect.
  151641. * @param scene The scene the effect belongs to.
  151642. * @param direction The direction the blur should be applied.
  151643. * @param kernel The size of the kernel used to blur.
  151644. * @param options The required width/height ratio to downsize to before computing the render pass.
  151645. * @param camera The camera to apply the render pass to.
  151646. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  151647. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  151648. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151649. * @param engine The engine which the post process will be applied. (default: current engine)
  151650. * @param reusable If the post process can be reused on the same frame. (default: false)
  151651. * @param textureType Type of textures used when performing the post process. (default: 0)
  151652. * @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)
  151653. */
  151654. 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);
  151655. }
  151656. }
  151657. declare module BABYLON {
  151658. /** @hidden */
  151659. export var depthOfFieldMergePixelShader: {
  151660. name: string;
  151661. shader: string;
  151662. };
  151663. }
  151664. declare module BABYLON {
  151665. /**
  151666. * Options to be set when merging outputs from the default pipeline.
  151667. */
  151668. export class DepthOfFieldMergePostProcessOptions {
  151669. /**
  151670. * The original image to merge on top of
  151671. */
  151672. originalFromInput: PostProcess;
  151673. /**
  151674. * Parameters to perform the merge of the depth of field effect
  151675. */
  151676. depthOfField?: {
  151677. circleOfConfusion: PostProcess;
  151678. blurSteps: Array<PostProcess>;
  151679. };
  151680. /**
  151681. * Parameters to perform the merge of bloom effect
  151682. */
  151683. bloom?: {
  151684. blurred: PostProcess;
  151685. weight: number;
  151686. };
  151687. }
  151688. /**
  151689. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  151690. */
  151691. export class DepthOfFieldMergePostProcess extends PostProcess {
  151692. private blurSteps;
  151693. /**
  151694. * Gets a string identifying the name of the class
  151695. * @returns "DepthOfFieldMergePostProcess" string
  151696. */
  151697. getClassName(): string;
  151698. /**
  151699. * Creates a new instance of DepthOfFieldMergePostProcess
  151700. * @param name The name of the effect.
  151701. * @param originalFromInput Post process which's input will be used for the merge.
  151702. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  151703. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  151704. * @param options The required width/height ratio to downsize to before computing the render pass.
  151705. * @param camera The camera to apply the render pass to.
  151706. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151707. * @param engine The engine which the post process will be applied. (default: current engine)
  151708. * @param reusable If the post process can be reused on the same frame. (default: false)
  151709. * @param textureType Type of textures used when performing the post process. (default: 0)
  151710. * @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)
  151711. */
  151712. 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);
  151713. /**
  151714. * Updates the effect with the current post process compile time values and recompiles the shader.
  151715. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  151716. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  151717. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  151718. * @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
  151719. * @param onCompiled Called when the shader has been compiled.
  151720. * @param onError Called if there is an error when compiling a shader.
  151721. */
  151722. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  151723. }
  151724. }
  151725. declare module BABYLON {
  151726. /**
  151727. * Specifies the level of max blur that should be applied when using the depth of field effect
  151728. */
  151729. export enum DepthOfFieldEffectBlurLevel {
  151730. /**
  151731. * Subtle blur
  151732. */
  151733. Low = 0,
  151734. /**
  151735. * Medium blur
  151736. */
  151737. Medium = 1,
  151738. /**
  151739. * Large blur
  151740. */
  151741. High = 2
  151742. }
  151743. /**
  151744. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  151745. */
  151746. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  151747. private _circleOfConfusion;
  151748. /**
  151749. * @hidden Internal, blurs from high to low
  151750. */
  151751. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  151752. private _depthOfFieldBlurY;
  151753. private _dofMerge;
  151754. /**
  151755. * @hidden Internal post processes in depth of field effect
  151756. */
  151757. _effects: Array<PostProcess>;
  151758. /**
  151759. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  151760. */
  151761. set focalLength(value: number);
  151762. get focalLength(): number;
  151763. /**
  151764. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  151765. */
  151766. set fStop(value: number);
  151767. get fStop(): number;
  151768. /**
  151769. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  151770. */
  151771. set focusDistance(value: number);
  151772. get focusDistance(): number;
  151773. /**
  151774. * 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.
  151775. */
  151776. set lensSize(value: number);
  151777. get lensSize(): number;
  151778. /**
  151779. * Creates a new instance DepthOfFieldEffect
  151780. * @param scene The scene the effect belongs to.
  151781. * @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.
  151782. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  151783. * @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)
  151784. */
  151785. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  151786. /**
  151787. * Get the current class name of the current effet
  151788. * @returns "DepthOfFieldEffect"
  151789. */
  151790. getClassName(): string;
  151791. /**
  151792. * 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.
  151793. */
  151794. set depthTexture(value: RenderTargetTexture);
  151795. /**
  151796. * Disposes each of the internal effects for a given camera.
  151797. * @param camera The camera to dispose the effect on.
  151798. */
  151799. disposeEffects(camera: Camera): void;
  151800. /**
  151801. * @hidden Internal
  151802. */
  151803. _updateEffects(): void;
  151804. /**
  151805. * Internal
  151806. * @returns if all the contained post processes are ready.
  151807. * @hidden
  151808. */
  151809. _isReady(): boolean;
  151810. }
  151811. }
  151812. declare module BABYLON {
  151813. /** @hidden */
  151814. export var displayPassPixelShader: {
  151815. name: string;
  151816. shader: string;
  151817. };
  151818. }
  151819. declare module BABYLON {
  151820. /**
  151821. * DisplayPassPostProcess which produces an output the same as it's input
  151822. */
  151823. export class DisplayPassPostProcess extends PostProcess {
  151824. /**
  151825. * Gets a string identifying the name of the class
  151826. * @returns "DisplayPassPostProcess" string
  151827. */
  151828. getClassName(): string;
  151829. /**
  151830. * Creates the DisplayPassPostProcess
  151831. * @param name The name of the effect.
  151832. * @param options The required width/height ratio to downsize to before computing the render pass.
  151833. * @param camera The camera to apply the render pass to.
  151834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151835. * @param engine The engine which the post process will be applied. (default: current engine)
  151836. * @param reusable If the post process can be reused on the same frame. (default: false)
  151837. */
  151838. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151839. /** @hidden */
  151840. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  151841. }
  151842. }
  151843. declare module BABYLON {
  151844. /** @hidden */
  151845. export var filterPixelShader: {
  151846. name: string;
  151847. shader: string;
  151848. };
  151849. }
  151850. declare module BABYLON {
  151851. /**
  151852. * Applies a kernel filter to the image
  151853. */
  151854. export class FilterPostProcess extends PostProcess {
  151855. /** The matrix to be applied to the image */
  151856. kernelMatrix: Matrix;
  151857. /**
  151858. * Gets a string identifying the name of the class
  151859. * @returns "FilterPostProcess" string
  151860. */
  151861. getClassName(): string;
  151862. /**
  151863. *
  151864. * @param name The name of the effect.
  151865. * @param kernelMatrix The matrix to be applied to the image
  151866. * @param options The required width/height ratio to downsize to before computing the render pass.
  151867. * @param camera The camera to apply the render pass to.
  151868. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151869. * @param engine The engine which the post process will be applied. (default: current engine)
  151870. * @param reusable If the post process can be reused on the same frame. (default: false)
  151871. */
  151872. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151873. /** @hidden */
  151874. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  151875. }
  151876. }
  151877. declare module BABYLON {
  151878. /** @hidden */
  151879. export var fxaaPixelShader: {
  151880. name: string;
  151881. shader: string;
  151882. };
  151883. }
  151884. declare module BABYLON {
  151885. /** @hidden */
  151886. export var fxaaVertexShader: {
  151887. name: string;
  151888. shader: string;
  151889. };
  151890. }
  151891. declare module BABYLON {
  151892. /**
  151893. * Fxaa post process
  151894. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  151895. */
  151896. export class FxaaPostProcess extends PostProcess {
  151897. /**
  151898. * Gets a string identifying the name of the class
  151899. * @returns "FxaaPostProcess" string
  151900. */
  151901. getClassName(): string;
  151902. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151903. private _getDefines;
  151904. /** @hidden */
  151905. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  151906. }
  151907. }
  151908. declare module BABYLON {
  151909. /** @hidden */
  151910. export var grainPixelShader: {
  151911. name: string;
  151912. shader: string;
  151913. };
  151914. }
  151915. declare module BABYLON {
  151916. /**
  151917. * The GrainPostProcess adds noise to the image at mid luminance levels
  151918. */
  151919. export class GrainPostProcess extends PostProcess {
  151920. /**
  151921. * The intensity of the grain added (default: 30)
  151922. */
  151923. intensity: number;
  151924. /**
  151925. * If the grain should be randomized on every frame
  151926. */
  151927. animated: boolean;
  151928. /**
  151929. * Gets a string identifying the name of the class
  151930. * @returns "GrainPostProcess" string
  151931. */
  151932. getClassName(): string;
  151933. /**
  151934. * Creates a new instance of @see GrainPostProcess
  151935. * @param name The name of the effect.
  151936. * @param options The required width/height ratio to downsize to before computing the render pass.
  151937. * @param camera The camera to apply the render pass to.
  151938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151939. * @param engine The engine which the post process will be applied. (default: current engine)
  151940. * @param reusable If the post process can be reused on the same frame. (default: false)
  151941. * @param textureType Type of textures used when performing the post process. (default: 0)
  151942. * @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)
  151943. */
  151944. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151945. /** @hidden */
  151946. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  151947. }
  151948. }
  151949. declare module BABYLON {
  151950. /** @hidden */
  151951. export var highlightsPixelShader: {
  151952. name: string;
  151953. shader: string;
  151954. };
  151955. }
  151956. declare module BABYLON {
  151957. /**
  151958. * Extracts highlights from the image
  151959. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151960. */
  151961. export class HighlightsPostProcess extends PostProcess {
  151962. /**
  151963. * Gets a string identifying the name of the class
  151964. * @returns "HighlightsPostProcess" string
  151965. */
  151966. getClassName(): string;
  151967. /**
  151968. * Extracts highlights from the image
  151969. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  151970. * @param name The name of the effect.
  151971. * @param options The required width/height ratio to downsize to before computing the render pass.
  151972. * @param camera The camera to apply the render pass to.
  151973. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151974. * @param engine The engine which the post process will be applied. (default: current engine)
  151975. * @param reusable If the post process can be reused on the same frame. (default: false)
  151976. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  151977. */
  151978. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  151979. }
  151980. }
  151981. declare module BABYLON {
  151982. /**
  151983. * Contains all parameters needed for the prepass to perform
  151984. * motion blur
  151985. */
  151986. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  151987. /**
  151988. * Is motion blur enabled
  151989. */
  151990. enabled: boolean;
  151991. /**
  151992. * Name of the configuration
  151993. */
  151994. name: string;
  151995. /**
  151996. * Textures that should be present in the MRT for this effect to work
  151997. */
  151998. readonly texturesRequired: number[];
  151999. }
  152000. }
  152001. declare module BABYLON {
  152002. interface Scene {
  152003. /** @hidden (Backing field) */
  152004. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152005. /**
  152006. * Gets or Sets the current geometry buffer associated to the scene.
  152007. */
  152008. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  152009. /**
  152010. * Enables a GeometryBufferRender and associates it with the scene
  152011. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  152012. * @returns the GeometryBufferRenderer
  152013. */
  152014. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  152015. /**
  152016. * Disables the GeometryBufferRender associated with the scene
  152017. */
  152018. disableGeometryBufferRenderer(): void;
  152019. }
  152020. /**
  152021. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152022. * in several rendering techniques.
  152023. */
  152024. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  152025. /**
  152026. * The component name helpful to identify the component in the list of scene components.
  152027. */
  152028. readonly name: string;
  152029. /**
  152030. * The scene the component belongs to.
  152031. */
  152032. scene: Scene;
  152033. /**
  152034. * Creates a new instance of the component for the given scene
  152035. * @param scene Defines the scene to register the component in
  152036. */
  152037. constructor(scene: Scene);
  152038. /**
  152039. * Registers the component in a given scene
  152040. */
  152041. register(): void;
  152042. /**
  152043. * Rebuilds the elements related to this component in case of
  152044. * context lost for instance.
  152045. */
  152046. rebuild(): void;
  152047. /**
  152048. * Disposes the component and the associated ressources
  152049. */
  152050. dispose(): void;
  152051. private _gatherRenderTargets;
  152052. }
  152053. }
  152054. declare module BABYLON {
  152055. /** @hidden */
  152056. export var motionBlurPixelShader: {
  152057. name: string;
  152058. shader: string;
  152059. };
  152060. }
  152061. declare module BABYLON {
  152062. /**
  152063. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  152064. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  152065. * As an example, all you have to do is to create the post-process:
  152066. * var mb = new BABYLON.MotionBlurPostProcess(
  152067. * 'mb', // The name of the effect.
  152068. * scene, // The scene containing the objects to blur according to their velocity.
  152069. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  152070. * camera // The camera to apply the render pass to.
  152071. * );
  152072. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  152073. */
  152074. export class MotionBlurPostProcess extends PostProcess {
  152075. /**
  152076. * Defines how much the image is blurred by the movement. Default value is equal to 1
  152077. */
  152078. motionStrength: number;
  152079. /**
  152080. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  152081. */
  152082. get motionBlurSamples(): number;
  152083. /**
  152084. * Sets the number of iterations to be used for motion blur quality
  152085. */
  152086. set motionBlurSamples(samples: number);
  152087. private _motionBlurSamples;
  152088. private _forceGeometryBuffer;
  152089. private _geometryBufferRenderer;
  152090. private _prePassRenderer;
  152091. /**
  152092. * Gets a string identifying the name of the class
  152093. * @returns "MotionBlurPostProcess" string
  152094. */
  152095. getClassName(): string;
  152096. /**
  152097. * Creates a new instance MotionBlurPostProcess
  152098. * @param name The name of the effect.
  152099. * @param scene The scene containing the objects to blur according to their velocity.
  152100. * @param options The required width/height ratio to downsize to before computing the render pass.
  152101. * @param camera The camera to apply the render pass to.
  152102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152103. * @param engine The engine which the post process will be applied. (default: current engine)
  152104. * @param reusable If the post process can be reused on the same frame. (default: false)
  152105. * @param textureType Type of textures used when performing the post process. (default: 0)
  152106. * @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)
  152107. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  152108. */
  152109. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  152110. /**
  152111. * Excludes the given skinned mesh from computing bones velocities.
  152112. * 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.
  152113. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  152114. */
  152115. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  152116. /**
  152117. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  152118. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  152119. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  152120. */
  152121. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  152122. /**
  152123. * Disposes the post process.
  152124. * @param camera The camera to dispose the post process on.
  152125. */
  152126. dispose(camera?: Camera): void;
  152127. /** @hidden */
  152128. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  152129. }
  152130. }
  152131. declare module BABYLON {
  152132. /** @hidden */
  152133. export var refractionPixelShader: {
  152134. name: string;
  152135. shader: string;
  152136. };
  152137. }
  152138. declare module BABYLON {
  152139. /**
  152140. * Post process which applies a refractin texture
  152141. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  152142. */
  152143. export class RefractionPostProcess extends PostProcess {
  152144. private _refTexture;
  152145. private _ownRefractionTexture;
  152146. /** the base color of the refraction (used to taint the rendering) */
  152147. color: Color3;
  152148. /** simulated refraction depth */
  152149. depth: number;
  152150. /** the coefficient of the base color (0 to remove base color tainting) */
  152151. colorLevel: number;
  152152. /** Gets the url used to load the refraction texture */
  152153. refractionTextureUrl: string;
  152154. /**
  152155. * Gets or sets the refraction texture
  152156. * Please note that you are responsible for disposing the texture if you set it manually
  152157. */
  152158. get refractionTexture(): Texture;
  152159. set refractionTexture(value: Texture);
  152160. /**
  152161. * Gets a string identifying the name of the class
  152162. * @returns "RefractionPostProcess" string
  152163. */
  152164. getClassName(): string;
  152165. /**
  152166. * Initializes the RefractionPostProcess
  152167. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  152168. * @param name The name of the effect.
  152169. * @param refractionTextureUrl Url of the refraction texture to use
  152170. * @param color the base color of the refraction (used to taint the rendering)
  152171. * @param depth simulated refraction depth
  152172. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  152173. * @param camera The camera to apply the render pass to.
  152174. * @param options The required width/height ratio to downsize to before computing the render pass.
  152175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152176. * @param engine The engine which the post process will be applied. (default: current engine)
  152177. * @param reusable If the post process can be reused on the same frame. (default: false)
  152178. */
  152179. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152180. /**
  152181. * Disposes of the post process
  152182. * @param camera Camera to dispose post process on
  152183. */
  152184. dispose(camera: Camera): void;
  152185. /** @hidden */
  152186. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  152187. }
  152188. }
  152189. declare module BABYLON {
  152190. /** @hidden */
  152191. export var sharpenPixelShader: {
  152192. name: string;
  152193. shader: string;
  152194. };
  152195. }
  152196. declare module BABYLON {
  152197. /**
  152198. * The SharpenPostProcess applies a sharpen kernel to every pixel
  152199. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  152200. */
  152201. export class SharpenPostProcess extends PostProcess {
  152202. /**
  152203. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  152204. */
  152205. colorAmount: number;
  152206. /**
  152207. * How much sharpness should be applied (default: 0.3)
  152208. */
  152209. edgeAmount: number;
  152210. /**
  152211. * Gets a string identifying the name of the class
  152212. * @returns "SharpenPostProcess" string
  152213. */
  152214. getClassName(): string;
  152215. /**
  152216. * Creates a new instance ConvolutionPostProcess
  152217. * @param name The name of the effect.
  152218. * @param options The required width/height ratio to downsize to before computing the render pass.
  152219. * @param camera The camera to apply the render pass to.
  152220. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152221. * @param engine The engine which the post process will be applied. (default: current engine)
  152222. * @param reusable If the post process can be reused on the same frame. (default: false)
  152223. * @param textureType Type of textures used when performing the post process. (default: 0)
  152224. * @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)
  152225. */
  152226. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152227. /** @hidden */
  152228. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  152229. }
  152230. }
  152231. declare module BABYLON {
  152232. /**
  152233. * PostProcessRenderPipeline
  152234. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152235. */
  152236. export class PostProcessRenderPipeline {
  152237. private engine;
  152238. private _renderEffects;
  152239. private _renderEffectsForIsolatedPass;
  152240. /**
  152241. * List of inspectable custom properties (used by the Inspector)
  152242. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  152243. */
  152244. inspectableCustomProperties: IInspectable[];
  152245. /**
  152246. * @hidden
  152247. */
  152248. protected _cameras: Camera[];
  152249. /** @hidden */
  152250. _name: string;
  152251. /**
  152252. * Gets pipeline name
  152253. */
  152254. get name(): string;
  152255. /** Gets the list of attached cameras */
  152256. get cameras(): Camera[];
  152257. /**
  152258. * Initializes a PostProcessRenderPipeline
  152259. * @param engine engine to add the pipeline to
  152260. * @param name name of the pipeline
  152261. */
  152262. constructor(engine: Engine, name: string);
  152263. /**
  152264. * Gets the class name
  152265. * @returns "PostProcessRenderPipeline"
  152266. */
  152267. getClassName(): string;
  152268. /**
  152269. * If all the render effects in the pipeline are supported
  152270. */
  152271. get isSupported(): boolean;
  152272. /**
  152273. * Adds an effect to the pipeline
  152274. * @param renderEffect the effect to add
  152275. */
  152276. addEffect(renderEffect: PostProcessRenderEffect): void;
  152277. /** @hidden */
  152278. _rebuild(): void;
  152279. /** @hidden */
  152280. _enableEffect(renderEffectName: string, cameras: Camera): void;
  152281. /** @hidden */
  152282. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  152283. /** @hidden */
  152284. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  152285. /** @hidden */
  152286. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  152287. /** @hidden */
  152288. _attachCameras(cameras: Camera, unique: boolean): void;
  152289. /** @hidden */
  152290. _attachCameras(cameras: Camera[], unique: boolean): void;
  152291. /** @hidden */
  152292. _detachCameras(cameras: Camera): void;
  152293. /** @hidden */
  152294. _detachCameras(cameras: Nullable<Camera[]>): void;
  152295. /** @hidden */
  152296. _update(): void;
  152297. /** @hidden */
  152298. _reset(): void;
  152299. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  152300. /**
  152301. * Sets the required values to the prepass renderer.
  152302. * @param prePassRenderer defines the prepass renderer to setup.
  152303. * @returns true if the pre pass is needed.
  152304. */
  152305. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  152306. /**
  152307. * Disposes of the pipeline
  152308. */
  152309. dispose(): void;
  152310. }
  152311. }
  152312. declare module BABYLON {
  152313. /**
  152314. * PostProcessRenderPipelineManager class
  152315. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152316. */
  152317. export class PostProcessRenderPipelineManager {
  152318. private _renderPipelines;
  152319. /**
  152320. * Initializes a PostProcessRenderPipelineManager
  152321. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152322. */
  152323. constructor();
  152324. /**
  152325. * Gets the list of supported render pipelines
  152326. */
  152327. get supportedPipelines(): PostProcessRenderPipeline[];
  152328. /**
  152329. * Adds a pipeline to the manager
  152330. * @param renderPipeline The pipeline to add
  152331. */
  152332. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  152333. /**
  152334. * Attaches a camera to the pipeline
  152335. * @param renderPipelineName The name of the pipeline to attach to
  152336. * @param cameras the camera to attach
  152337. * @param unique if the camera can be attached multiple times to the pipeline
  152338. */
  152339. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  152340. /**
  152341. * Detaches a camera from the pipeline
  152342. * @param renderPipelineName The name of the pipeline to detach from
  152343. * @param cameras the camera to detach
  152344. */
  152345. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  152346. /**
  152347. * Enables an effect by name on a pipeline
  152348. * @param renderPipelineName the name of the pipeline to enable the effect in
  152349. * @param renderEffectName the name of the effect to enable
  152350. * @param cameras the cameras that the effect should be enabled on
  152351. */
  152352. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  152353. /**
  152354. * Disables an effect by name on a pipeline
  152355. * @param renderPipelineName the name of the pipeline to disable the effect in
  152356. * @param renderEffectName the name of the effect to disable
  152357. * @param cameras the cameras that the effect should be disabled on
  152358. */
  152359. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  152360. /**
  152361. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  152362. */
  152363. update(): void;
  152364. /** @hidden */
  152365. _rebuild(): void;
  152366. /**
  152367. * Disposes of the manager and pipelines
  152368. */
  152369. dispose(): void;
  152370. }
  152371. }
  152372. declare module BABYLON {
  152373. interface Scene {
  152374. /** @hidden (Backing field) */
  152375. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  152376. /**
  152377. * Gets the postprocess render pipeline manager
  152378. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  152379. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  152380. */
  152381. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  152382. }
  152383. /**
  152384. * Defines the Render Pipeline scene component responsible to rendering pipelines
  152385. */
  152386. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  152387. /**
  152388. * The component name helpfull to identify the component in the list of scene components.
  152389. */
  152390. readonly name: string;
  152391. /**
  152392. * The scene the component belongs to.
  152393. */
  152394. scene: Scene;
  152395. /**
  152396. * Creates a new instance of the component for the given scene
  152397. * @param scene Defines the scene to register the component in
  152398. */
  152399. constructor(scene: Scene);
  152400. /**
  152401. * Registers the component in a given scene
  152402. */
  152403. register(): void;
  152404. /**
  152405. * Rebuilds the elements related to this component in case of
  152406. * context lost for instance.
  152407. */
  152408. rebuild(): void;
  152409. /**
  152410. * Disposes the component and the associated ressources
  152411. */
  152412. dispose(): void;
  152413. private _gatherRenderTargets;
  152414. }
  152415. }
  152416. declare module BABYLON {
  152417. /**
  152418. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  152419. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  152420. */
  152421. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152422. private _scene;
  152423. private _camerasToBeAttached;
  152424. /**
  152425. * ID of the sharpen post process,
  152426. */
  152427. private readonly SharpenPostProcessId;
  152428. /**
  152429. * @ignore
  152430. * ID of the image processing post process;
  152431. */
  152432. readonly ImageProcessingPostProcessId: string;
  152433. /**
  152434. * @ignore
  152435. * ID of the Fast Approximate Anti-Aliasing post process;
  152436. */
  152437. readonly FxaaPostProcessId: string;
  152438. /**
  152439. * ID of the chromatic aberration post process,
  152440. */
  152441. private readonly ChromaticAberrationPostProcessId;
  152442. /**
  152443. * ID of the grain post process
  152444. */
  152445. private readonly GrainPostProcessId;
  152446. /**
  152447. * Sharpen post process which will apply a sharpen convolution to enhance edges
  152448. */
  152449. sharpen: SharpenPostProcess;
  152450. private _sharpenEffect;
  152451. private bloom;
  152452. /**
  152453. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  152454. */
  152455. depthOfField: DepthOfFieldEffect;
  152456. /**
  152457. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152458. */
  152459. fxaa: FxaaPostProcess;
  152460. /**
  152461. * Image post processing pass used to perform operations such as tone mapping or color grading.
  152462. */
  152463. imageProcessing: ImageProcessingPostProcess;
  152464. /**
  152465. * Chromatic aberration post process which will shift rgb colors in the image
  152466. */
  152467. chromaticAberration: ChromaticAberrationPostProcess;
  152468. private _chromaticAberrationEffect;
  152469. /**
  152470. * Grain post process which add noise to the image
  152471. */
  152472. grain: GrainPostProcess;
  152473. private _grainEffect;
  152474. /**
  152475. * Glow post process which adds a glow to emissive areas of the image
  152476. */
  152477. private _glowLayer;
  152478. /**
  152479. * Animations which can be used to tweak settings over a period of time
  152480. */
  152481. animations: Animation[];
  152482. private _imageProcessingConfigurationObserver;
  152483. private _sharpenEnabled;
  152484. private _bloomEnabled;
  152485. private _depthOfFieldEnabled;
  152486. private _depthOfFieldBlurLevel;
  152487. private _fxaaEnabled;
  152488. private _imageProcessingEnabled;
  152489. private _defaultPipelineTextureType;
  152490. private _bloomScale;
  152491. private _chromaticAberrationEnabled;
  152492. private _grainEnabled;
  152493. private _buildAllowed;
  152494. /**
  152495. * Gets active scene
  152496. */
  152497. get scene(): Scene;
  152498. /**
  152499. * Enable or disable the sharpen process from the pipeline
  152500. */
  152501. set sharpenEnabled(enabled: boolean);
  152502. get sharpenEnabled(): boolean;
  152503. private _resizeObserver;
  152504. private _hardwareScaleLevel;
  152505. private _bloomKernel;
  152506. /**
  152507. * Specifies the size of the bloom blur kernel, relative to the final output size
  152508. */
  152509. get bloomKernel(): number;
  152510. set bloomKernel(value: number);
  152511. /**
  152512. * Specifies the weight of the bloom in the final rendering
  152513. */
  152514. private _bloomWeight;
  152515. /**
  152516. * Specifies the luma threshold for the area that will be blurred by the bloom
  152517. */
  152518. private _bloomThreshold;
  152519. private _hdr;
  152520. /**
  152521. * The strength of the bloom.
  152522. */
  152523. set bloomWeight(value: number);
  152524. get bloomWeight(): number;
  152525. /**
  152526. * The strength of the bloom.
  152527. */
  152528. set bloomThreshold(value: number);
  152529. get bloomThreshold(): number;
  152530. /**
  152531. * The scale of the bloom, lower value will provide better performance.
  152532. */
  152533. set bloomScale(value: number);
  152534. get bloomScale(): number;
  152535. /**
  152536. * Enable or disable the bloom from the pipeline
  152537. */
  152538. set bloomEnabled(enabled: boolean);
  152539. get bloomEnabled(): boolean;
  152540. private _rebuildBloom;
  152541. /**
  152542. * If the depth of field is enabled.
  152543. */
  152544. get depthOfFieldEnabled(): boolean;
  152545. set depthOfFieldEnabled(enabled: boolean);
  152546. /**
  152547. * Blur level of the depth of field effect. (Higher blur will effect performance)
  152548. */
  152549. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  152550. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  152551. /**
  152552. * If the anti aliasing is enabled.
  152553. */
  152554. set fxaaEnabled(enabled: boolean);
  152555. get fxaaEnabled(): boolean;
  152556. private _samples;
  152557. /**
  152558. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152559. */
  152560. set samples(sampleCount: number);
  152561. get samples(): number;
  152562. /**
  152563. * If image processing is enabled.
  152564. */
  152565. set imageProcessingEnabled(enabled: boolean);
  152566. get imageProcessingEnabled(): boolean;
  152567. /**
  152568. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  152569. */
  152570. set glowLayerEnabled(enabled: boolean);
  152571. get glowLayerEnabled(): boolean;
  152572. /**
  152573. * Gets the glow layer (or null if not defined)
  152574. */
  152575. get glowLayer(): Nullable<GlowLayer>;
  152576. /**
  152577. * Enable or disable the chromaticAberration process from the pipeline
  152578. */
  152579. set chromaticAberrationEnabled(enabled: boolean);
  152580. get chromaticAberrationEnabled(): boolean;
  152581. /**
  152582. * Enable or disable the grain process from the pipeline
  152583. */
  152584. set grainEnabled(enabled: boolean);
  152585. get grainEnabled(): boolean;
  152586. /**
  152587. * @constructor
  152588. * @param name - The rendering pipeline name (default: "")
  152589. * @param hdr - If high dynamic range textures should be used (default: true)
  152590. * @param scene - The scene linked to this pipeline (default: the last created scene)
  152591. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  152592. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  152593. */
  152594. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  152595. /**
  152596. * Get the class name
  152597. * @returns "DefaultRenderingPipeline"
  152598. */
  152599. getClassName(): string;
  152600. /**
  152601. * Force the compilation of the entire pipeline.
  152602. */
  152603. prepare(): void;
  152604. private _hasCleared;
  152605. private _prevPostProcess;
  152606. private _prevPrevPostProcess;
  152607. private _setAutoClearAndTextureSharing;
  152608. private _depthOfFieldSceneObserver;
  152609. private _buildPipeline;
  152610. private _disposePostProcesses;
  152611. /**
  152612. * Adds a camera to the pipeline
  152613. * @param camera the camera to be added
  152614. */
  152615. addCamera(camera: Camera): void;
  152616. /**
  152617. * Removes a camera from the pipeline
  152618. * @param camera the camera to remove
  152619. */
  152620. removeCamera(camera: Camera): void;
  152621. /**
  152622. * Dispose of the pipeline and stop all post processes
  152623. */
  152624. dispose(): void;
  152625. /**
  152626. * Serialize the rendering pipeline (Used when exporting)
  152627. * @returns the serialized object
  152628. */
  152629. serialize(): any;
  152630. /**
  152631. * Parse the serialized pipeline
  152632. * @param source Source pipeline.
  152633. * @param scene The scene to load the pipeline to.
  152634. * @param rootUrl The URL of the serialized pipeline.
  152635. * @returns An instantiated pipeline from the serialized object.
  152636. */
  152637. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  152638. }
  152639. }
  152640. declare module BABYLON {
  152641. /** @hidden */
  152642. export var lensHighlightsPixelShader: {
  152643. name: string;
  152644. shader: string;
  152645. };
  152646. }
  152647. declare module BABYLON {
  152648. /** @hidden */
  152649. export var depthOfFieldPixelShader: {
  152650. name: string;
  152651. shader: string;
  152652. };
  152653. }
  152654. declare module BABYLON {
  152655. /**
  152656. * BABYLON.JS Chromatic Aberration GLSL Shader
  152657. * Author: Olivier Guyot
  152658. * Separates very slightly R, G and B colors on the edges of the screen
  152659. * Inspired by Francois Tarlier & Martins Upitis
  152660. */
  152661. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  152662. /**
  152663. * @ignore
  152664. * The chromatic aberration PostProcess id in the pipeline
  152665. */
  152666. LensChromaticAberrationEffect: string;
  152667. /**
  152668. * @ignore
  152669. * The highlights enhancing PostProcess id in the pipeline
  152670. */
  152671. HighlightsEnhancingEffect: string;
  152672. /**
  152673. * @ignore
  152674. * The depth-of-field PostProcess id in the pipeline
  152675. */
  152676. LensDepthOfFieldEffect: string;
  152677. private _scene;
  152678. private _depthTexture;
  152679. private _grainTexture;
  152680. private _chromaticAberrationPostProcess;
  152681. private _highlightsPostProcess;
  152682. private _depthOfFieldPostProcess;
  152683. private _edgeBlur;
  152684. private _grainAmount;
  152685. private _chromaticAberration;
  152686. private _distortion;
  152687. private _highlightsGain;
  152688. private _highlightsThreshold;
  152689. private _dofDistance;
  152690. private _dofAperture;
  152691. private _dofDarken;
  152692. private _dofPentagon;
  152693. private _blurNoise;
  152694. /**
  152695. * @constructor
  152696. *
  152697. * Effect parameters are as follow:
  152698. * {
  152699. * chromatic_aberration: number; // from 0 to x (1 for realism)
  152700. * edge_blur: number; // from 0 to x (1 for realism)
  152701. * distortion: number; // from 0 to x (1 for realism)
  152702. * grain_amount: number; // from 0 to 1
  152703. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  152704. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  152705. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  152706. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  152707. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  152708. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  152709. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  152710. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  152711. * }
  152712. * Note: if an effect parameter is unset, effect is disabled
  152713. *
  152714. * @param name The rendering pipeline name
  152715. * @param parameters - An object containing all parameters (see above)
  152716. * @param scene The scene linked to this pipeline
  152717. * @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)
  152718. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152719. */
  152720. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  152721. /**
  152722. * Get the class name
  152723. * @returns "LensRenderingPipeline"
  152724. */
  152725. getClassName(): string;
  152726. /**
  152727. * Gets associated scene
  152728. */
  152729. get scene(): Scene;
  152730. /**
  152731. * Gets or sets the edge blur
  152732. */
  152733. get edgeBlur(): number;
  152734. set edgeBlur(value: number);
  152735. /**
  152736. * Gets or sets the grain amount
  152737. */
  152738. get grainAmount(): number;
  152739. set grainAmount(value: number);
  152740. /**
  152741. * Gets or sets the chromatic aberration amount
  152742. */
  152743. get chromaticAberration(): number;
  152744. set chromaticAberration(value: number);
  152745. /**
  152746. * Gets or sets the depth of field aperture
  152747. */
  152748. get dofAperture(): number;
  152749. set dofAperture(value: number);
  152750. /**
  152751. * Gets or sets the edge distortion
  152752. */
  152753. get edgeDistortion(): number;
  152754. set edgeDistortion(value: number);
  152755. /**
  152756. * Gets or sets the depth of field distortion
  152757. */
  152758. get dofDistortion(): number;
  152759. set dofDistortion(value: number);
  152760. /**
  152761. * Gets or sets the darken out of focus amount
  152762. */
  152763. get darkenOutOfFocus(): number;
  152764. set darkenOutOfFocus(value: number);
  152765. /**
  152766. * Gets or sets a boolean indicating if blur noise is enabled
  152767. */
  152768. get blurNoise(): boolean;
  152769. set blurNoise(value: boolean);
  152770. /**
  152771. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  152772. */
  152773. get pentagonBokeh(): boolean;
  152774. set pentagonBokeh(value: boolean);
  152775. /**
  152776. * Gets or sets the highlight grain amount
  152777. */
  152778. get highlightsGain(): number;
  152779. set highlightsGain(value: number);
  152780. /**
  152781. * Gets or sets the highlight threshold
  152782. */
  152783. get highlightsThreshold(): number;
  152784. set highlightsThreshold(value: number);
  152785. /**
  152786. * Sets the amount of blur at the edges
  152787. * @param amount blur amount
  152788. */
  152789. setEdgeBlur(amount: number): void;
  152790. /**
  152791. * Sets edge blur to 0
  152792. */
  152793. disableEdgeBlur(): void;
  152794. /**
  152795. * Sets the amout of grain
  152796. * @param amount Amount of grain
  152797. */
  152798. setGrainAmount(amount: number): void;
  152799. /**
  152800. * Set grain amount to 0
  152801. */
  152802. disableGrain(): void;
  152803. /**
  152804. * Sets the chromatic aberration amount
  152805. * @param amount amount of chromatic aberration
  152806. */
  152807. setChromaticAberration(amount: number): void;
  152808. /**
  152809. * Sets chromatic aberration amount to 0
  152810. */
  152811. disableChromaticAberration(): void;
  152812. /**
  152813. * Sets the EdgeDistortion amount
  152814. * @param amount amount of EdgeDistortion
  152815. */
  152816. setEdgeDistortion(amount: number): void;
  152817. /**
  152818. * Sets edge distortion to 0
  152819. */
  152820. disableEdgeDistortion(): void;
  152821. /**
  152822. * Sets the FocusDistance amount
  152823. * @param amount amount of FocusDistance
  152824. */
  152825. setFocusDistance(amount: number): void;
  152826. /**
  152827. * Disables depth of field
  152828. */
  152829. disableDepthOfField(): void;
  152830. /**
  152831. * Sets the Aperture amount
  152832. * @param amount amount of Aperture
  152833. */
  152834. setAperture(amount: number): void;
  152835. /**
  152836. * Sets the DarkenOutOfFocus amount
  152837. * @param amount amount of DarkenOutOfFocus
  152838. */
  152839. setDarkenOutOfFocus(amount: number): void;
  152840. private _pentagonBokehIsEnabled;
  152841. /**
  152842. * Creates a pentagon bokeh effect
  152843. */
  152844. enablePentagonBokeh(): void;
  152845. /**
  152846. * Disables the pentagon bokeh effect
  152847. */
  152848. disablePentagonBokeh(): void;
  152849. /**
  152850. * Enables noise blur
  152851. */
  152852. enableNoiseBlur(): void;
  152853. /**
  152854. * Disables noise blur
  152855. */
  152856. disableNoiseBlur(): void;
  152857. /**
  152858. * Sets the HighlightsGain amount
  152859. * @param amount amount of HighlightsGain
  152860. */
  152861. setHighlightsGain(amount: number): void;
  152862. /**
  152863. * Sets the HighlightsThreshold amount
  152864. * @param amount amount of HighlightsThreshold
  152865. */
  152866. setHighlightsThreshold(amount: number): void;
  152867. /**
  152868. * Disables highlights
  152869. */
  152870. disableHighlights(): void;
  152871. /**
  152872. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  152873. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  152874. */
  152875. dispose(disableDepthRender?: boolean): void;
  152876. private _createChromaticAberrationPostProcess;
  152877. private _createHighlightsPostProcess;
  152878. private _createDepthOfFieldPostProcess;
  152879. private _createGrainTexture;
  152880. }
  152881. }
  152882. declare module BABYLON {
  152883. /**
  152884. * Contains all parameters needed for the prepass to perform
  152885. * screen space subsurface scattering
  152886. */
  152887. export class SSAO2Configuration implements PrePassEffectConfiguration {
  152888. /**
  152889. * Is subsurface enabled
  152890. */
  152891. enabled: boolean;
  152892. /**
  152893. * Name of the configuration
  152894. */
  152895. name: string;
  152896. /**
  152897. * Textures that should be present in the MRT for this effect to work
  152898. */
  152899. readonly texturesRequired: number[];
  152900. }
  152901. }
  152902. declare module BABYLON {
  152903. /** @hidden */
  152904. export var ssao2PixelShader: {
  152905. name: string;
  152906. shader: string;
  152907. };
  152908. }
  152909. declare module BABYLON {
  152910. /** @hidden */
  152911. export var ssaoCombinePixelShader: {
  152912. name: string;
  152913. shader: string;
  152914. };
  152915. }
  152916. declare module BABYLON {
  152917. /**
  152918. * Render pipeline to produce ssao effect
  152919. */
  152920. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  152921. /**
  152922. * @ignore
  152923. * The PassPostProcess id in the pipeline that contains the original scene color
  152924. */
  152925. SSAOOriginalSceneColorEffect: string;
  152926. /**
  152927. * @ignore
  152928. * The SSAO PostProcess id in the pipeline
  152929. */
  152930. SSAORenderEffect: string;
  152931. /**
  152932. * @ignore
  152933. * The horizontal blur PostProcess id in the pipeline
  152934. */
  152935. SSAOBlurHRenderEffect: string;
  152936. /**
  152937. * @ignore
  152938. * The vertical blur PostProcess id in the pipeline
  152939. */
  152940. SSAOBlurVRenderEffect: string;
  152941. /**
  152942. * @ignore
  152943. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  152944. */
  152945. SSAOCombineRenderEffect: string;
  152946. /**
  152947. * The output strength of the SSAO post-process. Default value is 1.0.
  152948. */
  152949. totalStrength: number;
  152950. /**
  152951. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  152952. */
  152953. maxZ: number;
  152954. /**
  152955. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  152956. */
  152957. minZAspect: number;
  152958. private _samples;
  152959. /**
  152960. * Number of samples used for the SSAO calculations. Default value is 8
  152961. */
  152962. set samples(n: number);
  152963. get samples(): number;
  152964. private _textureSamples;
  152965. /**
  152966. * Number of samples to use for antialiasing
  152967. */
  152968. set textureSamples(n: number);
  152969. get textureSamples(): number;
  152970. /**
  152971. * Force rendering the geometry through geometry buffer
  152972. */
  152973. private _forceGeometryBuffer;
  152974. /**
  152975. * Ratio object used for SSAO ratio and blur ratio
  152976. */
  152977. private _ratio;
  152978. /**
  152979. * Dynamically generated sphere sampler.
  152980. */
  152981. private _sampleSphere;
  152982. /**
  152983. * Blur filter offsets
  152984. */
  152985. private _samplerOffsets;
  152986. private _expensiveBlur;
  152987. /**
  152988. * If bilateral blur should be used
  152989. */
  152990. set expensiveBlur(b: boolean);
  152991. get expensiveBlur(): boolean;
  152992. /**
  152993. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  152994. */
  152995. radius: number;
  152996. /**
  152997. * The base color of the SSAO post-process
  152998. * The final result is "base + ssao" between [0, 1]
  152999. */
  153000. base: number;
  153001. /**
  153002. * Support test.
  153003. */
  153004. static get IsSupported(): boolean;
  153005. private _scene;
  153006. private _randomTexture;
  153007. private _originalColorPostProcess;
  153008. private _ssaoPostProcess;
  153009. private _blurHPostProcess;
  153010. private _blurVPostProcess;
  153011. private _ssaoCombinePostProcess;
  153012. private _prePassRenderer;
  153013. /**
  153014. * Gets active scene
  153015. */
  153016. get scene(): Scene;
  153017. /**
  153018. * @constructor
  153019. * @param name The rendering pipeline name
  153020. * @param scene The scene linked to this pipeline
  153021. * @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 }
  153022. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153023. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  153024. */
  153025. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  153026. /**
  153027. * Get the class name
  153028. * @returns "SSAO2RenderingPipeline"
  153029. */
  153030. getClassName(): string;
  153031. /**
  153032. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153033. */
  153034. dispose(disableGeometryBufferRenderer?: boolean): void;
  153035. private _createBlurPostProcess;
  153036. /** @hidden */
  153037. _rebuild(): void;
  153038. private _bits;
  153039. private _radicalInverse_VdC;
  153040. private _hammersley;
  153041. private _hemisphereSample_uniform;
  153042. private _generateHemisphere;
  153043. private _getDefinesForSSAO;
  153044. private _createSSAOPostProcess;
  153045. private _createSSAOCombinePostProcess;
  153046. private _createRandomTexture;
  153047. /**
  153048. * Serialize the rendering pipeline (Used when exporting)
  153049. * @returns the serialized object
  153050. */
  153051. serialize(): any;
  153052. /**
  153053. * Parse the serialized pipeline
  153054. * @param source Source pipeline.
  153055. * @param scene The scene to load the pipeline to.
  153056. * @param rootUrl The URL of the serialized pipeline.
  153057. * @returns An instantiated pipeline from the serialized object.
  153058. */
  153059. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  153060. }
  153061. }
  153062. declare module BABYLON {
  153063. /** @hidden */
  153064. export var ssaoPixelShader: {
  153065. name: string;
  153066. shader: string;
  153067. };
  153068. }
  153069. declare module BABYLON {
  153070. /**
  153071. * Render pipeline to produce ssao effect
  153072. */
  153073. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  153074. /**
  153075. * @ignore
  153076. * The PassPostProcess id in the pipeline that contains the original scene color
  153077. */
  153078. SSAOOriginalSceneColorEffect: string;
  153079. /**
  153080. * @ignore
  153081. * The SSAO PostProcess id in the pipeline
  153082. */
  153083. SSAORenderEffect: string;
  153084. /**
  153085. * @ignore
  153086. * The horizontal blur PostProcess id in the pipeline
  153087. */
  153088. SSAOBlurHRenderEffect: string;
  153089. /**
  153090. * @ignore
  153091. * The vertical blur PostProcess id in the pipeline
  153092. */
  153093. SSAOBlurVRenderEffect: string;
  153094. /**
  153095. * @ignore
  153096. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  153097. */
  153098. SSAOCombineRenderEffect: string;
  153099. /**
  153100. * The output strength of the SSAO post-process. Default value is 1.0.
  153101. */
  153102. totalStrength: number;
  153103. /**
  153104. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  153105. */
  153106. radius: number;
  153107. /**
  153108. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  153109. * Must not be equal to fallOff and superior to fallOff.
  153110. * Default value is 0.0075
  153111. */
  153112. area: number;
  153113. /**
  153114. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  153115. * Must not be equal to area and inferior to area.
  153116. * Default value is 0.000001
  153117. */
  153118. fallOff: number;
  153119. /**
  153120. * The base color of the SSAO post-process
  153121. * The final result is "base + ssao" between [0, 1]
  153122. */
  153123. base: number;
  153124. private _scene;
  153125. private _depthTexture;
  153126. private _randomTexture;
  153127. private _originalColorPostProcess;
  153128. private _ssaoPostProcess;
  153129. private _blurHPostProcess;
  153130. private _blurVPostProcess;
  153131. private _ssaoCombinePostProcess;
  153132. private _firstUpdate;
  153133. /**
  153134. * Gets active scene
  153135. */
  153136. get scene(): Scene;
  153137. /**
  153138. * @constructor
  153139. * @param name - The rendering pipeline name
  153140. * @param scene - The scene linked to this pipeline
  153141. * @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 }
  153142. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  153143. */
  153144. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  153145. /**
  153146. * Get the class name
  153147. * @returns "SSAORenderingPipeline"
  153148. */
  153149. getClassName(): string;
  153150. /**
  153151. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  153152. */
  153153. dispose(disableDepthRender?: boolean): void;
  153154. private _createBlurPostProcess;
  153155. /** @hidden */
  153156. _rebuild(): void;
  153157. private _createSSAOPostProcess;
  153158. private _createSSAOCombinePostProcess;
  153159. private _createRandomTexture;
  153160. }
  153161. }
  153162. declare module BABYLON {
  153163. /**
  153164. * Contains all parameters needed for the prepass to perform
  153165. * screen space reflections
  153166. */
  153167. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  153168. /**
  153169. * Is ssr enabled
  153170. */
  153171. enabled: boolean;
  153172. /**
  153173. * Name of the configuration
  153174. */
  153175. name: string;
  153176. /**
  153177. * Textures that should be present in the MRT for this effect to work
  153178. */
  153179. readonly texturesRequired: number[];
  153180. }
  153181. }
  153182. declare module BABYLON {
  153183. /** @hidden */
  153184. export var screenSpaceReflectionPixelShader: {
  153185. name: string;
  153186. shader: string;
  153187. };
  153188. }
  153189. declare module BABYLON {
  153190. /**
  153191. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  153192. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  153193. */
  153194. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  153195. /**
  153196. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  153197. */
  153198. threshold: number;
  153199. /**
  153200. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  153201. */
  153202. strength: number;
  153203. /**
  153204. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  153205. */
  153206. reflectionSpecularFalloffExponent: number;
  153207. /**
  153208. * 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]
  153209. */
  153210. step: number;
  153211. /**
  153212. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  153213. */
  153214. roughnessFactor: number;
  153215. private _forceGeometryBuffer;
  153216. private _geometryBufferRenderer;
  153217. private _prePassRenderer;
  153218. private _enableSmoothReflections;
  153219. private _reflectionSamples;
  153220. private _smoothSteps;
  153221. /**
  153222. * Gets a string identifying the name of the class
  153223. * @returns "ScreenSpaceReflectionPostProcess" string
  153224. */
  153225. getClassName(): string;
  153226. /**
  153227. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  153228. * @param name The name of the effect.
  153229. * @param scene The scene containing the objects to calculate reflections.
  153230. * @param options The required width/height ratio to downsize to before computing the render pass.
  153231. * @param camera The camera to apply the render pass to.
  153232. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153233. * @param engine The engine which the post process will be applied. (default: current engine)
  153234. * @param reusable If the post process can be reused on the same frame. (default: false)
  153235. * @param textureType Type of textures used when performing the post process. (default: 0)
  153236. * @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)
  153237. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  153238. */
  153239. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  153240. /**
  153241. * Gets wether or not smoothing reflections is enabled.
  153242. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  153243. */
  153244. get enableSmoothReflections(): boolean;
  153245. /**
  153246. * Sets wether or not smoothing reflections is enabled.
  153247. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  153248. */
  153249. set enableSmoothReflections(enabled: boolean);
  153250. /**
  153251. * Gets the number of samples taken while computing reflections. More samples count is high,
  153252. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  153253. */
  153254. get reflectionSamples(): number;
  153255. /**
  153256. * Sets the number of samples taken while computing reflections. More samples count is high,
  153257. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  153258. */
  153259. set reflectionSamples(samples: number);
  153260. /**
  153261. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  153262. * more the post-process will require GPU power and can generate a drop in FPS.
  153263. * Default value (5.0) work pretty well in all cases but can be adjusted.
  153264. */
  153265. get smoothSteps(): number;
  153266. set smoothSteps(steps: number);
  153267. private _updateEffectDefines;
  153268. /** @hidden */
  153269. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  153270. }
  153271. }
  153272. declare module BABYLON {
  153273. /** @hidden */
  153274. export var standardPixelShader: {
  153275. name: string;
  153276. shader: string;
  153277. };
  153278. }
  153279. declare module BABYLON {
  153280. /**
  153281. * Standard rendering pipeline
  153282. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  153283. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  153284. */
  153285. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  153286. /**
  153287. * Public members
  153288. */
  153289. /**
  153290. * Post-process which contains the original scene color before the pipeline applies all the effects
  153291. */
  153292. originalPostProcess: Nullable<PostProcess>;
  153293. /**
  153294. * Post-process used to down scale an image x4
  153295. */
  153296. downSampleX4PostProcess: Nullable<PostProcess>;
  153297. /**
  153298. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  153299. */
  153300. brightPassPostProcess: Nullable<PostProcess>;
  153301. /**
  153302. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  153303. */
  153304. blurHPostProcesses: PostProcess[];
  153305. /**
  153306. * Post-process array storing all the vertical blur post-processes used by the pipeline
  153307. */
  153308. blurVPostProcesses: PostProcess[];
  153309. /**
  153310. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  153311. */
  153312. textureAdderPostProcess: Nullable<PostProcess>;
  153313. /**
  153314. * Post-process used to create volumetric lighting effect
  153315. */
  153316. volumetricLightPostProcess: Nullable<PostProcess>;
  153317. /**
  153318. * Post-process used to smooth the previous volumetric light post-process on the X axis
  153319. */
  153320. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  153321. /**
  153322. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  153323. */
  153324. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  153325. /**
  153326. * Post-process used to merge the volumetric light effect and the real scene color
  153327. */
  153328. volumetricLightMergePostProces: Nullable<PostProcess>;
  153329. /**
  153330. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  153331. */
  153332. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  153333. /**
  153334. * Base post-process used to calculate the average luminance of the final image for HDR
  153335. */
  153336. luminancePostProcess: Nullable<PostProcess>;
  153337. /**
  153338. * Post-processes used to create down sample post-processes in order to get
  153339. * the average luminance of the final image for HDR
  153340. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  153341. */
  153342. luminanceDownSamplePostProcesses: PostProcess[];
  153343. /**
  153344. * Post-process used to create a HDR effect (light adaptation)
  153345. */
  153346. hdrPostProcess: Nullable<PostProcess>;
  153347. /**
  153348. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  153349. */
  153350. textureAdderFinalPostProcess: Nullable<PostProcess>;
  153351. /**
  153352. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  153353. */
  153354. lensFlareFinalPostProcess: Nullable<PostProcess>;
  153355. /**
  153356. * Post-process used to merge the final HDR post-process and the real scene color
  153357. */
  153358. hdrFinalPostProcess: Nullable<PostProcess>;
  153359. /**
  153360. * Post-process used to create a lens flare effect
  153361. */
  153362. lensFlarePostProcess: Nullable<PostProcess>;
  153363. /**
  153364. * Post-process that merges the result of the lens flare post-process and the real scene color
  153365. */
  153366. lensFlareComposePostProcess: Nullable<PostProcess>;
  153367. /**
  153368. * Post-process used to create a motion blur effect
  153369. */
  153370. motionBlurPostProcess: Nullable<PostProcess>;
  153371. /**
  153372. * Post-process used to create a depth of field effect
  153373. */
  153374. depthOfFieldPostProcess: Nullable<PostProcess>;
  153375. /**
  153376. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  153377. */
  153378. fxaaPostProcess: Nullable<FxaaPostProcess>;
  153379. /**
  153380. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  153381. */
  153382. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  153383. /**
  153384. * Represents the brightness threshold in order to configure the illuminated surfaces
  153385. */
  153386. brightThreshold: number;
  153387. /**
  153388. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  153389. */
  153390. blurWidth: number;
  153391. /**
  153392. * Sets if the blur for highlighted surfaces must be only horizontal
  153393. */
  153394. horizontalBlur: boolean;
  153395. /**
  153396. * Gets the overall exposure used by the pipeline
  153397. */
  153398. get exposure(): number;
  153399. /**
  153400. * Sets the overall exposure used by the pipeline
  153401. */
  153402. set exposure(value: number);
  153403. /**
  153404. * Texture used typically to simulate "dirty" on camera lens
  153405. */
  153406. lensTexture: Nullable<Texture>;
  153407. /**
  153408. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  153409. */
  153410. volumetricLightCoefficient: number;
  153411. /**
  153412. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  153413. */
  153414. volumetricLightPower: number;
  153415. /**
  153416. * Used the set the blur intensity to smooth the volumetric lights
  153417. */
  153418. volumetricLightBlurScale: number;
  153419. /**
  153420. * Light (spot or directional) used to generate the volumetric lights rays
  153421. * The source light must have a shadow generate so the pipeline can get its
  153422. * depth map
  153423. */
  153424. sourceLight: Nullable<SpotLight | DirectionalLight>;
  153425. /**
  153426. * For eye adaptation, represents the minimum luminance the eye can see
  153427. */
  153428. hdrMinimumLuminance: number;
  153429. /**
  153430. * For eye adaptation, represents the decrease luminance speed
  153431. */
  153432. hdrDecreaseRate: number;
  153433. /**
  153434. * For eye adaptation, represents the increase luminance speed
  153435. */
  153436. hdrIncreaseRate: number;
  153437. /**
  153438. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  153439. */
  153440. get hdrAutoExposure(): boolean;
  153441. /**
  153442. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  153443. */
  153444. set hdrAutoExposure(value: boolean);
  153445. /**
  153446. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  153447. */
  153448. lensColorTexture: Nullable<Texture>;
  153449. /**
  153450. * The overall strengh for the lens flare effect
  153451. */
  153452. lensFlareStrength: number;
  153453. /**
  153454. * Dispersion coefficient for lens flare ghosts
  153455. */
  153456. lensFlareGhostDispersal: number;
  153457. /**
  153458. * Main lens flare halo width
  153459. */
  153460. lensFlareHaloWidth: number;
  153461. /**
  153462. * Based on the lens distortion effect, defines how much the lens flare result
  153463. * is distorted
  153464. */
  153465. lensFlareDistortionStrength: number;
  153466. /**
  153467. * Configures the blur intensity used for for lens flare (halo)
  153468. */
  153469. lensFlareBlurWidth: number;
  153470. /**
  153471. * Lens star texture must be used to simulate rays on the flares and is available
  153472. * in the documentation
  153473. */
  153474. lensStarTexture: Nullable<Texture>;
  153475. /**
  153476. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  153477. * flare effect by taking account of the dirt texture
  153478. */
  153479. lensFlareDirtTexture: Nullable<Texture>;
  153480. /**
  153481. * Represents the focal length for the depth of field effect
  153482. */
  153483. depthOfFieldDistance: number;
  153484. /**
  153485. * Represents the blur intensity for the blurred part of the depth of field effect
  153486. */
  153487. depthOfFieldBlurWidth: number;
  153488. /**
  153489. * Gets how much the image is blurred by the movement while using the motion blur post-process
  153490. */
  153491. get motionStrength(): number;
  153492. /**
  153493. * Sets how much the image is blurred by the movement while using the motion blur post-process
  153494. */
  153495. set motionStrength(strength: number);
  153496. /**
  153497. * Gets wether or not the motion blur post-process is object based or screen based.
  153498. */
  153499. get objectBasedMotionBlur(): boolean;
  153500. /**
  153501. * Sets wether or not the motion blur post-process should be object based or screen based
  153502. */
  153503. set objectBasedMotionBlur(value: boolean);
  153504. /**
  153505. * List of animations for the pipeline (IAnimatable implementation)
  153506. */
  153507. animations: Animation[];
  153508. /**
  153509. * Private members
  153510. */
  153511. private _scene;
  153512. private _currentDepthOfFieldSource;
  153513. private _basePostProcess;
  153514. private _fixedExposure;
  153515. private _currentExposure;
  153516. private _hdrAutoExposure;
  153517. private _hdrCurrentLuminance;
  153518. private _motionStrength;
  153519. private _isObjectBasedMotionBlur;
  153520. private _floatTextureType;
  153521. private _camerasToBeAttached;
  153522. private _ratio;
  153523. private _bloomEnabled;
  153524. private _depthOfFieldEnabled;
  153525. private _vlsEnabled;
  153526. private _lensFlareEnabled;
  153527. private _hdrEnabled;
  153528. private _motionBlurEnabled;
  153529. private _fxaaEnabled;
  153530. private _screenSpaceReflectionsEnabled;
  153531. private _motionBlurSamples;
  153532. private _volumetricLightStepsCount;
  153533. private _samples;
  153534. /**
  153535. * @ignore
  153536. * Specifies if the bloom pipeline is enabled
  153537. */
  153538. get BloomEnabled(): boolean;
  153539. set BloomEnabled(enabled: boolean);
  153540. /**
  153541. * @ignore
  153542. * Specifies if the depth of field pipeline is enabed
  153543. */
  153544. get DepthOfFieldEnabled(): boolean;
  153545. set DepthOfFieldEnabled(enabled: boolean);
  153546. /**
  153547. * @ignore
  153548. * Specifies if the lens flare pipeline is enabed
  153549. */
  153550. get LensFlareEnabled(): boolean;
  153551. set LensFlareEnabled(enabled: boolean);
  153552. /**
  153553. * @ignore
  153554. * Specifies if the HDR pipeline is enabled
  153555. */
  153556. get HDREnabled(): boolean;
  153557. set HDREnabled(enabled: boolean);
  153558. /**
  153559. * @ignore
  153560. * Specifies if the volumetric lights scattering effect is enabled
  153561. */
  153562. get VLSEnabled(): boolean;
  153563. set VLSEnabled(enabled: boolean);
  153564. /**
  153565. * @ignore
  153566. * Specifies if the motion blur effect is enabled
  153567. */
  153568. get MotionBlurEnabled(): boolean;
  153569. set MotionBlurEnabled(enabled: boolean);
  153570. /**
  153571. * Specifies if anti-aliasing is enabled
  153572. */
  153573. get fxaaEnabled(): boolean;
  153574. set fxaaEnabled(enabled: boolean);
  153575. /**
  153576. * Specifies if screen space reflections are enabled.
  153577. */
  153578. get screenSpaceReflectionsEnabled(): boolean;
  153579. set screenSpaceReflectionsEnabled(enabled: boolean);
  153580. /**
  153581. * Specifies the number of steps used to calculate the volumetric lights
  153582. * Typically in interval [50, 200]
  153583. */
  153584. get volumetricLightStepsCount(): number;
  153585. set volumetricLightStepsCount(count: number);
  153586. /**
  153587. * Specifies the number of samples used for the motion blur effect
  153588. * Typically in interval [16, 64]
  153589. */
  153590. get motionBlurSamples(): number;
  153591. set motionBlurSamples(samples: number);
  153592. /**
  153593. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  153594. */
  153595. get samples(): number;
  153596. set samples(sampleCount: number);
  153597. /**
  153598. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  153599. * @constructor
  153600. * @param name The rendering pipeline name
  153601. * @param scene The scene linked to this pipeline
  153602. * @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)
  153603. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  153604. * @param cameras The array of cameras that the rendering pipeline will be attached to
  153605. */
  153606. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  153607. private _buildPipeline;
  153608. private _createDownSampleX4PostProcess;
  153609. private _createBrightPassPostProcess;
  153610. private _createBlurPostProcesses;
  153611. private _createTextureAdderPostProcess;
  153612. private _createVolumetricLightPostProcess;
  153613. private _createLuminancePostProcesses;
  153614. private _createHdrPostProcess;
  153615. private _createLensFlarePostProcess;
  153616. private _createDepthOfFieldPostProcess;
  153617. private _createMotionBlurPostProcess;
  153618. private _getDepthTexture;
  153619. private _disposePostProcesses;
  153620. /**
  153621. * Dispose of the pipeline and stop all post processes
  153622. */
  153623. dispose(): void;
  153624. /**
  153625. * Serialize the rendering pipeline (Used when exporting)
  153626. * @returns the serialized object
  153627. */
  153628. serialize(): any;
  153629. /**
  153630. * Parse the serialized pipeline
  153631. * @param source Source pipeline.
  153632. * @param scene The scene to load the pipeline to.
  153633. * @param rootUrl The URL of the serialized pipeline.
  153634. * @returns An instantiated pipeline from the serialized object.
  153635. */
  153636. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  153637. /**
  153638. * Luminance steps
  153639. */
  153640. static LuminanceSteps: number;
  153641. }
  153642. }
  153643. declare module BABYLON {
  153644. /** @hidden */
  153645. export var stereoscopicInterlacePixelShader: {
  153646. name: string;
  153647. shader: string;
  153648. };
  153649. }
  153650. declare module BABYLON {
  153651. /**
  153652. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  153653. */
  153654. export class StereoscopicInterlacePostProcessI extends PostProcess {
  153655. private _stepSize;
  153656. private _passedProcess;
  153657. /**
  153658. * Gets a string identifying the name of the class
  153659. * @returns "StereoscopicInterlacePostProcessI" string
  153660. */
  153661. getClassName(): string;
  153662. /**
  153663. * Initializes a StereoscopicInterlacePostProcessI
  153664. * @param name The name of the effect.
  153665. * @param rigCameras The rig cameras to be appled to the post process
  153666. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  153667. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  153668. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153669. * @param engine The engine which the post process will be applied. (default: current engine)
  153670. * @param reusable If the post process can be reused on the same frame. (default: false)
  153671. */
  153672. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  153673. }
  153674. /**
  153675. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  153676. */
  153677. export class StereoscopicInterlacePostProcess extends PostProcess {
  153678. private _stepSize;
  153679. private _passedProcess;
  153680. /**
  153681. * Gets a string identifying the name of the class
  153682. * @returns "StereoscopicInterlacePostProcess" string
  153683. */
  153684. getClassName(): string;
  153685. /**
  153686. * Initializes a StereoscopicInterlacePostProcess
  153687. * @param name The name of the effect.
  153688. * @param rigCameras The rig cameras to be appled to the post process
  153689. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  153690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153691. * @param engine The engine which the post process will be applied. (default: current engine)
  153692. * @param reusable If the post process can be reused on the same frame. (default: false)
  153693. */
  153694. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  153695. }
  153696. }
  153697. declare module BABYLON {
  153698. /** @hidden */
  153699. export var tonemapPixelShader: {
  153700. name: string;
  153701. shader: string;
  153702. };
  153703. }
  153704. declare module BABYLON {
  153705. /** Defines operator used for tonemapping */
  153706. export enum TonemappingOperator {
  153707. /** Hable */
  153708. Hable = 0,
  153709. /** Reinhard */
  153710. Reinhard = 1,
  153711. /** HejiDawson */
  153712. HejiDawson = 2,
  153713. /** Photographic */
  153714. Photographic = 3
  153715. }
  153716. /**
  153717. * Defines a post process to apply tone mapping
  153718. */
  153719. export class TonemapPostProcess extends PostProcess {
  153720. private _operator;
  153721. /** Defines the required exposure adjustement */
  153722. exposureAdjustment: number;
  153723. /**
  153724. * Gets a string identifying the name of the class
  153725. * @returns "TonemapPostProcess" string
  153726. */
  153727. getClassName(): string;
  153728. /**
  153729. * Creates a new TonemapPostProcess
  153730. * @param name defines the name of the postprocess
  153731. * @param _operator defines the operator to use
  153732. * @param exposureAdjustment defines the required exposure adjustement
  153733. * @param camera defines the camera to use (can be null)
  153734. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  153735. * @param engine defines the hosting engine (can be ignore if camera is set)
  153736. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  153737. */
  153738. constructor(name: string, _operator: TonemappingOperator,
  153739. /** Defines the required exposure adjustement */
  153740. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  153741. }
  153742. }
  153743. declare module BABYLON {
  153744. /** @hidden */
  153745. export var volumetricLightScatteringPixelShader: {
  153746. name: string;
  153747. shader: string;
  153748. };
  153749. }
  153750. declare module BABYLON {
  153751. /** @hidden */
  153752. export var volumetricLightScatteringPassVertexShader: {
  153753. name: string;
  153754. shader: string;
  153755. };
  153756. }
  153757. declare module BABYLON {
  153758. /** @hidden */
  153759. export var volumetricLightScatteringPassPixelShader: {
  153760. name: string;
  153761. shader: string;
  153762. };
  153763. }
  153764. declare module BABYLON {
  153765. /**
  153766. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  153767. */
  153768. export class VolumetricLightScatteringPostProcess extends PostProcess {
  153769. private _volumetricLightScatteringPass;
  153770. private _volumetricLightScatteringRTT;
  153771. private _viewPort;
  153772. private _screenCoordinates;
  153773. private _cachedDefines;
  153774. /**
  153775. * If not undefined, the mesh position is computed from the attached node position
  153776. */
  153777. attachedNode: {
  153778. position: Vector3;
  153779. };
  153780. /**
  153781. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  153782. */
  153783. customMeshPosition: Vector3;
  153784. /**
  153785. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  153786. */
  153787. useCustomMeshPosition: boolean;
  153788. /**
  153789. * If the post-process should inverse the light scattering direction
  153790. */
  153791. invert: boolean;
  153792. /**
  153793. * The internal mesh used by the post-process
  153794. */
  153795. mesh: Mesh;
  153796. /**
  153797. * @hidden
  153798. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  153799. */
  153800. get useDiffuseColor(): boolean;
  153801. set useDiffuseColor(useDiffuseColor: boolean);
  153802. /**
  153803. * Array containing the excluded meshes not rendered in the internal pass
  153804. */
  153805. excludedMeshes: AbstractMesh[];
  153806. /**
  153807. * Controls the overall intensity of the post-process
  153808. */
  153809. exposure: number;
  153810. /**
  153811. * Dissipates each sample's contribution in range [0, 1]
  153812. */
  153813. decay: number;
  153814. /**
  153815. * Controls the overall intensity of each sample
  153816. */
  153817. weight: number;
  153818. /**
  153819. * Controls the density of each sample
  153820. */
  153821. density: number;
  153822. /**
  153823. * @constructor
  153824. * @param name The post-process name
  153825. * @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)
  153826. * @param camera The camera that the post-process will be attached to
  153827. * @param mesh The mesh used to create the light scattering
  153828. * @param samples The post-process quality, default 100
  153829. * @param samplingModeThe post-process filtering mode
  153830. * @param engine The babylon engine
  153831. * @param reusable If the post-process is reusable
  153832. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  153833. */
  153834. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  153835. /**
  153836. * Returns the string "VolumetricLightScatteringPostProcess"
  153837. * @returns "VolumetricLightScatteringPostProcess"
  153838. */
  153839. getClassName(): string;
  153840. private _isReady;
  153841. /**
  153842. * Sets the new light position for light scattering effect
  153843. * @param position The new custom light position
  153844. */
  153845. setCustomMeshPosition(position: Vector3): void;
  153846. /**
  153847. * Returns the light position for light scattering effect
  153848. * @return Vector3 The custom light position
  153849. */
  153850. getCustomMeshPosition(): Vector3;
  153851. /**
  153852. * Disposes the internal assets and detaches the post-process from the camera
  153853. */
  153854. dispose(camera: Camera): void;
  153855. /**
  153856. * Returns the render target texture used by the post-process
  153857. * @return the render target texture used by the post-process
  153858. */
  153859. getPass(): RenderTargetTexture;
  153860. private _meshExcluded;
  153861. private _createPass;
  153862. private _updateMeshScreenCoordinates;
  153863. /**
  153864. * Creates a default mesh for the Volumeric Light Scattering post-process
  153865. * @param name The mesh name
  153866. * @param scene The scene where to create the mesh
  153867. * @return the default mesh
  153868. */
  153869. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  153870. }
  153871. }
  153872. declare module BABYLON {
  153873. /** @hidden */
  153874. export var screenSpaceCurvaturePixelShader: {
  153875. name: string;
  153876. shader: string;
  153877. };
  153878. }
  153879. declare module BABYLON {
  153880. /**
  153881. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  153882. */
  153883. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  153884. /**
  153885. * Defines how much ridge the curvature effect displays.
  153886. */
  153887. ridge: number;
  153888. /**
  153889. * Defines how much valley the curvature effect displays.
  153890. */
  153891. valley: number;
  153892. private _geometryBufferRenderer;
  153893. /**
  153894. * Gets a string identifying the name of the class
  153895. * @returns "ScreenSpaceCurvaturePostProcess" string
  153896. */
  153897. getClassName(): string;
  153898. /**
  153899. * Creates a new instance ScreenSpaceCurvaturePostProcess
  153900. * @param name The name of the effect.
  153901. * @param scene The scene containing the objects to blur according to their velocity.
  153902. * @param options The required width/height ratio to downsize to before computing the render pass.
  153903. * @param camera The camera to apply the render pass to.
  153904. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  153905. * @param engine The engine which the post process will be applied. (default: current engine)
  153906. * @param reusable If the post process can be reused on the same frame. (default: false)
  153907. * @param textureType Type of textures used when performing the post process. (default: 0)
  153908. * @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)
  153909. */
  153910. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  153911. /**
  153912. * Support test.
  153913. */
  153914. static get IsSupported(): boolean;
  153915. /** @hidden */
  153916. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  153917. }
  153918. }
  153919. declare module BABYLON {
  153920. interface Scene {
  153921. /** @hidden (Backing field) */
  153922. _boundingBoxRenderer: BoundingBoxRenderer;
  153923. /** @hidden (Backing field) */
  153924. _forceShowBoundingBoxes: boolean;
  153925. /**
  153926. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  153927. */
  153928. forceShowBoundingBoxes: boolean;
  153929. /**
  153930. * Gets the bounding box renderer associated with the scene
  153931. * @returns a BoundingBoxRenderer
  153932. */
  153933. getBoundingBoxRenderer(): BoundingBoxRenderer;
  153934. }
  153935. interface AbstractMesh {
  153936. /** @hidden (Backing field) */
  153937. _showBoundingBox: boolean;
  153938. /**
  153939. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  153940. */
  153941. showBoundingBox: boolean;
  153942. }
  153943. /**
  153944. * Component responsible of rendering the bounding box of the meshes in a scene.
  153945. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  153946. */
  153947. export class BoundingBoxRenderer implements ISceneComponent {
  153948. /**
  153949. * The component name helpfull to identify the component in the list of scene components.
  153950. */
  153951. readonly name: string;
  153952. /**
  153953. * The scene the component belongs to.
  153954. */
  153955. scene: Scene;
  153956. /**
  153957. * Color of the bounding box lines placed in front of an object
  153958. */
  153959. frontColor: Color3;
  153960. /**
  153961. * Color of the bounding box lines placed behind an object
  153962. */
  153963. backColor: Color3;
  153964. /**
  153965. * Defines if the renderer should show the back lines or not
  153966. */
  153967. showBackLines: boolean;
  153968. /**
  153969. * Observable raised before rendering a bounding box
  153970. */
  153971. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  153972. /**
  153973. * Observable raised after rendering a bounding box
  153974. */
  153975. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  153976. /**
  153977. * When false, no bounding boxes will be rendered
  153978. */
  153979. enabled: boolean;
  153980. /**
  153981. * @hidden
  153982. */
  153983. renderList: SmartArray<BoundingBox>;
  153984. private _colorShader;
  153985. private _vertexBuffers;
  153986. private _indexBuffer;
  153987. private _fillIndexBuffer;
  153988. private _fillIndexData;
  153989. /**
  153990. * Instantiates a new bounding box renderer in a scene.
  153991. * @param scene the scene the renderer renders in
  153992. */
  153993. constructor(scene: Scene);
  153994. /**
  153995. * Registers the component in a given scene
  153996. */
  153997. register(): void;
  153998. private _evaluateSubMesh;
  153999. private _preActiveMesh;
  154000. private _prepareRessources;
  154001. private _createIndexBuffer;
  154002. /**
  154003. * Rebuilds the elements related to this component in case of
  154004. * context lost for instance.
  154005. */
  154006. rebuild(): void;
  154007. /**
  154008. * @hidden
  154009. */
  154010. reset(): void;
  154011. /**
  154012. * Render the bounding boxes of a specific rendering group
  154013. * @param renderingGroupId defines the rendering group to render
  154014. */
  154015. render(renderingGroupId: number): void;
  154016. /**
  154017. * In case of occlusion queries, we can render the occlusion bounding box through this method
  154018. * @param mesh Define the mesh to render the occlusion bounding box for
  154019. */
  154020. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  154021. /**
  154022. * Dispose and release the resources attached to this renderer.
  154023. */
  154024. dispose(): void;
  154025. }
  154026. }
  154027. declare module BABYLON {
  154028. interface Scene {
  154029. /** @hidden (Backing field) */
  154030. _depthRenderer: {
  154031. [id: string]: DepthRenderer;
  154032. };
  154033. /**
  154034. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  154035. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  154036. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  154037. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  154038. * @returns the created depth renderer
  154039. */
  154040. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  154041. /**
  154042. * Disables a depth renderer for a given camera
  154043. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  154044. */
  154045. disableDepthRenderer(camera?: Nullable<Camera>): void;
  154046. }
  154047. /**
  154048. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  154049. * in several rendering techniques.
  154050. */
  154051. export class DepthRendererSceneComponent implements ISceneComponent {
  154052. /**
  154053. * The component name helpfull to identify the component in the list of scene components.
  154054. */
  154055. readonly name: string;
  154056. /**
  154057. * The scene the component belongs to.
  154058. */
  154059. scene: Scene;
  154060. /**
  154061. * Creates a new instance of the component for the given scene
  154062. * @param scene Defines the scene to register the component in
  154063. */
  154064. constructor(scene: Scene);
  154065. /**
  154066. * Registers the component in a given scene
  154067. */
  154068. register(): void;
  154069. /**
  154070. * Rebuilds the elements related to this component in case of
  154071. * context lost for instance.
  154072. */
  154073. rebuild(): void;
  154074. /**
  154075. * Disposes the component and the associated ressources
  154076. */
  154077. dispose(): void;
  154078. private _gatherRenderTargets;
  154079. private _gatherActiveCameraRenderTargets;
  154080. }
  154081. }
  154082. declare module BABYLON {
  154083. interface AbstractScene {
  154084. /** @hidden (Backing field) */
  154085. _prePassRenderer: Nullable<PrePassRenderer>;
  154086. /**
  154087. * Gets or Sets the current prepass renderer associated to the scene.
  154088. */
  154089. prePassRenderer: Nullable<PrePassRenderer>;
  154090. /**
  154091. * Enables the prepass and associates it with the scene
  154092. * @returns the PrePassRenderer
  154093. */
  154094. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  154095. /**
  154096. * Disables the prepass associated with the scene
  154097. */
  154098. disablePrePassRenderer(): void;
  154099. }
  154100. /**
  154101. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  154102. * in several rendering techniques.
  154103. */
  154104. export class PrePassRendererSceneComponent implements ISceneComponent {
  154105. /**
  154106. * The component name helpful to identify the component in the list of scene components.
  154107. */
  154108. readonly name: string;
  154109. /**
  154110. * The scene the component belongs to.
  154111. */
  154112. scene: Scene;
  154113. /**
  154114. * Creates a new instance of the component for the given scene
  154115. * @param scene Defines the scene to register the component in
  154116. */
  154117. constructor(scene: Scene);
  154118. /**
  154119. * Registers the component in a given scene
  154120. */
  154121. register(): void;
  154122. private _beforeCameraDraw;
  154123. private _afterCameraDraw;
  154124. private _beforeClearStage;
  154125. /**
  154126. * Rebuilds the elements related to this component in case of
  154127. * context lost for instance.
  154128. */
  154129. rebuild(): void;
  154130. /**
  154131. * Disposes the component and the associated ressources
  154132. */
  154133. dispose(): void;
  154134. }
  154135. }
  154136. declare module BABYLON {
  154137. /** @hidden */
  154138. export var fibonacci: {
  154139. name: string;
  154140. shader: string;
  154141. };
  154142. }
  154143. declare module BABYLON {
  154144. /** @hidden */
  154145. export var diffusionProfile: {
  154146. name: string;
  154147. shader: string;
  154148. };
  154149. }
  154150. declare module BABYLON {
  154151. /** @hidden */
  154152. export var subSurfaceScatteringPixelShader: {
  154153. name: string;
  154154. shader: string;
  154155. };
  154156. }
  154157. declare module BABYLON {
  154158. /**
  154159. * Sub surface scattering post process
  154160. */
  154161. export class SubSurfaceScatteringPostProcess extends PostProcess {
  154162. /**
  154163. * Gets a string identifying the name of the class
  154164. * @returns "SubSurfaceScatteringPostProcess" string
  154165. */
  154166. getClassName(): string;
  154167. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  154168. }
  154169. }
  154170. declare module BABYLON {
  154171. /**
  154172. * Contains all parameters needed for the prepass to perform
  154173. * screen space subsurface scattering
  154174. */
  154175. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  154176. /** @hidden */
  154177. static _SceneComponentInitialization: (scene: Scene) => void;
  154178. private _ssDiffusionS;
  154179. private _ssFilterRadii;
  154180. private _ssDiffusionD;
  154181. /**
  154182. * Post process to attach for screen space subsurface scattering
  154183. */
  154184. postProcess: SubSurfaceScatteringPostProcess;
  154185. /**
  154186. * Diffusion profile color for subsurface scattering
  154187. */
  154188. get ssDiffusionS(): number[];
  154189. /**
  154190. * Diffusion profile max color channel value for subsurface scattering
  154191. */
  154192. get ssDiffusionD(): number[];
  154193. /**
  154194. * Diffusion profile filter radius for subsurface scattering
  154195. */
  154196. get ssFilterRadii(): number[];
  154197. /**
  154198. * Is subsurface enabled
  154199. */
  154200. enabled: boolean;
  154201. /**
  154202. * Name of the configuration
  154203. */
  154204. name: string;
  154205. /**
  154206. * Diffusion profile colors for subsurface scattering
  154207. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  154208. * See ...
  154209. * Note that you can only store up to 5 of them
  154210. */
  154211. ssDiffusionProfileColors: Color3[];
  154212. /**
  154213. * Defines the ratio real world => scene units.
  154214. * Used for subsurface scattering
  154215. */
  154216. metersPerUnit: number;
  154217. /**
  154218. * Textures that should be present in the MRT for this effect to work
  154219. */
  154220. readonly texturesRequired: number[];
  154221. private _scene;
  154222. /**
  154223. * Builds a subsurface configuration object
  154224. * @param scene The scene
  154225. */
  154226. constructor(scene: Scene);
  154227. /**
  154228. * Adds a new diffusion profile.
  154229. * Useful for more realistic subsurface scattering on diverse materials.
  154230. * @param color The color of the diffusion profile. Should be the average color of the material.
  154231. * @return The index of the diffusion profile for the material subsurface configuration
  154232. */
  154233. addDiffusionProfile(color: Color3): number;
  154234. /**
  154235. * Creates the sss post process
  154236. * @return The created post process
  154237. */
  154238. createPostProcess(): SubSurfaceScatteringPostProcess;
  154239. /**
  154240. * Deletes all diffusion profiles.
  154241. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  154242. */
  154243. clearAllDiffusionProfiles(): void;
  154244. /**
  154245. * Disposes this object
  154246. */
  154247. dispose(): void;
  154248. /**
  154249. * @hidden
  154250. * https://zero-radiance.github.io/post/sampling-diffusion/
  154251. *
  154252. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  154253. * ------------------------------------------------------------------------------------
  154254. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  154255. * PDF[r, phi, s] = r * R[r, phi, s]
  154256. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  154257. * ------------------------------------------------------------------------------------
  154258. * We importance sample the color channel with the widest scattering distance.
  154259. */
  154260. getDiffusionProfileParameters(color: Color3): number;
  154261. /**
  154262. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  154263. * 'u' is the random number (the value of the CDF): [0, 1).
  154264. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  154265. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  154266. */
  154267. private _sampleBurleyDiffusionProfile;
  154268. }
  154269. }
  154270. declare module BABYLON {
  154271. interface AbstractScene {
  154272. /** @hidden (Backing field) */
  154273. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  154274. /**
  154275. * Gets or Sets the current prepass renderer associated to the scene.
  154276. */
  154277. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  154278. /**
  154279. * Enables the subsurface effect for prepass
  154280. * @returns the SubSurfaceConfiguration
  154281. */
  154282. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  154283. /**
  154284. * Disables the subsurface effect for prepass
  154285. */
  154286. disableSubSurfaceForPrePass(): void;
  154287. }
  154288. /**
  154289. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  154290. * in several rendering techniques.
  154291. */
  154292. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  154293. /**
  154294. * The component name helpful to identify the component in the list of scene components.
  154295. */
  154296. readonly name: string;
  154297. /**
  154298. * The scene the component belongs to.
  154299. */
  154300. scene: Scene;
  154301. /**
  154302. * Creates a new instance of the component for the given scene
  154303. * @param scene Defines the scene to register the component in
  154304. */
  154305. constructor(scene: Scene);
  154306. /**
  154307. * Registers the component in a given scene
  154308. */
  154309. register(): void;
  154310. /**
  154311. * Serializes the component data to the specified json object
  154312. * @param serializationObject The object to serialize to
  154313. */
  154314. serialize(serializationObject: any): void;
  154315. /**
  154316. * Adds all the elements from the container to the scene
  154317. * @param container the container holding the elements
  154318. */
  154319. addFromContainer(container: AbstractScene): void;
  154320. /**
  154321. * Removes all the elements in the container from the scene
  154322. * @param container contains the elements to remove
  154323. * @param dispose if the removed element should be disposed (default: false)
  154324. */
  154325. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  154326. /**
  154327. * Rebuilds the elements related to this component in case of
  154328. * context lost for instance.
  154329. */
  154330. rebuild(): void;
  154331. /**
  154332. * Disposes the component and the associated ressources
  154333. */
  154334. dispose(): void;
  154335. }
  154336. }
  154337. declare module BABYLON {
  154338. /** @hidden */
  154339. export var outlinePixelShader: {
  154340. name: string;
  154341. shader: string;
  154342. };
  154343. }
  154344. declare module BABYLON {
  154345. /** @hidden */
  154346. export var outlineVertexShader: {
  154347. name: string;
  154348. shader: string;
  154349. };
  154350. }
  154351. declare module BABYLON {
  154352. interface Scene {
  154353. /** @hidden */
  154354. _outlineRenderer: OutlineRenderer;
  154355. /**
  154356. * Gets the outline renderer associated with the scene
  154357. * @returns a OutlineRenderer
  154358. */
  154359. getOutlineRenderer(): OutlineRenderer;
  154360. }
  154361. interface AbstractMesh {
  154362. /** @hidden (Backing field) */
  154363. _renderOutline: boolean;
  154364. /**
  154365. * Gets or sets a boolean indicating if the outline must be rendered as well
  154366. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  154367. */
  154368. renderOutline: boolean;
  154369. /** @hidden (Backing field) */
  154370. _renderOverlay: boolean;
  154371. /**
  154372. * Gets or sets a boolean indicating if the overlay must be rendered as well
  154373. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  154374. */
  154375. renderOverlay: boolean;
  154376. }
  154377. /**
  154378. * This class is responsible to draw bothe outline/overlay of meshes.
  154379. * It should not be used directly but through the available method on mesh.
  154380. */
  154381. export class OutlineRenderer implements ISceneComponent {
  154382. /**
  154383. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  154384. */
  154385. private static _StencilReference;
  154386. /**
  154387. * The name of the component. Each component must have a unique name.
  154388. */
  154389. name: string;
  154390. /**
  154391. * The scene the component belongs to.
  154392. */
  154393. scene: Scene;
  154394. /**
  154395. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  154396. */
  154397. zOffset: number;
  154398. private _engine;
  154399. private _effect;
  154400. private _cachedDefines;
  154401. private _savedDepthWrite;
  154402. /**
  154403. * Instantiates a new outline renderer. (There could be only one per scene).
  154404. * @param scene Defines the scene it belongs to
  154405. */
  154406. constructor(scene: Scene);
  154407. /**
  154408. * Register the component to one instance of a scene.
  154409. */
  154410. register(): void;
  154411. /**
  154412. * Rebuilds the elements related to this component in case of
  154413. * context lost for instance.
  154414. */
  154415. rebuild(): void;
  154416. /**
  154417. * Disposes the component and the associated ressources.
  154418. */
  154419. dispose(): void;
  154420. /**
  154421. * Renders the outline in the canvas.
  154422. * @param subMesh Defines the sumesh to render
  154423. * @param batch Defines the batch of meshes in case of instances
  154424. * @param useOverlay Defines if the rendering is for the overlay or the outline
  154425. */
  154426. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  154427. /**
  154428. * Returns whether or not the outline renderer is ready for a given submesh.
  154429. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  154430. * @param subMesh Defines the submesh to check readyness for
  154431. * @param useInstances Defines wheter wee are trying to render instances or not
  154432. * @returns true if ready otherwise false
  154433. */
  154434. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  154435. private _beforeRenderingMesh;
  154436. private _afterRenderingMesh;
  154437. }
  154438. }
  154439. declare module BABYLON {
  154440. /**
  154441. * Defines the basic options interface of a Sprite Frame Source Size.
  154442. */
  154443. export interface ISpriteJSONSpriteSourceSize {
  154444. /**
  154445. * number of the original width of the Frame
  154446. */
  154447. w: number;
  154448. /**
  154449. * number of the original height of the Frame
  154450. */
  154451. h: number;
  154452. }
  154453. /**
  154454. * Defines the basic options interface of a Sprite Frame Data.
  154455. */
  154456. export interface ISpriteJSONSpriteFrameData {
  154457. /**
  154458. * number of the x offset of the Frame
  154459. */
  154460. x: number;
  154461. /**
  154462. * number of the y offset of the Frame
  154463. */
  154464. y: number;
  154465. /**
  154466. * number of the width of the Frame
  154467. */
  154468. w: number;
  154469. /**
  154470. * number of the height of the Frame
  154471. */
  154472. h: number;
  154473. }
  154474. /**
  154475. * Defines the basic options interface of a JSON Sprite.
  154476. */
  154477. export interface ISpriteJSONSprite {
  154478. /**
  154479. * string name of the Frame
  154480. */
  154481. filename: string;
  154482. /**
  154483. * ISpriteJSONSpriteFrame basic object of the frame data
  154484. */
  154485. frame: ISpriteJSONSpriteFrameData;
  154486. /**
  154487. * boolean to flag is the frame was rotated.
  154488. */
  154489. rotated: boolean;
  154490. /**
  154491. * boolean to flag is the frame was trimmed.
  154492. */
  154493. trimmed: boolean;
  154494. /**
  154495. * ISpriteJSONSpriteFrame basic object of the source data
  154496. */
  154497. spriteSourceSize: ISpriteJSONSpriteFrameData;
  154498. /**
  154499. * ISpriteJSONSpriteFrame basic object of the source data
  154500. */
  154501. sourceSize: ISpriteJSONSpriteSourceSize;
  154502. }
  154503. /**
  154504. * Defines the basic options interface of a JSON atlas.
  154505. */
  154506. export interface ISpriteJSONAtlas {
  154507. /**
  154508. * Array of objects that contain the frame data.
  154509. */
  154510. frames: Array<ISpriteJSONSprite>;
  154511. /**
  154512. * object basic object containing the sprite meta data.
  154513. */
  154514. meta?: object;
  154515. }
  154516. }
  154517. declare module BABYLON {
  154518. /** @hidden */
  154519. export var spriteMapPixelShader: {
  154520. name: string;
  154521. shader: string;
  154522. };
  154523. }
  154524. declare module BABYLON {
  154525. /** @hidden */
  154526. export var spriteMapVertexShader: {
  154527. name: string;
  154528. shader: string;
  154529. };
  154530. }
  154531. declare module BABYLON {
  154532. /**
  154533. * Defines the basic options interface of a SpriteMap
  154534. */
  154535. export interface ISpriteMapOptions {
  154536. /**
  154537. * Vector2 of the number of cells in the grid.
  154538. */
  154539. stageSize?: Vector2;
  154540. /**
  154541. * Vector2 of the size of the output plane in World Units.
  154542. */
  154543. outputSize?: Vector2;
  154544. /**
  154545. * Vector3 of the position of the output plane in World Units.
  154546. */
  154547. outputPosition?: Vector3;
  154548. /**
  154549. * Vector3 of the rotation of the output plane.
  154550. */
  154551. outputRotation?: Vector3;
  154552. /**
  154553. * number of layers that the system will reserve in resources.
  154554. */
  154555. layerCount?: number;
  154556. /**
  154557. * number of max animation frames a single cell will reserve in resources.
  154558. */
  154559. maxAnimationFrames?: number;
  154560. /**
  154561. * number cell index of the base tile when the system compiles.
  154562. */
  154563. baseTile?: number;
  154564. /**
  154565. * boolean flip the sprite after its been repositioned by the framing data.
  154566. */
  154567. flipU?: boolean;
  154568. /**
  154569. * Vector3 scalar of the global RGB values of the SpriteMap.
  154570. */
  154571. colorMultiply?: Vector3;
  154572. }
  154573. /**
  154574. * Defines the IDisposable interface in order to be cleanable from resources.
  154575. */
  154576. export interface ISpriteMap extends IDisposable {
  154577. /**
  154578. * String name of the SpriteMap.
  154579. */
  154580. name: string;
  154581. /**
  154582. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  154583. */
  154584. atlasJSON: ISpriteJSONAtlas;
  154585. /**
  154586. * Texture of the SpriteMap.
  154587. */
  154588. spriteSheet: Texture;
  154589. /**
  154590. * The parameters to initialize the SpriteMap with.
  154591. */
  154592. options: ISpriteMapOptions;
  154593. }
  154594. /**
  154595. * Class used to manage a grid restricted sprite deployment on an Output plane.
  154596. */
  154597. export class SpriteMap implements ISpriteMap {
  154598. /** The Name of the spriteMap */
  154599. name: string;
  154600. /** The JSON file with the frame and meta data */
  154601. atlasJSON: ISpriteJSONAtlas;
  154602. /** The systems Sprite Sheet Texture */
  154603. spriteSheet: Texture;
  154604. /** Arguments passed with the Constructor */
  154605. options: ISpriteMapOptions;
  154606. /** Public Sprite Storage array, parsed from atlasJSON */
  154607. sprites: Array<ISpriteJSONSprite>;
  154608. /** Returns the Number of Sprites in the System */
  154609. get spriteCount(): number;
  154610. /** Returns the Position of Output Plane*/
  154611. get position(): Vector3;
  154612. /** Returns the Position of Output Plane*/
  154613. set position(v: Vector3);
  154614. /** Returns the Rotation of Output Plane*/
  154615. get rotation(): Vector3;
  154616. /** Returns the Rotation of Output Plane*/
  154617. set rotation(v: Vector3);
  154618. /** Sets the AnimationMap*/
  154619. get animationMap(): RawTexture;
  154620. /** Sets the AnimationMap*/
  154621. set animationMap(v: RawTexture);
  154622. /** Scene that the SpriteMap was created in */
  154623. private _scene;
  154624. /** Texture Buffer of Float32 that holds tile frame data*/
  154625. private _frameMap;
  154626. /** Texture Buffers of Float32 that holds tileMap data*/
  154627. private _tileMaps;
  154628. /** Texture Buffer of Float32 that holds Animation Data*/
  154629. private _animationMap;
  154630. /** Custom ShaderMaterial Central to the System*/
  154631. private _material;
  154632. /** Custom ShaderMaterial Central to the System*/
  154633. private _output;
  154634. /** Systems Time Ticker*/
  154635. private _time;
  154636. /**
  154637. * Creates a new SpriteMap
  154638. * @param name defines the SpriteMaps Name
  154639. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  154640. * @param spriteSheet is the Texture that the Sprites are on.
  154641. * @param options a basic deployment configuration
  154642. * @param scene The Scene that the map is deployed on
  154643. */
  154644. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  154645. /**
  154646. * Returns tileID location
  154647. * @returns Vector2 the cell position ID
  154648. */
  154649. getTileID(): Vector2;
  154650. /**
  154651. * Gets the UV location of the mouse over the SpriteMap.
  154652. * @returns Vector2 the UV position of the mouse interaction
  154653. */
  154654. getMousePosition(): Vector2;
  154655. /**
  154656. * Creates the "frame" texture Buffer
  154657. * -------------------------------------
  154658. * Structure of frames
  154659. * "filename": "Falling-Water-2.png",
  154660. * "frame": {"x":69,"y":103,"w":24,"h":32},
  154661. * "rotated": true,
  154662. * "trimmed": true,
  154663. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  154664. * "sourceSize": {"w":32,"h":32}
  154665. * @returns RawTexture of the frameMap
  154666. */
  154667. private _createFrameBuffer;
  154668. /**
  154669. * Creates the tileMap texture Buffer
  154670. * @param buffer normally and array of numbers, or a false to generate from scratch
  154671. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  154672. * @returns RawTexture of the tileMap
  154673. */
  154674. private _createTileBuffer;
  154675. /**
  154676. * Modifies the data of the tileMaps
  154677. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  154678. * @param pos is the iVector2 Coordinates of the Tile
  154679. * @param tile The SpriteIndex of the new Tile
  154680. */
  154681. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  154682. /**
  154683. * Creates the animationMap texture Buffer
  154684. * @param buffer normally and array of numbers, or a false to generate from scratch
  154685. * @returns RawTexture of the animationMap
  154686. */
  154687. private _createTileAnimationBuffer;
  154688. /**
  154689. * Modifies the data of the animationMap
  154690. * @param cellID is the Index of the Sprite
  154691. * @param _frame is the target Animation frame
  154692. * @param toCell is the Target Index of the next frame of the animation
  154693. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  154694. * @param speed is a global scalar of the time variable on the map.
  154695. */
  154696. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  154697. /**
  154698. * Exports the .tilemaps file
  154699. */
  154700. saveTileMaps(): void;
  154701. /**
  154702. * Imports the .tilemaps file
  154703. * @param url of the .tilemaps file
  154704. */
  154705. loadTileMaps(url: string): void;
  154706. /**
  154707. * Release associated resources
  154708. */
  154709. dispose(): void;
  154710. }
  154711. }
  154712. declare module BABYLON {
  154713. /**
  154714. * Class used to manage multiple sprites of different sizes on the same spritesheet
  154715. * @see https://doc.babylonjs.com/babylon101/sprites
  154716. */
  154717. export class SpritePackedManager extends SpriteManager {
  154718. /** defines the packed manager's name */
  154719. name: string;
  154720. /**
  154721. * Creates a new sprite manager from a packed sprite sheet
  154722. * @param name defines the manager's name
  154723. * @param imgUrl defines the sprite sheet url
  154724. * @param capacity defines the maximum allowed number of sprites
  154725. * @param scene defines the hosting scene
  154726. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  154727. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  154728. * @param samplingMode defines the smapling mode to use with spritesheet
  154729. * @param fromPacked set to true; do not alter
  154730. */
  154731. constructor(
  154732. /** defines the packed manager's name */
  154733. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  154734. }
  154735. }
  154736. declare module BABYLON {
  154737. /**
  154738. * Defines the list of states available for a task inside a AssetsManager
  154739. */
  154740. export enum AssetTaskState {
  154741. /**
  154742. * Initialization
  154743. */
  154744. INIT = 0,
  154745. /**
  154746. * Running
  154747. */
  154748. RUNNING = 1,
  154749. /**
  154750. * Done
  154751. */
  154752. DONE = 2,
  154753. /**
  154754. * Error
  154755. */
  154756. ERROR = 3
  154757. }
  154758. /**
  154759. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  154760. */
  154761. export abstract class AbstractAssetTask {
  154762. /**
  154763. * Task name
  154764. */ name: string;
  154765. /**
  154766. * Callback called when the task is successful
  154767. */
  154768. onSuccess: (task: any) => void;
  154769. /**
  154770. * Callback called when the task is not successful
  154771. */
  154772. onError: (task: any, message?: string, exception?: any) => void;
  154773. /**
  154774. * Creates a new AssetsManager
  154775. * @param name defines the name of the task
  154776. */
  154777. constructor(
  154778. /**
  154779. * Task name
  154780. */ name: string);
  154781. private _isCompleted;
  154782. private _taskState;
  154783. private _errorObject;
  154784. /**
  154785. * Get if the task is completed
  154786. */
  154787. get isCompleted(): boolean;
  154788. /**
  154789. * Gets the current state of the task
  154790. */
  154791. get taskState(): AssetTaskState;
  154792. /**
  154793. * Gets the current error object (if task is in error)
  154794. */
  154795. get errorObject(): {
  154796. message?: string;
  154797. exception?: any;
  154798. };
  154799. /**
  154800. * Internal only
  154801. * @hidden
  154802. */
  154803. _setErrorObject(message?: string, exception?: any): void;
  154804. /**
  154805. * Execute the current task
  154806. * @param scene defines the scene where you want your assets to be loaded
  154807. * @param onSuccess is a callback called when the task is successfully executed
  154808. * @param onError is a callback called if an error occurs
  154809. */
  154810. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154811. /**
  154812. * Execute the current task
  154813. * @param scene defines the scene where you want your assets to be loaded
  154814. * @param onSuccess is a callback called when the task is successfully executed
  154815. * @param onError is a callback called if an error occurs
  154816. */
  154817. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154818. /**
  154819. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  154820. * This can be used with failed tasks that have the reason for failure fixed.
  154821. */
  154822. reset(): void;
  154823. private onErrorCallback;
  154824. private onDoneCallback;
  154825. }
  154826. /**
  154827. * Define the interface used by progress events raised during assets loading
  154828. */
  154829. export interface IAssetsProgressEvent {
  154830. /**
  154831. * Defines the number of remaining tasks to process
  154832. */
  154833. remainingCount: number;
  154834. /**
  154835. * Defines the total number of tasks
  154836. */
  154837. totalCount: number;
  154838. /**
  154839. * Defines the task that was just processed
  154840. */
  154841. task: AbstractAssetTask;
  154842. }
  154843. /**
  154844. * Class used to share progress information about assets loading
  154845. */
  154846. export class AssetsProgressEvent implements IAssetsProgressEvent {
  154847. /**
  154848. * Defines the number of remaining tasks to process
  154849. */
  154850. remainingCount: number;
  154851. /**
  154852. * Defines the total number of tasks
  154853. */
  154854. totalCount: number;
  154855. /**
  154856. * Defines the task that was just processed
  154857. */
  154858. task: AbstractAssetTask;
  154859. /**
  154860. * Creates a AssetsProgressEvent
  154861. * @param remainingCount defines the number of remaining tasks to process
  154862. * @param totalCount defines the total number of tasks
  154863. * @param task defines the task that was just processed
  154864. */
  154865. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  154866. }
  154867. /**
  154868. * Define a task used by AssetsManager to load assets into a container
  154869. */
  154870. export class ContainerAssetTask extends AbstractAssetTask {
  154871. /**
  154872. * Defines the name of the task
  154873. */
  154874. name: string;
  154875. /**
  154876. * Defines the list of mesh's names you want to load
  154877. */
  154878. meshesNames: any;
  154879. /**
  154880. * Defines the root url to use as a base to load your meshes and associated resources
  154881. */
  154882. rootUrl: string;
  154883. /**
  154884. * Defines the filename or File of the scene to load from
  154885. */
  154886. sceneFilename: string | File;
  154887. /**
  154888. * Get the loaded asset container
  154889. */
  154890. loadedContainer: AssetContainer;
  154891. /**
  154892. * Gets the list of loaded meshes
  154893. */
  154894. loadedMeshes: Array<AbstractMesh>;
  154895. /**
  154896. * Gets the list of loaded particle systems
  154897. */
  154898. loadedParticleSystems: Array<IParticleSystem>;
  154899. /**
  154900. * Gets the list of loaded skeletons
  154901. */
  154902. loadedSkeletons: Array<Skeleton>;
  154903. /**
  154904. * Gets the list of loaded animation groups
  154905. */
  154906. loadedAnimationGroups: Array<AnimationGroup>;
  154907. /**
  154908. * Callback called when the task is successful
  154909. */
  154910. onSuccess: (task: ContainerAssetTask) => void;
  154911. /**
  154912. * Callback called when the task is successful
  154913. */
  154914. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  154915. /**
  154916. * Creates a new ContainerAssetTask
  154917. * @param name defines the name of the task
  154918. * @param meshesNames defines the list of mesh's names you want to load
  154919. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154920. * @param sceneFilename defines the filename or File of the scene to load from
  154921. */
  154922. constructor(
  154923. /**
  154924. * Defines the name of the task
  154925. */
  154926. name: string,
  154927. /**
  154928. * Defines the list of mesh's names you want to load
  154929. */
  154930. meshesNames: any,
  154931. /**
  154932. * Defines the root url to use as a base to load your meshes and associated resources
  154933. */
  154934. rootUrl: string,
  154935. /**
  154936. * Defines the filename or File of the scene to load from
  154937. */
  154938. sceneFilename: string | File);
  154939. /**
  154940. * Execute the current task
  154941. * @param scene defines the scene where you want your assets to be loaded
  154942. * @param onSuccess is a callback called when the task is successfully executed
  154943. * @param onError is a callback called if an error occurs
  154944. */
  154945. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154946. }
  154947. /**
  154948. * Define a task used by AssetsManager to load meshes
  154949. */
  154950. export class MeshAssetTask extends AbstractAssetTask {
  154951. /**
  154952. * Defines the name of the task
  154953. */
  154954. name: string;
  154955. /**
  154956. * Defines the list of mesh's names you want to load
  154957. */
  154958. meshesNames: any;
  154959. /**
  154960. * Defines the root url to use as a base to load your meshes and associated resources
  154961. */
  154962. rootUrl: string;
  154963. /**
  154964. * Defines the filename or File of the scene to load from
  154965. */
  154966. sceneFilename: string | File;
  154967. /**
  154968. * Gets the list of loaded meshes
  154969. */
  154970. loadedMeshes: Array<AbstractMesh>;
  154971. /**
  154972. * Gets the list of loaded particle systems
  154973. */
  154974. loadedParticleSystems: Array<IParticleSystem>;
  154975. /**
  154976. * Gets the list of loaded skeletons
  154977. */
  154978. loadedSkeletons: Array<Skeleton>;
  154979. /**
  154980. * Gets the list of loaded animation groups
  154981. */
  154982. loadedAnimationGroups: Array<AnimationGroup>;
  154983. /**
  154984. * Callback called when the task is successful
  154985. */
  154986. onSuccess: (task: MeshAssetTask) => void;
  154987. /**
  154988. * Callback called when the task is successful
  154989. */
  154990. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  154991. /**
  154992. * Creates a new MeshAssetTask
  154993. * @param name defines the name of the task
  154994. * @param meshesNames defines the list of mesh's names you want to load
  154995. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  154996. * @param sceneFilename defines the filename or File of the scene to load from
  154997. */
  154998. constructor(
  154999. /**
  155000. * Defines the name of the task
  155001. */
  155002. name: string,
  155003. /**
  155004. * Defines the list of mesh's names you want to load
  155005. */
  155006. meshesNames: any,
  155007. /**
  155008. * Defines the root url to use as a base to load your meshes and associated resources
  155009. */
  155010. rootUrl: string,
  155011. /**
  155012. * Defines the filename or File of the scene to load from
  155013. */
  155014. sceneFilename: string | File);
  155015. /**
  155016. * Execute the current task
  155017. * @param scene defines the scene where you want your assets to be loaded
  155018. * @param onSuccess is a callback called when the task is successfully executed
  155019. * @param onError is a callback called if an error occurs
  155020. */
  155021. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155022. }
  155023. /**
  155024. * Define a task used by AssetsManager to load text content
  155025. */
  155026. export class TextFileAssetTask extends AbstractAssetTask {
  155027. /**
  155028. * Defines the name of the task
  155029. */
  155030. name: string;
  155031. /**
  155032. * Defines the location of the file to load
  155033. */
  155034. url: string;
  155035. /**
  155036. * Gets the loaded text string
  155037. */
  155038. text: string;
  155039. /**
  155040. * Callback called when the task is successful
  155041. */
  155042. onSuccess: (task: TextFileAssetTask) => void;
  155043. /**
  155044. * Callback called when the task is successful
  155045. */
  155046. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  155047. /**
  155048. * Creates a new TextFileAssetTask object
  155049. * @param name defines the name of the task
  155050. * @param url defines the location of the file to load
  155051. */
  155052. constructor(
  155053. /**
  155054. * Defines the name of the task
  155055. */
  155056. name: string,
  155057. /**
  155058. * Defines the location of the file to load
  155059. */
  155060. url: string);
  155061. /**
  155062. * Execute the current task
  155063. * @param scene defines the scene where you want your assets to be loaded
  155064. * @param onSuccess is a callback called when the task is successfully executed
  155065. * @param onError is a callback called if an error occurs
  155066. */
  155067. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155068. }
  155069. /**
  155070. * Define a task used by AssetsManager to load binary data
  155071. */
  155072. export class BinaryFileAssetTask extends AbstractAssetTask {
  155073. /**
  155074. * Defines the name of the task
  155075. */
  155076. name: string;
  155077. /**
  155078. * Defines the location of the file to load
  155079. */
  155080. url: string;
  155081. /**
  155082. * Gets the lodaded data (as an array buffer)
  155083. */
  155084. data: ArrayBuffer;
  155085. /**
  155086. * Callback called when the task is successful
  155087. */
  155088. onSuccess: (task: BinaryFileAssetTask) => void;
  155089. /**
  155090. * Callback called when the task is successful
  155091. */
  155092. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  155093. /**
  155094. * Creates a new BinaryFileAssetTask object
  155095. * @param name defines the name of the new task
  155096. * @param url defines the location of the file to load
  155097. */
  155098. constructor(
  155099. /**
  155100. * Defines the name of the task
  155101. */
  155102. name: string,
  155103. /**
  155104. * Defines the location of the file to load
  155105. */
  155106. url: string);
  155107. /**
  155108. * Execute the current task
  155109. * @param scene defines the scene where you want your assets to be loaded
  155110. * @param onSuccess is a callback called when the task is successfully executed
  155111. * @param onError is a callback called if an error occurs
  155112. */
  155113. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155114. }
  155115. /**
  155116. * Define a task used by AssetsManager to load images
  155117. */
  155118. export class ImageAssetTask extends AbstractAssetTask {
  155119. /**
  155120. * Defines the name of the task
  155121. */
  155122. name: string;
  155123. /**
  155124. * Defines the location of the image to load
  155125. */
  155126. url: string;
  155127. /**
  155128. * Gets the loaded images
  155129. */
  155130. image: HTMLImageElement;
  155131. /**
  155132. * Callback called when the task is successful
  155133. */
  155134. onSuccess: (task: ImageAssetTask) => void;
  155135. /**
  155136. * Callback called when the task is successful
  155137. */
  155138. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  155139. /**
  155140. * Creates a new ImageAssetTask
  155141. * @param name defines the name of the task
  155142. * @param url defines the location of the image to load
  155143. */
  155144. constructor(
  155145. /**
  155146. * Defines the name of the task
  155147. */
  155148. name: string,
  155149. /**
  155150. * Defines the location of the image to load
  155151. */
  155152. url: string);
  155153. /**
  155154. * Execute the current task
  155155. * @param scene defines the scene where you want your assets to be loaded
  155156. * @param onSuccess is a callback called when the task is successfully executed
  155157. * @param onError is a callback called if an error occurs
  155158. */
  155159. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155160. }
  155161. /**
  155162. * Defines the interface used by texture loading tasks
  155163. */
  155164. export interface ITextureAssetTask<TEX extends BaseTexture> {
  155165. /**
  155166. * Gets the loaded texture
  155167. */
  155168. texture: TEX;
  155169. }
  155170. /**
  155171. * Define a task used by AssetsManager to load 2D textures
  155172. */
  155173. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  155174. /**
  155175. * Defines the name of the task
  155176. */
  155177. name: string;
  155178. /**
  155179. * Defines the location of the file to load
  155180. */
  155181. url: string;
  155182. /**
  155183. * Defines if mipmap should not be generated (default is false)
  155184. */
  155185. noMipmap?: boolean | undefined;
  155186. /**
  155187. * Defines if texture must be inverted on Y axis (default is true)
  155188. */
  155189. invertY: boolean;
  155190. /**
  155191. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155192. */
  155193. samplingMode: number;
  155194. /**
  155195. * Gets the loaded texture
  155196. */
  155197. texture: Texture;
  155198. /**
  155199. * Callback called when the task is successful
  155200. */
  155201. onSuccess: (task: TextureAssetTask) => void;
  155202. /**
  155203. * Callback called when the task is successful
  155204. */
  155205. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  155206. /**
  155207. * Creates a new TextureAssetTask object
  155208. * @param name defines the name of the task
  155209. * @param url defines the location of the file to load
  155210. * @param noMipmap defines if mipmap should not be generated (default is false)
  155211. * @param invertY defines if texture must be inverted on Y axis (default is true)
  155212. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155213. */
  155214. constructor(
  155215. /**
  155216. * Defines the name of the task
  155217. */
  155218. name: string,
  155219. /**
  155220. * Defines the location of the file to load
  155221. */
  155222. url: string,
  155223. /**
  155224. * Defines if mipmap should not be generated (default is false)
  155225. */
  155226. noMipmap?: boolean | undefined,
  155227. /**
  155228. * Defines if texture must be inverted on Y axis (default is true)
  155229. */
  155230. invertY?: boolean,
  155231. /**
  155232. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  155233. */
  155234. samplingMode?: number);
  155235. /**
  155236. * Execute the current task
  155237. * @param scene defines the scene where you want your assets to be loaded
  155238. * @param onSuccess is a callback called when the task is successfully executed
  155239. * @param onError is a callback called if an error occurs
  155240. */
  155241. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155242. }
  155243. /**
  155244. * Define a task used by AssetsManager to load cube textures
  155245. */
  155246. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  155247. /**
  155248. * Defines the name of the task
  155249. */
  155250. name: string;
  155251. /**
  155252. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155253. */
  155254. url: string;
  155255. /**
  155256. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155257. */
  155258. extensions?: string[] | undefined;
  155259. /**
  155260. * Defines if mipmaps should not be generated (default is false)
  155261. */
  155262. noMipmap?: boolean | undefined;
  155263. /**
  155264. * Defines the explicit list of files (undefined by default)
  155265. */
  155266. files?: string[] | undefined;
  155267. /**
  155268. * Gets the loaded texture
  155269. */
  155270. texture: CubeTexture;
  155271. /**
  155272. * Callback called when the task is successful
  155273. */
  155274. onSuccess: (task: CubeTextureAssetTask) => void;
  155275. /**
  155276. * Callback called when the task is successful
  155277. */
  155278. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  155279. /**
  155280. * Creates a new CubeTextureAssetTask
  155281. * @param name defines the name of the task
  155282. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155283. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155284. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155285. * @param files defines the explicit list of files (undefined by default)
  155286. */
  155287. constructor(
  155288. /**
  155289. * Defines the name of the task
  155290. */
  155291. name: string,
  155292. /**
  155293. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  155294. */
  155295. url: string,
  155296. /**
  155297. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  155298. */
  155299. extensions?: string[] | undefined,
  155300. /**
  155301. * Defines if mipmaps should not be generated (default is false)
  155302. */
  155303. noMipmap?: boolean | undefined,
  155304. /**
  155305. * Defines the explicit list of files (undefined by default)
  155306. */
  155307. files?: string[] | undefined);
  155308. /**
  155309. * Execute the current task
  155310. * @param scene defines the scene where you want your assets to be loaded
  155311. * @param onSuccess is a callback called when the task is successfully executed
  155312. * @param onError is a callback called if an error occurs
  155313. */
  155314. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155315. }
  155316. /**
  155317. * Define a task used by AssetsManager to load HDR cube textures
  155318. */
  155319. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  155320. /**
  155321. * Defines the name of the task
  155322. */
  155323. name: string;
  155324. /**
  155325. * Defines the location of the file to load
  155326. */
  155327. url: string;
  155328. /**
  155329. * Defines the desired size (the more it increases the longer the generation will be)
  155330. */
  155331. size: number;
  155332. /**
  155333. * Defines if mipmaps should not be generated (default is false)
  155334. */
  155335. noMipmap: boolean;
  155336. /**
  155337. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155338. */
  155339. generateHarmonics: boolean;
  155340. /**
  155341. * 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)
  155342. */
  155343. gammaSpace: boolean;
  155344. /**
  155345. * Internal Use Only
  155346. */
  155347. reserved: boolean;
  155348. /**
  155349. * Gets the loaded texture
  155350. */
  155351. texture: HDRCubeTexture;
  155352. /**
  155353. * Callback called when the task is successful
  155354. */
  155355. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  155356. /**
  155357. * Callback called when the task is successful
  155358. */
  155359. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  155360. /**
  155361. * Creates a new HDRCubeTextureAssetTask object
  155362. * @param name defines the name of the task
  155363. * @param url defines the location of the file to load
  155364. * @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.
  155365. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155366. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155367. * @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)
  155368. * @param reserved Internal use only
  155369. */
  155370. constructor(
  155371. /**
  155372. * Defines the name of the task
  155373. */
  155374. name: string,
  155375. /**
  155376. * Defines the location of the file to load
  155377. */
  155378. url: string,
  155379. /**
  155380. * Defines the desired size (the more it increases the longer the generation will be)
  155381. */
  155382. size: number,
  155383. /**
  155384. * Defines if mipmaps should not be generated (default is false)
  155385. */
  155386. noMipmap?: boolean,
  155387. /**
  155388. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  155389. */
  155390. generateHarmonics?: boolean,
  155391. /**
  155392. * 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)
  155393. */
  155394. gammaSpace?: boolean,
  155395. /**
  155396. * Internal Use Only
  155397. */
  155398. reserved?: boolean);
  155399. /**
  155400. * Execute the current task
  155401. * @param scene defines the scene where you want your assets to be loaded
  155402. * @param onSuccess is a callback called when the task is successfully executed
  155403. * @param onError is a callback called if an error occurs
  155404. */
  155405. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155406. }
  155407. /**
  155408. * Define a task used by AssetsManager to load Equirectangular cube textures
  155409. */
  155410. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  155411. /**
  155412. * Defines the name of the task
  155413. */
  155414. name: string;
  155415. /**
  155416. * Defines the location of the file to load
  155417. */
  155418. url: string;
  155419. /**
  155420. * Defines the desired size (the more it increases the longer the generation will be)
  155421. */
  155422. size: number;
  155423. /**
  155424. * Defines if mipmaps should not be generated (default is false)
  155425. */
  155426. noMipmap: boolean;
  155427. /**
  155428. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  155429. * but the standard material would require them in Gamma space) (default is true)
  155430. */
  155431. gammaSpace: boolean;
  155432. /**
  155433. * Gets the loaded texture
  155434. */
  155435. texture: EquiRectangularCubeTexture;
  155436. /**
  155437. * Callback called when the task is successful
  155438. */
  155439. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  155440. /**
  155441. * Callback called when the task is successful
  155442. */
  155443. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  155444. /**
  155445. * Creates a new EquiRectangularCubeTextureAssetTask object
  155446. * @param name defines the name of the task
  155447. * @param url defines the location of the file to load
  155448. * @param size defines the desired size (the more it increases the longer the generation will be)
  155449. * If the size is omitted this implies you are using a preprocessed cubemap.
  155450. * @param noMipmap defines if mipmaps should not be generated (default is false)
  155451. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  155452. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  155453. * (default is true)
  155454. */
  155455. constructor(
  155456. /**
  155457. * Defines the name of the task
  155458. */
  155459. name: string,
  155460. /**
  155461. * Defines the location of the file to load
  155462. */
  155463. url: string,
  155464. /**
  155465. * Defines the desired size (the more it increases the longer the generation will be)
  155466. */
  155467. size: number,
  155468. /**
  155469. * Defines if mipmaps should not be generated (default is false)
  155470. */
  155471. noMipmap?: boolean,
  155472. /**
  155473. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  155474. * but the standard material would require them in Gamma space) (default is true)
  155475. */
  155476. gammaSpace?: boolean);
  155477. /**
  155478. * Execute the current task
  155479. * @param scene defines the scene where you want your assets to be loaded
  155480. * @param onSuccess is a callback called when the task is successfully executed
  155481. * @param onError is a callback called if an error occurs
  155482. */
  155483. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  155484. }
  155485. /**
  155486. * This class can be used to easily import assets into a scene
  155487. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  155488. */
  155489. export class AssetsManager {
  155490. private _scene;
  155491. private _isLoading;
  155492. protected _tasks: AbstractAssetTask[];
  155493. protected _waitingTasksCount: number;
  155494. protected _totalTasksCount: number;
  155495. /**
  155496. * Callback called when all tasks are processed
  155497. */
  155498. onFinish: (tasks: AbstractAssetTask[]) => void;
  155499. /**
  155500. * Callback called when a task is successful
  155501. */
  155502. onTaskSuccess: (task: AbstractAssetTask) => void;
  155503. /**
  155504. * Callback called when a task had an error
  155505. */
  155506. onTaskError: (task: AbstractAssetTask) => void;
  155507. /**
  155508. * Callback called when a task is done (whatever the result is)
  155509. */
  155510. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  155511. /**
  155512. * Observable called when all tasks are processed
  155513. */
  155514. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  155515. /**
  155516. * Observable called when a task had an error
  155517. */
  155518. onTaskErrorObservable: Observable<AbstractAssetTask>;
  155519. /**
  155520. * Observable called when all tasks were executed
  155521. */
  155522. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  155523. /**
  155524. * Observable called when a task is done (whatever the result is)
  155525. */
  155526. onProgressObservable: Observable<IAssetsProgressEvent>;
  155527. /**
  155528. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  155529. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  155530. */
  155531. useDefaultLoadingScreen: boolean;
  155532. /**
  155533. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  155534. * when all assets have been downloaded.
  155535. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  155536. */
  155537. autoHideLoadingUI: boolean;
  155538. /**
  155539. * Creates a new AssetsManager
  155540. * @param scene defines the scene to work on
  155541. */
  155542. constructor(scene: Scene);
  155543. /**
  155544. * Add a ContainerAssetTask to the list of active tasks
  155545. * @param taskName defines the name of the new task
  155546. * @param meshesNames defines the name of meshes to load
  155547. * @param rootUrl defines the root url to use to locate files
  155548. * @param sceneFilename defines the filename of the scene file
  155549. * @returns a new ContainerAssetTask object
  155550. */
  155551. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  155552. /**
  155553. * Add a MeshAssetTask to the list of active tasks
  155554. * @param taskName defines the name of the new task
  155555. * @param meshesNames defines the name of meshes to load
  155556. * @param rootUrl defines the root url to use to locate files
  155557. * @param sceneFilename defines the filename of the scene file
  155558. * @returns a new MeshAssetTask object
  155559. */
  155560. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  155561. /**
  155562. * Add a TextFileAssetTask to the list of active tasks
  155563. * @param taskName defines the name of the new task
  155564. * @param url defines the url of the file to load
  155565. * @returns a new TextFileAssetTask object
  155566. */
  155567. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  155568. /**
  155569. * Add a BinaryFileAssetTask to the list of active tasks
  155570. * @param taskName defines the name of the new task
  155571. * @param url defines the url of the file to load
  155572. * @returns a new BinaryFileAssetTask object
  155573. */
  155574. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  155575. /**
  155576. * Add a ImageAssetTask to the list of active tasks
  155577. * @param taskName defines the name of the new task
  155578. * @param url defines the url of the file to load
  155579. * @returns a new ImageAssetTask object
  155580. */
  155581. addImageTask(taskName: string, url: string): ImageAssetTask;
  155582. /**
  155583. * Add a TextureAssetTask to the list of active tasks
  155584. * @param taskName defines the name of the new task
  155585. * @param url defines the url of the file to load
  155586. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155587. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  155588. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  155589. * @returns a new TextureAssetTask object
  155590. */
  155591. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  155592. /**
  155593. * Add a CubeTextureAssetTask to the list of active tasks
  155594. * @param taskName defines the name of the new task
  155595. * @param url defines the url of the file to load
  155596. * @param extensions defines the extension to use to load the cube map (can be null)
  155597. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155598. * @param files defines the list of files to load (can be null)
  155599. * @returns a new CubeTextureAssetTask object
  155600. */
  155601. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  155602. /**
  155603. *
  155604. * Add a HDRCubeTextureAssetTask to the list of active tasks
  155605. * @param taskName defines the name of the new task
  155606. * @param url defines the url of the file to load
  155607. * @param size defines the size you want for the cubemap (can be null)
  155608. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155609. * @param generateHarmonics defines if you want to automatically generate (true by default)
  155610. * @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)
  155611. * @param reserved Internal use only
  155612. * @returns a new HDRCubeTextureAssetTask object
  155613. */
  155614. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  155615. /**
  155616. *
  155617. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  155618. * @param taskName defines the name of the new task
  155619. * @param url defines the url of the file to load
  155620. * @param size defines the size you want for the cubemap (can be null)
  155621. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  155622. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  155623. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  155624. * @returns a new EquiRectangularCubeTextureAssetTask object
  155625. */
  155626. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  155627. /**
  155628. * Remove a task from the assets manager.
  155629. * @param task the task to remove
  155630. */
  155631. removeTask(task: AbstractAssetTask): void;
  155632. private _decreaseWaitingTasksCount;
  155633. private _runTask;
  155634. /**
  155635. * Reset the AssetsManager and remove all tasks
  155636. * @return the current instance of the AssetsManager
  155637. */
  155638. reset(): AssetsManager;
  155639. /**
  155640. * Start the loading process
  155641. * @return the current instance of the AssetsManager
  155642. */
  155643. load(): AssetsManager;
  155644. /**
  155645. * Start the loading process as an async operation
  155646. * @return a promise returning the list of failed tasks
  155647. */
  155648. loadAsync(): Promise<void>;
  155649. }
  155650. }
  155651. declare module BABYLON {
  155652. /**
  155653. * Wrapper class for promise with external resolve and reject.
  155654. */
  155655. export class Deferred<T> {
  155656. /**
  155657. * The promise associated with this deferred object.
  155658. */
  155659. readonly promise: Promise<T>;
  155660. private _resolve;
  155661. private _reject;
  155662. /**
  155663. * The resolve method of the promise associated with this deferred object.
  155664. */
  155665. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  155666. /**
  155667. * The reject method of the promise associated with this deferred object.
  155668. */
  155669. get reject(): (reason?: any) => void;
  155670. /**
  155671. * Constructor for this deferred object.
  155672. */
  155673. constructor();
  155674. }
  155675. }
  155676. declare module BABYLON {
  155677. /**
  155678. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  155679. */
  155680. export class MeshExploder {
  155681. private _centerMesh;
  155682. private _meshes;
  155683. private _meshesOrigins;
  155684. private _toCenterVectors;
  155685. private _scaledDirection;
  155686. private _newPosition;
  155687. private _centerPosition;
  155688. /**
  155689. * Explodes meshes from a center mesh.
  155690. * @param meshes The meshes to explode.
  155691. * @param centerMesh The mesh to be center of explosion.
  155692. */
  155693. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  155694. private _setCenterMesh;
  155695. /**
  155696. * Get class name
  155697. * @returns "MeshExploder"
  155698. */
  155699. getClassName(): string;
  155700. /**
  155701. * "Exploded meshes"
  155702. * @returns Array of meshes with the centerMesh at index 0.
  155703. */
  155704. getMeshes(): Array<Mesh>;
  155705. /**
  155706. * Explodes meshes giving a specific direction
  155707. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  155708. */
  155709. explode(direction?: number): void;
  155710. }
  155711. }
  155712. declare module BABYLON {
  155713. /**
  155714. * Class used to help managing file picking and drag'n'drop
  155715. */
  155716. export class FilesInput {
  155717. /**
  155718. * List of files ready to be loaded
  155719. */
  155720. static get FilesToLoad(): {
  155721. [key: string]: File;
  155722. };
  155723. /**
  155724. * Callback called when a file is processed
  155725. */
  155726. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  155727. private _engine;
  155728. private _currentScene;
  155729. private _sceneLoadedCallback;
  155730. private _progressCallback;
  155731. private _additionalRenderLoopLogicCallback;
  155732. private _textureLoadingCallback;
  155733. private _startingProcessingFilesCallback;
  155734. private _onReloadCallback;
  155735. private _errorCallback;
  155736. private _elementToMonitor;
  155737. private _sceneFileToLoad;
  155738. private _filesToLoad;
  155739. /**
  155740. * Creates a new FilesInput
  155741. * @param engine defines the rendering engine
  155742. * @param scene defines the hosting scene
  155743. * @param sceneLoadedCallback callback called when scene is loaded
  155744. * @param progressCallback callback called to track progress
  155745. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  155746. * @param textureLoadingCallback callback called when a texture is loading
  155747. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  155748. * @param onReloadCallback callback called when a reload is requested
  155749. * @param errorCallback callback call if an error occurs
  155750. */
  155751. 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>);
  155752. private _dragEnterHandler;
  155753. private _dragOverHandler;
  155754. private _dropHandler;
  155755. /**
  155756. * Calls this function to listen to drag'n'drop events on a specific DOM element
  155757. * @param elementToMonitor defines the DOM element to track
  155758. */
  155759. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  155760. /** Gets the current list of files to load */
  155761. get filesToLoad(): File[];
  155762. /**
  155763. * Release all associated resources
  155764. */
  155765. dispose(): void;
  155766. private renderFunction;
  155767. private drag;
  155768. private drop;
  155769. private _traverseFolder;
  155770. private _processFiles;
  155771. /**
  155772. * Load files from a drop event
  155773. * @param event defines the drop event to use as source
  155774. */
  155775. loadFiles(event: any): void;
  155776. private _processReload;
  155777. /**
  155778. * Reload the current scene from the loaded files
  155779. */
  155780. reload(): void;
  155781. }
  155782. }
  155783. declare module BABYLON {
  155784. /**
  155785. * Defines the root class used to create scene optimization to use with SceneOptimizer
  155786. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155787. */
  155788. export class SceneOptimization {
  155789. /**
  155790. * Defines the priority of this optimization (0 by default which means first in the list)
  155791. */
  155792. priority: number;
  155793. /**
  155794. * Gets a string describing the action executed by the current optimization
  155795. * @returns description string
  155796. */
  155797. getDescription(): string;
  155798. /**
  155799. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155800. * @param scene defines the current scene where to apply this optimization
  155801. * @param optimizer defines the current optimizer
  155802. * @returns true if everything that can be done was applied
  155803. */
  155804. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155805. /**
  155806. * Creates the SceneOptimization object
  155807. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155808. * @param desc defines the description associated with the optimization
  155809. */
  155810. constructor(
  155811. /**
  155812. * Defines the priority of this optimization (0 by default which means first in the list)
  155813. */
  155814. priority?: number);
  155815. }
  155816. /**
  155817. * Defines an optimization used to reduce the size of render target textures
  155818. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155819. */
  155820. export class TextureOptimization extends SceneOptimization {
  155821. /**
  155822. * Defines the priority of this optimization (0 by default which means first in the list)
  155823. */
  155824. priority: number;
  155825. /**
  155826. * 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
  155827. */
  155828. maximumSize: number;
  155829. /**
  155830. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155831. */
  155832. step: number;
  155833. /**
  155834. * Gets a string describing the action executed by the current optimization
  155835. * @returns description string
  155836. */
  155837. getDescription(): string;
  155838. /**
  155839. * Creates the TextureOptimization object
  155840. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155841. * @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
  155842. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155843. */
  155844. constructor(
  155845. /**
  155846. * Defines the priority of this optimization (0 by default which means first in the list)
  155847. */
  155848. priority?: number,
  155849. /**
  155850. * 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
  155851. */
  155852. maximumSize?: number,
  155853. /**
  155854. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  155855. */
  155856. step?: number);
  155857. /**
  155858. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155859. * @param scene defines the current scene where to apply this optimization
  155860. * @param optimizer defines the current optimizer
  155861. * @returns true if everything that can be done was applied
  155862. */
  155863. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155864. }
  155865. /**
  155866. * Defines an optimization used to increase or decrease the rendering resolution
  155867. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155868. */
  155869. export class HardwareScalingOptimization extends SceneOptimization {
  155870. /**
  155871. * Defines the priority of this optimization (0 by default which means first in the list)
  155872. */
  155873. priority: number;
  155874. /**
  155875. * Defines the maximum scale to use (2 by default)
  155876. */
  155877. maximumScale: number;
  155878. /**
  155879. * Defines the step to use between two passes (0.5 by default)
  155880. */
  155881. step: number;
  155882. private _currentScale;
  155883. private _directionOffset;
  155884. /**
  155885. * Gets a string describing the action executed by the current optimization
  155886. * @return description string
  155887. */
  155888. getDescription(): string;
  155889. /**
  155890. * Creates the HardwareScalingOptimization object
  155891. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  155892. * @param maximumScale defines the maximum scale to use (2 by default)
  155893. * @param step defines the step to use between two passes (0.5 by default)
  155894. */
  155895. constructor(
  155896. /**
  155897. * Defines the priority of this optimization (0 by default which means first in the list)
  155898. */
  155899. priority?: number,
  155900. /**
  155901. * Defines the maximum scale to use (2 by default)
  155902. */
  155903. maximumScale?: number,
  155904. /**
  155905. * Defines the step to use between two passes (0.5 by default)
  155906. */
  155907. step?: number);
  155908. /**
  155909. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155910. * @param scene defines the current scene where to apply this optimization
  155911. * @param optimizer defines the current optimizer
  155912. * @returns true if everything that can be done was applied
  155913. */
  155914. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155915. }
  155916. /**
  155917. * Defines an optimization used to remove shadows
  155918. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155919. */
  155920. export class ShadowsOptimization extends SceneOptimization {
  155921. /**
  155922. * Gets a string describing the action executed by the current optimization
  155923. * @return description string
  155924. */
  155925. getDescription(): string;
  155926. /**
  155927. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155928. * @param scene defines the current scene where to apply this optimization
  155929. * @param optimizer defines the current optimizer
  155930. * @returns true if everything that can be done was applied
  155931. */
  155932. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155933. }
  155934. /**
  155935. * Defines an optimization used to turn post-processes off
  155936. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155937. */
  155938. export class PostProcessesOptimization extends SceneOptimization {
  155939. /**
  155940. * Gets a string describing the action executed by the current optimization
  155941. * @return description string
  155942. */
  155943. getDescription(): string;
  155944. /**
  155945. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155946. * @param scene defines the current scene where to apply this optimization
  155947. * @param optimizer defines the current optimizer
  155948. * @returns true if everything that can be done was applied
  155949. */
  155950. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155951. }
  155952. /**
  155953. * Defines an optimization used to turn lens flares off
  155954. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155955. */
  155956. export class LensFlaresOptimization extends SceneOptimization {
  155957. /**
  155958. * Gets a string describing the action executed by the current optimization
  155959. * @return description string
  155960. */
  155961. getDescription(): string;
  155962. /**
  155963. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155964. * @param scene defines the current scene where to apply this optimization
  155965. * @param optimizer defines the current optimizer
  155966. * @returns true if everything that can be done was applied
  155967. */
  155968. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155969. }
  155970. /**
  155971. * Defines an optimization based on user defined callback.
  155972. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155973. */
  155974. export class CustomOptimization extends SceneOptimization {
  155975. /**
  155976. * Callback called to apply the custom optimization.
  155977. */
  155978. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  155979. /**
  155980. * Callback called to get custom description
  155981. */
  155982. onGetDescription: () => string;
  155983. /**
  155984. * Gets a string describing the action executed by the current optimization
  155985. * @returns description string
  155986. */
  155987. getDescription(): string;
  155988. /**
  155989. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  155990. * @param scene defines the current scene where to apply this optimization
  155991. * @param optimizer defines the current optimizer
  155992. * @returns true if everything that can be done was applied
  155993. */
  155994. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  155995. }
  155996. /**
  155997. * Defines an optimization used to turn particles off
  155998. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  155999. */
  156000. export class ParticlesOptimization extends SceneOptimization {
  156001. /**
  156002. * Gets a string describing the action executed by the current optimization
  156003. * @return description string
  156004. */
  156005. getDescription(): string;
  156006. /**
  156007. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156008. * @param scene defines the current scene where to apply this optimization
  156009. * @param optimizer defines the current optimizer
  156010. * @returns true if everything that can be done was applied
  156011. */
  156012. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156013. }
  156014. /**
  156015. * Defines an optimization used to turn render targets off
  156016. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156017. */
  156018. export class RenderTargetsOptimization extends SceneOptimization {
  156019. /**
  156020. * Gets a string describing the action executed by the current optimization
  156021. * @return description string
  156022. */
  156023. getDescription(): string;
  156024. /**
  156025. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156026. * @param scene defines the current scene where to apply this optimization
  156027. * @param optimizer defines the current optimizer
  156028. * @returns true if everything that can be done was applied
  156029. */
  156030. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  156031. }
  156032. /**
  156033. * Defines an optimization used to merge meshes with compatible materials
  156034. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156035. */
  156036. export class MergeMeshesOptimization extends SceneOptimization {
  156037. private static _UpdateSelectionTree;
  156038. /**
  156039. * Gets or sets a boolean which defines if optimization octree has to be updated
  156040. */
  156041. static get UpdateSelectionTree(): boolean;
  156042. /**
  156043. * Gets or sets a boolean which defines if optimization octree has to be updated
  156044. */
  156045. static set UpdateSelectionTree(value: boolean);
  156046. /**
  156047. * Gets a string describing the action executed by the current optimization
  156048. * @return description string
  156049. */
  156050. getDescription(): string;
  156051. private _canBeMerged;
  156052. /**
  156053. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  156054. * @param scene defines the current scene where to apply this optimization
  156055. * @param optimizer defines the current optimizer
  156056. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  156057. * @returns true if everything that can be done was applied
  156058. */
  156059. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  156060. }
  156061. /**
  156062. * Defines a list of options used by SceneOptimizer
  156063. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156064. */
  156065. export class SceneOptimizerOptions {
  156066. /**
  156067. * Defines the target frame rate to reach (60 by default)
  156068. */
  156069. targetFrameRate: number;
  156070. /**
  156071. * Defines the interval between two checkes (2000ms by default)
  156072. */
  156073. trackerDuration: number;
  156074. /**
  156075. * Gets the list of optimizations to apply
  156076. */
  156077. optimizations: SceneOptimization[];
  156078. /**
  156079. * Creates a new list of options used by SceneOptimizer
  156080. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  156081. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  156082. */
  156083. constructor(
  156084. /**
  156085. * Defines the target frame rate to reach (60 by default)
  156086. */
  156087. targetFrameRate?: number,
  156088. /**
  156089. * Defines the interval between two checkes (2000ms by default)
  156090. */
  156091. trackerDuration?: number);
  156092. /**
  156093. * Add a new optimization
  156094. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  156095. * @returns the current SceneOptimizerOptions
  156096. */
  156097. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  156098. /**
  156099. * Add a new custom optimization
  156100. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  156101. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  156102. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  156103. * @returns the current SceneOptimizerOptions
  156104. */
  156105. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  156106. /**
  156107. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  156108. * @param targetFrameRate defines the target frame rate (60 by default)
  156109. * @returns a SceneOptimizerOptions object
  156110. */
  156111. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156112. /**
  156113. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  156114. * @param targetFrameRate defines the target frame rate (60 by default)
  156115. * @returns a SceneOptimizerOptions object
  156116. */
  156117. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156118. /**
  156119. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  156120. * @param targetFrameRate defines the target frame rate (60 by default)
  156121. * @returns a SceneOptimizerOptions object
  156122. */
  156123. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  156124. }
  156125. /**
  156126. * Class used to run optimizations in order to reach a target frame rate
  156127. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  156128. */
  156129. export class SceneOptimizer implements IDisposable {
  156130. private _isRunning;
  156131. private _options;
  156132. private _scene;
  156133. private _currentPriorityLevel;
  156134. private _targetFrameRate;
  156135. private _trackerDuration;
  156136. private _currentFrameRate;
  156137. private _sceneDisposeObserver;
  156138. private _improvementMode;
  156139. /**
  156140. * Defines an observable called when the optimizer reaches the target frame rate
  156141. */
  156142. onSuccessObservable: Observable<SceneOptimizer>;
  156143. /**
  156144. * Defines an observable called when the optimizer enables an optimization
  156145. */
  156146. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  156147. /**
  156148. * Defines an observable called when the optimizer is not able to reach the target frame rate
  156149. */
  156150. onFailureObservable: Observable<SceneOptimizer>;
  156151. /**
  156152. * Gets a boolean indicating if the optimizer is in improvement mode
  156153. */
  156154. get isInImprovementMode(): boolean;
  156155. /**
  156156. * Gets the current priority level (0 at start)
  156157. */
  156158. get currentPriorityLevel(): number;
  156159. /**
  156160. * Gets the current frame rate checked by the SceneOptimizer
  156161. */
  156162. get currentFrameRate(): number;
  156163. /**
  156164. * Gets or sets the current target frame rate (60 by default)
  156165. */
  156166. get targetFrameRate(): number;
  156167. /**
  156168. * Gets or sets the current target frame rate (60 by default)
  156169. */
  156170. set targetFrameRate(value: number);
  156171. /**
  156172. * Gets or sets the current interval between two checks (every 2000ms by default)
  156173. */
  156174. get trackerDuration(): number;
  156175. /**
  156176. * Gets or sets the current interval between two checks (every 2000ms by default)
  156177. */
  156178. set trackerDuration(value: number);
  156179. /**
  156180. * Gets the list of active optimizations
  156181. */
  156182. get optimizations(): SceneOptimization[];
  156183. /**
  156184. * Creates a new SceneOptimizer
  156185. * @param scene defines the scene to work on
  156186. * @param options defines the options to use with the SceneOptimizer
  156187. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  156188. * @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)
  156189. */
  156190. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  156191. /**
  156192. * Stops the current optimizer
  156193. */
  156194. stop(): void;
  156195. /**
  156196. * Reset the optimizer to initial step (current priority level = 0)
  156197. */
  156198. reset(): void;
  156199. /**
  156200. * Start the optimizer. By default it will try to reach a specific framerate
  156201. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  156202. */
  156203. start(): void;
  156204. private _checkCurrentState;
  156205. /**
  156206. * Release all resources
  156207. */
  156208. dispose(): void;
  156209. /**
  156210. * Helper function to create a SceneOptimizer with one single line of code
  156211. * @param scene defines the scene to work on
  156212. * @param options defines the options to use with the SceneOptimizer
  156213. * @param onSuccess defines a callback to call on success
  156214. * @param onFailure defines a callback to call on failure
  156215. * @returns the new SceneOptimizer object
  156216. */
  156217. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  156218. }
  156219. }
  156220. declare module BABYLON {
  156221. /**
  156222. * Class used to serialize a scene into a string
  156223. */
  156224. export class SceneSerializer {
  156225. /**
  156226. * Clear cache used by a previous serialization
  156227. */
  156228. static ClearCache(): void;
  156229. /**
  156230. * Serialize a scene into a JSON compatible object
  156231. * @param scene defines the scene to serialize
  156232. * @returns a JSON compatible object
  156233. */
  156234. static Serialize(scene: Scene): any;
  156235. /**
  156236. * Serialize a mesh into a JSON compatible object
  156237. * @param toSerialize defines the mesh to serialize
  156238. * @param withParents defines if parents must be serialized as well
  156239. * @param withChildren defines if children must be serialized as well
  156240. * @returns a JSON compatible object
  156241. */
  156242. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  156243. }
  156244. }
  156245. declare module BABYLON {
  156246. /**
  156247. * Class used to host texture specific utilities
  156248. */
  156249. export class TextureTools {
  156250. /**
  156251. * Uses the GPU to create a copy texture rescaled at a given size
  156252. * @param texture Texture to copy from
  156253. * @param width defines the desired width
  156254. * @param height defines the desired height
  156255. * @param useBilinearMode defines if bilinear mode has to be used
  156256. * @return the generated texture
  156257. */
  156258. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  156259. }
  156260. }
  156261. declare module BABYLON {
  156262. /**
  156263. * This represents the different options available for the video capture.
  156264. */
  156265. export interface VideoRecorderOptions {
  156266. /** Defines the mime type of the video. */
  156267. mimeType: string;
  156268. /** Defines the FPS the video should be recorded at. */
  156269. fps: number;
  156270. /** Defines the chunk size for the recording data. */
  156271. recordChunckSize: number;
  156272. /** The audio tracks to attach to the recording. */
  156273. audioTracks?: MediaStreamTrack[];
  156274. }
  156275. /**
  156276. * This can help with recording videos from BabylonJS.
  156277. * This is based on the available WebRTC functionalities of the browser.
  156278. *
  156279. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  156280. */
  156281. export class VideoRecorder {
  156282. private static readonly _defaultOptions;
  156283. /**
  156284. * Returns whether or not the VideoRecorder is available in your browser.
  156285. * @param engine Defines the Babylon Engine.
  156286. * @returns true if supported otherwise false.
  156287. */
  156288. static IsSupported(engine: Engine): boolean;
  156289. private readonly _options;
  156290. private _canvas;
  156291. private _mediaRecorder;
  156292. private _recordedChunks;
  156293. private _fileName;
  156294. private _resolve;
  156295. private _reject;
  156296. /**
  156297. * True when a recording is already in progress.
  156298. */
  156299. get isRecording(): boolean;
  156300. /**
  156301. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  156302. * @param engine Defines the BabylonJS Engine you wish to record.
  156303. * @param options Defines options that can be used to customize the capture.
  156304. */
  156305. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  156306. /**
  156307. * Stops the current recording before the default capture timeout passed in the startRecording function.
  156308. */
  156309. stopRecording(): void;
  156310. /**
  156311. * Starts recording the canvas for a max duration specified in parameters.
  156312. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  156313. * If null no automatic download will start and you can rely on the promise to get the data back.
  156314. * @param maxDuration Defines the maximum recording time in seconds.
  156315. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  156316. * @return A promise callback at the end of the recording with the video data in Blob.
  156317. */
  156318. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  156319. /**
  156320. * Releases internal resources used during the recording.
  156321. */
  156322. dispose(): void;
  156323. private _handleDataAvailable;
  156324. private _handleError;
  156325. private _handleStop;
  156326. }
  156327. }
  156328. declare module BABYLON {
  156329. /**
  156330. * Class containing a set of static utilities functions for screenshots
  156331. */
  156332. export class ScreenshotTools {
  156333. /**
  156334. * Captures a screenshot of the current rendering
  156335. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156336. * @param engine defines the rendering engine
  156337. * @param camera defines the source camera
  156338. * @param size This parameter can be set to a single number or to an object with the
  156339. * following (optional) properties: precision, width, height. If a single number is passed,
  156340. * it will be used for both width and height. If an object is passed, the screenshot size
  156341. * will be derived from the parameters. The precision property is a multiplier allowing
  156342. * rendering at a higher or lower resolution
  156343. * @param successCallback defines the callback receives a single parameter which contains the
  156344. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  156345. * src parameter of an <img> to display it
  156346. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  156347. * Check your browser for supported MIME types
  156348. */
  156349. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  156350. /**
  156351. * Captures a screenshot of the current rendering
  156352. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156353. * @param engine defines the rendering engine
  156354. * @param camera defines the source camera
  156355. * @param size This parameter can be set to a single number or to an object with the
  156356. * following (optional) properties: precision, width, height. If a single number is passed,
  156357. * it will be used for both width and height. If an object is passed, the screenshot size
  156358. * will be derived from the parameters. The precision property is a multiplier allowing
  156359. * rendering at a higher or lower resolution
  156360. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  156361. * Check your browser for supported MIME types
  156362. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  156363. * to the src parameter of an <img> to display it
  156364. */
  156365. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  156366. /**
  156367. * Generates an image screenshot from the specified camera.
  156368. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156369. * @param engine The engine to use for rendering
  156370. * @param camera The camera to use for rendering
  156371. * @param size This parameter can be set to a single number or to an object with the
  156372. * following (optional) properties: precision, width, height. If a single number is passed,
  156373. * it will be used for both width and height. If an object is passed, the screenshot size
  156374. * will be derived from the parameters. The precision property is a multiplier allowing
  156375. * rendering at a higher or lower resolution
  156376. * @param successCallback The callback receives a single parameter which contains the
  156377. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  156378. * src parameter of an <img> to display it
  156379. * @param mimeType The MIME type of the screenshot image (default: image/png).
  156380. * Check your browser for supported MIME types
  156381. * @param samples Texture samples (default: 1)
  156382. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  156383. * @param fileName A name for for the downloaded file.
  156384. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  156385. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  156386. */
  156387. 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;
  156388. /**
  156389. * Generates an image screenshot from the specified camera.
  156390. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  156391. * @param engine The engine to use for rendering
  156392. * @param camera The camera to use for rendering
  156393. * @param size This parameter can be set to a single number or to an object with the
  156394. * following (optional) properties: precision, width, height. If a single number is passed,
  156395. * it will be used for both width and height. If an object is passed, the screenshot size
  156396. * will be derived from the parameters. The precision property is a multiplier allowing
  156397. * rendering at a higher or lower resolution
  156398. * @param mimeType The MIME type of the screenshot image (default: image/png).
  156399. * Check your browser for supported MIME types
  156400. * @param samples Texture samples (default: 1)
  156401. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  156402. * @param fileName A name for for the downloaded file.
  156403. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  156404. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  156405. * to the src parameter of an <img> to display it
  156406. */
  156407. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  156408. /**
  156409. * Gets height and width for screenshot size
  156410. * @private
  156411. */
  156412. private static _getScreenshotSize;
  156413. }
  156414. }
  156415. declare module BABYLON {
  156416. /**
  156417. * Interface for a data buffer
  156418. */
  156419. export interface IDataBuffer {
  156420. /**
  156421. * Reads bytes from the data buffer.
  156422. * @param byteOffset The byte offset to read
  156423. * @param byteLength The byte length to read
  156424. * @returns A promise that resolves when the bytes are read
  156425. */
  156426. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  156427. /**
  156428. * The byte length of the buffer.
  156429. */
  156430. readonly byteLength: number;
  156431. }
  156432. /**
  156433. * Utility class for reading from a data buffer
  156434. */
  156435. export class DataReader {
  156436. /**
  156437. * The data buffer associated with this data reader.
  156438. */
  156439. readonly buffer: IDataBuffer;
  156440. /**
  156441. * The current byte offset from the beginning of the data buffer.
  156442. */
  156443. byteOffset: number;
  156444. private _dataView;
  156445. private _dataByteOffset;
  156446. /**
  156447. * Constructor
  156448. * @param buffer The buffer to read
  156449. */
  156450. constructor(buffer: IDataBuffer);
  156451. /**
  156452. * Loads the given byte length.
  156453. * @param byteLength The byte length to load
  156454. * @returns A promise that resolves when the load is complete
  156455. */
  156456. loadAsync(byteLength: number): Promise<void>;
  156457. /**
  156458. * Read a unsigned 32-bit integer from the currently loaded data range.
  156459. * @returns The 32-bit integer read
  156460. */
  156461. readUint32(): number;
  156462. /**
  156463. * Read a byte array from the currently loaded data range.
  156464. * @param byteLength The byte length to read
  156465. * @returns The byte array read
  156466. */
  156467. readUint8Array(byteLength: number): Uint8Array;
  156468. /**
  156469. * Read a string from the currently loaded data range.
  156470. * @param byteLength The byte length to read
  156471. * @returns The string read
  156472. */
  156473. readString(byteLength: number): string;
  156474. /**
  156475. * Skips the given byte length the currently loaded data range.
  156476. * @param byteLength The byte length to skip
  156477. */
  156478. skipBytes(byteLength: number): void;
  156479. }
  156480. }
  156481. declare module BABYLON {
  156482. /**
  156483. * Class for storing data to local storage if available or in-memory storage otherwise
  156484. */
  156485. export class DataStorage {
  156486. private static _Storage;
  156487. private static _GetStorage;
  156488. /**
  156489. * Reads a string from the data storage
  156490. * @param key The key to read
  156491. * @param defaultValue The value if the key doesn't exist
  156492. * @returns The string value
  156493. */
  156494. static ReadString(key: string, defaultValue: string): string;
  156495. /**
  156496. * Writes a string to the data storage
  156497. * @param key The key to write
  156498. * @param value The value to write
  156499. */
  156500. static WriteString(key: string, value: string): void;
  156501. /**
  156502. * Reads a boolean from the data storage
  156503. * @param key The key to read
  156504. * @param defaultValue The value if the key doesn't exist
  156505. * @returns The boolean value
  156506. */
  156507. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  156508. /**
  156509. * Writes a boolean to the data storage
  156510. * @param key The key to write
  156511. * @param value The value to write
  156512. */
  156513. static WriteBoolean(key: string, value: boolean): void;
  156514. /**
  156515. * Reads a number from the data storage
  156516. * @param key The key to read
  156517. * @param defaultValue The value if the key doesn't exist
  156518. * @returns The number value
  156519. */
  156520. static ReadNumber(key: string, defaultValue: number): number;
  156521. /**
  156522. * Writes a number to the data storage
  156523. * @param key The key to write
  156524. * @param value The value to write
  156525. */
  156526. static WriteNumber(key: string, value: number): void;
  156527. }
  156528. }
  156529. declare module BABYLON {
  156530. /**
  156531. * Class used to record delta files between 2 scene states
  156532. */
  156533. export class SceneRecorder {
  156534. private _trackedScene;
  156535. private _savedJSON;
  156536. /**
  156537. * Track a given scene. This means the current scene state will be considered the original state
  156538. * @param scene defines the scene to track
  156539. */
  156540. track(scene: Scene): void;
  156541. /**
  156542. * Get the delta between current state and original state
  156543. * @returns a string containing the delta
  156544. */
  156545. getDelta(): any;
  156546. private _compareArray;
  156547. private _compareObjects;
  156548. private _compareCollections;
  156549. private static GetShadowGeneratorById;
  156550. /**
  156551. * Apply a given delta to a given scene
  156552. * @param deltaJSON defines the JSON containing the delta
  156553. * @param scene defines the scene to apply the delta to
  156554. */
  156555. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  156556. private static _ApplyPropertiesToEntity;
  156557. private static _ApplyDeltaForEntity;
  156558. }
  156559. }
  156560. declare module BABYLON {
  156561. /**
  156562. * A 3D trajectory consisting of an order list of vectors describing a
  156563. * path of motion through 3D space.
  156564. */
  156565. export class Trajectory {
  156566. private _points;
  156567. private readonly _segmentLength;
  156568. /**
  156569. * Serialize to JSON.
  156570. * @returns serialized JSON string
  156571. */
  156572. serialize(): string;
  156573. /**
  156574. * Deserialize from JSON.
  156575. * @param json serialized JSON string
  156576. * @returns deserialized Trajectory
  156577. */
  156578. static Deserialize(json: string): Trajectory;
  156579. /**
  156580. * Create a new empty Trajectory.
  156581. * @param segmentLength radius of discretization for Trajectory points
  156582. */
  156583. constructor(segmentLength?: number);
  156584. /**
  156585. * Get the length of the Trajectory.
  156586. * @returns length of the Trajectory
  156587. */
  156588. getLength(): number;
  156589. /**
  156590. * Append a new point to the Trajectory.
  156591. * NOTE: This implementation has many allocations.
  156592. * @param point point to append to the Trajectory
  156593. */
  156594. add(point: DeepImmutable<Vector3>): void;
  156595. /**
  156596. * Create a new Trajectory with a segment length chosen to make it
  156597. * probable that the new Trajectory will have a specified number of
  156598. * segments. This operation is imprecise.
  156599. * @param targetResolution number of segments desired
  156600. * @returns new Trajectory with approximately the requested number of segments
  156601. */
  156602. resampleAtTargetResolution(targetResolution: number): Trajectory;
  156603. /**
  156604. * Convert Trajectory segments into tokenized representation. This
  156605. * representation is an array of numbers where each nth number is the
  156606. * index of the token which is most similar to the nth segment of the
  156607. * Trajectory.
  156608. * @param tokens list of vectors which serve as discrete tokens
  156609. * @returns list of indices of most similar token per segment
  156610. */
  156611. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  156612. private static _forwardDir;
  156613. private static _inverseFromVec;
  156614. private static _upDir;
  156615. private static _fromToVec;
  156616. private static _lookMatrix;
  156617. /**
  156618. * Transform the rotation (i.e., direction) of a segment to isolate
  156619. * the relative transformation represented by the segment. This operation
  156620. * may or may not succeed due to singularities in the equations that define
  156621. * motion relativity in this context.
  156622. * @param priorVec the origin of the prior segment
  156623. * @param fromVec the origin of the current segment
  156624. * @param toVec the destination of the current segment
  156625. * @param result reference to output variable
  156626. * @returns whether or not transformation was successful
  156627. */
  156628. private static _transformSegmentDirToRef;
  156629. private static _bestMatch;
  156630. private static _score;
  156631. private static _bestScore;
  156632. /**
  156633. * Determine which token vector is most similar to the
  156634. * segment vector.
  156635. * @param segment segment vector
  156636. * @param tokens token vector list
  156637. * @returns index of the most similar token to the segment
  156638. */
  156639. private static _tokenizeSegment;
  156640. }
  156641. /**
  156642. * Class representing a set of known, named trajectories to which Trajectories can be
  156643. * added and using which Trajectories can be recognized.
  156644. */
  156645. export class TrajectoryClassifier {
  156646. private _maximumAllowableMatchCost;
  156647. private _vector3Alphabet;
  156648. private _levenshteinAlphabet;
  156649. private _nameToDescribedTrajectory;
  156650. /**
  156651. * Serialize to JSON.
  156652. * @returns JSON serialization
  156653. */
  156654. serialize(): string;
  156655. /**
  156656. * Deserialize from JSON.
  156657. * @param json JSON serialization
  156658. * @returns deserialized TrajectorySet
  156659. */
  156660. static Deserialize(json: string): TrajectoryClassifier;
  156661. /**
  156662. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  156663. * VERY naive, need to be generating these things from known
  156664. * sets. Better version later, probably eliminating this one.
  156665. * @returns auto-generated TrajectorySet
  156666. */
  156667. static Generate(): TrajectoryClassifier;
  156668. private constructor();
  156669. /**
  156670. * Add a new Trajectory to the set with a given name.
  156671. * @param trajectory new Trajectory to be added
  156672. * @param classification name to which to add the Trajectory
  156673. */
  156674. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  156675. /**
  156676. * Remove a known named trajectory and all Trajectories associated with it.
  156677. * @param classification name to remove
  156678. * @returns whether anything was removed
  156679. */
  156680. deleteClassification(classification: string): boolean;
  156681. /**
  156682. * Attempt to recognize a Trajectory from among all the classifications
  156683. * already known to the classifier.
  156684. * @param trajectory Trajectory to be recognized
  156685. * @returns classification of Trajectory if recognized, null otherwise
  156686. */
  156687. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  156688. }
  156689. }
  156690. declare module BABYLON {
  156691. /**
  156692. * An interface for all Hit test features
  156693. */
  156694. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  156695. /**
  156696. * Triggered when new babylon (transformed) hit test results are available
  156697. */
  156698. onHitTestResultObservable: Observable<T[]>;
  156699. }
  156700. /**
  156701. * Options used for hit testing
  156702. */
  156703. export interface IWebXRLegacyHitTestOptions {
  156704. /**
  156705. * Only test when user interacted with the scene. Default - hit test every frame
  156706. */
  156707. testOnPointerDownOnly?: boolean;
  156708. /**
  156709. * The node to use to transform the local results to world coordinates
  156710. */
  156711. worldParentNode?: TransformNode;
  156712. }
  156713. /**
  156714. * Interface defining the babylon result of raycasting/hit-test
  156715. */
  156716. export interface IWebXRLegacyHitResult {
  156717. /**
  156718. * Transformation matrix that can be applied to a node that will put it in the hit point location
  156719. */
  156720. transformationMatrix: Matrix;
  156721. /**
  156722. * The native hit test result
  156723. */
  156724. xrHitResult: XRHitResult | XRHitTestResult;
  156725. }
  156726. /**
  156727. * The currently-working hit-test module.
  156728. * Hit test (or Ray-casting) is used to interact with the real world.
  156729. * For further information read here - https://github.com/immersive-web/hit-test
  156730. */
  156731. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  156732. /**
  156733. * options to use when constructing this feature
  156734. */
  156735. readonly options: IWebXRLegacyHitTestOptions;
  156736. private _direction;
  156737. private _mat;
  156738. private _onSelectEnabled;
  156739. private _origin;
  156740. /**
  156741. * The module's name
  156742. */
  156743. static readonly Name: string;
  156744. /**
  156745. * The (Babylon) version of this module.
  156746. * This is an integer representing the implementation version.
  156747. * This number does not correspond to the WebXR specs version
  156748. */
  156749. static readonly Version: number;
  156750. /**
  156751. * Populated with the last native XR Hit Results
  156752. */
  156753. lastNativeXRHitResults: XRHitResult[];
  156754. /**
  156755. * Triggered when new babylon (transformed) hit test results are available
  156756. */
  156757. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  156758. /**
  156759. * Creates a new instance of the (legacy version) hit test feature
  156760. * @param _xrSessionManager an instance of WebXRSessionManager
  156761. * @param options options to use when constructing this feature
  156762. */
  156763. constructor(_xrSessionManager: WebXRSessionManager,
  156764. /**
  156765. * options to use when constructing this feature
  156766. */
  156767. options?: IWebXRLegacyHitTestOptions);
  156768. /**
  156769. * execute a hit test with an XR Ray
  156770. *
  156771. * @param xrSession a native xrSession that will execute this hit test
  156772. * @param xrRay the ray (position and direction) to use for ray-casting
  156773. * @param referenceSpace native XR reference space to use for the hit-test
  156774. * @param filter filter function that will filter the results
  156775. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156776. */
  156777. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  156778. /**
  156779. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  156780. * @param event the (select) event to use to select with
  156781. * @param referenceSpace the reference space to use for this hit test
  156782. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  156783. */
  156784. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  156785. /**
  156786. * attach this feature
  156787. * Will usually be called by the features manager
  156788. *
  156789. * @returns true if successful.
  156790. */
  156791. attach(): boolean;
  156792. /**
  156793. * detach this feature.
  156794. * Will usually be called by the features manager
  156795. *
  156796. * @returns true if successful.
  156797. */
  156798. detach(): boolean;
  156799. /**
  156800. * Dispose this feature and all of the resources attached
  156801. */
  156802. dispose(): void;
  156803. protected _onXRFrame(frame: XRFrame): void;
  156804. private _onHitTestResults;
  156805. private _onSelect;
  156806. }
  156807. }
  156808. declare module BABYLON {
  156809. /**
  156810. * Options used for hit testing (version 2)
  156811. */
  156812. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  156813. /**
  156814. * Do not create a permanent hit test. Will usually be used when only
  156815. * transient inputs are needed.
  156816. */
  156817. disablePermanentHitTest?: boolean;
  156818. /**
  156819. * Enable transient (for example touch-based) hit test inspections
  156820. */
  156821. enableTransientHitTest?: boolean;
  156822. /**
  156823. * Offset ray for the permanent hit test
  156824. */
  156825. offsetRay?: Vector3;
  156826. /**
  156827. * Offset ray for the transient hit test
  156828. */
  156829. transientOffsetRay?: Vector3;
  156830. /**
  156831. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  156832. */
  156833. useReferenceSpace?: boolean;
  156834. /**
  156835. * Override the default entity type(s) of the hit-test result
  156836. */
  156837. entityTypes?: XRHitTestTrackableType[];
  156838. }
  156839. /**
  156840. * Interface defining the babylon result of hit-test
  156841. */
  156842. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  156843. /**
  156844. * The input source that generated this hit test (if transient)
  156845. */
  156846. inputSource?: XRInputSource;
  156847. /**
  156848. * Is this a transient hit test
  156849. */
  156850. isTransient?: boolean;
  156851. /**
  156852. * Position of the hit test result
  156853. */
  156854. position: Vector3;
  156855. /**
  156856. * Rotation of the hit test result
  156857. */
  156858. rotationQuaternion: Quaternion;
  156859. /**
  156860. * The native hit test result
  156861. */
  156862. xrHitResult: XRHitTestResult;
  156863. }
  156864. /**
  156865. * The currently-working hit-test module.
  156866. * Hit test (or Ray-casting) is used to interact with the real world.
  156867. * For further information read here - https://github.com/immersive-web/hit-test
  156868. *
  156869. * Tested on chrome (mobile) 80.
  156870. */
  156871. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  156872. /**
  156873. * options to use when constructing this feature
  156874. */
  156875. readonly options: IWebXRHitTestOptions;
  156876. private _tmpMat;
  156877. private _tmpPos;
  156878. private _tmpQuat;
  156879. private _transientXrHitTestSource;
  156880. private _xrHitTestSource;
  156881. private initHitTestSource;
  156882. /**
  156883. * The module's name
  156884. */
  156885. static readonly Name: string;
  156886. /**
  156887. * The (Babylon) version of this module.
  156888. * This is an integer representing the implementation version.
  156889. * This number does not correspond to the WebXR specs version
  156890. */
  156891. static readonly Version: number;
  156892. /**
  156893. * When set to true, each hit test will have its own position/rotation objects
  156894. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  156895. * the developers will clone them or copy them as they see fit.
  156896. */
  156897. autoCloneTransformation: boolean;
  156898. /**
  156899. * Triggered when new babylon (transformed) hit test results are available
  156900. * Note - this will be called when results come back from the device. It can be an empty array!!
  156901. */
  156902. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  156903. /**
  156904. * Use this to temporarily pause hit test checks.
  156905. */
  156906. paused: boolean;
  156907. /**
  156908. * Creates a new instance of the hit test feature
  156909. * @param _xrSessionManager an instance of WebXRSessionManager
  156910. * @param options options to use when constructing this feature
  156911. */
  156912. constructor(_xrSessionManager: WebXRSessionManager,
  156913. /**
  156914. * options to use when constructing this feature
  156915. */
  156916. options?: IWebXRHitTestOptions);
  156917. /**
  156918. * attach this feature
  156919. * Will usually be called by the features manager
  156920. *
  156921. * @returns true if successful.
  156922. */
  156923. attach(): boolean;
  156924. /**
  156925. * detach this feature.
  156926. * Will usually be called by the features manager
  156927. *
  156928. * @returns true if successful.
  156929. */
  156930. detach(): boolean;
  156931. /**
  156932. * Dispose this feature and all of the resources attached
  156933. */
  156934. dispose(): void;
  156935. protected _onXRFrame(frame: XRFrame): void;
  156936. private _processWebXRHitTestResult;
  156937. }
  156938. }
  156939. declare module BABYLON {
  156940. /**
  156941. * Configuration options of the anchor system
  156942. */
  156943. export interface IWebXRAnchorSystemOptions {
  156944. /**
  156945. * a node that will be used to convert local to world coordinates
  156946. */
  156947. worldParentNode?: TransformNode;
  156948. /**
  156949. * If set to true a reference of the created anchors will be kept until the next session starts
  156950. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  156951. */
  156952. doNotRemoveAnchorsOnSessionEnded?: boolean;
  156953. }
  156954. /**
  156955. * A babylon container for an XR Anchor
  156956. */
  156957. export interface IWebXRAnchor {
  156958. /**
  156959. * A babylon-assigned ID for this anchor
  156960. */
  156961. id: number;
  156962. /**
  156963. * Transformation matrix to apply to an object attached to this anchor
  156964. */
  156965. transformationMatrix: Matrix;
  156966. /**
  156967. * The native anchor object
  156968. */
  156969. xrAnchor: XRAnchor;
  156970. /**
  156971. * if defined, this object will be constantly updated by the anchor's position and rotation
  156972. */
  156973. attachedNode?: TransformNode;
  156974. }
  156975. /**
  156976. * An implementation of the anchor system for WebXR.
  156977. * For further information see https://github.com/immersive-web/anchors/
  156978. */
  156979. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  156980. private _options;
  156981. private _lastFrameDetected;
  156982. private _trackedAnchors;
  156983. private _referenceSpaceForFrameAnchors;
  156984. private _futureAnchors;
  156985. /**
  156986. * The module's name
  156987. */
  156988. static readonly Name: string;
  156989. /**
  156990. * The (Babylon) version of this module.
  156991. * This is an integer representing the implementation version.
  156992. * This number does not correspond to the WebXR specs version
  156993. */
  156994. static readonly Version: number;
  156995. /**
  156996. * Observers registered here will be executed when a new anchor was added to the session
  156997. */
  156998. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  156999. /**
  157000. * Observers registered here will be executed when an anchor was removed from the session
  157001. */
  157002. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  157003. /**
  157004. * Observers registered here will be executed when an existing anchor updates
  157005. * This can execute N times every frame
  157006. */
  157007. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  157008. /**
  157009. * Set the reference space to use for anchor creation, when not using a hit test.
  157010. * Will default to the session's reference space if not defined
  157011. */
  157012. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  157013. /**
  157014. * constructs a new anchor system
  157015. * @param _xrSessionManager an instance of WebXRSessionManager
  157016. * @param _options configuration object for this feature
  157017. */
  157018. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  157019. private _tmpVector;
  157020. private _tmpQuaternion;
  157021. private _populateTmpTransformation;
  157022. /**
  157023. * Create a new anchor point using a hit test result at a specific point in the scene
  157024. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157025. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157026. *
  157027. * @param hitTestResult The hit test result to use for this anchor creation
  157028. * @param position an optional position offset for this anchor
  157029. * @param rotationQuaternion an optional rotation offset for this anchor
  157030. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  157031. */
  157032. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  157033. /**
  157034. * Add a new anchor at a specific position and rotation
  157035. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  157036. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  157037. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  157038. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  157039. *
  157040. * @param position the position in which to add an anchor
  157041. * @param rotationQuaternion an optional rotation for the anchor transformation
  157042. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  157043. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  157044. */
  157045. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  157046. /**
  157047. * detach this feature.
  157048. * Will usually be called by the features manager
  157049. *
  157050. * @returns true if successful.
  157051. */
  157052. detach(): boolean;
  157053. /**
  157054. * Dispose this feature and all of the resources attached
  157055. */
  157056. dispose(): void;
  157057. protected _onXRFrame(frame: XRFrame): void;
  157058. /**
  157059. * avoiding using Array.find for global support.
  157060. * @param xrAnchor the plane to find in the array
  157061. */
  157062. private _findIndexInAnchorArray;
  157063. private _updateAnchorWithXRFrame;
  157064. private _createAnchorAtTransformation;
  157065. }
  157066. }
  157067. declare module BABYLON {
  157068. /**
  157069. * Options used in the plane detector module
  157070. */
  157071. export interface IWebXRPlaneDetectorOptions {
  157072. /**
  157073. * The node to use to transform the local results to world coordinates
  157074. */
  157075. worldParentNode?: TransformNode;
  157076. /**
  157077. * If set to true a reference of the created planes will be kept until the next session starts
  157078. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  157079. */
  157080. doNotRemovePlanesOnSessionEnded?: boolean;
  157081. }
  157082. /**
  157083. * A babylon interface for a WebXR plane.
  157084. * A Plane is actually a polygon, built from N points in space
  157085. *
  157086. * Supported in chrome 79, not supported in canary 81 ATM
  157087. */
  157088. export interface IWebXRPlane {
  157089. /**
  157090. * a babylon-assigned ID for this polygon
  157091. */
  157092. id: number;
  157093. /**
  157094. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  157095. */
  157096. polygonDefinition: Array<Vector3>;
  157097. /**
  157098. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  157099. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  157100. */
  157101. transformationMatrix: Matrix;
  157102. /**
  157103. * the native xr-plane object
  157104. */
  157105. xrPlane: XRPlane;
  157106. }
  157107. /**
  157108. * The plane detector is used to detect planes in the real world when in AR
  157109. * For more information see https://github.com/immersive-web/real-world-geometry/
  157110. */
  157111. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  157112. private _options;
  157113. private _detectedPlanes;
  157114. private _enabled;
  157115. private _lastFrameDetected;
  157116. /**
  157117. * The module's name
  157118. */
  157119. static readonly Name: string;
  157120. /**
  157121. * The (Babylon) version of this module.
  157122. * This is an integer representing the implementation version.
  157123. * This number does not correspond to the WebXR specs version
  157124. */
  157125. static readonly Version: number;
  157126. /**
  157127. * Observers registered here will be executed when a new plane was added to the session
  157128. */
  157129. onPlaneAddedObservable: Observable<IWebXRPlane>;
  157130. /**
  157131. * Observers registered here will be executed when a plane is no longer detected in the session
  157132. */
  157133. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  157134. /**
  157135. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  157136. * This can execute N times every frame
  157137. */
  157138. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  157139. /**
  157140. * construct a new Plane Detector
  157141. * @param _xrSessionManager an instance of xr Session manager
  157142. * @param _options configuration to use when constructing this feature
  157143. */
  157144. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  157145. /**
  157146. * detach this feature.
  157147. * Will usually be called by the features manager
  157148. *
  157149. * @returns true if successful.
  157150. */
  157151. detach(): boolean;
  157152. /**
  157153. * Dispose this feature and all of the resources attached
  157154. */
  157155. dispose(): void;
  157156. protected _onXRFrame(frame: XRFrame): void;
  157157. private _init;
  157158. private _updatePlaneWithXRPlane;
  157159. /**
  157160. * avoiding using Array.find for global support.
  157161. * @param xrPlane the plane to find in the array
  157162. */
  157163. private findIndexInPlaneArray;
  157164. }
  157165. }
  157166. declare module BABYLON {
  157167. /**
  157168. * Options interface for the background remover plugin
  157169. */
  157170. export interface IWebXRBackgroundRemoverOptions {
  157171. /**
  157172. * Further background meshes to disable when entering AR
  157173. */
  157174. backgroundMeshes?: AbstractMesh[];
  157175. /**
  157176. * flags to configure the removal of the environment helper.
  157177. * If not set, the entire background will be removed. If set, flags should be set as well.
  157178. */
  157179. environmentHelperRemovalFlags?: {
  157180. /**
  157181. * Should the skybox be removed (default false)
  157182. */
  157183. skyBox?: boolean;
  157184. /**
  157185. * Should the ground be removed (default false)
  157186. */
  157187. ground?: boolean;
  157188. };
  157189. /**
  157190. * don't disable the environment helper
  157191. */
  157192. ignoreEnvironmentHelper?: boolean;
  157193. }
  157194. /**
  157195. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  157196. */
  157197. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  157198. /**
  157199. * read-only options to be used in this module
  157200. */
  157201. readonly options: IWebXRBackgroundRemoverOptions;
  157202. /**
  157203. * The module's name
  157204. */
  157205. static readonly Name: string;
  157206. /**
  157207. * The (Babylon) version of this module.
  157208. * This is an integer representing the implementation version.
  157209. * This number does not correspond to the WebXR specs version
  157210. */
  157211. static readonly Version: number;
  157212. /**
  157213. * registered observers will be triggered when the background state changes
  157214. */
  157215. onBackgroundStateChangedObservable: Observable<boolean>;
  157216. /**
  157217. * constructs a new background remover module
  157218. * @param _xrSessionManager the session manager for this module
  157219. * @param options read-only options to be used in this module
  157220. */
  157221. constructor(_xrSessionManager: WebXRSessionManager,
  157222. /**
  157223. * read-only options to be used in this module
  157224. */
  157225. options?: IWebXRBackgroundRemoverOptions);
  157226. /**
  157227. * attach this feature
  157228. * Will usually be called by the features manager
  157229. *
  157230. * @returns true if successful.
  157231. */
  157232. attach(): boolean;
  157233. /**
  157234. * detach this feature.
  157235. * Will usually be called by the features manager
  157236. *
  157237. * @returns true if successful.
  157238. */
  157239. detach(): boolean;
  157240. /**
  157241. * Dispose this feature and all of the resources attached
  157242. */
  157243. dispose(): void;
  157244. protected _onXRFrame(_xrFrame: XRFrame): void;
  157245. private _setBackgroundState;
  157246. }
  157247. }
  157248. declare module BABYLON {
  157249. /**
  157250. * Options for the controller physics feature
  157251. */
  157252. export class IWebXRControllerPhysicsOptions {
  157253. /**
  157254. * Should the headset get its own impostor
  157255. */
  157256. enableHeadsetImpostor?: boolean;
  157257. /**
  157258. * Optional parameters for the headset impostor
  157259. */
  157260. headsetImpostorParams?: {
  157261. /**
  157262. * The type of impostor to create. Default is sphere
  157263. */
  157264. impostorType: number;
  157265. /**
  157266. * the size of the impostor. Defaults to 10cm
  157267. */
  157268. impostorSize?: number | {
  157269. width: number;
  157270. height: number;
  157271. depth: number;
  157272. };
  157273. /**
  157274. * Friction definitions
  157275. */
  157276. friction?: number;
  157277. /**
  157278. * Restitution
  157279. */
  157280. restitution?: number;
  157281. };
  157282. /**
  157283. * The physics properties of the future impostors
  157284. */
  157285. physicsProperties?: {
  157286. /**
  157287. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  157288. * Note that this requires a physics engine that supports mesh impostors!
  157289. */
  157290. useControllerMesh?: boolean;
  157291. /**
  157292. * The type of impostor to create. Default is sphere
  157293. */
  157294. impostorType?: number;
  157295. /**
  157296. * the size of the impostor. Defaults to 10cm
  157297. */
  157298. impostorSize?: number | {
  157299. width: number;
  157300. height: number;
  157301. depth: number;
  157302. };
  157303. /**
  157304. * Friction definitions
  157305. */
  157306. friction?: number;
  157307. /**
  157308. * Restitution
  157309. */
  157310. restitution?: number;
  157311. };
  157312. /**
  157313. * the xr input to use with this pointer selection
  157314. */
  157315. xrInput: WebXRInput;
  157316. }
  157317. /**
  157318. * Add physics impostor to your webxr controllers,
  157319. * including naive calculation of their linear and angular velocity
  157320. */
  157321. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  157322. private readonly _options;
  157323. private _attachController;
  157324. private _controllers;
  157325. private _debugMode;
  157326. private _delta;
  157327. private _headsetImpostor?;
  157328. private _headsetMesh?;
  157329. private _lastTimestamp;
  157330. private _tmpQuaternion;
  157331. private _tmpVector;
  157332. /**
  157333. * The module's name
  157334. */
  157335. static readonly Name: string;
  157336. /**
  157337. * The (Babylon) version of this module.
  157338. * This is an integer representing the implementation version.
  157339. * This number does not correspond to the webxr specs version
  157340. */
  157341. static readonly Version: number;
  157342. /**
  157343. * Construct a new Controller Physics Feature
  157344. * @param _xrSessionManager the corresponding xr session manager
  157345. * @param _options options to create this feature with
  157346. */
  157347. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  157348. /**
  157349. * @hidden
  157350. * enable debugging - will show console outputs and the impostor mesh
  157351. */
  157352. _enablePhysicsDebug(): void;
  157353. /**
  157354. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  157355. * @param xrController the controller to add
  157356. */
  157357. addController(xrController: WebXRInputSource): void;
  157358. /**
  157359. * attach this feature
  157360. * Will usually be called by the features manager
  157361. *
  157362. * @returns true if successful.
  157363. */
  157364. attach(): boolean;
  157365. /**
  157366. * detach this feature.
  157367. * Will usually be called by the features manager
  157368. *
  157369. * @returns true if successful.
  157370. */
  157371. detach(): boolean;
  157372. /**
  157373. * Get the headset impostor, if enabled
  157374. * @returns the impostor
  157375. */
  157376. getHeadsetImpostor(): PhysicsImpostor | undefined;
  157377. /**
  157378. * Get the physics impostor of a specific controller.
  157379. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  157380. * @param controller the controller or the controller id of which to get the impostor
  157381. * @returns the impostor or null
  157382. */
  157383. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  157384. /**
  157385. * Update the physics properties provided in the constructor
  157386. * @param newProperties the new properties object
  157387. */
  157388. setPhysicsProperties(newProperties: {
  157389. impostorType?: number;
  157390. impostorSize?: number | {
  157391. width: number;
  157392. height: number;
  157393. depth: number;
  157394. };
  157395. friction?: number;
  157396. restitution?: number;
  157397. }): void;
  157398. protected _onXRFrame(_xrFrame: any): void;
  157399. private _detachController;
  157400. }
  157401. }
  157402. declare module BABYLON {
  157403. /**
  157404. * A babylon interface for a "WebXR" feature point.
  157405. * Represents the position and confidence value of a given feature point.
  157406. */
  157407. export interface IWebXRFeaturePoint {
  157408. /**
  157409. * Represents the position of the feature point in world space.
  157410. */
  157411. position: Vector3;
  157412. /**
  157413. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  157414. */
  157415. confidenceValue: number;
  157416. }
  157417. /**
  157418. * The feature point system is used to detect feature points from real world geometry.
  157419. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  157420. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  157421. */
  157422. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  157423. private _enabled;
  157424. private _featurePointCloud;
  157425. /**
  157426. * The module's name
  157427. */
  157428. static readonly Name: string;
  157429. /**
  157430. * The (Babylon) version of this module.
  157431. * This is an integer representing the implementation version.
  157432. * This number does not correspond to the WebXR specs version
  157433. */
  157434. static readonly Version: number;
  157435. /**
  157436. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  157437. * Will notify the observers about which feature points have been added.
  157438. */
  157439. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  157440. /**
  157441. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  157442. * Will notify the observers about which feature points have been updated.
  157443. */
  157444. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  157445. /**
  157446. * The current feature point cloud maintained across frames.
  157447. */
  157448. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  157449. /**
  157450. * construct the feature point system
  157451. * @param _xrSessionManager an instance of xr Session manager
  157452. */
  157453. constructor(_xrSessionManager: WebXRSessionManager);
  157454. /**
  157455. * Detach this feature.
  157456. * Will usually be called by the features manager
  157457. *
  157458. * @returns true if successful.
  157459. */
  157460. detach(): boolean;
  157461. /**
  157462. * Dispose this feature and all of the resources attached
  157463. */
  157464. dispose(): void;
  157465. /**
  157466. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  157467. */
  157468. protected _onXRFrame(frame: XRFrame): void;
  157469. /**
  157470. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  157471. */
  157472. private _init;
  157473. }
  157474. }
  157475. declare module BABYLON {
  157476. /**
  157477. * Configuration interface for the hand tracking feature
  157478. */
  157479. export interface IWebXRHandTrackingOptions {
  157480. /**
  157481. * The xrInput that will be used as source for new hands
  157482. */
  157483. xrInput: WebXRInput;
  157484. /**
  157485. * Configuration object for the joint meshes
  157486. */
  157487. jointMeshes?: {
  157488. /**
  157489. * Should the meshes created be invisible (defaults to false)
  157490. */
  157491. invisible?: boolean;
  157492. /**
  157493. * A source mesh to be used to create instances. Defaults to a sphere.
  157494. * This mesh will be the source for all other (25) meshes.
  157495. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  157496. */
  157497. sourceMesh?: Mesh;
  157498. /**
  157499. * This function will be called after a mesh was created for a specific joint.
  157500. * Using this function you can either manipulate the instance or return a new mesh.
  157501. * When returning a new mesh the instance created before will be disposed
  157502. */
  157503. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  157504. /**
  157505. * Should the source mesh stay visible. Defaults to false
  157506. */
  157507. keepOriginalVisible?: boolean;
  157508. /**
  157509. * Scale factor for all instances (defaults to 2)
  157510. */
  157511. scaleFactor?: number;
  157512. /**
  157513. * Should each instance have its own physics impostor
  157514. */
  157515. enablePhysics?: boolean;
  157516. /**
  157517. * If enabled, override default physics properties
  157518. */
  157519. physicsProps?: {
  157520. friction?: number;
  157521. restitution?: number;
  157522. impostorType?: number;
  157523. };
  157524. /**
  157525. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  157526. */
  157527. handMesh?: AbstractMesh;
  157528. };
  157529. }
  157530. /**
  157531. * Parts of the hands divided to writs and finger names
  157532. */
  157533. export const enum HandPart {
  157534. /**
  157535. * HandPart - Wrist
  157536. */
  157537. WRIST = "wrist",
  157538. /**
  157539. * HandPart - The THumb
  157540. */
  157541. THUMB = "thumb",
  157542. /**
  157543. * HandPart - Index finger
  157544. */
  157545. INDEX = "index",
  157546. /**
  157547. * HandPart - Middle finger
  157548. */
  157549. MIDDLE = "middle",
  157550. /**
  157551. * HandPart - Ring finger
  157552. */
  157553. RING = "ring",
  157554. /**
  157555. * HandPart - Little finger
  157556. */
  157557. LITTLE = "little"
  157558. }
  157559. /**
  157560. * Representing a single hand (with its corresponding native XRHand object)
  157561. */
  157562. export class WebXRHand implements IDisposable {
  157563. /** the controller to which the hand correlates */
  157564. readonly xrController: WebXRInputSource;
  157565. /** the meshes to be used to track the hand joints */
  157566. readonly trackedMeshes: AbstractMesh[];
  157567. /**
  157568. * Hand-parts definition (key is HandPart)
  157569. */
  157570. handPartsDefinition: {
  157571. [key: string]: number[];
  157572. };
  157573. /**
  157574. * Populate the HandPartsDefinition object.
  157575. * This is called as a side effect since certain browsers don't have XRHand defined.
  157576. */
  157577. private generateHandPartsDefinition;
  157578. /**
  157579. * Construct a new hand object
  157580. * @param xrController the controller to which the hand correlates
  157581. * @param trackedMeshes the meshes to be used to track the hand joints
  157582. */
  157583. constructor(
  157584. /** the controller to which the hand correlates */
  157585. xrController: WebXRInputSource,
  157586. /** the meshes to be used to track the hand joints */
  157587. trackedMeshes: AbstractMesh[]);
  157588. /**
  157589. * Update this hand from the latest xr frame
  157590. * @param xrFrame xrFrame to update from
  157591. * @param referenceSpace The current viewer reference space
  157592. * @param scaleFactor optional scale factor for the meshes
  157593. */
  157594. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  157595. /**
  157596. * Get meshes of part of the hand
  157597. * @param part the part of hand to get
  157598. * @returns An array of meshes that correlate to the hand part requested
  157599. */
  157600. getHandPartMeshes(part: HandPart): AbstractMesh[];
  157601. /**
  157602. * Dispose this Hand object
  157603. */
  157604. dispose(): void;
  157605. }
  157606. /**
  157607. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  157608. */
  157609. export class WebXRHandTracking extends WebXRAbstractFeature {
  157610. /**
  157611. * options to use when constructing this feature
  157612. */
  157613. readonly options: IWebXRHandTrackingOptions;
  157614. private static _idCounter;
  157615. /**
  157616. * The module's name
  157617. */
  157618. static readonly Name: string;
  157619. /**
  157620. * The (Babylon) version of this module.
  157621. * This is an integer representing the implementation version.
  157622. * This number does not correspond to the WebXR specs version
  157623. */
  157624. static readonly Version: number;
  157625. /**
  157626. * This observable will notify registered observers when a new hand object was added and initialized
  157627. */
  157628. onHandAddedObservable: Observable<WebXRHand>;
  157629. /**
  157630. * This observable will notify its observers right before the hand object is disposed
  157631. */
  157632. onHandRemovedObservable: Observable<WebXRHand>;
  157633. private _hands;
  157634. /**
  157635. * Creates a new instance of the hit test feature
  157636. * @param _xrSessionManager an instance of WebXRSessionManager
  157637. * @param options options to use when constructing this feature
  157638. */
  157639. constructor(_xrSessionManager: WebXRSessionManager,
  157640. /**
  157641. * options to use when constructing this feature
  157642. */
  157643. options: IWebXRHandTrackingOptions);
  157644. /**
  157645. * Check if the needed objects are defined.
  157646. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  157647. */
  157648. isCompatible(): boolean;
  157649. /**
  157650. * attach this feature
  157651. * Will usually be called by the features manager
  157652. *
  157653. * @returns true if successful.
  157654. */
  157655. attach(): boolean;
  157656. /**
  157657. * detach this feature.
  157658. * Will usually be called by the features manager
  157659. *
  157660. * @returns true if successful.
  157661. */
  157662. detach(): boolean;
  157663. /**
  157664. * Dispose this feature and all of the resources attached
  157665. */
  157666. dispose(): void;
  157667. /**
  157668. * Get the hand object according to the controller id
  157669. * @param controllerId the controller id to which we want to get the hand
  157670. * @returns null if not found or the WebXRHand object if found
  157671. */
  157672. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  157673. /**
  157674. * Get a hand object according to the requested handedness
  157675. * @param handedness the handedness to request
  157676. * @returns null if not found or the WebXRHand object if found
  157677. */
  157678. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  157679. protected _onXRFrame(_xrFrame: XRFrame): void;
  157680. private _attachHand;
  157681. private _detachHand;
  157682. }
  157683. }
  157684. declare module BABYLON {
  157685. /**
  157686. * The motion controller class for all microsoft mixed reality controllers
  157687. */
  157688. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  157689. protected readonly _mapping: {
  157690. defaultButton: {
  157691. valueNodeName: string;
  157692. unpressedNodeName: string;
  157693. pressedNodeName: string;
  157694. };
  157695. defaultAxis: {
  157696. valueNodeName: string;
  157697. minNodeName: string;
  157698. maxNodeName: string;
  157699. };
  157700. buttons: {
  157701. "xr-standard-trigger": {
  157702. rootNodeName: string;
  157703. componentProperty: string;
  157704. states: string[];
  157705. };
  157706. "xr-standard-squeeze": {
  157707. rootNodeName: string;
  157708. componentProperty: string;
  157709. states: string[];
  157710. };
  157711. "xr-standard-touchpad": {
  157712. rootNodeName: string;
  157713. labelAnchorNodeName: string;
  157714. touchPointNodeName: string;
  157715. };
  157716. "xr-standard-thumbstick": {
  157717. rootNodeName: string;
  157718. componentProperty: string;
  157719. states: string[];
  157720. };
  157721. };
  157722. axes: {
  157723. "xr-standard-touchpad": {
  157724. "x-axis": {
  157725. rootNodeName: string;
  157726. };
  157727. "y-axis": {
  157728. rootNodeName: string;
  157729. };
  157730. };
  157731. "xr-standard-thumbstick": {
  157732. "x-axis": {
  157733. rootNodeName: string;
  157734. };
  157735. "y-axis": {
  157736. rootNodeName: string;
  157737. };
  157738. };
  157739. };
  157740. };
  157741. /**
  157742. * The base url used to load the left and right controller models
  157743. */
  157744. static MODEL_BASE_URL: string;
  157745. /**
  157746. * The name of the left controller model file
  157747. */
  157748. static MODEL_LEFT_FILENAME: string;
  157749. /**
  157750. * The name of the right controller model file
  157751. */
  157752. static MODEL_RIGHT_FILENAME: string;
  157753. profileId: string;
  157754. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157755. protected _getFilenameAndPath(): {
  157756. filename: string;
  157757. path: string;
  157758. };
  157759. protected _getModelLoadingConstraints(): boolean;
  157760. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157761. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157762. protected _updateModel(): void;
  157763. }
  157764. }
  157765. declare module BABYLON {
  157766. /**
  157767. * The motion controller class for oculus touch (quest, rift).
  157768. * This class supports legacy mapping as well the standard xr mapping
  157769. */
  157770. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  157771. private _forceLegacyControllers;
  157772. private _modelRootNode;
  157773. /**
  157774. * The base url used to load the left and right controller models
  157775. */
  157776. static MODEL_BASE_URL: string;
  157777. /**
  157778. * The name of the left controller model file
  157779. */
  157780. static MODEL_LEFT_FILENAME: string;
  157781. /**
  157782. * The name of the right controller model file
  157783. */
  157784. static MODEL_RIGHT_FILENAME: string;
  157785. /**
  157786. * Base Url for the Quest controller model.
  157787. */
  157788. static QUEST_MODEL_BASE_URL: string;
  157789. profileId: string;
  157790. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  157791. protected _getFilenameAndPath(): {
  157792. filename: string;
  157793. path: string;
  157794. };
  157795. protected _getModelLoadingConstraints(): boolean;
  157796. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157797. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157798. protected _updateModel(): void;
  157799. /**
  157800. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  157801. * between the touch and touch 2.
  157802. */
  157803. private _isQuest;
  157804. }
  157805. }
  157806. declare module BABYLON {
  157807. /**
  157808. * The motion controller class for the standard HTC-Vive controllers
  157809. */
  157810. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  157811. private _modelRootNode;
  157812. /**
  157813. * The base url used to load the left and right controller models
  157814. */
  157815. static MODEL_BASE_URL: string;
  157816. /**
  157817. * File name for the controller model.
  157818. */
  157819. static MODEL_FILENAME: string;
  157820. profileId: string;
  157821. /**
  157822. * Create a new Vive motion controller object
  157823. * @param scene the scene to use to create this controller
  157824. * @param gamepadObject the corresponding gamepad object
  157825. * @param handedness the handedness of the controller
  157826. */
  157827. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  157828. protected _getFilenameAndPath(): {
  157829. filename: string;
  157830. path: string;
  157831. };
  157832. protected _getModelLoadingConstraints(): boolean;
  157833. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  157834. protected _setRootMesh(meshes: AbstractMesh[]): void;
  157835. protected _updateModel(): void;
  157836. }
  157837. }
  157838. declare module BABYLON {
  157839. /**
  157840. * A cursor which tracks a point on a path
  157841. */
  157842. export class PathCursor {
  157843. private path;
  157844. /**
  157845. * Stores path cursor callbacks for when an onchange event is triggered
  157846. */
  157847. private _onchange;
  157848. /**
  157849. * The value of the path cursor
  157850. */
  157851. value: number;
  157852. /**
  157853. * The animation array of the path cursor
  157854. */
  157855. animations: Animation[];
  157856. /**
  157857. * Initializes the path cursor
  157858. * @param path The path to track
  157859. */
  157860. constructor(path: Path2);
  157861. /**
  157862. * Gets the cursor point on the path
  157863. * @returns A point on the path cursor at the cursor location
  157864. */
  157865. getPoint(): Vector3;
  157866. /**
  157867. * Moves the cursor ahead by the step amount
  157868. * @param step The amount to move the cursor forward
  157869. * @returns This path cursor
  157870. */
  157871. moveAhead(step?: number): PathCursor;
  157872. /**
  157873. * Moves the cursor behind by the step amount
  157874. * @param step The amount to move the cursor back
  157875. * @returns This path cursor
  157876. */
  157877. moveBack(step?: number): PathCursor;
  157878. /**
  157879. * Moves the cursor by the step amount
  157880. * If the step amount is greater than one, an exception is thrown
  157881. * @param step The amount to move the cursor
  157882. * @returns This path cursor
  157883. */
  157884. move(step: number): PathCursor;
  157885. /**
  157886. * Ensures that the value is limited between zero and one
  157887. * @returns This path cursor
  157888. */
  157889. private ensureLimits;
  157890. /**
  157891. * Runs onchange callbacks on change (used by the animation engine)
  157892. * @returns This path cursor
  157893. */
  157894. private raiseOnChange;
  157895. /**
  157896. * Executes a function on change
  157897. * @param f A path cursor onchange callback
  157898. * @returns This path cursor
  157899. */
  157900. onchange(f: (cursor: PathCursor) => void): PathCursor;
  157901. }
  157902. }
  157903. declare module BABYLON {
  157904. /** @hidden */
  157905. export var blurPixelShader: {
  157906. name: string;
  157907. shader: string;
  157908. };
  157909. }
  157910. declare module BABYLON {
  157911. /** @hidden */
  157912. export var pointCloudVertexDeclaration: {
  157913. name: string;
  157914. shader: string;
  157915. };
  157916. }
  157917. // Mixins
  157918. interface Window {
  157919. mozIndexedDB: IDBFactory;
  157920. webkitIndexedDB: IDBFactory;
  157921. msIndexedDB: IDBFactory;
  157922. webkitURL: typeof URL;
  157923. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  157924. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  157925. WebGLRenderingContext: WebGLRenderingContext;
  157926. MSGesture: MSGesture;
  157927. CANNON: any;
  157928. AudioContext: AudioContext;
  157929. webkitAudioContext: AudioContext;
  157930. PointerEvent: any;
  157931. Math: Math;
  157932. Uint8Array: Uint8ArrayConstructor;
  157933. Float32Array: Float32ArrayConstructor;
  157934. mozURL: typeof URL;
  157935. msURL: typeof URL;
  157936. VRFrameData: any; // WebVR, from specs 1.1
  157937. DracoDecoderModule: any;
  157938. setImmediate(handler: (...args: any[]) => void): number;
  157939. }
  157940. interface HTMLCanvasElement {
  157941. requestPointerLock(): void;
  157942. msRequestPointerLock?(): void;
  157943. mozRequestPointerLock?(): void;
  157944. webkitRequestPointerLock?(): void;
  157945. /** Track wether a record is in progress */
  157946. isRecording: boolean;
  157947. /** Capture Stream method defined by some browsers */
  157948. captureStream(fps?: number): MediaStream;
  157949. }
  157950. interface CanvasRenderingContext2D {
  157951. msImageSmoothingEnabled: boolean;
  157952. }
  157953. interface MouseEvent {
  157954. mozMovementX: number;
  157955. mozMovementY: number;
  157956. webkitMovementX: number;
  157957. webkitMovementY: number;
  157958. msMovementX: number;
  157959. msMovementY: number;
  157960. }
  157961. interface Navigator {
  157962. mozGetVRDevices: (any: any) => any;
  157963. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157964. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157965. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  157966. webkitGetGamepads(): Gamepad[];
  157967. msGetGamepads(): Gamepad[];
  157968. webkitGamepads(): Gamepad[];
  157969. }
  157970. interface HTMLVideoElement {
  157971. mozSrcObject: any;
  157972. }
  157973. interface Math {
  157974. fround(x: number): number;
  157975. imul(a: number, b: number): number;
  157976. }
  157977. interface WebGLRenderingContext {
  157978. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  157979. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  157980. vertexAttribDivisor(index: number, divisor: number): void;
  157981. createVertexArray(): any;
  157982. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  157983. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  157984. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  157985. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  157986. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  157987. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  157988. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  157989. // Queries
  157990. createQuery(): WebGLQuery;
  157991. deleteQuery(query: WebGLQuery): void;
  157992. beginQuery(target: number, query: WebGLQuery): void;
  157993. endQuery(target: number): void;
  157994. getQueryParameter(query: WebGLQuery, pname: number): any;
  157995. getQuery(target: number, pname: number): any;
  157996. MAX_SAMPLES: number;
  157997. RGBA8: number;
  157998. READ_FRAMEBUFFER: number;
  157999. DRAW_FRAMEBUFFER: number;
  158000. UNIFORM_BUFFER: number;
  158001. HALF_FLOAT_OES: number;
  158002. RGBA16F: number;
  158003. RGBA32F: number;
  158004. R32F: number;
  158005. RG32F: number;
  158006. RGB32F: number;
  158007. R16F: number;
  158008. RG16F: number;
  158009. RGB16F: number;
  158010. RED: number;
  158011. RG: number;
  158012. R8: number;
  158013. RG8: number;
  158014. UNSIGNED_INT_24_8: number;
  158015. DEPTH24_STENCIL8: number;
  158016. MIN: number;
  158017. MAX: number;
  158018. /* Multiple Render Targets */
  158019. drawBuffers(buffers: number[]): void;
  158020. readBuffer(src: number): void;
  158021. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  158022. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  158023. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  158024. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  158025. // Occlusion Query
  158026. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  158027. ANY_SAMPLES_PASSED: number;
  158028. QUERY_RESULT_AVAILABLE: number;
  158029. QUERY_RESULT: number;
  158030. }
  158031. interface WebGLProgram {
  158032. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  158033. }
  158034. interface EXT_disjoint_timer_query {
  158035. QUERY_COUNTER_BITS_EXT: number;
  158036. TIME_ELAPSED_EXT: number;
  158037. TIMESTAMP_EXT: number;
  158038. GPU_DISJOINT_EXT: number;
  158039. QUERY_RESULT_EXT: number;
  158040. QUERY_RESULT_AVAILABLE_EXT: number;
  158041. queryCounterEXT(query: WebGLQuery, target: number): void;
  158042. createQueryEXT(): WebGLQuery;
  158043. beginQueryEXT(target: number, query: WebGLQuery): void;
  158044. endQueryEXT(target: number): void;
  158045. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  158046. deleteQueryEXT(query: WebGLQuery): void;
  158047. }
  158048. interface WebGLUniformLocation {
  158049. _currentState: any;
  158050. }
  158051. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  158052. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  158053. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  158054. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  158055. interface WebGLRenderingContext {
  158056. readonly RASTERIZER_DISCARD: number;
  158057. readonly DEPTH_COMPONENT24: number;
  158058. readonly TEXTURE_3D: number;
  158059. readonly TEXTURE_2D_ARRAY: number;
  158060. readonly TEXTURE_COMPARE_FUNC: number;
  158061. readonly TEXTURE_COMPARE_MODE: number;
  158062. readonly COMPARE_REF_TO_TEXTURE: number;
  158063. readonly TEXTURE_WRAP_R: number;
  158064. readonly HALF_FLOAT: number;
  158065. readonly RGB8: number;
  158066. readonly RED_INTEGER: number;
  158067. readonly RG_INTEGER: number;
  158068. readonly RGB_INTEGER: number;
  158069. readonly RGBA_INTEGER: number;
  158070. readonly R8_SNORM: number;
  158071. readonly RG8_SNORM: number;
  158072. readonly RGB8_SNORM: number;
  158073. readonly RGBA8_SNORM: number;
  158074. readonly R8I: number;
  158075. readonly RG8I: number;
  158076. readonly RGB8I: number;
  158077. readonly RGBA8I: number;
  158078. readonly R8UI: number;
  158079. readonly RG8UI: number;
  158080. readonly RGB8UI: number;
  158081. readonly RGBA8UI: number;
  158082. readonly R16I: number;
  158083. readonly RG16I: number;
  158084. readonly RGB16I: number;
  158085. readonly RGBA16I: number;
  158086. readonly R16UI: number;
  158087. readonly RG16UI: number;
  158088. readonly RGB16UI: number;
  158089. readonly RGBA16UI: number;
  158090. readonly R32I: number;
  158091. readonly RG32I: number;
  158092. readonly RGB32I: number;
  158093. readonly RGBA32I: number;
  158094. readonly R32UI: number;
  158095. readonly RG32UI: number;
  158096. readonly RGB32UI: number;
  158097. readonly RGBA32UI: number;
  158098. readonly RGB10_A2UI: number;
  158099. readonly R11F_G11F_B10F: number;
  158100. readonly RGB9_E5: number;
  158101. readonly RGB10_A2: number;
  158102. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  158103. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  158104. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  158105. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  158106. readonly DEPTH_COMPONENT32F: number;
  158107. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  158108. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  158109. 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;
  158110. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  158111. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  158112. readonly TRANSFORM_FEEDBACK: number;
  158113. readonly INTERLEAVED_ATTRIBS: number;
  158114. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  158115. createTransformFeedback(): WebGLTransformFeedback;
  158116. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  158117. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  158118. beginTransformFeedback(primitiveMode: number): void;
  158119. endTransformFeedback(): void;
  158120. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  158121. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158122. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158123. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  158124. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  158125. }
  158126. interface ImageBitmap {
  158127. readonly width: number;
  158128. readonly height: number;
  158129. close(): void;
  158130. }
  158131. interface WebGLQuery extends WebGLObject {
  158132. }
  158133. declare var WebGLQuery: {
  158134. prototype: WebGLQuery;
  158135. new(): WebGLQuery;
  158136. };
  158137. interface WebGLSampler extends WebGLObject {
  158138. }
  158139. declare var WebGLSampler: {
  158140. prototype: WebGLSampler;
  158141. new(): WebGLSampler;
  158142. };
  158143. interface WebGLSync extends WebGLObject {
  158144. }
  158145. declare var WebGLSync: {
  158146. prototype: WebGLSync;
  158147. new(): WebGLSync;
  158148. };
  158149. interface WebGLTransformFeedback extends WebGLObject {
  158150. }
  158151. declare var WebGLTransformFeedback: {
  158152. prototype: WebGLTransformFeedback;
  158153. new(): WebGLTransformFeedback;
  158154. };
  158155. interface WebGLVertexArrayObject extends WebGLObject {
  158156. }
  158157. declare var WebGLVertexArrayObject: {
  158158. prototype: WebGLVertexArrayObject;
  158159. new(): WebGLVertexArrayObject;
  158160. };
  158161. // Type definitions for WebVR API
  158162. // Project: https://w3c.github.io/webvr/
  158163. // Definitions by: six a <https://github.com/lostfictions>
  158164. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  158165. interface VRDisplay extends EventTarget {
  158166. /**
  158167. * Dictionary of capabilities describing the VRDisplay.
  158168. */
  158169. readonly capabilities: VRDisplayCapabilities;
  158170. /**
  158171. * z-depth defining the far plane of the eye view frustum
  158172. * enables mapping of values in the render target depth
  158173. * attachment to scene coordinates. Initially set to 10000.0.
  158174. */
  158175. depthFar: number;
  158176. /**
  158177. * z-depth defining the near plane of the eye view frustum
  158178. * enables mapping of values in the render target depth
  158179. * attachment to scene coordinates. Initially set to 0.01.
  158180. */
  158181. depthNear: number;
  158182. /**
  158183. * An identifier for this distinct VRDisplay. Used as an
  158184. * association point in the Gamepad API.
  158185. */
  158186. readonly displayId: number;
  158187. /**
  158188. * A display name, a user-readable name identifying it.
  158189. */
  158190. readonly displayName: string;
  158191. readonly isConnected: boolean;
  158192. readonly isPresenting: boolean;
  158193. /**
  158194. * If this VRDisplay supports room-scale experiences, the optional
  158195. * stage attribute contains details on the room-scale parameters.
  158196. */
  158197. readonly stageParameters: VRStageParameters | null;
  158198. /**
  158199. * Passing the value returned by `requestAnimationFrame` to
  158200. * `cancelAnimationFrame` will unregister the callback.
  158201. * @param handle Define the hanle of the request to cancel
  158202. */
  158203. cancelAnimationFrame(handle: number): void;
  158204. /**
  158205. * Stops presenting to the VRDisplay.
  158206. * @returns a promise to know when it stopped
  158207. */
  158208. exitPresent(): Promise<void>;
  158209. /**
  158210. * Return the current VREyeParameters for the given eye.
  158211. * @param whichEye Define the eye we want the parameter for
  158212. * @returns the eye parameters
  158213. */
  158214. getEyeParameters(whichEye: string): VREyeParameters;
  158215. /**
  158216. * Populates the passed VRFrameData with the information required to render
  158217. * the current frame.
  158218. * @param frameData Define the data structure to populate
  158219. * @returns true if ok otherwise false
  158220. */
  158221. getFrameData(frameData: VRFrameData): boolean;
  158222. /**
  158223. * Get the layers currently being presented.
  158224. * @returns the list of VR layers
  158225. */
  158226. getLayers(): VRLayer[];
  158227. /**
  158228. * Return a VRPose containing the future predicted pose of the VRDisplay
  158229. * when the current frame will be presented. The value returned will not
  158230. * change until JavaScript has returned control to the browser.
  158231. *
  158232. * The VRPose will contain the position, orientation, velocity,
  158233. * and acceleration of each of these properties.
  158234. * @returns the pose object
  158235. */
  158236. getPose(): VRPose;
  158237. /**
  158238. * Return the current instantaneous pose of the VRDisplay, with no
  158239. * prediction applied.
  158240. * @returns the current instantaneous pose
  158241. */
  158242. getImmediatePose(): VRPose;
  158243. /**
  158244. * The callback passed to `requestAnimationFrame` will be called
  158245. * any time a new frame should be rendered. When the VRDisplay is
  158246. * presenting the callback will be called at the native refresh
  158247. * rate of the HMD. When not presenting this function acts
  158248. * identically to how window.requestAnimationFrame acts. Content should
  158249. * make no assumptions of frame rate or vsync behavior as the HMD runs
  158250. * asynchronously from other displays and at differing refresh rates.
  158251. * @param callback Define the eaction to run next frame
  158252. * @returns the request handle it
  158253. */
  158254. requestAnimationFrame(callback: FrameRequestCallback): number;
  158255. /**
  158256. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  158257. * Repeat calls while already presenting will update the VRLayers being displayed.
  158258. * @param layers Define the list of layer to present
  158259. * @returns a promise to know when the request has been fulfilled
  158260. */
  158261. requestPresent(layers: VRLayer[]): Promise<void>;
  158262. /**
  158263. * Reset the pose for this display, treating its current position and
  158264. * orientation as the "origin/zero" values. VRPose.position,
  158265. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  158266. * updated when calling resetPose(). This should be called in only
  158267. * sitting-space experiences.
  158268. */
  158269. resetPose(): void;
  158270. /**
  158271. * The VRLayer provided to the VRDisplay will be captured and presented
  158272. * in the HMD. Calling this function has the same effect on the source
  158273. * canvas as any other operation that uses its source image, and canvases
  158274. * created without preserveDrawingBuffer set to true will be cleared.
  158275. * @param pose Define the pose to submit
  158276. */
  158277. submitFrame(pose?: VRPose): void;
  158278. }
  158279. declare var VRDisplay: {
  158280. prototype: VRDisplay;
  158281. new(): VRDisplay;
  158282. };
  158283. interface VRLayer {
  158284. leftBounds?: number[] | Float32Array | null;
  158285. rightBounds?: number[] | Float32Array | null;
  158286. source?: HTMLCanvasElement | null;
  158287. }
  158288. interface VRDisplayCapabilities {
  158289. readonly canPresent: boolean;
  158290. readonly hasExternalDisplay: boolean;
  158291. readonly hasOrientation: boolean;
  158292. readonly hasPosition: boolean;
  158293. readonly maxLayers: number;
  158294. }
  158295. interface VREyeParameters {
  158296. /** @deprecated */
  158297. readonly fieldOfView: VRFieldOfView;
  158298. readonly offset: Float32Array;
  158299. readonly renderHeight: number;
  158300. readonly renderWidth: number;
  158301. }
  158302. interface VRFieldOfView {
  158303. readonly downDegrees: number;
  158304. readonly leftDegrees: number;
  158305. readonly rightDegrees: number;
  158306. readonly upDegrees: number;
  158307. }
  158308. interface VRFrameData {
  158309. readonly leftProjectionMatrix: Float32Array;
  158310. readonly leftViewMatrix: Float32Array;
  158311. readonly pose: VRPose;
  158312. readonly rightProjectionMatrix: Float32Array;
  158313. readonly rightViewMatrix: Float32Array;
  158314. readonly timestamp: number;
  158315. }
  158316. interface VRPose {
  158317. readonly angularAcceleration: Float32Array | null;
  158318. readonly angularVelocity: Float32Array | null;
  158319. readonly linearAcceleration: Float32Array | null;
  158320. readonly linearVelocity: Float32Array | null;
  158321. readonly orientation: Float32Array | null;
  158322. readonly position: Float32Array | null;
  158323. readonly timestamp: number;
  158324. }
  158325. interface VRStageParameters {
  158326. sittingToStandingTransform?: Float32Array;
  158327. sizeX?: number;
  158328. sizeY?: number;
  158329. }
  158330. interface Navigator {
  158331. getVRDisplays(): Promise<VRDisplay[]>;
  158332. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  158333. }
  158334. interface Window {
  158335. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  158336. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  158337. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  158338. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  158339. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  158340. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  158341. }
  158342. interface Gamepad {
  158343. readonly displayId: number;
  158344. }
  158345. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  158346. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  158347. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  158348. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  158349. type XRHandedness = "none" | "left" | "right";
  158350. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  158351. type XREye = "none" | "left" | "right";
  158352. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  158353. interface XRSpace extends EventTarget {}
  158354. interface XRRenderState {
  158355. depthNear?: number;
  158356. depthFar?: number;
  158357. inlineVerticalFieldOfView?: number;
  158358. baseLayer?: XRWebGLLayer;
  158359. }
  158360. interface XRInputSource {
  158361. handedness: XRHandedness;
  158362. targetRayMode: XRTargetRayMode;
  158363. targetRaySpace: XRSpace;
  158364. gripSpace: XRSpace | undefined;
  158365. gamepad: Gamepad | undefined;
  158366. profiles: Array<string>;
  158367. hand: XRHand | undefined;
  158368. }
  158369. interface XRSessionInit {
  158370. optionalFeatures?: string[];
  158371. requiredFeatures?: string[];
  158372. }
  158373. interface XRSession {
  158374. addEventListener: Function;
  158375. removeEventListener: Function;
  158376. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  158377. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  158378. requestAnimationFrame: Function;
  158379. end(): Promise<void>;
  158380. renderState: XRRenderState;
  158381. inputSources: Array<XRInputSource>;
  158382. // hit test
  158383. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  158384. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  158385. // legacy AR hit test
  158386. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  158387. // legacy plane detection
  158388. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  158389. }
  158390. interface XRReferenceSpace extends XRSpace {
  158391. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  158392. onreset: any;
  158393. }
  158394. type XRPlaneSet = Set<XRPlane>;
  158395. type XRAnchorSet = Set<XRAnchor>;
  158396. interface XRFrame {
  158397. session: XRSession;
  158398. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  158399. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  158400. // AR
  158401. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  158402. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  158403. // Anchors
  158404. trackedAnchors?: XRAnchorSet;
  158405. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  158406. // Planes
  158407. worldInformation: {
  158408. detectedPlanes?: XRPlaneSet;
  158409. };
  158410. // Hand tracking
  158411. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  158412. }
  158413. interface XRViewerPose extends XRPose {
  158414. views: Array<XRView>;
  158415. }
  158416. interface XRPose {
  158417. transform: XRRigidTransform;
  158418. emulatedPosition: boolean;
  158419. }
  158420. interface XRWebGLLayerOptions {
  158421. antialias?: boolean;
  158422. depth?: boolean;
  158423. stencil?: boolean;
  158424. alpha?: boolean;
  158425. multiview?: boolean;
  158426. framebufferScaleFactor?: number;
  158427. }
  158428. declare var XRWebGLLayer: {
  158429. prototype: XRWebGLLayer;
  158430. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  158431. };
  158432. interface XRWebGLLayer {
  158433. framebuffer: WebGLFramebuffer;
  158434. framebufferWidth: number;
  158435. framebufferHeight: number;
  158436. getViewport: Function;
  158437. }
  158438. declare class XRRigidTransform {
  158439. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  158440. position: DOMPointReadOnly;
  158441. orientation: DOMPointReadOnly;
  158442. matrix: Float32Array;
  158443. inverse: XRRigidTransform;
  158444. }
  158445. interface XRView {
  158446. eye: XREye;
  158447. projectionMatrix: Float32Array;
  158448. transform: XRRigidTransform;
  158449. }
  158450. interface XRInputSourceChangeEvent {
  158451. session: XRSession;
  158452. removed: Array<XRInputSource>;
  158453. added: Array<XRInputSource>;
  158454. }
  158455. interface XRInputSourceEvent extends Event {
  158456. readonly frame: XRFrame;
  158457. readonly inputSource: XRInputSource;
  158458. }
  158459. // Experimental(er) features
  158460. declare class XRRay {
  158461. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  158462. origin: DOMPointReadOnly;
  158463. direction: DOMPointReadOnly;
  158464. matrix: Float32Array;
  158465. }
  158466. declare enum XRHitTestTrackableType {
  158467. "point",
  158468. "plane",
  158469. "mesh",
  158470. }
  158471. interface XRHitResult {
  158472. hitMatrix: Float32Array;
  158473. }
  158474. interface XRTransientInputHitTestResult {
  158475. readonly inputSource: XRInputSource;
  158476. readonly results: Array<XRHitTestResult>;
  158477. }
  158478. interface XRHitTestResult {
  158479. getPose(baseSpace: XRSpace): XRPose | undefined;
  158480. // When anchor system is enabled
  158481. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  158482. }
  158483. interface XRHitTestSource {
  158484. cancel(): void;
  158485. }
  158486. interface XRTransientInputHitTestSource {
  158487. cancel(): void;
  158488. }
  158489. interface XRHitTestOptionsInit {
  158490. space: XRSpace;
  158491. entityTypes?: Array<XRHitTestTrackableType>;
  158492. offsetRay?: XRRay;
  158493. }
  158494. interface XRTransientInputHitTestOptionsInit {
  158495. profile: string;
  158496. entityTypes?: Array<XRHitTestTrackableType>;
  158497. offsetRay?: XRRay;
  158498. }
  158499. interface XRAnchor {
  158500. anchorSpace: XRSpace;
  158501. delete(): void;
  158502. }
  158503. interface XRPlane {
  158504. orientation: "Horizontal" | "Vertical";
  158505. planeSpace: XRSpace;
  158506. polygon: Array<DOMPointReadOnly>;
  158507. lastChangedTime: number;
  158508. }
  158509. interface XRJointSpace extends XRSpace {}
  158510. interface XRJointPose extends XRPose {
  158511. radius: number | undefined;
  158512. }
  158513. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  158514. readonly length: number;
  158515. [index: number]: XRJointSpace;
  158516. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  158517. readonly WRIST: number;
  158518. readonly THUMB_METACARPAL: number;
  158519. readonly THUMB_PHALANX_PROXIMAL: number;
  158520. readonly THUMB_PHALANX_DISTAL: number;
  158521. readonly THUMB_PHALANX_TIP: number;
  158522. readonly INDEX_METACARPAL: number;
  158523. readonly INDEX_PHALANX_PROXIMAL: number;
  158524. readonly INDEX_PHALANX_INTERMEDIATE: number;
  158525. readonly INDEX_PHALANX_DISTAL: number;
  158526. readonly INDEX_PHALANX_TIP: number;
  158527. readonly MIDDLE_METACARPAL: number;
  158528. readonly MIDDLE_PHALANX_PROXIMAL: number;
  158529. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  158530. readonly MIDDLE_PHALANX_DISTAL: number;
  158531. readonly MIDDLE_PHALANX_TIP: number;
  158532. readonly RING_METACARPAL: number;
  158533. readonly RING_PHALANX_PROXIMAL: number;
  158534. readonly RING_PHALANX_INTERMEDIATE: number;
  158535. readonly RING_PHALANX_DISTAL: number;
  158536. readonly RING_PHALANX_TIP: number;
  158537. readonly LITTLE_METACARPAL: number;
  158538. readonly LITTLE_PHALANX_PROXIMAL: number;
  158539. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  158540. readonly LITTLE_PHALANX_DISTAL: number;
  158541. readonly LITTLE_PHALANX_TIP: number;
  158542. }
  158543. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  158544. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  158545. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  158546. interface XRSession {
  158547. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  158548. }
  158549. interface XRFrame {
  158550. featurePointCloud? : Array<number>;
  158551. }